// JavaScript Document
var lastID = '';

function hideCorporatebox(id){
	var infobox = 'corporatebox-'+id;
	var btnBack = 'btn-back-'+id;
	
	if(id == 2){
		$(infobox).setStyle({display: 'none'});
		$(infobox).setStyle({position: 'absolute'});
		$(infobox).setStyle({top: '290px'});
		$('corporate-linkbox').show();
		$(btnBack).setStyle({display: 'none'});
	} else {
		if($('visual-corporate').getStyle('height') == '451px'){
			$(infobox).setStyle({display: 'none'});
			$(infobox).setStyle({position: 'absolute'});
			$(infobox).setStyle({top: '290px'});
			$('content-section').setStyle({display: 'block'});
			$('visual-corporate').setStyle({height: '224px'});
			$('corporate-linkbox').show();
			$(btnBack).setStyle({display: 'none'});
		}
	}
}

function showInfobox(id){
	var infobox = 'corporatebox-'+id;
	var btnBack = 'btn-back-'+id;
	$(infobox).setStyle({display: 'block'});
	$(infobox).setStyle({position: 'absolute'});
	$(infobox).setStyle({top: '0px'});
	
	if(id == 2){
		$(btnBack).show();
	} else {
		$('content-section').setStyle({display: 'none'});
		//$('visual').morph('height:451px;');
		new Effect.Morph($('visual-corporate'), {
			style: {
				height: '451px'
			},
			afterFinish: function(){ $(btnBack).show(); }
		})
	}
	$('corporate-linkbox').setStyle({display: 'none'});
}

function InfoboxOver(id){
	var infolink = 'Infolink-'+id;
	$(infolink).setStyle({backgroundPosition:"0px -38px"});
}
function InfoboxOut(id){
	var infolink = 'Infolink-'+id;
	$(infolink).setStyle({backgroundPosition:"0px 0px"});
}

function showInfoSection(id){
	var linkId  = 'tnav-link-'+id;
	var oImg = $(linkId).firstChild.getAttribute('name');
	over(oImg);
	if(lastID != ''){
		var lastInfoId  = 'tnav-infobox-'+lastID;
		$(lastInfoId).setStyle({display: 'none'});
	}
	var infoId  = 'tnav-infobox-'+id;
	$(infoId).setStyle({display: 'block'});
	lastID = id;
}
function hideInfoSection(id){
	var linkId  = 'tnav-link-'+id;
	var oImg = $(linkId).firstChild.getAttribute('name');
	out(oImg);
	var infoId  = 'tnav-infobox-'+id;
	$(infoId).setStyle({display: 'none'});
}

function hideCorporateContentbox(id){
	var infobox = 'corporate-contentbox-'+id;
	var btnBack = 'btn-back-'+id;
	
	if(id == 2){
		$(infobox).setStyle({display: 'none'});
		$(infobox).setStyle({position: 'absolute'});
		$(infobox).setStyle({top: '290px'});
		$('corporate-content-linkbox').show();
		$(btnBack).setStyle({display: 'none'});
	} else {
		if($('visual-content').getStyle('height') == '451px'){
			$(infobox).setStyle({display: 'none'});
			$(infobox).setStyle({position: 'absolute'});
			$(infobox).setStyle({top: '290px'});
			$('content-section').setStyle({display: 'block'});
			$('visual-content').setStyle({height: '159px'});
			$('corporate-content-linkbox').show();
			$(btnBack).setStyle({display: 'none'});
		}
	}
}

function hideCorporateContentbox_nl(id){
	var infobox = 'corporate-contentbox-'+id;
	var btnBack = 'btn-back-'+id;
	

		if($('visual-content').getStyle('height') == '451px'){
			$(infobox).setStyle({display: 'none'});
			$(infobox).setStyle({position: 'absolute'});
			$(infobox).setStyle({top: '290px'});
			$('content-section').setStyle({display: 'block'});
			$('visual-content').setStyle({height: '159px'});
			$('corporate-content-linkbox').show();
			$(btnBack).setStyle({display: 'none'});
		}
	
}

function showCorporateContentbox(id){
	var infobox = 'corporate-contentbox-'+id;
	var btnBack = 'btn-back-'+id;
	$(infobox).setStyle({display: 'block'});
	$(infobox).setStyle({position: 'absolute'});
	$(infobox).setStyle({top: '0px'});
	
	if(id == 2){
		$(btnBack).show();
	} else {
		$('content-section').setStyle({display: 'none'});
		//$('visual').morph('height:451px;');
		new Effect.Morph($('visual-content'), {
			style: {
				height: '451px'
			},
			afterFinish: function(){ $(btnBack).show(); }
		})
	}
	$('corporate-content-linkbox').setStyle({display: 'none'});
}

function showCorporateContentbox_nl(id){
	var infobox = 'corporate-contentbox-'+id;
	var btnBack = 'btn-back-'+id;
	$(infobox).setStyle({display: 'block'});
	//alert("text");
	$(infobox).setStyle({position: 'absolute'});
	$(infobox).setStyle({top: '0px'});
	

		$('content-section').setStyle({display: 'none'});
		//$('visual').morph('height:451px;');
		new Effect.Morph($('visual-content'), {
			style: {
				height: '451px'
			},
			afterFinish: function(){ $(btnBack).show(); }
		})
	$('corporate-content-linkbox').setStyle({display: 'none'});
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
		 
		 if (str.indexOf("mymail")!=-1){
		    return false
		 }
		 
 		 return true					
	}
	
function CheckInputs() {
	
	var check = true;
  	var form = document.getElementById('newsletterForm');
	var email = form.elements['inp_3'];
	var protect = form.elements['protect'];

	//Check Email
	if (email.value == "" || email.value == "E-Mail-Adresse fehlt!") {
		email.value = "E-Mail-Adresse fehlt!";
		email.style.color = '#e20000';
		check = false;		
	} else{
		if(echeck(email.value) == false ){
			email.value = "E-Mail-Adresse ist falsch!";
			email.style.color = '#e20000';
			check = false;		
		}
	}
	if (protect.value != ""){
		check = false;		
	}
   return check;
 } 
