function checkRadio (frmName, rbGroupName) { 
 var radios = document[frmName].elements[rbGroupName]; 
 for (var i=0; i <radios.length; i++) { 
  if (radios[i].checked) { 
   return true; 
  } 
 } 
 return false; 
} 

function checkInlog(){ 
    if(!document.inlogForm.debnr.value){
        alert("Klantnummer is verplicht...");
        document.inlogForm.debnr.focus();
    }else if(!document.inlogForm.pwd.value){
        alert("Wachtwoord is verplicht...");
        document.inlogForm.pwd.focus();	
	}else if(!checkRadio("inlogForm","vestiging")){
		alert("U dient een vestiging aan te geven....");
		document.inlogForm.vestiging.focus();
    }else{
        if(document.getElementById("onthouden").checked==true){
            createCookie("bakeplus","1",365);
            createCookie("bakeplus1",document.inlogForm.debnr.value,365);
            createCookie("bakeplus2",document.inlogForm.pwd.value,365);
        }else{
            eraseCookie("bakeplus");
            eraseCookie("bakeplus1");
            eraseCookie("bakeplus2");
        }		
        document.inlogForm.submit();
    }
}

function logOut(){
    if(confirm('U wordt nu uitgelogd.')){
        location.href="/check.asp?act=logout";
    }
}

function prijsStr(var1,digits){
    var prijs;
    prijs=Math.floor(Math.round(var1*Math.pow(10,digits))/Math.pow(10,digits));
    var var2,var3,first=1;
    var2=prijs;
    while(prijs > 0) {
        if (prijs > 999)
            var3=String( (prijs % 1000) + 1000 ).substr(1,3);
        else
            var3=prijs;
        if (first) {
            var2=var3;
            first=0;
        } else var2=var3 + "." + var2;
        prijs=parseInt(prijs/1000);
    }
	
    if (digits>0){
        var2=var2+",";
        prijs=var1 % 1;

        prijs=(prijs+1)*Math.pow(10,digits)
        prijs=Math.round(prijs)
        prijs=(prijs+"").substr(1,2)
        var2+=prijs
    }
    return var2;
}

function flyButton(){
    var h = document.body.scrollTop;
    if(h==0){
        h=250;
    }else{
        h=h+250;
    }
    document.getElementById('flyButton').style.top = h;
}

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 eraseCookie(name) {
    createCookie(name,"",-1);
}

function getGegevens(){
    var onth = ""+readCookie("bakeplus");
    var un = ""+readCookie("bakeplus1");
    var uw = ""+readCookie("bakeplus2");
    if(onth=='1'){
        document.getElementById("onthouden").checked = "true";
    }
    if(un!='null'){
        document.getElementById("debnr").value = un;
    }
    if(uw!='null'){
        document.getElementById("pwd").value = uw;
    }
}

        
