function hideDiv(id) {
   wmt = document.getElementById(id);
   wmt.style.display = 'none';
   wmt.visibility = 'hidden';
}

function showDiv(id) {
   wmt = document.getElementById(id);
   wmt.style.display = '';
   wmt.visibility = 'visible';
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function checkDomain(did, eingabe, divID) {
      try {
         if(window.XMLHttpRequest) {
            req = new XMLHttpRequest();
         } 
         else if(window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
         } 
         else {
            alert("Ihr Webbrowser unterstuetzt leider kein Ajax!");
         }
         req.open("GET", '/addons/2009_108.php?dom='+did, true);
         req.onreadystatechange = new Function('fx', 'callAjaxFunction("'+did+'", "'+eingabe+'", "'+divID+'")');
         req.send(null);
      } catch(e) {
         alert("Fehler: " + e);
      }
}

function checkVorwahl(){
   if(document.forms[0].land.selectedIndex==0){
      document.forms[0].telland.value='+49';
      document.forms[0].faxland.value='+49';
   }
   else if(document.forms[0].land.selectedIndex==1){
      document.forms[0].telland.value='+43';
      document.forms[0].faxland.value='+43';
   }
   else if(document.forms[0].land.selectedIndex==2){
      document.forms[0].telland.value='+41';
      document.forms[0].faxland.value='+41';
   }
}

function checkKunde(){
   if(document.forms[0].perso[0].checked==1){
      for(i=0; i<=10; i++){
	 aktuell = 'personeu'+i;
         showDiv(aktuell);
      }
      hideDiv('persoalt0');
      hideDiv('persoalt1');
   }
   else{
      showDiv('persoalt0');
      showDiv('persoalt1');
      for(i=0; i<=10; i++){
	 aktuell = 'personeu'+i;
         hideDiv(aktuell);
      }
   }
}

function checkCity() {
   if(document.forms[0].plz.value.length>3){
      try {
         if(window.XMLHttpRequest) {
            req1 = new XMLHttpRequest();
         } 
         else if(window.ActiveXObject) {
            req1 = new ActiveXObject("Microsoft.XMLHTTP");
         } 
         else {
            alert("Ihr Webbrowser unterstuetzt leider kein Ajax!");
         }
		 document.forms[0].ort.readOnly = true;
         req1.open("GET", '/addons/2009_102.php?cid=<?=$cid?>&c='+document.forms[0].land.selectedIndex+'&zip='+document.forms[0].plz.value, true);
         req1.onreadystatechange = callbackFkt1;
         req1.send(null);
      } catch(e) {
        alert("Fehler: " + e);
      }
   }
}

function checkBank() {
   if(document.forms[0].kto.value.length>2 && document.forms[0].blz.value.length>6){
      try {
         if(window.XMLHttpRequest) {
            req2 = new XMLHttpRequest();
         } 
         else if(window.ActiveXObject) {
            req2 = new ActiveXObject("Microsoft.XMLHTTP");
         } 
         else {
            alert("Ihr Webbrowser unterstuetzt leider kein Ajax!");
         }
         req2.open("GET", '/addons/2009_109.php?blz='+document.forms[0].blz.value+'&kto='+document.forms[0].kto.value, true);
         req2.onreadystatechange = callbackFkt2;
         req2.send(null);
      } catch(e) {
        alert("Fehler: " + e);
      }
   }
}

function checkLastschrift(){
   if(document.forms[0].zahlstatus.value!='einzug'){
      showDiv('ezdata');
      document.forms[0].zahlstatus.value='einzug';
   }
}

function checkZahlung(){
   if(!document.forms[0].zahlungsart[0].checked && (document.forms[0].zahlungsart[1].checked || document.forms[0].zahlungsart[2].checked)){
      hideDiv('ezdata');
      document.forms[0].zahlstatus.value='other';
   }
}

function checkIntervall(){
   if(document.forms[0].intervall.selectedIndex==1){
      document.forms[0].zahlungsart[0].checked = 1;
      showDiv('ezdata');
   }
}

function checkIntervall2(){
   if(document.forms[0].intervall.selectedIndex==1){
      document.forms[0].intervall.selectedIndex = 0;
   }
   hideDiv('ezdata');
}

function callbackFkt1() {
	if(req1.readyState==4) {
		if(req1.status!=200) {
			alert("Fehler "+req1.status+": "+req1.statusText);
		} else {
			document.forms[0].ort.value = req1.responseText;
			if(req1.responseText==''){
				document.forms[0].ort.readOnly = false;
			}
		}
	}
}

function callbackFkt2() {
   if(req2.readyState==4) {
       if(req2.status!=200) {
          alert("Fehler "+req2.status+": "+req2.statusText);
       } else {
	  document.forms[0].bnk.value = req2.responseText;
       }
   }
}

function passwordStrength(password)
{
	var desc = new Array();
	desc[0] = "sehr unsicher";
	desc[1] = "unsicher";
	desc[2] = "mittel";
	desc[3] = "sicher";
	desc[4] = "sehr sicher";
	desc[5] = "sehr sicher";

	var score = 0;

	if ( password.length > 5 ) score++;
	if ( password.match(/[a-z]/) && password.match(/[A-Z]/) ) score++;
	if ( password.match(/\d+/) ) score++;
	if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) )	score++;
	if ( password.length > 9 ) score++;

	 document.getElementById("pwDesc").innerHTML = desc[score];
	 document.getElementById("pwStrength").className = "strength" + score;
}

function openagb(){
	window.open("","agbc",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=550,height=450,resizable=0');
}

function openwiderruf(){
	window.open("","agbc",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=550,height=450,resizable=0');
}

function opensupport(){
	window.open("","supportc",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=750,height=400,resizable=1');
}
