// JavaScript Document


function validatePhone(phoneField, format) {
    var num = phoneField.value.replace(/[^\d]/g,'');
    switch(format) {
            
            default: //Format xxxxxxxxxx
                phoneField.value = num;
                break;
        }
	if(num.length <= 8) {
        //Alert the user that the phone number entered was invalid.
        //alert('Die eingegebene Nummer ist zu kurz');                    
    } else {
        //Email was valid.  If format type is set, format the Phone to the desired style.
       
    }
}

function validateAW(awField, format) {
    var awnum = awField.value.replace(/[^\w]/g,'');
    switch(format) {
            
            default:
                awField.value = awnum;
                break;
        }
	if(awnum.length <= 2) {
        //Alert the user that the phone number entered was invalid.
        //alert('Die eingegebene Nummer ist zu kurz');                    
    } else {
        //Email was valid.  If format type is set, format the Phone to the desired style.
       
    }
}

function CheckLength()
{
var msg_area = document.getElementById("Message");
msg_area.innerHTML = "";
if (document.getElementById("password1").value.length < 4) {
msg_area.innerHTML = "Mit einem * gekennzeichnete Felder sind Pflichtfelder. Bitte f&uuml;llen Sie diese vollst&auml;ndig aus.<br>- Ihr Kennwort muss aus mindestens 4 Zeichen bestehen.";
return false;
}
else if (document.getElementById("users__first_name").value.length < 2) {
msg_area.innerHTML = "Mit einem * gekennzeichnete Felder sind Pflichtfelder. Bitte f&uuml;llen Sie diese vollst&auml;ndig aus.<br>- Vorname und Nachname müssen aus mindestens 2 Zeichen bestehen.";
return false;
}
else if (document.getElementById("users__last_name").value.length < 2) {
msg_area.innerHTML = "Mit einem * gekennzeichnete Felder sind Pflichtfelder. Bitte f&uuml;llen Sie diese vollst&auml;ndig aus.<br>- Vorname und Nachname müssen aus mindestens 2 Zeichen bestehen.";
return false;
}

 return true;
}

function setcontact(){

if(document.getElementById('users__email').value.length == 0){
setTextOfTextfield('communication_type','','0');
	}
else {
setTextOfTextfield('communication_type','','1');
}

}


function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
  } else {
    e.style.display="none"
  }
  return true;
}

function toggleMe2(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="none"
  } else {
    e.style.display="none"
  }
  return true;
}

function toggleMe3(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="block"){
    e.style.display="none"
  } else {
    e.style.display="none"
  }
  return true;
}

function toggleMe4(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block"
  } else {
    e.style.display="block"
  }
  return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* Altersabfrage   */

function checkCheckBox(f){

var dob=new Date();
var date=dob.getDate();
var month=dob.getMonth() + 1;
var year=dob.getFullYear();

var birthmonth=parseInt(document.getElementById("birthmonth").options[document.getElementById("birthmonth").selectedIndex].value);
var birthday=parseInt(document.getElementById("birthday").options[document.getElementById("birthday").selectedIndex].value);
var birthyear=parseInt(document.getElementById("birthyear").options[document.getElementById("birthyear").selectedIndex].value);

age=year-birthyear;

if(birthmonth>month){age--;}

else{if(birthmonth==month && birthday>=date){age--;}}

if(birthmonth==0){return true;}
else if(birthday==0){return true;}
else if(birthyear==2005){return true;}
else if(age<18){
if(age<16){return true;}
else if(!document.getElementById("agree").checked){
	setTextOfLayer('error','','Die Einwilligung meines Erziehungsberechtigten zum Abschluss dieses Vertrages liegt vor. Zur Best&auml;tigung der Einwilligung werde ich diese innerhalb von 2 Wochen nach Absendung meiner Bestellung mit folgendem <a href="#" target="_blank">Formular</a> schriftlich nachreichen. Das Vertragsverh&auml;ltnis mit WHITELABEL steht unter der Bedingung, dass die schriftliche Best&auml;tigung fristgerecht nachgereicht wird. Andernfalls ist WHITELABEL berechtigt, das Vertragsverh&auml;ltnis zu beenden.');showHideLayers('error','','show');showHideLayers('16check','','show');
;return false;
}

}

}

function checkAgeCheckBox(f){

var dob=new Date();
var date=dob.getDate();
var month=dob.getMonth() + 1;
var year=dob.getFullYear();

var birthmonth=parseInt(document.getElementById("birthmonth").options[document.getElementById("birthmonth").selectedIndex].value);
var birthday=parseInt(document.getElementById("birthday").options[document.getElementById("birthday").selectedIndex].value);
var birthyear=parseInt(document.getElementById("birthyear").options[document.getElementById("birthyear").selectedIndex].value);

age=year-birthyear;

if(birthmonth>month){age--;}

else{if(birthmonth==month && birthday>=date){age--;}}

if(birthmonth==0){return false;}
else if(birthday==0){return false;}
else if(birthyear==2005){return false;}
else if(age<18){
if(age<16){
	setTextOfLayer('error','','Wenn Sie unter 16 Jahre alt sind, ist es nicht möglich, diesen Dienst zu bestellen.');
	showHideLayers('16check','','hide');showHideLayers('error','','show');
	
;return false;}
else
	setTextOfLayer('error','','Die Einwilligung meines Erziehungsberechtigten zum Abschluss dieses Vertrages liegt vor. Zur Best&auml;tigung der Einwilligung werde ich diese innerhalb von 2 Wochen nach Absendung meiner Bestellung mit folgendem <a href="#" target="_blank">Formular</a> schriftlich nachreichen. Das Vertragsverh&auml;ltnis mit WHITELABEL steht unter der Bedingung, dass die schriftliche Best&auml;tigung fristgerecht nachgereicht wird. Andernfalls ist WHITELABEL berechtigt, das Vertragsverh&auml;ltnis zu beenden.');showHideLayers('16check','','show');showHideLayers('error','','show');
	
	return false;
}

else{
setTextOfLayer('error','','');showHideLayers('error','','hide');showHideLayers('16check','','hide')

return true;}

}

function showHideLayers() { //v9.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

function setTextOfLayer(objId,x,newText) { //v9.0
  with (document) if (getElementById && ((obj=getElementById(objId))!=null))
    with (obj) innerHTML = unescape(newText);
}



function setTextOfTextfield(objId,x,newText) { //v9.0

  with (document){ if (getElementById){

    var obj = getElementById(objId);} if (obj) obj.value = newText;

  }

}


function getUrlVars()
{
    var vars = [], hash;
var hashes = window.location.href.split('/');
//alert(hashes.length);
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i];
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

if (hashes[5]=="SavePersonalInfo")
{
checkAgeCheckBox(this)
document.getElementById('agree').checked = true
}
    return vars;

}


var currentItem = "link_1";
 function Navigation(Id) {
	
	var CssClassActive = "faq-subnav-aktiv";
	var CssCLassInactive = "faq-subnav";
	
	// Altem Item inaktive Klasse zuweisen
	if(currentItem != "") {
	   document.getElementById(currentItem).className = CssCLassInactive;
	}
	
	// Neuem Item aktive Klasse zuweisen
	document.getElementById(Id).className = CssClassActive;
	
	// Neues Item merken
	currentItem = Id;
	
 }
 
 function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}


function limitTextp(limitFieldp, limitCountp, limitNump) {
	if (limitFieldp.value.length >= limitNump) {
		//limitField.value = limitField.value.substring(0, limitNum);
		mySwf.Play(); 
		limitFieldp.style.borderColor = '#cc0000';
		
		setTextOfLayer('textf','','Ihr Passwort hat die maximale Länge von 10 Zeichen erreicht!<br/><br/>');
		
	} else {
		limitCountp.value = limitNump - limitFieldp.value.length;
		setTextOfLayer('textf','','');
		limitFieldp.style.borderColor = '#999999';
		
	}
}

/*
	Header Information------------------------------------[Do Not Remove This Header]--
	Title: OO Dom Image Rollover
	Description: This script makes it easy to add rollover/ mousedown 
  	effects to any image on the page, including image submit buttons. Automatically 
  	preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+, 
  	Opera7+.
	
	Legal: Copyright 2005 Adam Smith
	Author Email Address: ibulwark@hotmail.com
	Date Created: June 6, 2005
	Website: Codevendor.com | eBadgeman.com
	Script featured on Dynamic Drive: http://www.dynamicdrive.com
	-----------------------------------------------------------------------------------
*/

function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;
	
	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){
			
			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';
			
			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;			
			}
			
			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener){window.addEventListener("load", preloadimgsrc, false);} 
else{
	if(window.attachEvent){window.attachEvent("onload", preloadimgsrc);}
	else{if(document.getElementById){window.onload=preloadimgsrc;}}
}

////
// settings
var wing_cookiename='fonic_customer';
var wing_removeCookie =365;
var wing_default_customer=false;
var wing_customer=false;
//settings

var wing_ablauf = new Date();
var wing_deletecookiein= wing_ablauf.getTime() + (wing_removeCookie * 24 * 60 * 60 * 1000);
wing_ablauf.setTime(wing_deletecookiein);


function wing_readcookie2(read_cookie) {
	if (document.cookie) {
		var wing_cookie = document.cookie;
		var wing_ac=wing_cookie.split("; ");
		for (var i=0;i<wing_ac.length;i++) {
			var wing_tmp=wing_ac[i].split("=");
			var wing_wert=wing_tmp[0];
			var wing_val=wing_tmp[1];
			if (wing_wert==read_cookie) {
				return wing_val;
			}
		}
		return "NULL";
	} else {
		return "NULL";
	}
}

function wing_costumer_write_cookie() {
	if (wing_readcookie2(wing_cookiename)=="true") {
		document.cookie = wing_cookiename+"=true; expires=" + wing_ablauf.toGMTString()+"; path=/";
	} else {
		document.cookie = wing_cookiename+"="+wing_customer+"; expires=" + wing_ablauf.toGMTString()+"; path=/";
	}
}


function wing_write_iframe() {
	if (wing_readcookie2(wing_cookiename)=="NULL" || wing_readcookie2(wing_cookiename)=="false") {
		//kein kunde
		//iframe
		document.write('<ifr'+'ame width="1" height="1" scrolling="no" frameborder="0" src="/html/dat/nocustomer.htm"></ifr'+'ame>');
	} else {
		//ein kunde
		//iframe
		document.write('<ifr'+'ame width="1" height="1" scrolling="no" frameborder="0" src="/html/dat/customer.htm"></ifr'+'ame>');
	}
}
