
function bearbeitenRS (xmloid, teil, type, zusatz, returl){
	// hier wird mit in zusatz der Pfadname übergeben, damit angezeigt wird wohin das Rundschreiben geht
	var chkOid = 1;
	for(i=0;i<xmloid.length;++i)
		if(xmloid.charAt(i) < "0" || xmloid.charAt(i) > "9")
			chkOid = -1;
	if(chkOid == 1){
		teilUp = teil.toUpperCase();
		document.write("<span  class=\"editLink\"><a href=\"/VISTEST_p/formservlet?xmloid=" + xmloid + "&xslpart=" + teil + "&bereichname=" + zusatz + "&pagetype=" + type + "&action=checkout&returl=" + returl + "\">Bearbeiten</a></span><br>&nbsp;<br>");
	}
}

function bearbeitenRSZugriff (xmloid, teil, type, zusatz, returl, status){
	if (status == "editable"){
		bearbeitenRS(xmloid, teil, type, zusatz, returl);
	}
}

function confirmRelease (xmloid, returl, was) {
	var check = window.confirm("Sie beabsichtigen, " + was + " freizugeben. Möchten Sie fortfahren?");
	if (check == true) {
		directSubmitForm(xmloid, returl);
	}
	return check;
}

function direktFreigeben (xmloid, status, returl, was) {
	if (status == "submittable"){
		document.write("<button class=\"direktfreigabe\" onclick=\"runSubmit" + was + "('freigabe','" + xmloid + "','" + returl + "')\">Direkt freigeben</button>");
 	}
}

function directSubmitForm(xmloid, returl){
	location.href = "/VISTEST_p/formservlet?xmloid=" + xmloid + "&action=directsubmit&returl=" + returl;
}

function printAnAus (xmloid, was, ordner){
	var adresse = self.location.href;
	if (adresse.indexOf("formservlet?") < 0) {
		document.write("<a href=\"javascript:openpopup('http://visportal.gdv.org" + ordner + "/include/jsp/" + was + ".jsp?oid=" + xmloid + "','print','460','580',1,0);\"><img src=\"http://visportal.gdv.org" + ordner + "/images/drucker.gif\" width=\"14\" height=\"12\" alt=\"\" border=\"0\"/> Drucken</a>");
	}
}

function getVIPURL(url) {return url}

function setFormValues(wert,feld){
	editform.feld.value = wert; 
	return true;
}

// ***** Bezüge *****
function setLinkUrl(){
	var link = "";
	for (var i = 0; i < document.linkform.bezug.length; i++){
		if(document.linkform.bezug[i].checked == true){
			link = link + ":" + document.linkform.bezug[i].value;
		}
	}
	window.opener.document.bezuege.newoid.value = link;	
	window.opener.document.bezuege.submit();	
	window.close();
}
// ***** Ende Bezüge *****

// Übertragungspfeile
function insert(liste, anzeige, auswahl) {
	var feldListe = eval("document.editform." + liste);
	var feldAuswahl = eval("document.editform." + anzeige);
	var feldHidden = eval("document.editform." + auswahl);

	if (feldListe.options.selectedIndex != -1) {
		var exist;
		index = feldAuswahl.length;
		for ( i=0; i<index; i++ ){
			if ( feldAuswahl.options[i].value == feldListe.options[feldListe.options.selectedIndex].value ){
				exist = true;
			}
		}
		if ( !exist ){
			feldAuswahl.options[index] = new Option(feldListe.options[feldListe.options.selectedIndex].text, feldListe.options[feldListe.options.selectedIndex].value);
			var hiddenInhalt = feldHidden.value;
			if(hiddenInhalt.indexOf(feldListe.options[feldListe.options.selectedIndex].value)<0){
				if(feldListe.options[feldListe.options.selectedIndex].value == feldListe.options[feldListe.options.selectedIndex].text){
					hiddenInhalt = hiddenInhalt + ":" + feldListe.options[feldListe.options.selectedIndex].value;
				}
				else{
					hiddenInhalt = hiddenInhalt + ":" + feldListe.options[feldListe.options.selectedIndex].value + ";" + feldListe.options[feldListe.options.selectedIndex].text;
				}
				feldHidden.value = hiddenInhalt;
			}
		}
	}
}

function insertThemen(liste, anzeige, auswahl) {
	var feldListe = eval("document.editform." + liste);
	var feldAuswahl = eval("document.editform." + anzeige);
	var feldHidden = eval("document.editform." + auswahl);

	if (feldListe.options.selectedIndex != -1) {
		var exist;
		index = feldAuswahl.length;
		for ( i=0; i<index; i++ ){
			if ( feldAuswahl.options[i].value == feldListe.options[feldListe.options.selectedIndex].value ){
				exist = true;
			}
		}
		if ( !exist ){
			feldAuswahl.options[index] = new Option(feldListe.options[feldListe.options.selectedIndex].text, feldListe.options[feldListe.options.selectedIndex].value);
			var hiddenInhalt = feldHidden.value;
			if(hiddenInhalt.indexOf(feldListe.options[feldListe.options.selectedIndex].value)<0){
				if(feldListe.options[feldListe.options.selectedIndex].value == feldListe.options[feldListe.options.selectedIndex].text){
					hiddenInhalt = hiddenInhalt + ":" + feldListe.options[feldListe.options.selectedIndex].value;
				}
				else{
					hiddenInhalt = hiddenInhalt + ":" + feldListe.options[feldListe.options.selectedIndex].text;
				}
				feldHidden.value = hiddenInhalt;
			}
		}
	}
}

function erase(auswahl,anzeige) {
	var feldAuswahl = eval("document.editform." + anzeige);
	var feldHidden = eval("document.editform." + auswahl);

	if (feldAuswahl.options.selectedIndex != -1){
		var text = feldAuswahl.options[feldAuswahl.options.selectedIndex].value;
		var hiddenText = feldHidden.value;
		if(hiddenText.indexOf(text) > -1){
			var ersterString = hiddenText.substring(0,hiddenText.indexOf(text));
			hiddenText = hiddenText.substring(hiddenText.indexOf(text));
			var zweiterString = "";
			if(hiddenText.indexOf(":") > -1){
				zweiterString = hiddenText.substring(hiddenText.indexOf(":")+1);
			}
			hiddenText = ersterString +zweiterString;
			feldHidden.value = hiddenText;
		}
		feldAuswahl.options[feldAuswahl.options.selectedIndex] = null;		
	}
}

// Übertragungspfeile für Single Auswahl (Abteilungen bei Terminen)

function insertSingle(liste, anzeige, auswahl) {
	var feldListe = eval("document.editform." + liste);
	var feldAuswahl = eval("document.editform." + anzeige);
	var feldHidden = eval("document.editform." + auswahl);

	if (feldListe.options.selectedIndex != -1) {
		var exist;
		index = feldAuswahl.length;
		if (index > 0) {
			if ( feldAuswahl.options[0].value == feldListe.options[feldListe.options.selectedIndex].value ){
				exist = true;
			}
		}
		if ( !exist ){
			feldAuswahl.options[0] = new Option(feldListe.options[feldListe.options.selectedIndex].text, feldListe.options[feldListe.options.selectedIndex].value);
			var hiddenInhalt = feldHidden.value;
			if(hiddenInhalt.indexOf(feldListe.options[feldListe.options.selectedIndex].value)<0){
				if(feldListe.options[feldListe.options.selectedIndex].value == feldListe.options[feldListe.options.selectedIndex].text){
					hiddenInhalt = feldListe.options[feldListe.options.selectedIndex].value;
				}
				else if(feldListe.options[feldListe.options.selectedIndex].value >= 0){
					hiddenInhalt = feldListe.options[feldListe.options.selectedIndex].text;
				}
				else{
					hiddenInhalt = feldListe.options[feldListe.options.selectedIndex].value + ";" + feldListe.options[feldListe.options.selectedIndex].text;
				}
				feldHidden.value = hiddenInhalt;
			}
		}
	}
}


/***** Funktionen, die nicht gebraucht werden. Waren ursprünglich da. Prüfen!! *****/
/*
function anmelden (signal, sitzungstag, sitzungsmonat, sitzungsjahr, check){
	document.write("<a href='/VISTEST_p/VIS/VIS/Suche/komm_anmeldeform.jsp?komm="+signal+"&termin="+sitzungstag+sitzungsmonat+sitzungsjahr+"&anm="+check+"'>Zur Anmeldung</a>");
}
*/

function bearbeiten (xmloid, position, teil, type, returl){
	var chkOid = 1;
	for (i = 0; i < xmloid.length; ++i)
		if(xmloid.charAt(i) < "0" || xmloid.charAt(i) > "9")
			chkOid = -1;
	if(chkOid == 1){
		document.write("<span  class=\"editLink\"><a href=\"/VISTEST_p/formservlet?xmloid=" + xmloid + "&xslpart="+teil+"&pagetype="+type+"&position=" + position + "&checkout=true&returl=" + returl + "\">Bearbeiten</a></span><br>&nbsp;<br>");
	}
}

function bearbeiten (xmloid, teil, type, returl){
	var chkOid = 1;
	for(i = 0; i < xmloid.length; ++i)
		if(xmloid.charAt(i) < "0" || xmloid.charAt(i) > "9")
			chkOid = -1;
	if(chkOid == 1){
		teilUp = teil.toUpperCase();
		document.write("<span  class=\"editLink\"><a href=\"/VISTEST_p/formservlet?xmloid=" + xmloid+"&xslpart="+teil+"&pagetype="+type+"&action=checkout&returl=" + returl + "\">Bearbeiten</a></span><br>&nbsp;<br>");
	}
}

function openGrafikFenster(grafiklink, formname){
	// alert(grafiklink);
	// alert(formname);
	ImageFenster = window.open('/VISTEST_p/VIS/VIS/Vorlagen/util/upload.jsp?link=' + grafiklink + '&name=' + formname, 'Grafikfenster', 'width=680,height=650,left=20,top=20,resizable=yes,dependent=yes,scrollbars=yes');
	ImageFenster.focus();
}

function openLinkFenster(link, formname) {
	// alert(link);
	// alert(formname);
	LinkFenster = window.open(/*VIPURL*/'/VISTEST_p/FormGenerator_Standalone/util/additionalFeatures/linkliste.jsp?link=' + link + '&name=' + formname, 'Linkfenster', 'width=820,height=550,left=20,top=20,resizable=yes,dependent=yes,scrollbars=yes');
	LinkFenster.focus();
}
 
function submitForm(xmloid, returl){
	wfmessage = document.editform.wfmessage.value;
	// alert(xmloid);
	// alert(returl);
	// alert(wfmessage);
	location.href="/VISTEST_p/formservlet?xmloid=" + xmloid + "&action=submit&returl=" + returl + "&wfmessage=" + wfmessage;
}

function vorlegen(xmloid, status, returl){
	if (status == "submittable"){
		document.write("<br>");	
		document.write("&nbsp;&nbsp;&nbsp;Mitteilung an den Qualit&auml;tssicherer:<br>");	
		document.write("&nbsp;&nbsp;&nbsp;");	
		document.write("<textarea rows=\"3\"  name=\"wfmessage\"></textarea><br>"); 
		document.write("&nbsp;&nbsp;&nbsp;");	
	document.write("<button onclick=\"javascript:submitForm('" + xmloid + "','" + returl + "')\">&Auml;nderungen vorlegen</button>");
 	}
}

function QS(vipoid, status, returl){
	if (status == "releasable") {
		document.write("<br>");
		document.write("<form name=\"editform\">");	
		document.write("&nbsp;&nbsp;&nbsp;Mitteilung:<br>");	
		document.write("<textarea rows=\"3\"  name=\"wfmessage\"></textarea><br>"); 
		document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		document.write("<button onclick=\"javascript:release('" + vipoid + "','" + returl + "')\">Freigeben</button>");
		document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
		document.write("<button onclick=\"javascript:reject('" + vipoid + "','" + returl + "')\">Ablehnen</button>");
		document.write("</form>");
	}
}	

function reject(xmloid, returl){
	wfmessage = document.editform.wfmessage.value;
	// alert(xmloid);
	// alert(returl);
	// alert(wfmessage);
	location.href = "/VISTEST_p/formservlet?xmloid=" + xmloid + "&action=reject&returl=" + returl + "&wfmessage=" + wfmessage;
}

function release(xmloid, returl){
	wfmessage = document.editform.wfmessage.value;
	// alert(xmloid);
	// alert(returl);
	// alert(wfmessage);
	location.href = "/VISTEST_p/formservlet?xmloid=" + xmloid + "&action=release&returl=" + returl + "&wfmessage=" + wfmessage;
}
