// JavaScript Document

function ss(theNb){
	
	document.getElementById("s"+theNb).style.display="block";
}
function hs(theNb){
	document.getElementById("s"+theNb).style.display="none";
}
function flashAusblenden(){
	
	document.getElementById("homeFlash").style.display="none";	
	document.getElementById("backgroundLayer").style.display="block";
	document.getElementById("coverArea").style.display="none";
	document.getElementById("m5").style.display="block";
	document.getElementById("al5").style.display="block";
	

}
function mapDotClicked(dotNb){
	document.getElementById("city"+dotNb).style.display="block";
}
function mapDotOvered(dotNb){
	
	mapDotClicked(dotNb);
}
function mapDotOut(dotNb){
	document.getElementById("city"+dotNb).style.display="none";
}
/* Formulare */
function evalunternPrForm(){
	
	
	mailError="";
	eng_mailError="";
		
	errors=new Array();
	eng_errors=new Array();
	
	if(document.forms['unternPrForm'].elements['name'].value.length<2) {
		errors[errors.length]="Name";
		eng_errors[eng_errors.length]="Name";
	}
	if(document.forms['unternPrForm'].elements['firma'].value.length<2) {
		errors[errors.length]="Firma";
		eng_errors[eng_errors.length]="First Name";
	}
	if(document.forms['unternPrForm'].elements['telefon'].value.length<2) {
		errors[errors.length]="Telefon";
		eng_errors[eng_errors.length]="Street + No.";
	}
	if(document.forms['unternPrForm'].elements['anschrift'].value.length<2) {
		errors[errors.length]="Anschrift";
		eng_errors[eng_errors.length]="Country";
	}
	if(document.forms['unternPrForm'].elements['email'].value.length<5) {
		errors[errors.length]="Email";
		eng_errors[eng_errors.length]="Email";
	}
	else if(document.forms['unternPrForm'].elements['email'].value.indexOf("@")<1) {
		mailError="Bitte geben Sie eine gültige Email-Adresse an. ";
		eng_mailError="Please submit a valid email adress. ";
	}


	//alert("fehler: "+errors.join(","));
	
	if((errors.length>0)||(mailError.length>0)){
		
		// deutsch	
		for (i=0;i<document.getElementById("errorMsg").childNodes.length;i++){
			document.getElementById("errorMsg").removeChild(document.getElementById("errorMsg").childNodes[i]);	
		}
		
		errorNode=document.createElement("div");
		if(errors.length>0)	
			errorNode.appendChild(wrapMessage("Bitte füllen Sie folgende Felder aus: "+errors.join(", "), ""));
		if(mailError.length>0) 
			errorNode.appendChild(wrapMessage(mailError, ""));
			
		document.getElementById("errorMsg").appendChild(errorNode);
		
		// english
		for (i=0;i<document.getElementById("eng_errorMsg").childNodes.length;i++){
			document.getElementById("eng_errorMsg").removeChild(document.getElementById("eng_errorMsg").childNodes[i]);	
		}
		
		eng_errorNode=document.createElement("div");
		if(eng_errors.length>0)	
			eng_errorNode.appendChild(wrapMessage("Please fill in these fields: "+eng_errors.join(", "), ""));
		if(eng_mailError.length>0) 
			eng_errorNode.appendChild(wrapMessage(eng_mailError, ""));
			
		//document.getElementById("eng_errorMsg").appendChild(eng_errorNode);		
		document.getElementById("errorWin").style.visibility="visible";
	}
	else document.forms['unternPrForm'].submit();
	

}
 function wrapMessage(theHeader, theContent){
   		
		theMsg=document.createElement("div");	
		theMsgHd=document.createElement("div");
		theClass=document.createAttribute("id");
		theClass.nodeValue="hd";
		theMsgHd.setAttributeNode(theClass);
			
		theMsgHd.appendChild(document.createTextNode(theHeader));
			
		theMsg.appendChild(theMsgHd);
		theMsg.appendChild(document.createTextNode(theContent));
			
		
   		return theMsg;
   
 }
 function wrapDialog(theHeader, theContent, theOptions){
   		
		theMsg=document.createElement("div");	
		theMsgHd=document.createElement("div");
		theLinks=new Array();
		for(o=0;o<theOptions.length;o++){
			theLinks[o]=document.createElement("a");
			theLinks[o].href=theOptions[o][0];
			theLinks[o].appendChild(document.createTextNode(theOptions[o][1]));
		}
		
		theClass=document.createAttribute("id");
		theClass.nodeValue="hd";
		theMsgHd.setAttributeNode(theClass);
			
		theMsgHd.appendChild(document.createTextNode(theHeader));
			
		theMsg.appendChild(theMsgHd);
		theMsg.appendChild(document.createTextNode(theContent));
		theMsg.appendChild(document.createElement("br"));
		theMsg.appendChild(document.createElement("br"));
		for(o=0;o<theOptions.length;o++){
			theMsg.appendChild(theLinks[o]);
		}
		theMsg.appendChild(document.createElement("br"));	
		
   		return theMsg;
   	
   }
 function closeErrorWin(){
 	document.getElementById("errorWin").style.visibility="hidden";
 }
function openMovieWin(theMovieName, w, h){

	MeinFenster = window.open("showMovie.php?nm="+theMovieName+"&w="+w+"&h="+h, "Filmfenster", "width="+(w)+",height="+(h+16)+",scrollbars=no");  	MeinFenster.focus();
}
