var nwindow;


/*	
	hide current tab (currTab) and show next tab (nextTab) 
*/
function showTab (nextTab, currTab) {
	if (currTab) {
		document.getElementById(currTab).style.visibility = "hidden";
	}
	document.getElementById(nextTab).style.visibility = "visible";

	if (document.getElementById("lastTab")) {
		document.getElementById("lastTab").value = nextTab;
	}
	document.main.tab.value = nextTab;	document.main.lastTab.value = currTab;
}


/*
	extracts the value of request parameter 'name' from the
	search string 'search'. If not found, the default 'def' is used.
*/
function getSearchValue (search, name, def) {
	var i = 1;
	var s = name+"=";
	while (i < search.length) {
		if (search.substring(i, i+s.length) == s) {
			var ende = search.indexOf("&",i+s.length);
			ende = (ende>-1) ? ende : search.length;
			var t = search.substring(i+s.length, ende);
			return unescape(t);
		}
		i++;
	}
	return def;
}

/* 
	class for tracking changes 
	usage: 
	place the following script in the head:
	<script>
		myTracker = new ChangeTracker('myForm');
	</script>
	
	Any input field, check box should use following function call in the
	onchange event:
	onchange="myTracker.setChanged()"
	
	The functions that would leave the dialog will then call this function:
	myTracker.checkQuit ('xxx')
	where xxx must be replaced with the url of the following dialog. This dialog
	will be shown, if no changes were made. Otherwise a question is opened that 
	asks for saving. If answered with 'yes' the form given with the constructor
	is submitted.
*/
function ChangeTracker (myForm) {
	var chgFlag;
	var formName;
	this.chgFlag = false;
	this.formName = myForm;
	this.setChanged = setChanged;
	this.checkQuit = checkQuit;
	this.checkQuitAW = checkQuitAW;
}
function setChanged () {
	this.chgFlag = true;
}

function checkQuit (nextDialog) {
	var gotoDialog = true;
	if (this.chgFlag) {
		var check = confirm("Änderungen speichern?");
		if (check) {
			if (document.forms[this.formName].nextDialog) {
				document.forms[this.formName].nextDialog.value = nextDialog.substr(3); // ein Verzeichnis höher (relativ zu /js/lib.js)
			}
			document.forms[this.formName].submit();
			gotoDialog = false;
		}
	}
	
	if (gotoDialog) {
		if (nextDialog == "back") {
			history.back();
		} else {
			location.href = nextDialog;
		}
	}
}

function checkQuitAW (nextDialog) {
	var gotoDialog = true;
	if (this.chgFlag) {
		var check = confirm("Änderungen speichern?");
		if (check) {
			document.forms[this.formName].submit();
		} 
	} else {
		document.location.href = nextDialog;
	}
}

function executeNextDialog(nextDialog){
	if (nextDialog == "berufsfunktionHinzu") {
	      berufsfunktionHinzu();
	      return;
	}
	if(nextDialog == "zusatzqualifikationHinzu"){
		 zusatzqualifikationHinzu();
		 return;
	}
	if(nextDialog == "taetigkeitHinzu"){
		 taetigkeitHinzu();
		 return;
	}
	if(nextDialog == "kongressfunktionHinzu"){
		 kongressfunktionHinzu();
		 return;
	}
	if(nextDialog == "addAdditionalFP"){
		 addAdditionalFP();
		 return;
	}
	if(nextDialog == "addGremium"){
		 addGremium();
		 return;
	}
}

function checkDelete (weiter) {
	var check = confirm("Wirklich inaktiv setzen?");
	if (check) {
		location.href = weiter;
	}
}

function checkDeleteSeminar (weiter) {
	var check = confirm("Sind Sie sicher, dass Sie das Seminar löschen möchten?");
	if (check) {
		location.href = weiter;
	}
}

function checkDeleteVer (weiter) {
	var check = confirm("Alle diesen Veranstalter betreffenden Daten werden gelöscht und gehen unwiederbringlich verloren! \n Wirklich Löschen?");
	if (check) {
		check = confirm("Den Veranstalter per Mail benachrichtigen?");
		if (check) {
			location.href = weiter + "&mail=Ja";
		} else location.href = weiter + "&mail=Nein";
	}
}

function checkMailVer (weiter) {
	//check = confirm("Den Veranstalter per Mail benachrichtigen?");
	//if (check) {
		// document.main.mail.value = "Ja";
		// location.href = weiter + "&mail=Ja";
		//document.main.submit();
	//} else {
		// location.href = weiter + "&mail=Nein";
		document.main.submit();
	//}
}

function stopMailVer () {
		document.main.abbrechen.value = "Nein";
		document.main.submit();
}


/**************************************************************************************************/
/* open a browser window                                                                          */
/**************************************************************************************************/
function openWindow(link,wname,xsize,ysize,xpos,ypos,f) {
	if (xsize==-1)
		xsize=screen.availWidth-40;
	if (ysize==-1)
		ysize=screen.availHeight-120;
	if (xpos==-1)
		xpos=(screen.availWidth-xsize)/2;
	if (ypos==-1)
		ypos=(screen.availHeight-ysize)/2;
	
   	features = 'width='+xsize+',height='+ysize+',top='+ypos+',left='+xpos+',screenY='+ypos+',screenX='+xpos;
   	if (f != '') {
   		features = features + ','+ f;
   	} else {
   		features = features + ',status=yes,scrollbars=yes';
   	}

	nwindow  = open(link, wname, features); 
	nwindow.focus();
}

function openWindowExt(link,wname) {
	nwindow  = open(link, wname); 
	nwindow.focus();
}

function openDlg(link,wname,xsize,ysize) {
   	features = 'status=no,scrollbars=no,noresizable,dependent=yes';
	openWindow (link, wname, xsize, ysize, -1, -1, features);
}

function openDialog(link,wname,xsize,ysize) {
   	features = 'status=no,scrollbars=yes,dependent=yes';
	openWindow (link, wname, xsize, ysize, -1, -1, features);
}

/**************************************************************************************************/
/* Personen hinzufügen und entfernen                                                                          */
/**************************************************************************************************/
function addPerson() {
	del = new Array();
	count = 0;

	if (document.main.personAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.personAuswahlIdList.length; i++) {
			if(document.main.personAuswahlIdList.options[i].selected == true)
	 		{
	 			NeuerEintrag = new Option(document.main.personAuswahlIdList.options[i].text,document.main.personAuswahlIdList.options[i].value,false,false);
	  			document.main.teilnehmerAuswahlIdList.options[document.main.teilnehmerAuswahlIdList.length]  = NeuerEintrag;
	  			del[count] = i;
	  			count++;
	 		}
		}
		for(i=del.length; i>-1; i--) {
			document.main.personAuswahlIdList.options[del[i]] = null;
		}
	} else alert("Keine Person ausgewählt!");
	document.main.teilnehmerAuswahlIdList.options[document.main.teilnehmerAuswahlIdList.length-1].selected=true;
	Aendern();
}

function addPersonAnmeldung() {
	//del = new Array();
	//count = 0;
	if (document.main.personAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.personAuswahlIdList.length; i++) {
			if(document.main.personAuswahlIdList.options[i].selected == true)
	 		{
	  			//count=i;
	  			location.href="../../servlet/Kongressplaner?action=anmeldungSelectPerson&index="+i;
	 		}
		}
	} else alert("Keine Person ausgewählt!");
	
}

function addPersonId() {
	//del = new Array();
	//count = 0;
	if (document.main.personAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.personAuswahlIdList.length; i++) {
			if(document.main.personAuswahlIdList.options[i].selected == true)
	 		{
	  			//count=i;
	  			alert("Bitte prüfen Sie anschliessend ob die Beitragskatgorie Mitglied/nicht Mitglied noch stimmt?");
	  			location.href="../../servlet/Kongressplaner?action=anmeldungSelectPersonId&index="+i;
	 		}
		}
	} else alert("Keine Person ausgewählt!");
	
}

function addPersonNeu() {
	location.href="../../servlet/Kongressplaner?action=anmeldungPersonNeu";
}

function jumpPerson() {
 if(document.main.teilnehmerAuswahlIdList.length > 0)
	document.main.teilnehmerAuswahlIdList.options[document.main.teilnehmerAuswahlIdList.length-1].selected=true;
}

function jumpPerson2() {
	document.main.teilnehmerAuswahlIdList.options[document.main.teilnehmerAuswahlIdList.length-1].selected=false;
}

function delPerson() {
	del = new Array();
	count = 0;

	if (document.main.teilnehmerAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
			if(document.main.teilnehmerAuswahlIdList.options[i].selected == true)
	 		{
	 			NeuerEintrag = new Option(document.main.teilnehmerAuswahlIdList.options[i].text,document.main.teilnehmerAuswahlIdList.options[i].value,false,false);
	  			document.main.personAuswahlIdList.options[document.main.personAuswahlIdList.length]  = NeuerEintrag;
	  			del[count] = i;
	  			count++;
	 		}
		}
		for(i=del.length; i>-1; i--) {
			document.main.teilnehmerAuswahlIdList.options[del[i]] = null;
		}
	} else alert("Kein Teilnehmer ausgewählt!");
	Aendern();
}

function personAuswahlReset() {
	document.main.personVorname.value = "";
	document.main.personNachname.value = "";
	document.main.adressePlz.value = "";
	document.main.adresseOrt.value = "";
	document.main.adresseStrasse.value = "";
	document.main.mitgliedNummer.value = "";
	document.main.chipkartenNummer.value = "";
	
	for(i=0; i<document.main.verband.length; i++) {
		document.main.verband.options[i].selected = false;
	}
	
//	for(i=0; i<document.main.unterVerband.length; i++) {
//		document.main.unterVerband.options[i].selected = false;
//	}
	
	for(i=document.main.personAuswahlIdList.length; i>-1; i--) {
		document.main.personAuswahlIdList.options[i] = null;
	}
	
	for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
		document.main.teilnehmerAuswahlIdList.options[i].selected = true;
	}
}

function selectAllTeilnehmer(x) {
	document.main.aktion.value = x;
	
	for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
		document.main.teilnehmerAuswahlIdList.options[i].selected = true;
	}
}

function selectAllTeilnehmer2() {
	for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
		document.main.teilnehmerAuswahlIdList.options[i].selected = true;
	}
}

function selectTeilnehmer(feldName, value, listName){
	if(feldName != null){
		document.getElementById(feldName).value = value;
	}
	
	for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
		document.main.teilnehmerAuswahlIdList.options[i].selected = true;
	}

}

function selectAllVortraege() {
	for(i=0; i<document.main.vortragAuswahlIdList.length; i++) {
		document.main.vortragAuswahlIdList.options[i].selected = true;
	}
}

function selectAllReferent() {
	
	document.main.aktion.value = "speichernReferent";

	for(i=0; i<document.main.teilnehmerAuswahlIdList.length; i++) {
		document.main.teilnehmerAuswahlIdList.options[i].selected = true;
	}
}

function nachladenSeminar(SId, param) {
	opener.location.href = "../../servlet/Action?action=zuSeminar&SId="+SId+"&showTab="+param;
	window.close();
}

function nachladenSeminar2(SId) {
	opener.location.href = "../../servlet/Action?action=verzuSeminar&SId="+SId;
	window.close();
}

function nachladenReferat(SId) {
	opener.location.href = "../../servlet/Action?action=zuReferat&SId="+SId;
	window.close();
}

function nachladenReferat2(SId) {
	opener.location.href = "../../servlet/Action?action=verzuReferat&SId="+SId;
	window.close();
}

function relay(url) {
	opener.location.href = "../../servlet/Action?action=" + url;
	window.close();
}

function addVeranstalter() {
	if (document.main.personAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.personAuswahlIdList.length; i++) {
			if(document.main.personAuswahlIdList.options[i].selected == true)
	 		{
	 			NeuerEintrag = new Option(document.main.personAuswahlIdList.options[i].text,document.main.personAuswahlIdList.options[i].value,false,false);
	  			document.main.teilnehmerAuswahlIdList.options[0]  = NeuerEintrag;
	 		}
		}
	} else alert("Keine Person ausgewählt!");
}

function delVeranstalter() {
	if (document.main.teilnehmerAuswahlIdList.selectedIndex > -1) { 
		document.main.teilnehmerAuswahlIdList.options[0] = null;
	} else alert("Kein Veranstalter ausgewählt!");
}

function vortragPosition(richtung) {
	tmpId = "";
	tmpWert = "";
	flagg = 0;
	count = 0;
	
	if (document.main.vortragAuswahlIdList.selectedIndex > -1) { 
	//	for(i=0; i<document.main.vortragAuswahlIdList.length; i++) {
	//		if(document.main.vortragAuswahlIdList.options[i].selected == true) {
	//			count = count + 1;
	//		}
	//	}
		
	//	if (count==1){
			for(i=0; i<document.main.vortragAuswahlIdList.length; i++) {
				if(document.main.vortragAuswahlIdList.options[i].selected == true)
		 		{
		 			if (richtung<0) {
						if (i>0) {
			 				tmpId = document.main.vortragAuswahlIdList.options[i-1].value;
			 				tmpWert = document.main.vortragAuswahlIdList.options[i-1].text;
			 				
			 				document.main.vortragAuswahlIdList.options[i-1].text  = document.main.vortragAuswahlIdList.options[i].text;
			 				document.main.vortragAuswahlIdList.options[i-1].value  = document.main.vortragAuswahlIdList.options[i].value;
			 				
			 				document.main.vortragAuswahlIdList.options[i].text  = tmpWert;
			 				document.main.vortragAuswahlIdList.options[i].value  = tmpId;
			 				
			 				flagg = i-1;
		 				} else flagg = i;
		 			} else {
		 				if (i<(document.main.vortragAuswahlIdList.length-1)) {
			 				tmpId = document.main.vortragAuswahlIdList.options[i+1].value;
			 				tmpWert = document.main.vortragAuswahlIdList.options[i+1].text;
			 				
			 				document.main.vortragAuswahlIdList.options[i+1].text  = document.main.vortragAuswahlIdList.options[i].text;
			 				document.main.vortragAuswahlIdList.options[i+1].value  = document.main.vortragAuswahlIdList.options[i].value;
			 				
			 				document.main.vortragAuswahlIdList.options[i].text  = tmpWert;
			 				document.main.vortragAuswahlIdList.options[i].value  = tmpId;
			 				
			 				flagg =  i+1;
		 				} else flagg = i;
		 			}
		 			break;
		 		}
			}
	//	} else alert("Bitte nur einen Vortrag auswählen!");
		for(i=0; i<document.main.vortragAuswahlIdList.length; i++) {
			if (i==flagg) {
				document.main.vortragAuswahlIdList.options[i].selected = true;
			} else document.main.vortragAuswahlIdList.options[i].selected = false;
		}
	} else alert("Keine Vortrag ausgewählt!");
}
var stammdatenWindow = null;
function centerPopup(popup_name,popup_url,popup_with,popup_height,myWidth,myHeight) {
	 var previousWindow = null;
		
	

	 if(stammdatenWindow!= null && !stammdatenWindow.closed && stammdatenWindow.name == popup_name){
	 	previousWindow = stammdatenWindow;
	 }
	
	 if ( previousWindow!= null) {
    	if (previousWindow.closed) {   	 
    		previousWindow =null;
    	} else {
        	previousWindow.close();
        }
    }
	if(!myWidth) {myWidth = 10;}
	if(!myHeight){myHeight = 50;}
	var popup_left = (window.screen.width/2)  - (popup_with/2 + myWidth);
	var popup_top  = (window.screen.height/2) - (popup_height/2 + myHeight);
	previousWindow = window.open(popup_url,popup_name,"toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + popup_with + ",height=" + popup_height + ",left=" + popup_left + ",top=" + popup_top + ",screenX=" + popup_left + ",screenY=" + popup_top);
	previousWindow.focus();
	return previousWindow;
}

function stammdaten() {
	stammdatenWindow=centerPopup('stammdatenPopup','../../servlet/Action?action=stammdatenHM','800','640');
}

function mitgliedVerband() {
	stammdatenWindow=centerPopup('mitgliedVerbandPopup','../../servlet/Action?action=mitgliedVerbandSchluessel','800','640');
}

function selectMitgliedVerband(value) {
	var match = 0;
	for(i = 0; i < document.main.unterVerband.length; i++) {
		if (document.main.unterVerband.options[i].value == value) {
			document.main.unterVerband.options[i].selected = true;
			match = 1;
		} else document.main.unterVerband.options[i].selected = false;
	}
	if (match == 0) alert("Sie haben keine Berechtigung, diesen Verband auszuwählen.\nEine Auswahl ist nur innerhalb der eigenen Verbandsstruktur möglich!");
}

function closePopup(popup_name) {
	if(stammdatenWindow!= null && !stammdatenWindow.closed && stammdatenWindow.name == popup_name){
	 	if (stammdatenWindow.closed) {   	 
			stammdatenWindow =null;
		} else {
	    	stammdatenWindow.close();
	    }
	}
}
function reloadParent() {
	if(self.window.name=='stammdatenPopup'){
		if(window.opener){
			window.opener.location.reload();
		}
	}
}

function taetigkeitHinzu(){
  if (document.main.taetigkeit.selectedIndex > 0) { 
	  for(i=0; i<document.main.taetigkeit.length; i++) {
		if(document.main.taetigkeit.options[i].selected == true){
			text = document.main.taetigkeit.options[i].text
			value = document.main.taetigkeit.options[i].value
		}
	  }
	  lokation = "Person.jsp?taetigkeitNeuText=" + text + "&taetigkeitNeuValue=" + value;
	  document.location.href = lokation;
  } else alert("Keine Tätigkeit ausgewählt!");
}

function addAdditionalFP(){
	if (document.main.optionalFocalPoint.selectedIndex > 0) { 
		for(i=0; i<document.main.optionalFocalPoint.length; i++) {
			if(document.main.optionalFocalPoint.options[i].selected == true){
				text = document.main.optionalFocalPoint.options[i].text
				value = document.main.optionalFocalPoint.options[i].value
			}
		}
		lokation = "Person.jsp?afpText=" + text + "&afpValue=" + value;
		document.location.href = lokation;
	} else alert("Nichts ausgewählt!");
}

function addGremium(){
	if (document.main.gremium.selectedIndex > 0) { 
		for(i=0; i<document.main.gremium.length; i++) {
			if(document.main.gremium.options[i].selected == true){
				text = document.main.gremium.options[i].text
				value = document.main.gremium.options[i].value
			}
		}
		lokation = "Person.jsp?gremText=" + text + "&gremValue=" + value;
		document.location.href = lokation;
	} else alert("Nichts ausgewählt!");
}

function zusatzqualifikationHinzu(){
var form = document.main;
var params=getAdditionalParameters(form, "additionalOptionDate");
	if (document.main.zusatzqualifikation.selectedIndex > 0) { 
		for(i=0; i<document.main.zusatzqualifikation.length; i++) {
			if(document.main.zusatzqualifikation.options[i].selected == true){
				text = document.main.zusatzqualifikation.options[i].text
				value = document.main.zusatzqualifikation.options[i].value
			}
		}
		lokation = "Person.jsp?zusatzqualifikationNeuText=" + text + "&zusatzqualifikationNeuValue=" + value+"&additionalParams="+params;
		document.location.href = lokation;
	} else alert("Keine Zusatzqualifikation ausgewählt!");
}

function getAdditionalParameters(form, elementName, index){
var params="";
var j = 0;
for (var i = 0; i<form.length;i++ ){
	if(form.elements[i].name == elementName){
			if(index == null || j != index){
				form.elements[i].value == "" ? params += " ;" : params += form.elements[i].value+";"
				}
			j++;
			}
	}
return params;
}

function removeDirector(object, index){
var form = document.main;
var forwardURI = object+"Ext.jsp";
var params=getAdditionalParameters(form, "comment", index);
	document.location.href = forwardURI+"?removeDirector="+index+"&additionalParams="+params;
}

function addDirector(object, test){
var form = document.main;
var forwardURI = object+"Ext.jsp";
var params=getAdditionalParameters(form, "comment", null);
var selectedIndex = document.main.directors.selectedIndex;
if (selectedIndex > 0) { 
	var id = document.main.directors.options[selectedIndex].value
	document.location.href = forwardURI+"?addDirector="+id+"&additionalParams="+params;
	} else alert("Keine Leiter selektiert!");

}

function berufsfunktionHinzu(){
var form = document.main;
var params=getAdditionalParameters(form, "approvalDate");
	if (document.main.berufsfunktion.selectedIndex > 0) { 
		for(i=0; i<document.main.berufsfunktion.length; i++) {
			if(document.main.berufsfunktion.options[i].selected == true){
					text = document.main.berufsfunktion.options[i].text
					value = document.main.berufsfunktion.options[i].value
			}
		}
		lokation = "Person.jsp?berufsfunktionNeuText=" + text + "&berufsfunktionNeuValue=" + value+"&additionalParams="+params;
		document.location.href = lokation;
	} else alert("Keine Berufsfunktion ausgewählt!");
}

function kongressfunktionHinzu(){
var form = document.main;
var params=getAdditionalParameters(form, "kongressFktComment");
	if (document.main.kongressfunktion.selectedIndex > 0) { 
		for(i=0; i<document.main.kongressfunktion.length; i++) {
			if(document.main.kongressfunktion.options[i].selected == true){
				text = document.main.kongressfunktion.options[i].text
				value = document.main.kongressfunktion.options[i].value
			}
		}
		lokation = "Person.jsp?kongressfunktionNeuText=" + text + "&kongressfunktionNeuValue=" + value+"&additionalParams="+params;
		document.location.href = lokation;
		} else alert("Keine Kongressfunktion ausgewählt!");
}

function opschwerpunktHinzu(){
	if (document.main.opSchwerpunkt.selectedIndex > 0) { 
		for(i=0; i<document.main.opSchwerpunkt.length; i++) {
			if(document.main.opSchwerpunkt.options[i].selected == true){
				text = document.main.opSchwerpunkt.options[i].text
				value = document.main.opSchwerpunkt.options[i].value
			}
		}
		lokation = "KlinikExt.jsp?opschwerpunktNeuText=" + text + "&opschwerpunktNeuValue=" + value;
		document.location.href = lokation;
	} else alert("Kein OP-Schwerpunkt ausgewählt!");
}

function opschwerpunktPHinzu(){
	if (document.main.opSchwerpunkt.selectedIndex > 0) { 
		for(i=0; i<document.main.opSchwerpunkt.length; i++) {
			if(document.main.opSchwerpunkt.options[i].selected == true){
				text = document.main.opSchwerpunkt.options[i].text
				value = document.main.opSchwerpunkt.options[i].value
			}
		}
		lokation = "PraxisExt.jsp?opschwerpunktNeuText=" + text + "&opschwerpunktNeuValue=" + value + "&showTab=tab2";
		document.location.href = lokation;
	} else alert("Kein OP-Schwerpunkt ausgewählt!");
}

function opschwerpunktPHinzuK(){
	if (document.main.opSchwerpunkt.selectedIndex > 0) { 
		for(i=0; i<document.main.opSchwerpunkt.length; i++) {
			if(document.main.opSchwerpunkt.options[i].selected == true){
				text = document.main.opSchwerpunkt.options[i].text
				value = document.main.opSchwerpunkt.options[i].value
			}
		}
		lokation = "KlinikExt.jsp?opschwerpunktNeuText=" + text + "&opschwerpunktNeuValue=" + value + "&showTab=tab2";
		document.location.href = lokation;
	} else alert("Kein OP-Schwerpunkt ausgewählt!");
}

function schwerpunktHinzu(){
	if (document.main.schwerpunkt.selectedIndex > 0) { 
		for(i=0; i<document.main.schwerpunkt.length; i++) {
			if(document.main.schwerpunkt.options[i].selected == true){
				text = document.main.schwerpunkt.options[i].text
				value = document.main.schwerpunkt.options[i].value
			}
		}
		lokation = "PraxisExt.jsp?schwerpunktNeuText=" + text + "&schwerpunktNeuValue=" + value + "&showTab=tab2";
		document.location.href = lokation;
	} else alert("Kein Schwerpunkt ausgewählt!");
}

function schwerpunktHinzuK(){
	if (document.main.schwerpunkt.selectedIndex > 0) { 
		for(i=0; i<document.main.schwerpunkt.length; i++) {
			if(document.main.schwerpunkt.options[i].selected == true){
				text = document.main.schwerpunkt.options[i].text
				value = document.main.schwerpunkt.options[i].value
			}
		}
		lokation = "KlinikExt.jsp?schwerpunktNeuText=" + text + "&schwerpunktNeuValue=" + value + "&showTab=tab2";
		document.location.href = lokation;
	} else alert("Kein Schwerpunkt ausgewählt!");
}

function verbandfunktionHinzu(){
	if (document.main.verbandFunktion.selectedIndex > 0) { 
		for(i=0; i<document.main.verbandFunktion.length; i++) {
			if(document.main.verbandFunktion.options[i].selected == true){
				text = document.main.verbandFunktion.options[i].text
				value = document.main.verbandFunktion.options[i].value
			}
		}
		lokation = "Mitglied.jsp?verbandfunktionNeuText=" + text + "&verbandfunktionNeuValue=" + value;
		document.location.href = lokation;
	} else alert("Keine Verbandsfunktion ausgewählt!");
}

function seminarListe() {
	stammdatenWindow=centerPopup('stammdatenPopup','../../servlet/Public?action=seminarKalenderLaden','800','640');
}

function gotoKalenderDatum(nextDialog, zeit) {
	location.href = "index.jsp?datum=" + nextDialog+"&zeit="+zeit;
}

function gotoKalenderDatumPlaner(nextDialog, zeit) {
	location.href = "../../servlet/Kongressplaner?action=gotoKalenderDatum&datum=" + nextDialog+"&zeit="+zeit;
}

function gotoKalenderDatumPlanerExt(nextDialog, zeit) {
	location.href = "../../servlet/Public?action=gotoKalenderDatum&datum=" + nextDialog+"&zeit="+zeit;
}

function gotoKalenderDatumPlanerExt2(nextDialog) {
	zeit = document.forms[this.formName].zeit.options[document.forms[this.formName].zeit.selectedIndex].value;
	location.href = "../../servlet/Public?action=gotoKalenderDatum&datum=" + nextDialog+"&zeit="+zeit;
}

function saveasnew(nextDialog, zeit) {
	titel = prompt("Bitte geben Sie einen Titel ein.","Neue Version ...");
	if (titel.length==0){
		titel="kein Titel";
	}
	location.href = "../../servlet/Kongressplaner?action=saveAsNew&titel="+titel;
	
}

function setRaum() {
	if(document.main.seminarRaumH.selectedIndex > 0) document.main.seminarRaum.value = document.main.seminarRaumH.options[document.main.seminarRaumH.selectedIndex].value;
}

function launchApp(strCmdLine)
{
    var obj = new ActiveXObject("LaunchinIE.Launch");
    obj.LaunchApplication(strCmdLine);
}
  
function openDoc(strDoc)
{
    var obj = new ActiveXObject("LaunchinIE.Launch");
    obj.ShellExecute("open", strDoc);
}
  
function fillDefaultValues(textArea){
textArea.value = defaultValues;
}

function fillValueinTextField(destination, content){
destination.value = content;
}


function luis(stra, link_1){
	var elements = document.getElementsByTagName("td");
	var link = document.getElementById(link_1);

	for(i=0;i<elements.length;i++){
		var elem = elements[i];
		if (elem.getAttribute("id")==stra) {
			if (elem.style.visibility == 'hidden') {
				elem.style.visibility = 'visible';
				link.firstChild.nodeValue = "verbergen";
			}else{
				elem.style.visibility = 'hidden';
				var link = document.getElementById(link_1);
				link.firstChild.nodeValue = "anzeigen";
//				elem.style.z-index=9999;
			}
			
		}
	}
}

function getRelatedAdresses(){
	var hiddenSubmitter = top.window.frames['AddressBox'].document.forms['hiddenSubmitForm'];
	var mainForm = document.forms['main'];
	hiddenSubmitter.elements[param_Ort].value = mainForm.elements[param_Ort].value;
	hiddenSubmitter.elements[param_PLZ].value = mainForm.elements[param_PLZ].value;
	hiddenSubmitter.elements[param_Strasse].value = mainForm.elements[param_Strasse].value;
	hiddenSubmitter.elements[param_Land].value = mainForm.elements[param_Land].value;
	hiddenSubmitter.elements[param_desrciption].value = mainForm.elements[param_desrciption].value;
	hiddenSubmitter.elements[param_idAddresse].value = mainForm.elements[param_idAddresse].value;
	hiddenSubmitter.submit();
}

function setValuetoCombo(combo, defaultValue){
	for(iIndex=0;iIndex<combo.length;iIndex++){
		var valueCombo = combo.options[iIndex].text;
		if(valueCombo.toLowerCase()==defaultValue){
			combo.options.selectedIndex = iIndex;
			continue;
		}
	}
}
function plz(feldPlz, feldOrt, feldStrasse) {
	var plz = document.main.elements[feldPlz].value;
	if (plz.length != 5) {
		alert("Das Format der Postleitzahl ist falsch!");
		return;
	}
	var str = '&feldOrt='+feldOrt+'&feldStrasse='+feldStrasse
	stammdatenWindow=centerPopup('plz','../../servlet/Action?action=zipcodeSuchen&zipcode=' + plz + str,'800','640');
}

function updateplz(city, street, feldOrt, feldStrasse) {
	if (street.length > 1) opener.document.main.elements[feldStrasse].value = street;
	if (city.length > 1) opener.document.main.elements[feldOrt].value = city;
	window.close();
}

function addPreisM1(){
	if(document.main.mitgliedPreis1.checked){
		document.main.kostenfrei.checked = "checked";
		m_value_1 = eval(document.main.mitgliedPreis1.value);
		alert("m_value_1 " + m_value_1);
		addPreisM(m_value_1);
	}
}

function addPreisN1(){
	if(document.main.nichtMitgliedPreis1.checked){
		m_value_1 = eval(document.main.nichtMitgliedPreis1.value);
		alert("m_value_1 " + m_value_1);
		addPreisN(m_value_1);
	}
}

function addPreisDate(){
	if(document.main.mitgliedPreis2.checked){
		m_value_2 = eval(document.main.mitgliedPreis2.value);
		addPreisM(m_value_2);	
	}
}

function addPreisM2(){
 	if(!document.main.mitgliedPreis1.checked){
 	    if(!document.main.mitgliedPreis3.checked){
 			document.main.mitgliedPreis3.checked = "checked";
			m_value_3 = eval(document.main.mitgliedPreis3.value);
			alert("m_value_3 " + m_value_3);
	        addPreisM(m_value_3);		
 	    }else{
 	    	return;
 	    }
    }
}

function addPreisN2(){
	if(document.main.nichtMitgliedPreis2.checked){
 		if(!document.main.nichtMitgliedPreis1.checked){
			document.main.nichtMitgliedPreis3.checked = "checked";
			m_value_3 = eval(document.main.nichtMitgliedPreis3.value);
			alert("m_value_3 " + m_value_3);
            addPreisN(m_value_3);		
         }
		m_value_2 = eval(document.main.nichtMitgliedPreis2.value);
		alert("m_value_2 " + m_value_2);
		addPreisN(m_value_2);
	}
}

function addPreisM3(){
    if(document.main.kostenfrei.checked){
    	return;
    } 
	if(document.main.mitgliedPreis3.checked){
		m_value_1 = eval(document.main.mitgliedPreis3.value);
		alert("m_value_1 " + m_value_1);
		addPreisM(m_value_1);
	}
}

function addPreisN3(){
	if(document.main.nichtMitgliedPreis3.checked){
		m_value_1 = eval(document.main.nichtMitgliedPreis3.value);
		alert("m_value_1 " + m_value_1);
		addPreisN(m_value_1);
	}
}

function addPreisM(x){
	sum_1 = eval(document.main.mitgliedGesamtbetrag.value);
	document.main.mitgliedGesamtbetrag.value = sum_1 + x;
}

function addPreisN(x){
	sum_1 = eval(document.main.nichtMitgliedGesamtbetrag.value);
	document.main.nichtMitgliedGesamtbetrag.value = sum_1 + x;
}

function addselection(x,y){
		if (x != "") { 
			//document.location.href = y+x;
			ct_main.checkQuitAW(y+x);
		} else {
			alert("Bitte Wert auswählen!");
		}	
}

function addselection(x,y,check){
	if (x != "") { 
		//document.location.href = y+x;
		if(check == "true"){
			ct_main.checkQuitAW(y+x);
		}else{
			document.location.href = y+x;
		}
		
	} else {
		alert("Bitte Wert auswählen!");
	}	
}

function launchApp(strCmdLine)
{
	alert(strCmdLine);
    var obj = new ActiveXObject("LaunchinIE.Launch");
    obj.LaunchApplication(strCmdLine);
}


function closeDialog(){
		if(nwindow != null && !nwindow.closed){
			nwindow.close();
		}
}


function addPersonIdZugang(x) {
	if (document.main.personAuswahlIdList.selectedIndex > -1) { 
		for(i=0; i<document.main.personAuswahlIdList.length; i++) {
			if(document.main.personAuswahlIdList.options[i].selected == true)
	 		{
	  			location.href="../../servlet/AenderungsMeldungen?action=anmeldungSelectPersonId&index="+i+"&aid="+x;
	 		}
		}
	} else alert("Keine Person ausgewählt!");
	
}

