function go_main(lang)
{
	document.f3.lang.value = lang;
	document.f3.action = "main.php";
	document.f3.submit();
}

function goto(men)
{
	document.f3.men.value = men;
	document.f3.sub_men.value = "";
	document.f3.action = "main.php";
	document.f3.submit();
}

function gotosub(submen)
{
	document.f3.men.value = 'program';
	document.f3.sub_men.value = submen;
	document.f3.action = "main.php";
	document.f3.submit();
}

function language(lang)
{
	
	document.f3.lang.value = lang;
	document.f3.action = "main.php";
	document.f3.submit();
}

function show_popup(style,path)
{
	var path = "popup.php?style=" + style + "&img=" + path;
	///alert(path);
	f1 = window.open(path,"PETOPA","width=800,height=600,screenX=0,screenY=0,menubar=no,scrollbars=yes,resizable=yes,status=yes");
	f1.focus();

}


function chkFormular() 
{ 
	if(document.f3.Firma.value == "")  { 
		alert("Bitte geben Sie Ihre Firma an."); 
		document.f3.Firma.focus(); 
		return false; 
	} 
 
	if(document.f3.Ansprechpartner.value == "")  { 
		alert("Bitte geben Sie einen Ansprechpartner an."); 
		document.f3.Ansprechpartner.focus(); 
		return false; 
	} 
 	if(document.f3.Strasse.value == "")  { 
		alert("Bitte geben Sie eine Strasse an."); 
		document.f3.Strasse.focus(); 
		return false; 
	} 
 	if(document.f3.PLZ.value == "")  { 
		alert("Bitte geben Sie Ihre PLZ an."); 
		document.f3.PLZ.focus(); 
		return false; 
	} 
 	if(document.f3.Ort.value == "")  { 
		alert("Bitte geben Sie einen Ort an."); 
		document.f3.Ort.focus(); 
		return false; 
	} 
 	if(document.f3.Telefon.value == "")  { 
		alert("Bitte geben Sie eine Telefonnummer an."); 
		document.f3.Telefon.focus(); 
		return false; 
	} 
 
	if(document.f3.email.value == "")  { 
		alert("Bitte geben Sie Ihre eMail-Adresse an."); 
		document.f3.email.focus(); 
		return false; 
	} 
 	var mm_email_check = document.f3.email.value.match(/^[a-z\d][\w\d_\.-]+@([a-z\d][a-z\d\-]+[a-z\d]\.)+\w{2,6}$/i); 
	if(!mm_email_check && document.f3.email.value !="")  { 
		alert("Bitte geben Sie eine gültige eMail-Adresse an."); 
		document.f3.email.focus(); 
		return false; 
	} 
	document.f3.aktion.value = "mail_send";
	document.f3.submit()
}

/*

// SOME GENERIC FUNCTIONS FOR USE IN ALL THE PAGES
	function gopage(script)
	{
		document.f3.action = script;
		if (script == "index.php") {
			document.f3.page.value = "index";
		}
		else if (script == "collection.php") {
			document.f3.page.value = "collection";
		}
		else if (script == "philosophy.php") {
			document.f3.page.value = "philosophy";
		}
		else if (script == "company.php") {
			document.f3.page.value = "company";
		}
		else if (script == "sales.php") {
			document.f3.page.value = "sales";
		}
		else if (script == "press.php") {
			document.f3.page.value = "press";
		}
		else if (script == "contact.php") {
			document.f3.page.value = "contact";
		}
		else if (script == "about.php") {
			document.f3.page.value = "about";
		}
		document.f3.submit();
	}

	function home()
	{
		///alert("home");
		document.f3.page.value = "index";
		document.f3.action = "index.php";
		document.f3.submit();
	}
	
	function language()
	{
		if (document.f3.lang.value == "DE") {
			document.f3.lang.value = "EN";
		}
		else {
			document.f3.lang.value = "DE";
		}
		document.f3.submit();
	}
	
	function collselect(img, img_select)
	{
		///document.f3_image_id.value = img;
		var idArr = document.f3.id_arr.value.split(";");
		var thmbArr = document.f3.thmb_arr.value.split(";");
		var thmbInArr = document.f3.thmb_arr_in.value.split(";");
		var bigArr = document.f3.big_arr.value.split(";");
		///alert(img_select);
		if (img_select == "start") {
			///Aufruf zum ersten mal
			document.f3.big.src = bigArr[0];
			var thmb = "document.f3.thmb_" + idArr[0] + ".src = \"" + thmbArr[0] + "\"";
			eval(thmb);
		}
		else {
			///suchen nach index
			for (var i = 0; i < idArr.length; i++) {
				if (idArr[i] == img) {
					document.f3.big.src = bigArr[i];
					var thmb = "document.f3.thmb_" + img + ".src = \"" + thmbArr[i] + "\"";
					///alert(thmb);
					eval(thmb);
				}
				else {
					var n = i + 1;
					var thmb = "document.f3.thmb_" + n + ".src = \"" + thmbInArr[i] + "\"";
					///alert(thmb);
					eval(thmb);
					
				}
			}
		}	
	}
	
	
	function send(lang)
	{

		///verify contactform
		if (document.f3.company.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre Firma ein!");
			}
			else {
				alert("Please insert your company!");
			}
			document.f3.company.focus();
			return;
		}
		if (document.f3.name.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre Namen ein!");
			}
			else {
				alert("Please insert your name!");
			}
			document.f3.name.focus();
			return;
		}
		if (document.f3.street.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre Strasse ein!");
			}
			else {
				alert("Please insert your street!");
			}
			document.f3.street.focus();
			return;
		}
		if (document.f3.city.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre PLZ / Ort ein!");
			}
			else {
				alert("Please insert your zipcode and city!");
			}
			document.f3.city.focus();
			return;
		}
		if (document.f3.telephon.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre Telefonnummer ein!");
			}
			else {
				alert("Please insert your phone-number!");
			}
			document.f3.telephon.focus();
			return;
		}
		if (document.f3.email.value == "") {
			if (lang == "DE") {
				alert("Bitte geben Sie Ihre E-Mail Adresse ein!");
			}
			else {
				alert("Please insert your email!");
			}
			document.f3.email.focus();
			return;
		}
		if(document.f3.email.value.match(/^[a-zA-Z0-9_\.-]{2,}@[a-z0-9-]{3,}\.[a-z]{2,4}|museum$/)) {
			
		}
		else{
			if (lang == "DE") {
	    		alert('E-Mailadresse ist NICHT gültig !');
	    	}
	    	else {
	    		alert('Your E-Mailadress is not valid !');
		    }
    		document.f3.email.focus();
    		return;
  		}
		if (document.f3.info.value == "" && !document.f3.call.checked && !document.f3.prospect.checked) {
			if (lang == "DE") {
				alert("Bitte geben Sie eine Nachricht ein!");
			}
			else {
				alert("Please insert a message!");
			}
			document.f3.info.focus();
			return;
		}

		document.f3.aktion.value = "send_email";
		document.f3.submit();
		
	}
	
	
	function sales_detail(val)
	{
		document.f3.city_select.value = val;
		document.f3.submit();
	}

	function sales_country(val)
	{
		document.f3.country_select.value = val;
		document.f3.city_select.value = "";
		document.f3.submit();
	}

	function press_cat(val)
	{
		document.f3.cat_select.value = val;
		document.f3.submit();
	}

	function show_content(type, filename)
	{
		if (type == "pdf" || type == "image") {
			var url = "upload/presse/" + filename;
		}
		if (type == "video") {
			var url = "press_vid_window.php?src=" + filename;
		}
		
	   	f2 = window.open(url,"module","width=760,height=600,screenX=0,screenY=0,menubar=no,scrollbars=yes,resizable=yes,status=yes");
	   	f2.focus();
	
	}

/*
	function resform()
	{
		///reservierungsanfrage checken
		if (document.f3.art[0].checked == false && document.f3.art[1].checked == false) {
			alert("Bitte wählen Sie zwischen Anfrage und Reservierung aus !");
			return;
		}
		else {
			if (document.f3.art[0].checked == true) {
				document.f3.artrec.value = "Anfrage";
			}
			else {
				document.f3.artrec.value = "Reservierung";
			}
		}
		if (document.f3.name.value == "") {
			alert("Bitte geben Sie Ihren Namen ein!");
			document.f3.name.focus();
			return;
		}
		if (document.f3.vorname.value == "") {
			alert("Bitte geben Sie Ihren Vornamen ein!");
			document.f3.vorname.focus();
			return;
		}
		if (document.f3.strasse.value == "") {
			alert("Bitte geben Sie Ihre Strasse ein!");
			document.f3.strasse.focus();
			return;
		}
		if (document.f3.plz_ort.value == "") {
			alert("Bitte geben Sie Ihre PLZ / Ortschaft ein!");
			document.f3.plz_ort.focus();
			return;
		}
		if (document.f3.telefon.value == "") {
			alert("Bitte geben Sie Ihre Telefonnummer ein!");
			document.f3.telefon.focus();
			return;
		}
		if (document.f3.email.value == "") {
			alert("Bitte geben Sie Ihre Emailadresse ein!");
			document.f3.email.focus();
			return;
		}
		if (document.f3.type[0].checked == false && document.f3.type[1].checked == false && document.f3.type[2].checked == false) {
			alert("Auf welche Art möchten Sie informiert werden ?");
			return;
		}
		else {
			if (document.f3.type[0].checked == true) {
				document.f3.back.value = "E-Mail";
			}
			if (document.f3.type[1].checked == true) {
					document.f3.back.value = "Fax";
			}
			if (document.f3.type[2].checked == true) {
					document.f3.back.value = "Post";
			}
		}
		document.f3.aktion.value = "sendemail";
		document.f3.job.value = "reservierung";
		document.f3.submit();
	}

	function resdel()
	{
		document.f3.name.value == "";
		document.f3.vorname.value == "";
		document.f3.strasse.value == "";
		document.f3.plz_ort.value == "";
		document.f3.land.value == "";
		document.f3.telefon.value == "";
		document.f3.email.value == "";
		document.f3.telefax.value == "";
		document.f3.anzahl_erw.value = "";
		document.f3.anzahl_kinder.value = "";
		document.f3.wuensche.value = "";
		document.f3.aktion.value = "";
		document.f3.job.value = "";
		document.f3.submit();
	}

	function resprint()
	{
		window.print();
	}
	


	function eventform()
	{
		///feiernanfrage checken
		if (document.f3.art[0].checked == false && document.f3.art[1].checked == false) {
			alert("Bitte wählen Sie zwischen Anfrage und Reservierung aus !");
			return;
		}
		else {
			if (document.f3.art[0].checked == true) {
				document.f3.artrec.value = "Anfrage";
			}
			else {
				document.f3.artrec.value = "Reservierung";
			}
		}
		if (document.f3.name.value == "") {
			alert("Bitte geben Sie Ihren Namen ein!");
			document.f3.name.focus();
			return;
		}
		if (document.f3.vorname.value == "") {
			alert("Bitte geben Sie Ihren Vornamen ein!");
			document.f3.vorname.focus();
			return;
		}
		if (document.f3.strasse.value == "") {
			alert("Bitte geben Sie Ihre Strasse ein!");
			document.f3.strasse.focus();
			return;
		}
		if (document.f3.plz_ort.value == "") {
			alert("Bitte geben Sie Ihre PLZ / Ortschaft ein!");
			document.f3.plz_ort.focus();
			return;
		}
		if (document.f3.telefon.value == "") {
			alert("Bitte geben Sie Ihre Telefonnummer ein!");
			document.f3.telefon.focus();
			return;
		}
		if (document.f3.email.value == "") {
			alert("Bitte geben Sie Ihre Emailadresse ein!");
			document.f3.email.focus();
			return;
		}

		if (document.f3.type[0].checked == false && document.f3.type[1].checked == false && document.f3.type[2].checked == false) {
			alert("Auf welche Art möchten Sie informiert werden ?");
			return;
		}
		else {
			if (document.f3.type[0].checked == true) {
				document.f3.back.value = "E-Mail";
			}
			if (document.f3.type[1].checked == true) {
					document.f3.back.value = "Fax";
			}
			if (document.f3.type[2].checked == true) {
					document.f3.back.value = "Post";
			}
		}
		document.f3.aktion.value = "sendemail";
		document.f3.job.value = "feiern";
		document.f3.submit();
	}

	function eventdel()
	{
		document.f3.name.value == "";
		document.f3.vorname.value == "";
		document.f3.strasse.value == "";
		document.f3.plz_ort.value == "";
		document.f3.land.value == "";
		document.f3.telefon.value == "";
		document.f3.email.value == "";
		document.f3.telefax.value == "";
		document.f3.event_uhrzeit.value = "";
		document.f3.event_art.value = "";
		document.f3.event_teilnehmer.value = "";
		document.f3.aktion.value = "";
		document.f3.job.value = "";
		document.f3.submit();
	}


	function tagform()
	{
		///feiernanfrage checken
		if (document.f3.art[0].checked == false && document.f3.art[1].checked == false) {
			alert("Bitte wählen Sie zwischen Anfrage und Reservierung aus !");
			return;
		}
		else {
			if (document.f3.art[0].checked == true) {
				document.f3.artrec.value = "Anfrage";
			}
			else {
				document.f3.artrec.value = "Reservierung";
			}
		}
		if (document.f3.name.value == "") {
			alert("Bitte geben Sie Ihren Namen ein!");
			document.f3.name.focus();
			return;
		}
		if (document.f3.vorname.value == "") {
			alert("Bitte geben Sie Ihren Vornamen ein!");
			document.f3.vorname.focus();
			return;
		}
		if (document.f3.strasse.value == "") {
			alert("Bitte geben Sie Ihre Strasse ein!");
			document.f3.strasse.focus();
			return;
		}
		if (document.f3.plz_ort.value == "") {
			alert("Bitte geben Sie Ihre PLZ / Ortschaft ein!");
			document.f3.plz_ort.focus();
			return;
		}
		if (document.f3.telefon.value == "") {
			alert("Bitte geben Sie Ihre Telefonnummer ein!");
			document.f3.telefon.focus();
			return;
		}
		if (document.f3.email.value == "") {
			alert("Bitte geben Sie Ihre Emailadresse ein!");
			document.f3.email.focus();
			return;
		}

		if (document.f3.type[0].checked == false && document.f3.type[1].checked == false && document.f3.type[2].checked == false) {
			alert("Auf welche Art möchten Sie informiert werden ?");
			return;
		}
		else {
			if (document.f3.type[0].checked == true) {
				document.f3.back.value = "E-Mail";
			}
			if (document.f3.type[1].checked == true) {
					document.f3.back.value = "Fax";
			}
			if (document.f3.type[2].checked == true) {
					document.f3.back.value = "Post";
			}
		}
		document.f3.aktion.value = "sendemail";
		document.f3.job.value = "tagung";
		document.f3.submit();
	}

	function tagdel()
	{
		document.f3.name.value == "";
		document.f3.vorname.value == "";
		document.f3.strasse.value == "";
		document.f3.plz_ort.value == "";
		document.f3.land.value == "";
		document.f3.telefon.value == "";
		document.f3.email.value == "";
		document.f3.telefax.value == "";
		
		document.f3.tag_bis.value = "";
		document.f3.tag_ez.value = "";
		document.f3.tag_dz.value = "";
		document.f3.tag_personen.value = "";
		document.f3.tag_uhrzeit_beginn.value = "";
		document.f3.tag_uhrzeit_ende.value = "";
		document.f3.gruppe_personen.value = "";
		document.f3.gruppe_uhrzeit_beginn.value = "";
		document.f3.gruppe_uhrzeit_ende.value = "";
		document.f3.technik.value = "";
		document.f3.bestuhlung.value = "";
		document.f3.wuensche.value = "";
		document.f3.verplegung.value = "";
		document.f3.ansprechpartner.value = "";
		document.f3.seminarleiter.value = "";
		
		document.f3.aktion.value = "";
		document.f3.job.value = "";
		document.f3.submit();
	}


	function tischform()
	{
		///tischanfrage checken

		if (document.f3.name.value == "") {
			alert("Bitte geben Sie Ihren Namen ein!");
			document.f3.name.focus();
			return;
		}
		if (document.f3.vorname.value == "") {
			alert("Bitte geben Sie Ihren Vornamen ein!");
			document.f3.vorname.focus();
			return;
		}
		if (document.f3.telefon.value == "") {
			alert("Bitte geben Sie Ihre Telefonnummer ein!");
			document.f3.telefon.focus();
			return;
		}
		if (document.f3.email.value == "") {
			alert("Bitte geben Sie Ihre Emailadresse ein!");
			document.f3.email.focus();
			return;
		}

		if (document.f3.type[0].checked == false && document.f3.type[1].checked == false ) {
		///if (document.f3.type[0].checked == false && document.f3.type[1].checked == false && document.f3.type[2].checked == false) {
			alert("Auf welche Art möchten Sie informiert werden ?");
			return;
		}
		else {
			if (document.f3.type[0].checked == true) {
				document.f3.back.value = "E-Mail";
			}
			if (document.f3.type[1].checked == true) {
					document.f3.back.value = "Telefon";
			}
		}
		document.f3.aktion.value = "sendemail";
		document.f3.job.value = "tischreservierung";
		document.f3.submit();
	}

	function tischdel()
	{
		document.f3.name.value == "";
		document.f3.vorname.value == "";
		document.f3.strasse.value == "";
		document.f3.plz_ort.value == "";
		document.f3.land.value == "";
		document.f3.telefon.value == "";
		document.f3.email.value == "";
		document.f3.telefax.value == "";
		
		document.f3.tisch_uhrzeit.value = "";
		document.f3.tisch_personen.value = "";
		document.f3.wuensche.value = "";
		
		document.f3.aktion.value = "";
		document.f3.job.value = "";
		document.f3.submit();
	}



	function shb_goto(goto,id)
	{
		document.f3.m_id.value = id;
		if (goto == "hotel") {
			///hotelpage
			document.f3.sub_menu.value = "";
			document.f3.action = "hotel.php";
		}
		else if (goto == "congress") {
			///alle artikel
			document.f3.sub_menu.value = "";
			document.f3.action = "congress.php";
		}
		else if (goto == "gastronomy") {
			///alle artikel
			document.f3.sub_menu.value = "";
			document.f3.action = "gastro.php";
		}
		else if (goto == "event") {
			///alle artikel
			document.f3.sub_menu.value = "";
			document.f3.action = "event.php";
		}
		else if (goto == "freetime") {
			///alle artikel
			document.f3.sub_menu.value = "";
			document.f3.action = "free.php";
		}
		else if (goto == "welcome") {
			///alle artikel
			document.f3.m_id.value = "1";
			document.f3.sub_menu.value = "";
			document.f3.action = "index.php";
		}
		else {
			///baustelle
			document.f3.action = "no_content.php";
		}
		document.f3.submit();
	}
	
	
	function shb_goto_info(goto)
	{
		document.f3.m_id.value = goto;
		document.f3.sub_menu.value = "";
		document.f3.action = "info.php";
		document.f3.submit();
	}
	
	
	function shb_subcontent(m_id,sub_menu,page)
	{
		document.f3.m_id.value = m_id;
		document.f3.sub_menu.value = sub_menu;
		document.f3.page.value = page;
		document.f3.submit();
	}
	
	function goto_quiz()
	{
		document.f3.m_id.value = "quiz";
		document.f3.sub_menu.value = "";
		document.f3.action = "quiz.php";
		document.f3.question.value = "";
		document.f3.submit();
		
	}

	function go_quiz1()
	{
		document.f3.m_id.value = "quiz";
		document.f3.sub_menu.value = "";
		document.f3.action = "quiz.php";
		document.f3.question.value = "true";
		document.f3.submit();
		
	}
	function verfuegbarkeit()
	{
		if (document.f3.anzahl_zimmer.value == "") {
			alert("Bitte geben Sie die gewünschte Anzahl Zimmer ein !");
			document.f3.anzahl_zimmer.focus();
			return;
		}
		if (isDigit(document.f3.anzahl_zimmer.value) == false)
		{
			alert("Bitte nur numerische Werte eingeben (0-9)");
			document.f3.anzahl_zimmer.focus();
			return;
		}
		document.f3.verfuegbarkeit.value = "true";
		document.f3.action = "hotel.php";
		document.f3.submit();
		
	}
	
	function zur_anfrage()
	{
		document.f3.verfuegbarkeit.value = "";
		document.f3.sub_menu.value = "11";
		document.f3.m_id.value = "2";
		document.f3.action = "hotel.php";
		document.f3.submit();
		
	}
	
	
	function quizform()
	{
		///verifizieren des Gewinnspiel-Forms
		if (document.f3.q1[0].checked == false && document.f3.q1[1].checked == false) {
			alert("Sie haben Frage 1 nicht beantwortet !");
			return;
		}
		if (document.f3.q2[0].checked == false && document.f3.q2[1].checked == false && document.f3.q2[2].checked == false) {
			alert("Sie haben Frage 2 nicht beantwortet !");
			return;
		}
		if (document.f3.q3[0].checked == false && document.f3.q3[1].checked == false && document.f3.q3[2].checked == false) {
			alert("Sie haben Frage 3 nicht beantwortet !");
			return;
		}
		if (document.f3.q4[0].checked == false && document.f3.q4[1].checked == false && document.f3.q4[2].checked == false) {
			alert("Sie haben Frage 4 nicht beantwortet !");
			return;
		}
		if (document.f3.name.value == "") {
			alert("Bitte geben Sie Ihren Namen ein!");
			document.f3.name.focus();
			return;
		}
		if (document.f3.vorname.value == "") {
			alert("Bitte geben Sie Ihren Vornamen ein!");
			document.f3.vorname.focus();
			return;
		}
		if (document.f3.strasse.value == "") {
			alert("Bitte geben Sie Ihre Strasse ein!");
			document.f3.strasse.focus();
			return;
		}
		if (document.f3.plz_ort.value == "") {
			alert("Bitte geben Sie Ihre PLZ / Ortschaft ein!");
			document.f3.plz_ort.focus();
			return;
		}
		document.f3.aktion.value = "save";
		document.f3.submit();
		
	}


	function go_news(id)
	{
		document.f3.sub_menu.value = id;
		document.f3.action = "news.php";
		document.f3.submit();
		
	}

	

	function kontakt()
	{
		document.f3.sub1.value = "";
		document.f3.sub2.value = "";
		document.f3.m_id.value = "";
		document.f3.w_nav.value = "kontakt";
		document.f3.action = "kontakt.php";
		document.f3.submit();
	}
	
	function lageplan()
	{
		document.f3.sub1.value = "";
		document.f3.sub2.value = "";
		document.f3.m_id.value = "";
		document.f3.w_nav.value = "kontakt";
		document.f3.action = "anfahrt.php";
		document.f3.submit();
	}
	
	function sitemap()
	{
		document.f3.sub1.value = "";
		document.f3.sub2.value = "";
		document.f3.m_id.value = "";
		document.f3.w_nav.value = "sitemap";
		document.f3.action = "sitemap.php";
		document.f3.submit();
	}
	
	function impressum()
	{
		document.f3.sub1.value = "";
		document.f3.sub2.value = "";
		document.f3.m_id.value = "";
		document.f3.w_nav.value = "impressum";
		document.f3.action = "impressum.php";
		document.f3.submit();
	}	
	function news(n_id)
	{
		document.f3.sub1.value = "";
		document.f3.sub2.value = "";
		document.f3.m_id.value = "";
		document.f3.n_id.value = n_id;
		document.f3.w_nav.value = "news";
		document.f3.action = "news.php";
		document.f3.submit();
	}
	
	function language(lang)
	{
		document.f3.lang.value = lang;
		document.f3.submit();
	}
	function printpage()
	{
		window.print();
	}

	function sub1(mid)
	{
		var action;
		if (mid == "11") {
			document.f3.j_id.value = "";
			action = "karriere.php";
		}
		else {
			action = "index.php";
		}
		if (document.f3.sub1.value == "")
		{
			document.f3.sub1.value = mid;
			document.f3.sub2.value = "";
			document.f3.m_id.value = mid;
		}
		else {
			document.f3.sub1.value = mid;
			document.f3.sub2.value = "";
			document.f3.m_id.value = mid;
		}
		document.f3.w_nav.value = "";
		document.f3.action = action;
		document.f3.submit();
	
	}
	
	function sub2(parent_m_id, mid)
	{
		var action;
		if (mid == "6") {
			document.f3.j_id.value = "";
			action = "kontakt.php";
		}
		else {
			action = "index.php";
		}
		document.f3.sub1.value = parent_m_id;
		document.f3.sub2.value = mid;
		document.f3.m_id.value = mid;
		document.f3.w_nav.value = "";
		document.f3.action = action;
		document.f3.submit();
	}
	
*/	
// this function checks if there are at least [minutes] between the from and
// the to date-time.
// returns false if not



function isDigit( ch )
  {
    if ( (ch >= '0') && (ch <= '9') )
      return true;
    else
      return false;
  }


  function isAlpha( ch )
  {
    if ( ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) )
      return true;
    else
      return false;
  }


  function isAlnum( ch )
  {
    if ( isAlpha( ch ) || isDigit( ch ) )
      return true;
    else
      return false;
  }


  function notIn( str1, str2 )
  {
    var i = 0;
    var j = str2.length;
    for( ; i<j; i++ )
    {
      var str3 =  str2.charAt(i);
      if( str1.indexOf( str3 ) != -1 )
        return false;
    }
    return true;
  }


  function checkUsername( username, mustBeQuoted )
  {
    var i = 0;
    var j = username.length;
    if ( username.charAt(0) != '"' )
    {
      if ( (username.charAt(0) <  ' ') || (username.charAt(0) >  '~')
            || !notIn( mustBeQuoted, username.charAt(0) ) )
        return false;
      for( i=1; i<j; i++ )
      {
        if ( ( (username.charAt(i) < ' ') || (username.charAt(i) >  '~')
              || !notIn ( mustBeQuoted, username.charAt(i) ) )
             && ( username.charAt(i-1) != '\\' ) )
          return false;
      }
    }
    else
    {
      if ( username.charAt( j-1 ) != '"' )
        return false;
      for( i=1; i<j-1; i++ )
      {
        if ( ( (username.charAt(i) == '\n') || (username.charAt(i) == '\r')
              || (username.charAt(i) == '\"') )
            && (username.charAt(i-1) != '\\') )
          return false;
      }

    }
    return true;
  }


  function checkNr ( nr )
  {
    var i=0;
    var j=nr.length;

    if( j < 1 )
      return false;

    for( ; i<j; i++ )
      if( ( nr.charAt(i) < '0' ) || ( nr.charAt(i) > '9' ) )
        return false;

    return true;
  }


  function checkIpnr( ipnr )
  {
    var iL=0;
    var iC=0;
    var i=0;
    var sNr = "";

    for( ; i< ipnr.length; i++ )
    {
      if ( ipnr.charAt(i) == '.' )
      {
        if ( !iL || (iL> 3) || parseInt( sNr,10 ) > 255 )
          return false;
        iC++;
        iL = 0;
        sNr = "";
        continue;
      }
      if ( isDigit ( ipnr.charAt(i) ) )
      {
        iL++;
        sNr = sNr + ipnr.charAt(i);
        continue;
      }
      return false;
    }

    if ( parseInt( sNr,10 ) > 255 )
      return false;
    if ( ( (iC==3) && (iL>=1) && (iL<=3) ) || ( (iC==4) && (!iL) )  )
      return true;
    else
      return false;
  }


  function checkFqdn( fqdn )
  {
    var iL=0;
    var iC=0;
    var i=fqdn.length-1;

    if ( (fqdn.charAt(0) == '.') || (fqdn.charAt(0) == '-') )
      return false;
    if ( fqdn.charAt(i) == '.' )
      i=i-1;

    for( ; i>=0; i-- )
    {
      if ( fqdn.charAt(i) == '.' )
      {
        if ( iL < 2 && iC < 2 )
          return false;
        if ( fqdn.charAt(i-1) == '-' )
          return false;
        iC++;
        iL = 0;
        continue;
      }
      if ( isAlnum ( fqdn.charAt(i) ) )
      {
        iL++;
        continue;
      }
      if ( fqdn.charAt(i) == '-' )
      {
        if ( !iL )
          return false;
        iL++;
        continue;
      }
      return false;
    }

    if ( !iC || ( iL == 1 && iC < 2 ) || ( !iL && iC==1 ) ) {
      return false;
    }

    return true;

  }


  function checkHostname( hostname )
  {
    if ( hostname.charAt(0) == '[' )
    {
      if ( hostname.charAt(hostname.length-1) != ']' )
        return false;
      var ipnr = hostname.substring( 1, hostname.length -1 );
        return checkIpnr( ipnr );
    }

    if ( hostname.charAt(0) == '#' )
    {
      var nr = hostname.substring( 1, hostname.length );
        return checkNr( nr );
    }

    return checkFqdn( hostname );
  }


  function checkEmailAdr( address )
  {
    var status = true;
    var username = "";
    var hostname = "";

    if ( address.length < 8 )
      return false;

    var seperate = address.lastIndexOf("@");
    if ( seperate == -1 )
      return false;

    username = address.substring(0, seperate );
    if ( ! checkUsername( username, "<>()[],;:@\" " ) )
      return false;

    hostname = address.substring(seperate+1, address.length );
    if ( ! checkHostname( hostname ) )
      return false;

    return true;
  }


  function checkEmail( email, allowFullname )
  {
    var existFullname = false;
    var status = true;
    var fullname = "";
    var adress = "";
    if ( email.length < 8 )
      return false;
    var emailBegin = email.indexOf("<");
    var emailEnd = email.lastIndexOf(">");

    if ( (emailBegin == -1) && (emailEnd == -1) )
      return checkEmailAdr( email );

    if ( ( (emailBegin == -1) && (emailEnd != -1) )
        || ( (emailBegin != -1) && (emailEnd == -1) ) )
      return false;

    adress = email.substring( emailBegin+1, emailEnd );

    if ( ! checkEmailAdr( adress ) )
      return false;

    if ( email.length == adress.length + 2 )
      return true;
    else
      if ( ! allowFullname )
        return false;

    if ( emailEnd == email.length - 1 )
    {
      if ( emailBegin == 0 )
        return true;
      if ( email.charAt( emailBegin -1 ) != ' ' )
        return false;
      fullname = email.substring( 0, emailBegin-1 );
      return checkUsername ( fullname, "<>()[],;:@\"" );
    }

    return false ;

  }


////-------------------------------ende email test





function check_valid_interval(date_from, time_from, date_to, time_to, minutes)
{
  date_from = date_from.substr(8,2) + '-' + date_from.substr(3,2) + '-' + date_from.substr(0,2);
  date_to   = date_to.substr(8,2)   + '-' + date_to.substr(3,2)   + '-' + date_to.substr(0,2);

  // the date_from > date_to - not possible
  if (date_from > date_to) return false;

  // the dates are equal - check the time difference
  if (date_from == date_to)
  {
    var minutes_from = eval(time_from.substr(3,2)) + minutes;
    var hours_from   = eval(time_from.substr(0,2));

    if (minutes_from > "60")
    {
      minutes_from = minutes_from - 60;
      hours_from   = hours_from + 1;
      alert("minutes / 60 = " + (minutes / 60));
    }
    time_from_plus_interval = hours_from + ":" + minutes_from;

    if (time_from_plus_interval > time_to) return false;
  }
  return true;
}

// this function checks if the date provided is a valid date
// returns an error code if not and "ok" if everything went fine



function convertdate(datum)
{
	// ergänzt datumsfelder
	//mögliche eingaben : 
	//leer => ergibt aktuelles Tagesdatum TT.MM.YY 
	//TT => ergibt TT.aktmonth.aktyear
	//TTMM => ergibt TT.MM.aktyear
	var aktDate = new Date();
	var aktDay = aktDate.getDate();
	if (aktDay < 10) {
		aktDay = "0" + aktDay;
	}
	var aktMonth = aktDate.getMonth();
	aktMonth = aktMonth + 1;
	if (aktMonth < 10) {
		aktMonth = "0" + aktMonth;
	}
	var aktYear = aktDate.getYear().toString();
	//var year = a
	aktYear = aktYear.substring(2,4);
	var returnDate;

	///alert ("convertdate start : " + datum.length + "aktmonth = " + aktMonth);
	if (datum.length == 0) {
		returnDate = aktDay + "." + aktMonth + "." + aktYear;
	}
	else if (datum.length == 2) {
		returnDate = datum + "." + aktMonth + "." + aktYear;
	}
	else if (datum.length == 4) {
		
		returnDate = datum.substring(0,2) + "." + datum.substring(2,4) + "." + aktYear;
	}
	else {
		returnDate = datum;
	}	
	return returnDate;
}






function checkdate(datum)
{
	///---------------------------------------------------------------------------------------------
	///funktion zum überprüfen des Datumsfeldes verwendung bei formular-validierungen
	///---------------------------------------------------------------------------------------------

	///nur zahlen und . erlaubt
	var check = checkDouble(datum);
 	if(check == false) {
	  	alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\n Ungültiges Zeichen (0-9.)!");
 		return "date_format";
 	}
 	if (datum == "" || datum.length != 8)
  	{
  		alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
    	return "date_format";
  	}
  	else
  	{
	    tag = datum.substr(0,2);
	    monat = datum.substr(3,2);
	    jahr = datum.substr(8,2);
	
	    if (monat > "12" || monat < "01")
	    {
	      alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
	      return "month_format";
	      return false;
	    }
	    if (monat=="01" || monat=="03" || monat=="05" || monat=="07" || monat=="08" || monat=="10" || monat=="12") max_tage = 31;
	    if (monat=="04" || monat=="06" || monat=="09" || monat=="11")                                              max_tage = 30;
	    if (monat=="02")                                                                                           max_tage = 28;
	
	    if (tag > max_tage || tag < "01")
	    {
	      alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
	      return "day_format";
	      return false;
	    }
  }
  return "ok";
}

// this function checks if the date provided is a valid date
// returns an error code if not and "ok" if everything went fine

function checktime(uhrzeit)
{
  if ( uhrzeit == "" || uhrzeit.length != 5)
  {
    return "time_format";
  }
  else
  {
    stunden = uhrzeit.substr(0,2);
    minuten = uhrzeit.substr(3,2);

    if (stunden > "23" || stunden < "00") return "hour_format";
    if (minuten > "59" || minuten < "00") return "minute_format";
  }
  return "ok";
}

function checkInt(number)
{
	var chkZ = 1;
	for(i=0;i<number.length;++i)
 	{
   		if(number.charAt(i) < "0" || number.charAt(i) > "9") {
     		chkZ = -1;
   		}
   	}
 	if(chkZ == -1) 	return false;
}

function checkDouble(number)
{
 var chkZ = 1;
 for(i=0;i<number.length;++i)
 {
   if(number.charAt(i) < "0" || number.charAt(i) > "9") {
   		if(number.charAt(i) != "," && number.charAt(i) != ".") {
     		chkZ = -1;
     	}
   }
 }
 if(chkZ == -1) return false;
}








function KonvertTag(tag)
{
	if (tag < 10) {
		KonvertTag = "0" + tag;
	}else {
		KonvertTag = tag;
	}
	return KonvertTag;
} 

function KonvertMonat(monat)
{
	alert("in KonvertMonat");
	monat = monat + 1;
	if (monat < 10) {
		KonvertMonat = "0" + monat;
	}else {
		KonvertMonat = monat;
	}
	return KonvertMonat;
} 

function KonvertJahr(jahr)
{
	var test = String(jahr);
	test = test.substr(2,2);
	KonvertJahr = test;
	return KonvertJahr;
}
 
function isDate(datum)
{
	///---------------------------------------------------------------------------------------------
	///funktion zum überprüfen eines Datumswertes
	///---------------------------------------------------------------------------------------------
 	if (datum.length != 8)
  	{
  		///alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
    	return "error_laenge";
  	}
  	else
  	{
	    tag = datum.substr(0,2);
	    monat = datum.substr(3,2);
	    jahr = datum.substr(8,2);
	
	    if (monat > "12" || monat < "01")
	    {
	    	
	      ///alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
	      return "error_month";
	      ///return false;
	    }
	    if (monat=="01" || monat=="03" || monat=="05" || monat=="07" || monat=="08" || monat=="10" || monat=="12") max_tage = 31;
	    if (monat=="04" || monat=="06" || monat=="09" || monat=="11")                                              max_tage = 30;
	    if (monat=="02")                                                                                           max_tage = 28;
	
	    if (tag > max_tage || tag < "01")
	    {
	      return "error_day";
	      ///alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
	      ///return false;
	    }
  }
  return "";
}









function InputDateField(val,docFieldName,auto,pflicht, tagesdatum)
{
	/*----------------------------------------------------------------------
	parameter:
	val = wert des feldes
	docFieldName = name des feldes
	auto = automatisches vervollständigen bei teileingaben
	pflicht = feld darf nicht leer sein
	tagesdatum = bei leer wird tagesdatum eingesetzt
	-------------------------------------------------------------------------*/
	///alert("parameter val=" + val + " feldname=" + docFieldName + " auto=" + auto + " pflicht=" + pflicht + " tagesdatum=" + tagesdatum);
	if (auto == "true" && val == "") {
		///alert("0");
		if (pflicht == "true"  && tagesdatum == "false") {
			alert("Datumsfeld darf nicht leer sein!");
			var tag = "document." + docFieldName + ".focus()";			eval(tag);			var mark = "document." + docFieldName + ".select()";			eval(mark);
			return;
		}
		if (pflicht == "true" && tagesdatum == "true") {
			///alert("1");	
			//Bei Leereingabe eines Datumsfeldes aktuelles Tagesdatum setzen
			var aktdate = getAktDate('full','');
			var tag = "document." + docFieldName + ".value = '" + aktdate + "';";
			eval(tag);	return ;
		}
		return;
	}
	if (checkDouble(val) == false)		{
		///	feld nicht leer übergeben
		///ungültige zeichen im feld
		alert("In Datumsfeldern sind nur die Zeichen 1-9 und ., erlaubt!");
		var tag = "document." + docFieldName + ".focus()";			eval(tag);			var mark = "document." + docFieldName + ".select()";			eval(mark);
		return;
	}
	if (auto == "true")		{
		///autovervollständigung
		var eingabeLaenge = val.length;
		if (val.indexOf(".") == -1) {
			//keine separatoren
			if (eingabeLaenge == 1 || eingabeLaenge == 3 || eingabeLaenge == 5 || eingabeLaenge > 6) {
				alert("Falsche Eingabelänge !");	var tag = "document." + docFieldName + ".focus()";	eval(tag);	var mark = "document." + docFieldName + ".select()";	eval(mark);
				return;
			}
			if (eingabeLaenge == 2) {
				///eingabe von tt
				var jetzt = new Date(); 	///Monat ersetzen
				var jetztMonat = jetzt.getMonth();			jetztMonat = jetztMonat + 1;		if (jetztMonat < 10) {		jetztMonat = "0" + jetztMonat;		}
				var jetztJahr = String(jetzt.getYear()).substr(2,2);
				var back = val + "." + jetztMonat + "." + jetztJahr;	
			}
			if (eingabeLaenge == 4) {
				///eingabe von ttmm 
				var jetzt = new Date();
				var jetztJahr = String(jetzt.getYear()).substr(2,2);		///werte zurückschreiben
				var back = val.substr(0,2) + "." + val.substr(2,2) + "." + jetztJahr;			
			}
			if (eingabeLaenge == 6) {
				///eingabe von ttmmyy 
				var jetzt = new Date();
				var back = val.substr(0,2) + "." + val.substr(2,2) + "." +  val.substr(4,2);			
			}
			///eingabe überprüfen
			var result = isDate(back);
			if (result == "error_laenge") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");		var tag = "document." + docFieldName + ".focus()";	eval(tag);
				var mark = "document." + docFieldName + ".select()";	eval(mark);	return;
			}
			if (result == "error_month") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");		var tag = "document." + docFieldName + ".focus()";		eval(tag);
				var mark = "document." + docFieldName + ".select()"; eval(mark);	return;
			}
			if (result == "error_day") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");	var tag = "document." + docFieldName + ".focus()";	eval(tag);
				var mark = "document." + docFieldName + ".select()"; eval(mark);				return;
			}
			///werte zurückschreiben
			var tag = "document." + docFieldName + ".value = '" + back + "';";			
			eval(tag);
			return ;
		}
		else {
			///mit separator
			if (eingabeLaenge < 3 || eingabeLaenge == 4 || eingabeLaenge == 7 || eingabeLaenge > 8) {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");		var tag = "document." + docFieldName + ".focus()";			eval(tag);
				var mark = "document." + docFieldName + ".select()";	eval(mark);	return;
			}
			if ( eingabeLaenge == 3) {
				///eingabe von tt.
				var jetzt = new Date();		///Monat ersetzen
				var jetztMonat = jetzt.getMonth();	jetztMonat = jetztMonat + 1; 	if (jetztMonat < 10) {	jetztMonat = "0" + jetztMonat;		}
				///monat und jahr ersetzen
				var jetztJahr = String(jetzt.getYear()).substr(2,2);
				///werte zurückschreiben
				var back = val + jetztMonat + "." + jetztJahr;	
			}
			if (eingabeLaenge == 5 || eingabeLaenge == 6) {
				///eingabe von tt.mm oder tt.mm.
				var jetzt = new Date();		///jahr ersetzen
				var jetztJahr = String(jetzt.getYear()).substr(2,2);	
				if (eingabeLaenge == 5) {	
					var back = val + "." + jetztJahr;	
				}	
				else {	
					var back = val.substr(0,5) + "." + jetztJahr;	
				}
			}
			if (eingabeLaenge == 8) {
				///eingabe von tt.mm.yy
				var jetzt = new Date();		///jahr ersetzen
				var back = val;	
			}
			///eingabe überprüfen
			var result = isDate(back);
			if (result == "error_laenge") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
				var tag = "document." + docFieldName + ".focus()";
				eval(tag);	var mark = "document." + docFieldName + ".select()";	eval(mark);	return;
			}
			if (result == "error_month") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
				var tag = "document." + docFieldName + ".focus()";	eval(tag);	var mark = "document." + docFieldName + ".select()"; eval(mark);	return;
			}
			if (result == "error_day") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
				var tag = "document." + docFieldName + ".focus()";		eval(tag);	var mark = "document." + docFieldName + ".select()";	eval(mark); 	return;
			}			
			///werte zurückschreiben
			var tag = "document." + docFieldName + ".value = '" + back + "';";			
			eval(tag);
			return ;
		}
	}
	else {
		///auto-vervollständigen aus
		var result = isDate(val)
		var errmsg = "";
		if (result == "error_laenge") {
			alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
		}
		if (result == "error_month") {
			alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
		}
		if (result == "error_day") {
			alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
		}
		if (result == "error_laenge" || result == "error_month" || result == "error_day") {
			var tag = "document." + docFieldName + ".focus()";	eval(tag);
			var mark = "document." + docFieldName + ".select()";	eval(mark);
			return;
		}
	}		
}

function getAktDate(type,val)
{
	var back;
	var jetzt = new Date();
	var jetztTag = jetzt.getDate();
	if (jetztTag < 10) 	jetztTag = "0" + jetztTag;
	var jetztMonat = jetzt.getMonth() + 1;
	if (jetztMonat < 10) jetztMonat = "0" + jetztMonat;
	var jetztJahr = String(jetzt.getYear()).substr(2,2);
	if (type == "full") {
		back = jetztTag + "." + jetztMonat + "." + jetztJahr;
	}
	return back;	
	
}



function DateField(val,docFieldName,auto)
{
	///---------------------------------------------------------------------------------------------
	///funktion zum überprüfen des Datumsfeldes verwendung bei onBlur methoden
	///---------------------------------------------------------------------------------------------
	
	///parameter val = wert des datumsfeldes
	///parameter docFieldName = name des Formulares und Feldes (z.b. document.f3.von)
	///parameter autoDate = "true/false" (true=vervollständigen des datums)
	///alert("parameter = " + val);
	if (val == "")
	{
		///feld wurde leer übergeben
		if (auto == "true") {
			//Bei Leereingabe eines Datumsfeldes aktuelles Tagesdatum setzen
			var jetzt = new Date();
			var jetztTag = jetzt.getDate();
			if (jetztTag < 10) 	jetztTag = "0" + jetztTag;
			var jetztMonat = jetzt.getMonth() + 1;
			if (jetztMonat < 10) jetztMonat = "0" + jetztMonat;
			var jetztJahr = String(jetzt.getYear()).substr(2,2);
			var back = jetztTag + "." + jetztMonat + "." + jetztJahr;
			var tag = "document." + docFieldName + ".value = '" + back + "';";
			eval(tag);
			return ;
	
		}
	}
	else {
		///	feld nicht leer übergeben
		if (checkDouble(val) == false)
		{
			///ungültige zeichen im feld
			alert("In Datumsfeldern sind nur die Zeichen 1-9 und ., erlaubt!");
			var tag = "document." + docFieldName + ".focus()";
			eval(tag);
			var mark = "document." + docFieldName + ".select()";
			eval(mark);
			return;
		}
		if (auto == "true")
		{
			///autovervollständigung
			var eingabeLaenge = val.length;
			///alert(eingabeLaenge);
			if (eingabeLaenge == 1) {
				alert("Falsche Eingabe !");
				var tag = "document." + docFieldName + ".focus()";
				eval(tag);
				var mark = "document." + docFieldName + ".select()";
				eval(mark);
				return;
			}
			if (eingabeLaenge == 2 || eingabeLaenge == 3) {
				///eingabe von tt
				var jetzt = new Date();
				///Monat ersetzen
				var jetztMonat = jetzt.getMonth();
				jetztMonat = jetztMonat + 1;
				if (jetztMonat < 10) {
					jetztMonat = "0" + jetztMonat;
				}
				///jahr ersetzen
				var jetztJahr = String(jetzt.getYear()).substr(2,2);
				///werte zurückschreiben
				if (eingabeLaenge == 2) {
					var back = val + "." + jetztMonat + "." + jetztJahr;
				}
				else {
					var back = val.substr(0,2) + "." + jetztMonat + "." + jetztJahr;
				}
				var tag = "document." + docFieldName + ".value = '" + back + "';";
				eval(tag);
				return ;
			}
			if (eingabeLaenge == 5 || eingabeLaenge == 6) {
				///eingabe von tt.mm oder tt.mm.
				var jetzt = new Date();
				///Monat ersetzen
				///jahr ersetzen
				var jetztJahr = String(jetzt.getYear()).substr(2,2);
				///werte zurückschreiben
				if (eingabeLaenge == 5) {
					var back = val + "." + jetztJahr;
				}
				else {
					var back = val.substr(0,5) + "." + jetztJahr;
				}
				var tag = "document." + docFieldName + ".value = '" + back + "';";
				eval(tag);
				return ;
			}
			if (eingabeLaenge > 6) {
				///eingabe überprüfen
				var result = isDate(val)
				if (result == "error_laenge") {
					alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
					var tag = "document." + docFieldName + ".focus()";
					eval(tag);
					var mark = "document." + docFieldName + ".select()";
					eval(mark);
					return;
				}
				if (result == "error_month") {
					alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
					var tag = "document." + docFieldName + ".focus()";
					eval(tag);
					var mark = "document." + docFieldName + ".select()";
					eval(mark);
					return;
				}
				if (result == "error_day") {
					alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
					var tag = "document." + docFieldName + ".focus()";
					eval(tag);
					var mark = "document." + docFieldName + ".select()";
					eval(mark);
					return;
				}			
			}
		}
		else {
			///datumseingabe auf länge und tag/monat checken
			var result = isDate(val)
			if (result == "error_laenge") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nLänge ungültig!");
				var tag = "document." + docFieldName + ".focus()";
				eval(tag);
				var mark = "document." + docFieldName + ".select()";
				eval(mark);
				return;
			}
			if (result == "error_month") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nMonat ungültig!");
				var tag = "document." + docFieldName + ".focus()";
				eval(tag);
				var mark = "document." + docFieldName + ".select()";
				eval(mark);
				return;
			}
			if (result == "error_day") {
				alert("Bitte geben Sie das Datum in der Form 'tt.mm.jj' an!\nTag ungültig!");
				var tag = "document." + docFieldName + ".focus()";
				eval(tag);
				var mark = "document." + docFieldName + ".select()";
				eval(mark);
				return;
			}
			
				
		}
	}

	
}



function DoubleField(val,docFieldName)
{
	///---------------------------------------------------------------------------------------------
	///funktion zum überprüfen eines double feldes verwendung bei onBlur methoden
	///---------------------------------------------------------------------------------------------
	
	///parameter val = wert des doublefeldes
	///parameter docFieldName = name des Formulares und Feldes (z.b. document.f3.menge)
	///alert("parameter = " + val);
	if (val == "")
	{
		///feld wurde leer übergeben rückgabe 0,00
		var tag = "document." + docFieldName + ".value = '0,00';";
		eval(tag);
		return ;
	}
	else {
		///	feld nicht leer übergeben
		if (checkDouble(val) == false)
		{
			///ungültige zeichen im feld
			alert("In Dezimalfelder sind nur die Zeichen 1-9 und ., erlaubt!");
			var tag = "document." + docFieldName + ".focus()";
			eval(tag);
			var mark = "document." + docFieldName + ".select()";
			eval(mark);
			return;
		}
	}

}


function selectField(id)
{
	document.getElementById(id).style.backgroundColor = '#A4F4AA';
	
}

function deSelectField(id)
{
	document.getElementById(id).style.backgroundColor = '#FFFFFF';
	
}

function selectMenu(id)
{
	document.getElementById(id).style.backgroundColor = '#A4F4AA';
	
}

function deSelectMenu(id)
{
	document.getElementById(id).style.backgroundColor = '';
	//document.getElementById(id).style.backgroundColor = '#E7E7E7';
	
}
function checkDezi(wert,element)
{
	if (wert != "" && wert != "0,00") {
		var check = checkDouble(wert);
		//alert(check);
		if (check == false) {
			alert("Bitte nur numerische Werte eingeben !");
			var tag = "document.f3." + element + ".focus()";
			eval(tag);
			var mark = "document.f3." + element + ".select()";
			eval(mark);
			return;
		}
	}
}

function checkDeziOform(wert,element)
{
	if (wert != "" && wert != "0,00") {
		var check = checkDouble(wert);
		//alert(check);
		if (check == false) {
			alert("Bitte nur numerische Werte eingeben !");
			var tag = "document.oform3." + element + ".focus()";
			eval(tag);
			var mark = "document.oform3." + element + ".select()";
			eval(mark);
			return;
		}
	}
}
function formatdezi(wert)
{
	///dezimalzahl formatieren auf 2 nachkommastellen
	var back = "";
	var laenge = wert.length;
	var isKomma = wert.indexOf(",");
	if (isKomma == -1) {
		back = wert + ",00";
	}
	else {
		var kommaPos = laenge - isKomma;
		if (kommaPos == 2) {
			///1 Nachkommastelle z.b. 53,1
			back = wert + "0";
		}
		else {
			///mehrere nachkommastellen - abschneiden
			kommaPos = isKomma + 3;
			back = wert.substr(0,kommaPos);
		}
	}
	return back;
}

function verifydate(von,bis)
{
	/*
	// überprüft ob datum von kleiner als datum bis ist
	var vonDay = von.substring(0,2);
	if (vonDay.substring(0,1) == "0") {
		vonDay = von.substring(1,2);
	}
	var vonMonth = von.substring(3,5);
	if (vonMonth.substring(0,1) == "0") {
		vonMonth = von.substring(1,2);
	}
	vonMonth = vonMonth - 1;
	var vonYear = "20" + von.substring(6,8);
	//bis
	var bisDay = bis.substring(0,2);
	if (bisDay.substring(0,1) == "0") {
		bisDay = bis.substring(1,2);
	}
	var bisMonth = bis.substring(3,5);
	if (bisMonth.substring(0,1) == "0") {
		bisMonth = bis.substring(1,2);
	}
	bisMonth = bisMonth - 1;
	var bisYear = "20" + bis.substring(6,8);

	var vonDate = new Date(vonYear,vonMonth,vonDay);
	var bisDate = new Date(bisYear,bisMonth,bisDay);
	if (bisDate.getTime() <= vonDate.getTime()) {
		return "NOK";
	}
	else {
		return "OK";
	}
	*/
}

/* $Id: functions.js 10297 2007-04-17 16:43:24Z lem9 $ */

/**
 * @var sql_box_locked lock for the sqlbox textarea in the querybox/querywindow
 */
var sql_box_locked = false;

/**
 * @var array holds elements which content should only selected once
 */
var only_once_elements = new Array();

/**
 * selects the content of a given object, f.e. a textarea
 *
 * @param   object  element     element of which the content will be selected
 * @param   var     lock        variable which holds the lock for this element
 *                              or true, if no lock exists
 * @param   boolean only_once   if true this is only done once
 *                              f.e. only on first focus
 */
function selectContent( element, lock, only_once ) {
    if ( only_once && only_once_elements[element.name] ) {
        return;
    }

    only_once_elements[element.name] = true;

    if ( lock  ) {
        return;
    }

    element.select();
}

/**
 * Displays an confirmation box before to submit a "DROP DATABASE" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to submit
 *
 * @return  boolean  whether to run the query or not
 */
function confirmLinkDropDB(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsgDropDB + '\n' + confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLinkDropDB()' function

/**
 * Displays an confirmation box before to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to submit
 *
 * @return  boolean  whether to run the query or not
 */
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else if ( typeof(theLink.form) != 'undefined' ) {
            theLink.form.action += '?is_js_confirmed=1';
        }
    }

    return is_confirmed;
} // end of the 'confirmLink()' function


/**
 * Displays an confirmation box before doing some action
 *
 * @param   object   the message to display
 *
 * @return  boolean  whether to run the query or not
 */
function confirmAction(theMessage)
{
    // TODO: Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(theMessage);

    return is_confirmed;
} // end of the 'confirmAction()' function


/**
 * Displays an error message if a "DROP DATABASE" statement is submitted
 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
 * sumitting it if required.
 * This function is called by the 'checkSqlQuery()' js function.
 *
 * @param   object   the form
 * @param   object   the sql query textarea
 *
 * @return  boolean  whether to run the query or not
 *
 * @see     checkSqlQuery()
 */
function confirmQuery(theForm1, sqlQuery1)
{
    // Confirmation is not required in the configuration file
    if (confirmMsg == '') {
        return true;
    }

    // The replace function (js1.2) isn't supported
    else if (typeof(sqlQuery1.value.replace) == 'undefined') {
        return true;
    }

    // js1.2+ -> validation with regular expressions
    else {
        // "DROP DATABASE" statement isn't allowed
        if (noDropDbMsg != '') {
            var drop_re = new RegExp('(^|;)\\s*DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
            if (drop_re.test(sqlQuery1.value)) {
                alert(noDropDbMsg);
                theForm1.reset();
                sqlQuery1.focus();
                return false;
            } // end if
        } // end if

        // Confirms a "DROP/DELETE/ALTER" statement
        //
        // TODO: find a way (if possible) to use the parser-analyser
        // for this kind of verification
        // For now, I just added a ^ to check for the statement at
        // beginning of expression

        var do_confirm_re_0 = new RegExp('^DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
        var do_confirm_re_1 = new RegExp('^ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
        var do_confirm_re_2 = new RegExp('^DELETE\\s+FROM\\s', 'i');
        if (do_confirm_re_0.test(sqlQuery1.value)
            || do_confirm_re_1.test(sqlQuery1.value)
            || do_confirm_re_2.test(sqlQuery1.value)) {
            var message      = (sqlQuery1.value.length > 100)
                             ? sqlQuery1.value.substr(0, 100) + '\n    ...'
                             : sqlQuery1.value;
            var is_confirmed = confirm(confirmMsg + ' :\n' + message);
            // drop/delete/alter statement is confirmed -> update the
            // "is_js_confirmed" form field so the confirm test won't be
            // run on the server side and allows to submit the form
            if (is_confirmed) {
                theForm1.elements['is_js_confirmed'].value = 1;
                return true;
            }
            // "DROP/DELETE/ALTER" statement is rejected -> do not submit
            // the form
            else {
                window.focus();
                sqlQuery1.focus();
                return false;
            } // end if (handle confirm box result)
        } // end if (display confirm box)
    } // end confirmation stuff

    return true;
} // end of the 'confirmQuery()' function


/**
 * Displays an error message if the user submitted the sql query form with no
 * sql query, else checks for "DROP/DELETE/ALTER" statements
 *
 * @param   object   the form
 *
 * @return  boolean  always false
 *
 * @see     confirmQuery()
 */
function checkSqlQuery(theForm)
{
    var sqlQuery = theForm.elements['sql_query'];
    var isEmpty  = 1;

    // The replace function (js1.2) isn't supported -> basic tests
    if (typeof(sqlQuery.value.replace) == 'undefined') {
        isEmpty      = (sqlQuery.value == '') ? 1 : 0;
        if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_file'].value == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_localfile'].value == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
            isEmpty  = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
        }
    }
    // js1.2+ -> validation with regular expressions
    else {
        var space_re = new RegExp('\\s+');
        if (typeof(theForm.elements['sql_file']) != 'undefined' &&
                theForm.elements['sql_file'].value.replace(space_re, '') != '') {
            return true;
        }
        if (typeof(theForm.elements['sql_localfile']) != 'undefined' &&
                theForm.elements['sql_localfile'].value.replace(space_re, '') != '') {
            return true;
        }
        if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' &&
                (theForm.elements['id_bookmark'].value != null || theForm.elements['id_bookmark'].value != '') &&
                theForm.elements['id_bookmark'].selectedIndex != 0
                ) {
            return true;
        }
        // Checks for "DROP/DELETE/ALTER" statements
        if (sqlQuery.value.replace(space_re, '') != '') {
            if (confirmQuery(theForm, sqlQuery)) {
                return true;
            } else {
                return false;
            }
        }
        theForm.reset();
        isEmpty = 1;
    }

    if (isEmpty) {
        sqlQuery.select();
        alert(errorMsg0);
        sqlQuery.focus();
        return false;
    }

    return true;
} // end of the 'checkSqlQuery()' function


/**
 * Check if a form's element is empty
 * should be
 *
 * @param   object   the form
 * @param   string   the name of the form field to put the focus on
 *
 * @return  boolean  whether the form field is empty or not
 */
function emptyCheckTheField(theForm, theFieldName)
{
    var isEmpty  = 1;
    var theField = theForm.elements[theFieldName];
    // Whether the replace function (js1.2) is supported or not
    var isRegExp = (typeof(theField.value.replace) != 'undefined');

    if (!isRegExp) {
        isEmpty      = (theField.value == '') ? 1 : 0;
    } else {
        var space_re = new RegExp('\\s+');
        isEmpty      = (theField.value.replace(space_re, '') == '') ? 1 : 0;
    }

    return isEmpty;
} // end of the 'emptyCheckTheField()' function


/**
 * Displays an error message if an element of a form hasn't been completed and
 * should be
 *
 * @param   object   the form
 * @param   string   the name of the form field to put the focus on
 *
 * @return  boolean  whether the form field is empty or not
 */
function emptyFormElements(theForm, theFieldName)
{
    var theField = theForm.elements[theFieldName];
    var isEmpty = emptyCheckTheField(theForm, theFieldName);

    if (isEmpty) {
        theForm.reset();
        theField.select();
        alert(errorMsg0);
        theField.focus();
        return false;
    }

    return true;
} // end of the 'emptyFormElements()' function


/**
 * Ensures a value submitted in a form is numeric and is in a range
 *
 * @param   object   the form
 * @param   string   the name of the form field to check
 * @param   integer  the minimum authorized value
 * @param   integer  the maximum authorized value
 *
 * @return  boolean  whether a valid number has been submitted or not
 */
function checkFormElementInRange(theForm, theFieldName, message, min, max)
{
    var theField         = theForm.elements[theFieldName];
    var val              = parseInt(theField.value);

    if (typeof(min) == 'undefined') {
        min = 0;
    }
    if (typeof(max) == 'undefined') {
        max = Number.MAX_VALUE;
    }

    // It's not a number
    if (isNaN(val)) {
        theField.select();
        alert(errorMsg1);
        theField.focus();
        return false;
    }
    // It's a number but it is not between min and max
    else if (val < min || val > max) {
        theField.select();
        alert(message.replace('%d', val));
        theField.focus();
        return false;
    }
    // It's a valid number
    else {
        theField.value = val;
    }
    return true;

} // end of the 'checkFormElementInRange()' function


function checkTableEditForm(theForm, fieldsCnt)
{
    // TODO: avoid sending a message if user just wants to add a line
    // on the form but has not completed at least one field name

    var atLeastOneField = 0;
    var i, elm, elm2, elm3, val, id;

    for (i=0; i<fieldsCnt; i++)
    {
        id = "field_" + i + "_2";
        elm = getElement(id);
        if (elm.value == 'VARCHAR' || elm.value == 'CHAR') {
            elm2 = getElement("field_" + i + "_3");
            val = parseInt(elm2.value);
            elm3 = getElement("field_" + i + "_1");
            if (isNaN(val) && elm3.value != "") {
                elm2.select();
                alert(errorMsg1);
                elm2.focus();
                return false;
            }
        }

        if (atLeastOneField == 0) {
            id = "field_" + i + "_1";
            if (!emptyCheckTheField(theForm, id)) {
                atLeastOneField = 1;
            }
        }
    }
    if (atLeastOneField == 0) {
        var theField = theForm.elements["field_0_1"];
        alert(errorMsg0);
        theField.focus();
        return false;
    }

    return true;
} // enf of the 'checkTableEditForm()' function


/**
 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
 * checkboxes is consistant
 *
 * @param   object   the form
 * @param   string   a code for the action that causes this function to be run
 *
 * @return  boolean  always true
 */
function checkTransmitDump(theForm, theAction)
{
    var formElts = theForm.elements;

    // 'zipped' option has been checked
    if (theAction == 'zip' && formElts['zip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
            theForm.elements['gzip'].checked = false;
        }
        if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
            theForm.elements['bzip'].checked = false;
        }
    }
    // 'gzipped' option has been checked
    else if (theAction == 'gzip' && formElts['gzip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
            theForm.elements['bzip'].checked = false;
        }
    }
    // 'bzipped' option has been checked
    else if (theAction == 'bzip' && formElts['bzip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
            theForm.elements['gzip'].checked = false;
        }
    }
    // 'transmit' option has been unchecked
    else if (theAction == 'transmit' && !formElts['asfile'].checked) {
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) {
            theForm.elements['gzip'].checked = false;
        }
        if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) {
            theForm.elements['bzip'].checked = false;
        }
    }

    return true;
} // end of the 'checkTransmitDump()' function


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' marked';
            } else {
                this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
        }

        // ... and disable label ...
        var labeltag = rows[i].getElementsByTagName('label')[0];
        if ( labeltag ) {
            labeltag.onclick = function() {
                return false;
            }
        }
        // .. and checkbox clicks
        var checkbox = rows[i].getElementsByTagName('input')[0];
        if ( checkbox ) {
            checkbox.onclick = function() {
                // opera does not recognize return false;
                this.checked = ! this.checked;
            }
        }
    }
}
window.onload=PMA_markRowsInit;

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
        }
    }

    return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
    }

    return true;
}

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;
///	alert('angang :' +  theRow + "/" + theRowNum + "/" +  theAction + "/" + theDefaultColor + "/" +  thePointerColor + "/" + theMarkColor);
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3
///alert("color = " + currentColor);
    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
///    alert("currentColor=" + currentColor + " theDefaultColor=" + theDefaultColor); 
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
///        	alert("c1");
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
///             	alert("c2");
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
 ///   	alert("c3");
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5
///alert('ende :' +  newColor);
    return true;
} // end of the 'setPointer()' function

/*
 * Sets/unsets the pointer and marker in vertical browse mode
 *
 * @param   object    the table row
 * @param   integer   the column number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background Class
 * @param   string    the Class to use for mouseover
 * @param   string    the Class to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 *
 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
 */
function setVerticalPointer(theRow, theColNum, theAction, theDefaultClass1, theDefaultClass2, thePointerClass, theMarkClass) {
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerClass == '' && theMarkClass == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    var tagSwitch = null;

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        tagSwitch = 'tag';
    } else if (typeof(document.getElementById('table_results')) != 'undefined') {
        tagSwitch = 'cells';
    } else {
        return false;
    }

    var theCells = null;

    if (tagSwitch == 'tag') {
        theRows     = document.getElementById('table_results').getElementsByTagName('tr');
        theCells    = theRows[1].getElementsByTagName('td');
    } else if (tagSwitch == 'cells') {
        theRows     = document.getElementById('table_results').rows;
        theCells    = theRows[1].cells;
    }

    // 3. Gets the current Class...
    var currentClass   = null;
    var newClass       = null;

    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[theColNum].getAttribute) != 'undefined') {
        currentClass = theCells[theColNum].className;
    } // end 3

    // 4. Defines the new Class
    // 4.1 Current Class is the default one
    if (currentClass == ''
        || currentClass.toLowerCase() == theDefaultClass1.toLowerCase()
        || currentClass.toLowerCase() == theDefaultClass2.toLowerCase()) {
        if (theAction == 'over' && thePointerClass != '') {
            newClass              = thePointerClass;
        } else if (theAction == 'click' && theMarkClass != '') {
            newClass              = theMarkClass;
            marked_row[theColNum] = true;
        }
    }
    // 4.1.2 Current Class is the pointer one
    else if (currentClass.toLowerCase() == thePointerClass.toLowerCase() &&
             (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum]) || marked_row[theColNum] == false) {
            if (theAction == 'out') {
                if (theColNum % 2) {
                    newClass              = theDefaultClass1;
                } else {
                    newClass              = theDefaultClass2;
                }
            }
            else if (theAction == 'click' && theMarkClass != '') {
                newClass              = theMarkClass;
                marked_row[theColNum] = true;
            }
    }
    // 4.1.3 Current Class is the marker one
    else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) {
        if (theAction == 'click') {
            newClass              = (thePointerClass != '')
                                  ? thePointerClass
                                  : ((theColNum % 2) ? theDefaultClass2 : theDefaultClass1);
            marked_row[theColNum] = false;
        }
    } // end 4

    // 5 ... with DOM compatible browsers except Opera

    if (newClass) {
        var c = null;
        var rowCnt = theRows.length;
        for (c = 0; c < rowCnt; c++) {
            if (tagSwitch == 'tag') {
                Cells = theRows[c].getElementsByTagName('td');
            } else if (tagSwitch == 'cells') {
                Cells = theRows[c].cells;
            }

            Cell  = Cells[theColNum];

            // 5.1 Sets the new Class...
            Cell.className = Cell.className.replace(currentClass, newClass);
        } // end for
    } // end 5

     return true;
 } // end of the 'setVerticalPointer()' function

/**
 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
 *
 * @param   string   container_id  the container id
 * @param   boolean  state         new value for checkbox (true or false)
 * @return  boolean  always true
 */
function setCheckboxes( container_id, state ) {
    var checkboxes = document.getElementById(container_id).getElementsByTagName('input');

    for ( var i = 0; i < checkboxes.length; i++ ) {
        if ( checkboxes[i].type == 'checkbox' ) {
            checkboxes[i].checked = state;
        }
    }

    return true;
} // end of the 'setCheckboxes()' function


// added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
//   copy the checked from left to right or from right to left
//   so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
function copyCheckboxesRange(the_form, the_name, the_clicked)
{
    if (typeof(document.forms[the_form].elements[the_name]) != 'undefined' && typeof(document.forms[the_form].elements[the_name + 'r']) != 'undefined') {
        if (the_clicked !== 'r') {
            if (document.forms[the_form].elements[the_name].checked == true) {
                document.forms[the_form].elements[the_name + 'r'].checked = true;
            }else {
                document.forms[the_form].elements[the_name + 'r'].checked = false;
            }
        } else if (the_clicked == 'r') {
            if (document.forms[the_form].elements[the_name + 'r'].checked == true) {
                document.forms[the_form].elements[the_name].checked = true;
            }else {
                document.forms[the_form].elements[the_name].checked = false;
            }
       }
    }
}


// added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
//  - this was directly written to each td, so why not a function ;)
//  setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
function setCheckboxColumn(theCheckbox){
    if (document.getElementById(theCheckbox)) {
        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
        }
    } else {
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
            if (document.getElementById(theCheckbox)) {
                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
            }
        }
    }
}


/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */
function setSelectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function

/**
  * Inserts multiple fields.
  *
  */
function insertValueQuery() {
    var myQuery = document.sqlform.sql_query;
    var myListBox = document.sqlform.dummy;

    if(myListBox.options.length > 0) {
        sql_box_locked = true;
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += myListBox.options[i].value;
            }
        }

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
            document.sqlform.insert.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
            var startPos = document.sqlform.sql_query.selectionStart;
            var endPos = document.sqlform.sql_query.selectionEnd;
            var chaineSql = document.sqlform.sql_query.value;

            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
        sql_box_locked = false;
    }
}

/**
  * listbox redirection
  */
function goToUrl(selObj, goToLocation) {
    eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
}

/**
 * getElement
 */
function getElement(e,f){
    if(document.layers){
        f=(f)?f:self;
        if(f.document.layers[e]) {
            return f.document.layers[e];
        }
        for(W=0;W<f.document.layers.length;W++) {
            return(getElement(e,f.document.layers[W]));
        }
    }
    if(document.all) {
        return document.all[e];
    }
    return document.getElementById(e);
}

/**
  * Refresh the WYSIWYG-PDF scratchboard after changes have been made
  */
function refreshDragOption(e) {
    myid = getElement(e);
    if (myid.style.visibility == 'visible') {
        refreshLayout();
    }
}

/**
  * Refresh/resize the WYSIWYG-PDF scratchboard
  */
function refreshLayout() {
        myid = getElement('pdflayout');

        if (document.pdfoptions.orientation.value == 'P') {
            posa = 'x';
            posb = 'y';
        } else {
            posa = 'y';
            posb = 'x';
        }

        myid.style.width = pdfPaperSize(document.pdfoptions.paper.value, posa) + 'px';
        myid.style.height = pdfPaperSize(document.pdfoptions.paper.value, posb) + 'px';
}

/**
  * Show/hide the WYSIWYG-PDF scratchboard
  */
function ToggleDragDrop(e) {
    myid = getElement(e);

    if (myid.style.visibility == 'hidden') {
        init();
        myid.style.visibility = 'visible';
        myid.style.display = 'block';
        document.edcoord.showwysiwyg.value = '1';
    } else {
        myid.style.visibility = 'hidden';
        myid.style.display = 'none';
        document.edcoord.showwysiwyg.value = '0';
    }
}

/**
  * PDF scratchboard: When a position is entered manually, update
  * the fields inside the scratchboard.
  */
function dragPlace(no, axis, value) {
    if (axis == 'x') {
        getElement("table_" + no).style.left = value + 'px';
    } else {
        getElement("table_" + no).style.top  = value + 'px';
    }
}

/**
 * Returns paper sizes for a given format
 */
function pdfPaperSize(format, axis) {
    switch (format.toUpperCase()) {
        case '4A0':
            if (axis == 'x') return 4767.87; else return 6740.79;
            break;
        case '2A0':
            if (axis == 'x') return 3370.39; else return 4767.87;
            break;
        case 'A0':
            if (axis == 'x') return 2383.94; else return 3370.39;
            break;
        case 'A1':
            if (axis == 'x') return 1683.78; else return 2383.94;
            break;
        case 'A2':
            if (axis == 'x') return 1190.55; else return 1683.78;
            break;
        case 'A3':
            if (axis == 'x') return 841.89; else return 1190.55;
            break;
        case 'A4':
            if (axis == 'x') return 595.28; else return 841.89;
            break;
        case 'A5':
            if (axis == 'x') return 419.53; else return 595.28;
            break;
        case 'A6':
            if (axis == 'x') return 297.64; else return 419.53;
            break;
        case 'A7':
            if (axis == 'x') return 209.76; else return 297.64;
            break;
        case 'A8':
            if (axis == 'x') return 147.40; else return 209.76;
            break;
        case 'A9':
            if (axis == 'x') return 104.88; else return 147.40;
            break;
        case 'A10':
            if (axis == 'x') return 73.70; else return 104.88;
            break;
        case 'B0':
            if (axis == 'x') return 2834.65; else return 4008.19;
            break;
        case 'B1':
            if (axis == 'x') return 2004.09; else return 2834.65;
            break;
        case 'B2':
            if (axis == 'x') return 1417.32; else return 2004.09;
            break;
        case 'B3':
            if (axis == 'x') return 1000.63; else return 1417.32;
            break;
        case 'B4':
            if (axis == 'x') return 708.66; else return 1000.63;
            break;
        case 'B5':
            if (axis == 'x') return 498.90; else return 708.66;
            break;
        case 'B6':
            if (axis == 'x') return 354.33; else return 498.90;
            break;
        case 'B7':
            if (axis == 'x') return 249.45; else return 354.33;
            break;
        case 'B8':
            if (axis == 'x') return 175.75; else return 249.45;
            break;
        case 'B9':
            if (axis == 'x') return 124.72; else return 175.75;
            break;
        case 'B10':
            if (axis == 'x') return 87.87; else return 124.72;
            break;
        case 'C0':
            if (axis == 'x') return 2599.37; else return 3676.54;
            break;
        case 'C1':
            if (axis == 'x') return 1836.85; else return 2599.37;
            break;
        case 'C2':
            if (axis == 'x') return 1298.27; else return 1836.85;
            break;
        case 'C3':
            if (axis == 'x') return 918.43; else return 1298.27;
            break;
        case 'C4':
            if (axis == 'x') return 649.13; else return 918.43;
            break;
        case 'C5':
            if (axis == 'x') return 459.21; else return 649.13;
            break;
        case 'C6':
            if (axis == 'x') return 323.15; else return 459.21;
            break;
        case 'C7':
            if (axis == 'x') return 229.61; else return 323.15;
            break;
        case 'C8':
            if (axis == 'x') return 161.57; else return 229.61;
            break;
        case 'C9':
            if (axis == 'x') return 113.39; else return 161.57;
            break;
        case 'C10':
            if (axis == 'x') return 79.37; else return 113.39;
            break;
        case 'RA0':
            if (axis == 'x') return 2437.80; else return 3458.27;
            break;
        case 'RA1':
            if (axis == 'x') return 1729.13; else return 2437.80;
            break;
        case 'RA2':
            if (axis == 'x') return 1218.90; else return 1729.13;
            break;
        case 'RA3':
            if (axis == 'x') return 864.57; else return 1218.90;
            break;
        case 'RA4':
            if (axis == 'x') return 609.45; else return 864.57;
            break;
        case 'SRA0':
            if (axis == 'x') return 2551.18; else return 3628.35;
            break;
        case 'SRA1':
            if (axis == 'x') return 1814.17; else return 2551.18;
            break;
        case 'SRA2':
            if (axis == 'x') return 1275.59; else return 1814.17;
            break;
        case 'SRA3':
            if (axis == 'x') return 907.09; else return 1275.59;
            break;
        case 'SRA4':
            if (axis == 'x') return 637.80; else return 907.09;
            break;
        case 'LETTER':
            if (axis == 'x') return 612.00; else return 792.00;
            break;
        case 'LEGAL':
            if (axis == 'x') return 612.00; else return 1008.00;
            break;
        case 'EXECUTIVE':
            if (axis == 'x') return 521.86; else return 756.00;
            break;
        case 'FOLIO':
            if (axis == 'x') return 612.00; else return 936.00;
            break;
    } // end switch

    return 0;
}

