// library.js
var browsertype;

if(navigator.appName == "Microsoft Internet Explorer"){
	//appname = navigator.appVersion;
	teil = navigator.appVersion.split(";");
	bvers = teil[1];
	if(bvers == " MSIE 6.0") {
		browsertype = "IE6";
	}else{
		browsertype = "IE";
	}
}
function toggleMainNav(obj) {
	nObj = $('mainNav').childElements();
	resetNav();
	if (browsertype=="IE6") {
	// 162, 159, 196, 161, 230, 141, 143
		if (obj.innerHTML.match(/Pageid=162/ig)) {
			obj.previous("li").down(0).style.left = "-615px";
		} else if (obj.innerHTML.match(/Pageid=159/ig)) {
			obj.previous("li").down(0).style.left = "-515px";
		} else if (obj.innerHTML.match(/Pageid=196/ig)) {
			obj.previous("li").down(0).style.left = "-429px";
		} else if (obj.innerHTML.match(/Pageid=161/ig)) {
			obj.previous("li").down(0).style.left = "-360px";
		} else if (obj.innerHTML.match(/Pageid=230/ig)) {
			obj.previous("li").down(0).style.left = "-240px";
		} else if (obj.innerHTML.match(/Pageid=141/ig)) {
			obj.previous("li").down(0).style.left = "-150px";
		} else if (obj.innerHTML.match(/Pageid=143/ig)) {
			obj.previous("li").down(0).style.left = "-71px";
		} else {
		}
	}
	if ($(obj).next("li").className != "mainNavR_high active") {
		$(obj).previous("li").className = "mainNavL_high";
		obj.className = "mainNav_high";
		$(obj).next("li").className = "mainNavR_high";
		obj.previous("li").down(0).style.display = "block";
	} else {
		obj.previous("li").down(0).style.display = "block";
	}
	
}
function toggleSubNav(obj) {
	nObj = $('subNav').childElements();
	for (n=0;n<=nObj.length -1; n++) {
		//alert(nObj[n].tagName);
		$(nObj[n]).down(0).down(0).className = "subNavL_low";
		$(nObj[n]).down(0).down(1).className = "subNav_low";
		$(nObj[n]).down(0).down(2).className = "subNavR_low";
	}
	$(obj).previous("li").className = "subNavL_high";
	obj.className = "subNav_high";
	$(obj).next("li").className = "subNavR_high";
	//obj.previous("li").down(0).style.display = "block";
}
function toggleSubNavContent(obj) {
	nObj = $('subNav').childElements();
	for (n=0;n<=nObj.length -1; n++) {
		//alert(nObj[n].tagName);
		if ($(nObj[n]).down(0).down(0).className != "subNavL_high active") {
			$(nObj[n]).down(0).down(0).className = "subNavL_low";
			$(nObj[n]).down(0).down(1).className = "subNav_low";
			$(nObj[n]).down(0).down(3).className = "subNavR_low";
		}
	}
	if ($(obj).previous("li").className != "subNavL_high active") {
		$(obj).previous("li").className = "subNavL_high";
		obj.className = "subNav_high";
		$(obj).next("li").className = "subNavR_high";
	}
}
function resetNav() {
	resetDropdown();
	nObj = $('mainNav').childElements();
	for (n=0;n<=nObj.length -1; n++) {
		if ($(nObj[n]).down(1).next(1).className != "mainNavR_high active") {
			$(nObj[n]).down(1).className = "mainNavL_low";
			$(nObj[n]).down(1).down(0).style.display = "none";
			$(nObj[n]).down(1).next(0).className = "mainNav_low";
			$(nObj[n]).down(1).next(1).className = "mainNavR_low";
		} else {
			$(nObj[n]).down(1).down(0).style.display = "none";
		}
	}
	if (document.getElementById('subNav')) {
		nObj = $('subNav').childElements();
		for (n=0;n<=nObj.length -1; n++) {
			//alert(nObj[n].tagName);
			if ($(nObj[n]).down(0).down(0).className != "subNavL_high active") {
				$(nObj[n]).down(0).down(0).className = "subNavL_low";
				$(nObj[n]).down(0).down(1).className = "subNav_low";
				$(nObj[n]).down(0).down(3).className = "subNavR_low";
			}
		}
	}
}
function resetSubNav() {
	resetDropdown();
	if (document.getElementById('subNav')) {
		nObj = $('subNav').childElements();
		for (n=0;n<=nObj.length -1; n++) {
			//alert(nObj[n].tagName);
			$(nObj[n]).down(0).down(0).className = "subNavL_low";
			$(nObj[n]).down(0).down(1).className = "subNav_low";
			$(nObj[n]).down(0).down(3).className = "subNavR_low";
		}
	}
}
function showDropdown(objId) {
	//alert(document.getElementById(objId).style.display);
	resetDropdown();
	if (document.getElementById(objId).style.display == "none") {
		Effect.Appear(objId, { duration: 0.7 });
		//Effect.ScrollTo('pageEnd', {offset: 260});
	} else {
		Effect.Fade(objId, { duration: 0.7 });
		//Effect.ScrollTo('header');
	}
}
function resetDropdown() {
	
	if (document.getElementById("regionen_selectfield_values")) {
		if (document.getElementById("regionen_selectfield_values").style.display != "none") {
			Effect.Fade("regionen_selectfield_values", { duration: 0.7 });
		}
		if (document.getElementById("methoden_selectfield_values").style.display != "none") {
			Effect.Fade("methoden_selectfield_values", { duration: 0.7 });
		}
	}
}
function resetNLField(obj) {
	obj.value="";
}
function setNLField(obj, lang) {
	if (lang == "de") {
		obj.value="Ihre Email Adresse";
	} else {
		obj.value="Your email address";
	}
}

function loadDynContent() {
	new Ajax.Updater('ibox_1', "/application/veranstaltungen.pl", { method: 'get' });

}
function loadDynContentStart() {
	new Ajax.Updater('teaserbox_1', "/application/veranstaltungen_start.pl", { method: 'get' });

}
function loadPage(url, obj) {
	//alert("url:" + url + "\n" + "obj:" + obj);
	new Ajax.Updater(obj, url, { method: 'get' });
}
function loadTeam() {
	new Ajax.Updater('teaserbox_2', "/application/team.pl", { method: 'get' });

}
function chkFormular2(Language)
{
	chkError = false;
	for (i = 0; i < document.all.length; i++)
	{
		if (document.all(i).getAttribute("mandatory"))
		{
			if (document.all(i).getAttribute("mandatory") == 1)
			{
				FieldName = document.all(i).name;
				switch (document.all(i).tagName)
				{
					case "SELECT":
								if (document.all(i).selectedIndex == -1)
									chkError = true;
								else if (document.all(i).options(document.all(i).selectedIndex).text == "")
									chkError = true;
								break;
					case "INPUT":
								if (document.all(i).value == "")
									chkError = true;
								break;
					case "TEXTAREA":
								if (document.all(i).innerText == "")
									chkError = true;
								break;
				}
				if (chkError)
				{
					switch (Language)
					{
						case "de":	
								msg = "Geben Sie bitte einen Wert für das Feld <" + FieldName + "> an!";
								break;
						case "en":	
								msg = "Please enter a value for the field <" + FieldName + ">!";
								break;
					}
					alert(msg);
					document.all(i).focus();
					return false;
				}
			}
		}
	}
	return true;
}