function zeit(){
	var datum = new Date();
	var Wochentag = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch","Donnerstag", "Freitag", "Samstag");
	var tag     = datum.getDate();
	var monat   = datum.getMonth() + 1;
	var jahr    = datum.getYear();
	if (jahr<1900) jahr = jahr + 1900;
	var stunde  = datum.getHours();
	var minute  = datum.getMinutes();
	var sekunde = datum.getSeconds();

	if (tag<10)     tag="0"+tag;
	if (monat<10)   monat="0"+monat;
	if (stunde<10)  stunde="0"+stunde;
	if (minute<10)  minute="0"+minute;
	if (sekunde<10) sekunde="0"+sekunde;

	if (document.getElementById("datum")) document.getElementById("datum").innerText   = Wochentag[datum.getDay()] + ", der " + (tag + "." + monat + "." + jahr);
	if (document.getElementById("uhrzeit")) document.getElementById("uhrzeit").innerText = (stunde + ":" + minute + ":" + sekunde) + " Uhr";

	window.status = Wochentag[datum.getDay()] + ", der " + (tag + "." + monat + "." + jahr) + " - " + (stunde + ":" + minute + ":" + sekunde);
}

var aufruf = window.setInterval("zeit()", 1000);


function newWindow (popupURL, width, height) {
	Info = window.open(popupURL,"Info",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,width='+width+',height='+height+',top=80,left=80');
	Info.focus();
}

function newWindow2 (popupURL, width, height, name) {
	Info = window.open(popupURL,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width='+width+',height='+height+',top=80,left=80');
	Info.focus();
}

function SetFocus (elm) {
	if (document.forms[0].elements[elm]) {
		document.forms[0].elements[elm].focus();
	}
}

function rgbToHex (bgc) {

	if (!bgc) bgc = '#ffffff';
	if (eval(bgc.indexOf("#")) < 0) {

		var hex="#",tmp,rgb=bgc;
		tmp=(rgb.substring(rgb.indexOf("(")+1,rgb.indexOf(")"))).split(",");
		for(j=0;j<3;j++) {
			die_zahl = (tmp[j]*1).toString(16);
			if (die_zahl < 10) die_zahl = "0"+die_zahl;
			hex += die_zahl.toLowerCase();
		}

		bgc = hex;
	}
	return bgc;

}

function LmOver(id1, clr, doCount, highlightColor) {
	if (doCount) {
		for (i=1; i<= doCount; i++) {
			color = rgbToHex(document.getElementById(id1+"_"+i).style.backgroundColor);
			if (color != highlightColor) {
				document.getElementById(id1+"_"+i).style.backgroundColor = clr;
			}
		}
	} else {
		document.getElementById(id1).style.backgroundColor = clr;
	}
}

function LmOut(id1, clr, doCount, highlightColor) {
	if (doCount) {
		for (i = 1; i<= doCount; i++) {
			color = rgbToHex(document.getElementById(id1+"_"+i).style.backgroundColor);
			if (color != highlightColor) {
				document.getElementById(id1+"_"+i).style.backgroundColor = clr;
			}
		}
	} else {
		document.getElementById(id1).style.backgroundColor = clr;
	}

}

function LmDown(id1, clr, doCount, highlightColor) {
	if (doCount) {
		for (i = 1; i<= doCount; i++) {
			color = rgbToHex(document.getElementById(id1+"_"+i).style.backgroundColor);
			if (color == highlightColor) {
				document.getElementById(id1+"_"+i).style.backgroundColor = clr;
			} else {
				document.getElementById(id1+"_"+i).style.backgroundColor = highlightColor;
			}
		}
	} else {
		document.getElementById(id1).style.backgroundColor = clr;
	}
}

var alleCookies;
var cookieArr;
var cookieLenght;
alleCookies=document.cookie;
cookieArr=alleCookies.split(";");
cookieLenght=cookieArr.length;

function SetzCookie (name, value) {
	expires="Sun, 04-Jan-2025 00:00:00 GMT";
	document.cookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "");
}

function LeseCookie(Keksname) {

	for(var i=0;i<cookieLenght;i++) {
		key = cookieArr[i].split("=")[0];
		key  = key.replace (" ", "");
		if(key==Keksname) {
			cookieWert=cookieArr[i].split("=");
			cookieWert=unescape(cookieWert[1]);
			return cookieWert;
		}
	}
	return false;
}

function LeseCookie2(Keksname, myImage) {

	for(var i=0;i<cookieLenght;i++) {
		key = cookieArr[i].split("=")[0];
		key  = key.replace (" ", "");
		if(key==Keksname) {
			cookieWert=cookieArr[i].split("=");
			cookieWert=unescape(cookieWert[1]);

			if (cookieWert == "none") {
				document.getElementById(myImage).src = "modules/templates/workflow/bilder/plus.gif";
			} else {
				document.getElementById(myImage).src = "modules/templates/workflow/bilder/minus.gif";
			}

			return cookieWert;
		}
	}
	return false;
}

function showhideLayer (myElement) {
	if (document.getElementById(myElement).style.display=="block") {
		document.getElementById(myElement).style.visibility="hidden";
		document.getElementById(myElement).style.display="none";
		SetzCookie (document.getElementById(myElement).id, "none");
	} else {
		document.getElementById(myElement).style.visibility="visible";
		document.getElementById(myElement).style.display="block";
		SetzCookie (document.getElementById(myElement).id, "block");
	}
	LeseCookie(document.getElementById(myElement).id);
}

function showhideLayer2 (myElement, myImage) {
	if (document.getElementById(myElement).style.display=="block") {
		document.getElementById(myElement).style.visibility="hidden";
		document.getElementById(myElement).style.display="none";
		SetzCookie (document.getElementById(myElement).id, "none");
		document.getElementById(myImage).src = "modules/templates/workflow/bilder/plus.gif";
	} else {
		document.getElementById(myElement).style.visibility="visible";
		document.getElementById(myElement).style.display="block";
		SetzCookie (document.getElementById(myElement).id, "block");
		document.getElementById(myImage).src = "modules/templates/workflow/bilder/minus.gif";
	}
	LeseCookie(document.getElementById(myElement).id);
}



// Veranstaltung anlegen
// Location-Liste durch Veranstalterwechsel aktualisieren
function select_something(mainselect, subselect, anz_array, hidden_array) {
	
	// Ausgewählten Hersteller und Anzahl der Hersteller-Typen holen
	var mainselect_id = document.getElementById(mainselect).options[document.getElementById(mainselect).options.selectedIndex].value;

	var anz_subselect = document.form.elements[anz_array+"["+mainselect_id+"]"].value;

	// Bestehende Select-Felder löschen
	removeOptions (subselect);
	// Select-Feld wieder füllen
	for (i=0; i < anz_subselect; i++) {
		var txt = document.form.elements[hidden_array+"["+mainselect_id+"]["+i+"][sel_name]"].value;
		var val = document.form.elements[hidden_array+"["+mainselect_id+"]["+i+"][sel_id]"].value;
		addOption (i, txt, val, subselect);
	}

}

// Select-Felder füllen
function addOption (position, txt, val, subselect) {
	ne = new Option(txt, val, false, false);
	document.getElementById(subselect).options[position] = ne;
}

// Select-Feld löschen
function removeOptions (subselect) {	
	for (i = 100; i >= 0; i--) {
		document.getElementById(subselect).options[i] = null;
	}
}