function validatevaf(){
	var ref = document.forms['vaf'].elements;
	if( ref.antwort[0].checked && ref.gerne_email.value.length < 5 ){
		alert("Bitte geben Sie noch Ihre E-Mail Adresse an. Vielen Dank.");
		return false;
	}
	
	if( ref.antwort[1].checked && ref.zusendung_email.value.length < 5 ){
		alert("Bitte geben Sie noch Ihre E-Mail Adresse an. Vielen Dank.");
		return false;
	}
	
	if( ref.antwort[2].checked && ref.leider_email.value.length < 5 ){
		alert("Bitte geben Sie noch Ihre E-Mail Adresse an. Vielen Dank.");
		return false;
	}
				

	return true;	

}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function hideIntro(){
	document.getElementById("introswf").style.visibility = "hidden";
     	var ielem = document.getElementById("introswf");
     	if( ielem.childNodes[0] ){ielem.removeChild(ielem.childNodes[0]);}
     	if( ielem.childNodes[1] ){ielem.removeChild(ielem.childNodes[1]);}     	
}



function swfIntro( _url ){
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if( readCookie("intro") == null ){
		if(hasRightVersion) {
   			 var tag = new FlashTag(_url, "952", "790"); // last two arguments are height and width
   			 tag.write(document);
			 hasRightVersion=true;
  		} else {
        		var alternateContent = '<a href="http://www.adobe.com/de/products/flashplayer/" target="_blank"><img src="/fileadmin/media/swf/intro/getflash.jpg" alt="" border="0" /></a>';
       	 		document.write(alternateContent);
  		}  
  		createCookie("intro","aktiv");
  	} else {
  		hideIntro();
  	}
  		
}

function swfHeader( _url ){
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(hasRightVersion) {
    		var tag = new FlashTag(_url, 952, 212); // last two arguments are height and width
    		tag.setFlashvars('lcId=141421356237');
    		tag.setId("__141421356237");
    		tag.write(document); 
		hasRightVersion=true;
  	} else {
        	var alternateContent = '<a href="http://www.adobe.com/de/products/flashplayer/" target="_blank"><img src="/fileadmin/template/img/header_hinweis.jpg" alt="" border="0" /></a>';
       	 	document.write(alternateContent);
  	}    
}


function swfHomeHeader( _url ){
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(hasRightVersion) {
   		 var tag = new FlashTag(_url, "952", "304"); // last two arguments are height and width
   		 tag.write(document);
		 hasRightVersion=true;
  	} else {
        	var alternateContent = '<a href="http://www.adobe.com/de/products/flashplayer/" target="_blank"><img src="/fileadmin/template/img/hinweis.jpg" alt="" border="0" /></a>';
       	 	document.write(alternateContent);
  	}  
}

function swfAcc( _url, _id, _width, _height ){

	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(hasRightVersion) {
   		 var tag = new FlashTag(_url, _width, _height); // last two arguments are height and width
   		 tag.setFlashvars('lcId='+_id);
   		 tag.setId("__"+_id);    
   		 tag.write(document);
		hasRightVersion=true;
  	} else {
        	var alternateContent = '<a href="http://www.adobe.com/de/products/flashplayer/" target="_blank"><img src="/fileadmin/template/img/accordion_hinweis.jpg" alt="" border="0" /></a>';
       	 	document.write(alternateContent);
  	}    

}


function insertHeader( _url ){
	if( _url.indexOf(".swf") != -1 ){
		swfHeader( _url );
	} else {
		document.write('<img src="' + _url + '" width="952" height="212" alt="" />');
	}
}

function insertHomeHeader( _url ){
	if( _url.indexOf(".swf") != -1 ){
		swfHomeHeader( _url );
	} else {
		document.write('<img src="' + _url + '" width="952" height="304" alt="" />');
	}
}



SWFOPEN = 0;
SWFTITLE = "";
SWFID = "";
flashProxy = null;
flashProxy2 = null;


function communicate( _obj ){
	var swfid = _obj.nextSibling.childNodes[2];
	//alert(swfid.nodeName);
	if( swfid != null){
		if( swfid.nodeName.toLowerCase() == "object" ){
			swfid = swfid.getAttribute("id").substr(2);
		} else if( swfid.nodeName.toLowerCase() == "embed" ){
			swfid = swfid.getAttribute("name").substr(2);		
		} else {
			swfid = false;
		}
	} else {
		swfid = false;
	}
	//alert(swfid);
	if( swfid && SWFOPEN == 0 && SWFTITLE == "" ){
		//alert("Öffne Film: " + _obj.innerHTML + " (" + swfid + ")" );
		SWFOPEN = 1;
		SWFID = swfid;
		SWFTITLE = _obj.innerHTML;
		
		flashProxy = new FlashProxy(swfid, "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		flashProxy2 = new FlashProxy("141421356237", "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		
		flashProxy.call('playFlash');
		flashProxy2.call('soundOff');	
		
		//alert(SWFID);	
		
		
	} else if( swfid && SWFTITLE != "" && SWFOPEN == 1 && _obj.innerHTML != SWFTITLE ) {
		//alert("Schliesse Film\n " + SWFTITLE + "\n und öffne Film: \n" + _obj.innerHTML + " (" + swfid + ")" );
		SWFTITLE = _obj.innerHTML;
		SWFOPEN = 1;	
		
		flashProxy = new FlashProxy(swfid, "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		flashProxy2 = new FlashProxy("141421356237", "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		flashProxyX = new FlashProxy(SWFID, '/fileadmin/template/swf/JavaScriptFlashGateway.swf');

		SWFID = swfid;	

		//alert("pausiere offenees flash");
		flashProxyX.call('pauseFlash');					
		//alert("sound off oben");		
		flashProxy2.call('soundOff');	
		//alert("spiele neues flash");		
		flashProxy.call('playFlash');			
		
		//alert(SWFID);		
		
	} else if ( swfid && SWFOPEN == 1 ){
		SWFTITLE = _obj.innerHTML;
		//alert("Schliesse Film " + SWFTITLE + " (" + swfid + ")" );		
		SWFOPEN = 0;			
		SWFTITLE = "";
		SWFID = "";	
		
		flashProxy = new FlashProxy(swfid, "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		flashProxy2 = new FlashProxy("141421356237", "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		
		flashProxy2.call('soundOn');				
		flashProxy.call('pauseFlash');
		
		//alert(SWFID);		
						
	} else if ( SWFOPEN == 1 && SWFTITLE != "" && SWFID != "" ){
		//alert("keine swfid - Schliesse Film " + SWFTITLE + " (" + SWFID + ")" );	
		SWFOPEN = 0;			
		SWFTITLE = "";		
			
		flashProxy = new FlashProxy(SWFID, "/fileadmin/template/swf/JavaScriptFlashGateway.swf");
		flashProxy2 = new FlashProxy("141421356237", "/fileadmin/template/swf/JavaScriptFlashGateway.swf");			
		
		flashProxy.call('pauseFlash');
		flashProxy2.call('soundOn');	
		
		SWFID = "";			

							
	}
}


function validateEmail(){
	var theRegEx_notValid = new RegExp("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", "gi");
	var theRegEx_isValid = new RegExp("^.+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})$","");
	if (!theRegEx_isValid.test(document.forms['nlform'].EMail.value)){
		alert("E-Mail Adresse ungültig.\nYou have entered an invalid eMail address.");
		return false;
	}
	document.forms['nlform'].action = document.forms['nlform'].action + document.forms['nlform'].EMail.value
	return true;
}

function goBack(){
	var ref = document.referrer;
	if( ref.indexOf("p55891.typo3server.info") != -1 || ref.indexOf("sibeth.com") != -1 ){
		history.back();
	} else {
		location.href = "/";
	}
}

function validateNLF(){
	var ref = document.forms['nlf'].elements;
	if( ref.vorname.value < 3 ){
		alert("Bitte geben Sie Ihren Vornamen an.\nPlease enter your first name.");
		return false;
	}
	if( ref.nachname.value < 2 ){
		alert("Bitte geben Sie Ihren Nachnamen an.\nPlease enter your last name.");
		return false;		
	}	
	var theRegEx_notValid = new RegExp("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", "gi");
	var theRegEx_isValid = new RegExp("^.+\@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})$","");
	if (!theRegEx_isValid.test(ref.email.value)){
		alert("E-Mail Adresse ungültig.\nYou have entered an invalid eMail address.");
		return false;
	}	
	
	if( ref['Newsletter-Deutsch'] ){
		if( ref['Newsletter-Deutsch'].checked ){
		
			if( ref.adresse1.value < 3 || ref.adresse2.value < 3 || ref.land.options[0].selected ){
				alert("Bitte geben Sie für den Postversand Ihre vollständige Adresse an.");
				return false;
			}	
		
		}
	}
	
	ref.land.options[ref.land.options.selectedIndex].value = ref.land.options[ref.land.options.selectedIndex].text;
	
	return true;	

}

function checkNLF(){
	if( self.location.href.indexOf("index.php?id=187") != -1 ){
		document.forms['nlf'].email.value = self.location.href.substr( self.location.href.lastIndexOf("&")+1 );
	}
}


function printAccordion( _elem ){
	var myhtml = _elem.parentNode.parentNode.innerHTML;
	mypw = window.open('blank','dfw','width=500,height=500,top=200,left=200,scrollbars=yes');
	var mycontent = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';	
	mycontent += '<html xmlns="http://www.w3.org/1999/xhtml">';
	mycontent += '<head><base href="http://www.sibeth.com/" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" type="text/css" href="/fileadmin/template/css/rgaccordion2print.css" /></head><body>';
	mycontent += myhtml;
	mycontent += '<script language="JavaScript">self.print();</script></body></html>';			
	mypw.document.open();	
	mypw.document.write(mycontent);
	mypw.document.close();
}