﻿// JavaScript Document

function checkForm() {
	//var f = document.anmeldung;
	var FormFields = new Array();
	var Error = new Array;
	FormFields[0] = new Object();
	FormFields[0]["Error"] = "checkVorname";
	FormFields[0]["Field"] = "Vorname";
	FormFields[1] = new Object();
	FormFields[1]["Error"] = "checkNachname";
	FormFields[1]["Field"] = "Nachname";
	FormFields[2] = new Object();
	FormFields[2]["Error"] = "checkStrasse";
	FormFields[2]["Field"] = "Strasse";
	FormFields[3] = new Object();
	FormFields[3]["Error"] = "checkStrasse";
	FormFields[3]["Field"] = "Nr";
	FormFields[4] = new Object();
	FormFields[4]["Error"] = "checkPLZ";
	FormFields[4]["Field"] = "PLZ";
	FormFields[5] = new Object();
	FormFields[5]["Error"] = "checkPLZ";
	FormFields[5]["Field"] = "Ort";
	FormFields[6] = new Object();
	FormFields[6]["Error"] = "checkEmail";
	FormFields[6]["Field"] = "Email";
	FormFields[6]["Email"] = true;
	FormFields[7] = new Object();
	FormFields[7]["Error"] = "checkTelefon";
	FormFields[7]["Field"] = "Telefon";
	FormFields[8] = new Object();
	FormFields[8]["Error"] = "checkSeminar";
	FormFields[8]["Field"] = "Seminar";
	FormFields[9] = new Object();
	FormFields[9]["Error"] = "checkAGB";
	FormFields[9]["Field"] = "agb";
	FormFields[10] = new Object();
	FormFields[10]["Error"] = "checkTermin";
	FormFields[10]["Field"] = "Termin";
	FormFields[11] = new Object();
	FormFields[11]["Error"] = "checkDate";
	FormFields[11]["Field"] = "Tag";
	FormFields[12] = new Object();
	FormFields[12]["Error"] = "checkDate";
	FormFields[12]["Field"] = "Monat";
	FormFields[13] = new Object();
	FormFields[13]["Error"] = "checkDate";
	FormFields[13]["Field"] = "Jahr";
	FormFields[14] = new Object();
	FormFields[14]["Error"] = "checkTime";
	FormFields[14]["Field"] = "Uhrzeit[]";
	FormFields[15] = new Object();
	FormFields[15]["Error"] = "checkEvent";
	FormFields[15]["Field"] = "Veranstaltung";
	FormFields[16] = new Object();
	FormFields[16]["Error"] = "checkName";
	FormFields[16]["Field"] = "Name";
	
	for (var i = 0; i < FormFields.length; i++) {
  		//Textfelder
		
		if (document.anmeldung[FormFields[i]["Field"]] && document.anmeldung[FormFields[i]["Field"]].value == "") {
			Error.push(FormFields[i]["Error"]);
		} else if (FormFields[i]["Email"] && FormFields[i]["Email"] == true) {
			var ad = document.anmeldung[FormFields[i]["Field"]].value.indexOf("@");
			if (ad < 1)  
				Error.push(FormFields[i]["Error"]);
			else {
				var point = document.anmeldung[FormFields[i]["Field"]].value.substring(ad).indexOf(".");
				if (point < 2) Error.push(FormFields[i]["Error"]);
				else document.getElementById(FormFields[i]["Error"]).style.display = "none";
			}
		} else {
			if (document.getElementById(FormFields[i]["Error"])) 
				document.getElementById(FormFields[i]["Error"]).style.display = "none";
		}
	}
	
	//AGB Überprüfung:
	if (document.anmeldung.agb && document.anmeldung.agb.checked != true) {
		Error.push(FormFields[9]["Error"]);
	}

	if (Error.length > 0) {
		for (var i=0; i<Error.length; i++) {
			document.getElementById(Error[i]).style.display = "inline";
		}
		document.getElementById("ErrorText").style.display = "inline";
		return false;
	} 
	return true;
}

var checkInt = 0;
	
//Größenänderung

	var checkPerInterval;
	
	function checkContentSize() {

		if (window.innerHeight)
			docHeight = window.innerHeight;
		else if (document.body.clientHeight)
			docHeight = document.body.clientHeight;
		else if (document.documentElement.clientHeight)
			docHeight = document.documentElement.clientHeight;
	
		co = document.getElementById("content");
		bo = document.getElementById("borderEntry");
		bl = document.getElementById("blog");
		sz = document.getElementById("contentSize");
		sb = document.getElementById("innersidebar");
		//alert(sb.style.height);
		
		contentHeight = sz.offsetHeight;//Höhe, des inneren, nicht veränderten Layers
		 if (docHeight > 680) { //bei größeren Monitoren wird der Blog am unteren Rand fixiert
			 bl.style.bottom = "0px";
			 bl.style.top = "auto";
			 if (bo) {
			 	bo.style.bottom = "178px";
			 	bo.style.top = "auto";
			 }
			
			co.style.height = (docHeight - 150 - 39 - 178) + "px";
			sb.style.height = (docHeight - 150 - 39 - 178) + "px";
			//alert(sb.style.height);
			
		 } else {
		  if (contentHeight > 323) { //das gesamte Fenster beginnt zu scrollen
				bl.style.bottom = "auto";
				if (bo) bo.style.bottom = "auto";
				bl.style.top = 680 - 178 + "px";
				if (bo) bo.style.top = 680 - 178 - 29 + "px";
				
				co.style.height = (680 - 150 - 39 - 178) + "px";
				sb.style.height = (680 - 150 - 39 - 178) + "px";
		   } else {
			   if ((docHeight - 150 - 29 - 178) > contentHeight) { //der Blog wird am unteren Rand fixiert
			  		bl.style.bottom = "0px";
			 		bl.style.top = "auto";
			 		if (bo) {
			 			bo.style.bottom = "178px";
			 			bo.style.top = "auto";
			 		}
			
			 		co.style.height = (docHeight - 150 - 29 - 178) + "px";
					sb.style.height = (docHeight - 150 - 29 - 178) + "px";
			   } else {										//das gesamte Fenster beginnt zu scrollen
					bl.style.bottom = "auto";
					if (bo) bo.style.bottom = "auto";
					
					bl.style.top = contentHeight + 150 + 29 + "px";
					if (bo) bo.style.top = contentHeight + 150 + "px";
					//document.form.test.value = bl.style.top;
					
					co.style.height = contentHeight - 10 + "px";
					sb.style.height = contentHeight - 10 + "px";
			   }
		   	}
		} 
		if (checkInt == 2) {
			//window.clearInterval(checkPerInterval);
			checkInt = 0;
		} else {
			checkInt++; //für das Intervall wird gezählt;
		}
	}
	
	function mclick(e) {
		if (checkPerInterval) {
			//window.clearInterval(checkPerInterval);
		}
		//checkPerInterval = window.setInterval("checkContentSize()", 10);
		
  		checkContentSize();
	}
	
window.onload = function () {
	checkContentSize();
	elStyle = document.getElementById('styleNoScript');
	if (elStyle.getAttribute('href') == "http://www.kulturdidaktik.at/wp-content/themes/kulturdidaktik/style_noscript.css")
	{
		elStyle.removeAttribute("href");
		elStyle.setAttribute( "href", "http://www.kulturdidaktik.at/wp-content/themes/kulturdidaktik/style_script.css");
	}
	
	//jQery Scrollbalken aufrufen
	$(function()
	{
		$('#blogText1').jScrollPane({showArrows:true});
		$('#blogText2').jScrollPane({showArrows:true});
		$('#blogText3').jScrollPane({showArrows:true});
		$('#innersidebar').jScrollPane({showArrows:true});
	});
}
 
window.onresize = mclick;

