var map = null;
var geocoder = null;
var aantal_ma=1;
var aantal_di=1;
var aantal_wo=1;
var aantal_do=1;
var aantal_vr=1;
var aantal_za=1;
var aantal_zo=1;
var aantal=0;
var foutmelding = new Array("Gelieve de bedrijfsnaam in te vullen",
                            "Gelieve de straat in te vullen",
                            "Gelieve de postcode in te vullen",
                            "Gelieve de stad in te vullen",
                            "Er zit een fout in de openingsuren");
var dagen = new Array("ma","di","wo","do","vr","za","zo");                          
var address;                            
                                

bAllow = true;

function showCommentaar(){
    if(document.getElementById('Reageer').style.display == "none"){
        document.getElementById('Reageer').style.display = "";
    }else{
        document.getElementById('Reageer').style.display = "none";
    
    }
} 
function zendMail(stad , bedrijfsnaam , us,what){
    createXMLHttpRequest();
    if(typeof(us)=="undefined"){
        emailvriend = document.getElementById('toAddress').value;
        mijnemailadres = document.getElementById('fromAddress').value
        mijnnaam = document.getElementById('fromName').value
        boodschap = document.getElementById('message').value;
        naamvriend = document.getElementById('toName').value ;
    }else{
        emailvriend = "ralph@openingsuren.info";
        mijnemailadres="ralph@openingsuren.info";
        mijnnaam = "Boodschap van de website";
        naamvriend= "Ralph";
        boodschap=what;


    }
     url = document.getElementById('url').value;
     var queryString =  "/zendvriend.php?emailvriend="+emailvriend;
     queryString += "&naamvriend="+naamvriend;
     queryString += "&boodschap="+boodschap;
     queryString += "&mijnemailadres="+mijnemailadres;
     queryString += "&mijnnaam="+mijnnaam;
     queryString += "&bedrijfsnaam="+bedrijfsnaam;
     queryString += "&stad="+stad;
     queryString += "&url="+url;
    


    
    xmlHttp.onreadystatechange = handleStateEmail;
    xmlHttp.open("GET", queryString, true);
    xmlHttp.send(null);
         
}
function handleStateEmail() {
    if(xmlHttp.readyState == 4 && xmlHttp.status == 200 ){
       ajaxWaarden = xmlHttp.responseText.split(" ");
       alert(xmlHttp.responseText);
       showDiv('divMail');
    }
}




function showDiv(div){
    if(document.getElementById(div).style.display == "none"){
        document.getElementById(div).style.display = "";
    }else{
        document.getElementById(div).style.display = "none";
    
    }
}


/*ajax*/
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
 
function GETRequest(id,punten) {
    createXMLHttpRequest();
          
    var queryString =  "http://www.openingsuren.info/ajax.php?id="+id+"&punten="+punten;
    
    
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", queryString, true);
    xmlHttp.send(null);
}

function GETRequestVerwijder(id) {
    createXMLHttpRequest();
          
    var queryString =  "http://www.openingsuren.info/verwijderstem.php?id="+id;
    
    
    xmlHttp.onreadystatechange = handleStateChangeVerwijder;
    xmlHttp.open("GET", queryString, true);
    xmlHttp.send(null);

}

function POSTRequest(query) {
    createXMLHttpRequest();
    
    var url = "http://www.openingsuren.info/ajax.php";
   
    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
    xmlHttp.send(query);
}
function handleStateChangeVerwijder() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            document.getElementById('tdEigenRating').innerHTML ="";
         ajaxWaarden = xmlHttp.responseText.split(" ");
         avgPunten=parseInt(ajaxWaarden[0]);
         aantalStem=parseInt(ajaxWaarden[1]);
          eigenRating=document.getElementById('tdEigenRating');
            eigenRating.innerHTML="";
         avgRating = document.getElementById('tdAvgRating');
         //txtAvgRating=avgRating.getElementsByTagName('br')[0].nextSibling;
         avgRating.innerHTML="";
         for(i=0;i<5;i++){
            image=document.createElement('img');
        
         if(i<avgPunten){
            image.src="/images/ster1.gif";
            
            
            
            //<img id = 'ster".$i."' src='/images/ster1.gif' onmouseout='hideSter(\"ster".$i."\");' alt='volSter'  title='volSter' onmouseover='(\"ster".$i."\");' />"
            
            
            
            
            
         }else{
            image.src="/images/ster0.gif";
        
         }
         j=i+1;
         ster= "ster"+j;
         
         image.setAttribute("id",ster);
         
         image.setAttribute('onmouseover','showSter("ster'+j+'");');
         image.setAttribute('onmouseout','hideSter("ster'+j+'");');
         avgRating.appendChild(image);
         }
         avgRating.appendChild(document.createElement('br')); 
     
         avgRating.appendChild(document.createTextNode(aantalStem+" stemmen"));
         
     
        }
    }

}

function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            parseResults();
        }
    }
}

function parseResults() {
     //xmlHttp.responseText.replace(" ","");
     ajaxWaarden = xmlHttp.responseText.split(" ");
     punten=parseInt(ajaxWaarden[2]);
     avgPunten=parseInt(ajaxWaarden[0]);
     aantalStem=parseInt(ajaxWaarden[1]);
    id=parseInt(ajaxWaarden[3]);
     //eigenRating=document.getElementById('div_eigenrating');
     eigenRating=document.getElementById('tdEigenRating');
     
     eigenRating.innerHTML="";
     for(i=0;i<5;i++){
        image=document.createElement('img');
        if(i<punten){
            image.src="/images/ster1.gif";
        }else{
            image.src="/images/ster0.gif";
        }
        eigenRating.appendChild(image);
     }
     eigenRating.appendChild(document.createElement('br')); 
     atag = document.createElement("a");
    
    //<a href="javascript:verwijderStem('9973');">Verwijder stem</a>
    atag.setAttribute("href","javascript:verwijderStem("+id+")");
    //eigenRating.appendChild(document.createTextNode('Verwijder stem'));
     atag.appendChild(document.createTextNode('Verwijder stem'));
     eigenRating.appendChild(atag);
     avgRating = document.getElementById('tdAvgRating');
     //txtAvgRating=avgRating.getElementsByTagName('br')[0].nextSibling;
     avgRating.innerHTML="";
    for(i=0;i<5;i++){
        image=document.createElement('img');
        
        if(i<avgPunten){
        image.src="/images/ster1.gif";
        }else{
        image.src="/images/ster0.gif";
        
        }
        avgRating.appendChild(image);
     }
     avgRating.appendChild(document.createElement('br')); 
     
     avgRating.appendChild(document.createTextNode(aantalStem+" stemmen"));
    
    // document.getElementbyId('whatever').innerHTML = xmlHttp.responseText;
}
function voegRatingToe(id){
volSter=0;
for(i=1;i<6;i++){
    if(parseInt(document.getElementById('ster'+i).src.substring(40,41))==1)
    {
     volSter++;
    }

}

GETRequest(id,volSter);
}

function verwijderStem(id){
   GETRequestVerwijder(id);
}
/*ajax*/


function showSter(id){
    //document.getElementById(id).src='/images/ster1.gif';

    nummer = parseInt(id.substring(4));
    //if(nummer>1){
        for(i=1;i<nummer+1;i++){
            document.getElementById("ster"+i).src='/images/ster1.gif';
        }
    //}
}
function hideSter(id){
//document.getElementById(id).src='/images/ster0.gif';
    nummer = parseInt(id.substring(4));
    
        for(i=1;i<nummer+1;i++){
            document.getElementById("ster"+i).src='/images/ster0.gif';
        }
    
}

function checkContact(){
   error ="";
   for(i=3;i<6;i++){
      if(document.getElementsByTagName('input')[i].value==""){
         error = "<ul><li>Niet alle velden zijn ingevuld</li></ul>";
         break;
      }
   }
   if(document.getElementById('txt_bericht').value == ""){
      error = "<ul><li>Niet alle velden zijn ingevuld</li></ul>";
   }
   if(error == ""){
      document.getElementById('frm_contact').submit();

   }else{
      document.getElementById('divError').innerHTML = error;
      document.getElementById('divError').style.display="";
   }
}
function checkEigenaar(){
   error ="";
   if(document.getElementById('txtRelatie').value != "")
   {  document.frmEigenaar.submit();
   
   }else{
      error = "<ul><li>Gelieve de relatie t.o.v. het bedrijf in te vullen </li></ul>";
      document.getElementById('divError').innerHTML=error;
      document.getElementById('divError').style.display="";
   
   
   }
}
function check(div){
    var error="";
    var error_tijden="N";
    var exist_error = "N";//bestaat de error al
    inputs = document.getElementById(div).getElementsByTagName('input');
    for(i=0;i<inputs.length;i++){
        if(inputs[i].type == 'text'){
            if(i<4){
                if(inputs[i].value.length == 0){
                    if(exist_error != "N"){
                        var error = error+"<li>"+foutmelding[i]+"</li>";
                
                    }else{
                        var error = "<ul><li>"+foutmelding[i]+"</li>";
                        exist_error = "Y";
                    }
                    
                }
            }else{
                if(inputs[i].name.substring(10,13)=="uur" ){
                    if(inputs[i].value > 23){
                        error_tijden = "Y";
                  break;
                    }
                }
                
                if(inputs[i].name.substring(10,13)=="min" ){
                
                    if(inputs[i].value > 59){
                        error_tijden = "Y";
                  break;
                    }
                }
            }
        }   
    }
    var lege_velden = 0;
    var volle_velden = 0;
    for(j=0;j<dagen.length;j++){
        if(error_tijden == "N"){
            for(i=0;i<document.getElementById('tbl_'+dagen[j]).getElementsByTagName('input').length;i++){
                if(document.getElementById('tbl_'+dagen[j]).getElementsByTagName('input')[i].value != ""){
                    volle_velden = volle_velden + 1;
                    
                }else{
                    lege_velden = lege_velden + 1;
                }
                if(volle_velden+lege_velden == 4){
                    if((lege_velden == 0 && volle_velden == 4 )|| (volle_velden == 0 && lege_velden == 4)){
                        lege_velden = 0;
                        volle_velden = 0;
                        continue;
                    }else{
                        lege_velden = 0;
                        volle_velden = 0;
                        error_tijden = "Y";
                        
        
                    }
                    
                    
                }
        
            }
        }else{
         break;
      }
    }
    if (error_tijden =="Y"){
        if(exist_error =="Y"){
            var error = error +"<li>"+foutmelding[4]+"</li>";
        }else{
            var error = "<ul><li>"+foutmelding[4]+"</li>";
        }
    }
   if(error!=""){
        
        error = error + "</ul>";
        document.getElementById('divError').innerHTML=error;
        document.getElementById('divError').style.display="";
        scroll(0,0);
        //document.location='top';
    }else{
        document.getElementById('divError').style.display="none";
        document.frm_bedrijf.submit();
    
    }

}
    
function limitinput(evt, strList, bAllow)
/*Limits the input to strList. If bAllow is true, then
only allow what is in strList. If bAllow is false,
then do not allow what is in strList.*/
{
var charCode = evt.keyCode;
if (charCode==0)
{
charCode = evt.which;
}
var strChar = String.fromCharCode(charCode);
/*controlArray holds the ASCII codes for valid
control commands (BS, CR, LF, etc)*/
var intOut = 0;

if (bAllow==true)
{
if (charCode==8 || charCode==9 || charCode==37 || charCode==39 || charCode==46 | charCode==116 || (strList.indexOf(strChar)!=-1))
/*Valid*/
{
return true;
}
else
{
return false;
}
}
else
{
if (charCode==8 || charCode==9 || charCode==37 || charCode==39 || charCode==46 || charCode==116 || (strList.indexOf(strChar)==-1))
{
return true;
}
else
{
return false;
}
}

}
function ShowLoginBox() {
document.getElementById('divLoginDialogFade').style.display='block';
if(document.getElementById('divLoginDialog')){
    document.getElementById('divLoginDialog').style.display='block';
}
document.getElementById('divLoginDialogForm').style.display='block';
if(document.getElementById('divLoginDialogFB')){
    document.getElementById('divLoginDialogFB').style.display='block';
    document.getElementById('divLoginDialogFormFB').style.display='block';
}

}
function HideLoginBox() {
document.getElementById('divLoginDialogFade').style.display='none';
if(document.getElementById('divLoginDialog')){
    document.getElementById('divLoginDialog').style.display='none';
}
document.getElementById('divLoginDialogForm').style.display='none';
if(document.getElementById('divLoginDialogFB')){
    document.getElementById('divLoginDialogFB').style.display='none';
    document.getElementById('divLoginDialogFormFB').style.display='none';
}
if (document.getElementById('divLoginDialogForm').getElementsByTagName('td')[0].innerHTML != "Emailadres:"){
       document.getElementById('divLoginDialogForm').getElementsByTagName('td')[0].innerHTML = "";
     }
}



function ShowLogin() {
document.getElementById('divLoginDialogFade').style.display='block';
document.getElementById('divLoginDialogFB').style.display='block';
document.getElementById('divLoginDialogForm').style.display='block';
document.getElementById('divLoginDialogFormFB').style.display='block';
}
function HideLogin() {
document.getElementById('divLoginDialogFade').style.display='none';
document.getElementById('divLoginDialogFB').style.display='none';
document.getElementById('divLoginDialogForm').style.display='none';
document.getElementById('divLoginDialogFormFB').style.display='none';
if (document.getElementById('divLoginDialogForm').getElementsByTagName('td')[0].innerHTML != "Emailadres:"){
       document.getElementById('divLoginDialogForm').getElementsByTagName('td')[0].innerHTML = "";
     }
}



















function checkRegister(){
   
   
   
   var error = "";
   var existError = "N";
   inputs = document.getElementById("registreerFunction").getElementsByTagName('input');
   for(i=0;i<10;i++){
      if(inputs[i].type=="text" && inputs[i].value==""){
         if (error!= ""){
            error = error +  inputs[i].name.substring(4) + ", ";
         }else{
            error = "<ul><li>"+  inputs[i].name.substring(4,5).toUpperCase() + inputs[i].name.substring(5) + ", ";
         
         }
      }
   }
   if(error != ""){
      error += "zijn nog niet ingevuld.";
      error += "</li>";
   }
   if(inputs[2].checked == 0 && inputs[3].checked == 0){
      if(error != ""){
         error += "<li>Het geslacht is niet ingevuld.</li>";
      }else{
         error += "<ul><li>Het geslacht is niet ingevuld.</li>";
      
      }
   }
  //if(div == "divRegistreer"){
      if(inputs[8].value!=inputs[9].value){
      if(error !=""){
         error += "<li>De ingegeven wachtwoorden komen niet overeen.</li>";
      }else{
         error += "<ul><li>De ingegeven wachtwoorden komen niet overeen.</li>";
      }
      }else{
      if(inputs[8].value.length < 5){
         if(error !=""){
               error += "<li>Het wachtwoord moet minimum 5 karakters lang zijn.</li>";
            }else{
               error += "<ul><li>Het wachtwoord moet minimum 5 karakters lang zijn.</li>";
            }
      
      }
   }
   //}
   if(inputs[7].value.indexOf("@") == -1 || inputs[7].value.indexOf(".")== -1){
      if(error!=""){
         error += "<li>Het e-mail adres is niet ingevuld of niet geldig.</li>";
      }else{
         error += "<ul><li>Het e-mail adres is niet ingevuld of niet geldig.</li>";

      }
   }
   if(error!=""){
      error += "</ul>";
      document.getElementById('divError2').innerHTML=error;
        document.getElementById('divError2').style.display="";
    }else{
        document.getElementById('divError2').style.display="none";
        //if(div=="divRegisteer"){
         document.frmRegistreer.submit();
      //}else{
         //document.frmWijzigenAccount.submit();
      //}
    }
   

}

function submitBedrijf( stad , naam , categorie , id )
{
 document.frm_bedrijf.naam.value = naam;
 document.frm_bedrijf.stad.value = stad;
 document.frm_bedrijf.categorie.value = categorie;
 document.frm_bedrijf.bedrijfid.value = id;
 
 document.frm_bedrijf.submit();
 }



function handleErrors(){
 if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
 alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
 else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
 alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);

 else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

 // else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
 // alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);

 else if (gdir.getStatus().code == G_GEO_BAD_KEY)
 alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

 else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
 alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);

 else alert("An unknown error occurred.");

 }
function setDirections() {
  var map = new GMap2(document.getElementById("map"));
 var gdir = new GDirections(map, document.getElementById("div_directie"));
 GEvent.addListener(gdir, "error", handleErrors);

 fromAddress=van;
 toAddress= address;
 var locale = "nl_BE";
 gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
 }
function showAddress() {
      var map = new GMap2(document.getElementById("map"));
      var straat=document.getElementById('tdAdres').innerHTML;
      var stad= document.getElementById('tdStad').innerHTML;
      address = straat + "," + stad + ", BE";
        map.addControl(new GSmallMapControl()); 
        map.addControl(new GMapTypeControl()); 
        geocoder = new GClientGeocoder();
      
       //document.getElementById('map').getElementsByTagName('span')[0].innerHTML="";
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              document.getElementById('map').innerHTML = "<img src=/images/map_owner.jpg";
          } else {
              var icon = new GIcon();  
              icon.image = "http://www.openingsuren.info/images/maphome.png";  
              icon.size = new GSize(2,2);  
              icon.iconAnchor = new GPoint(8,9);  
              icon.infoWindowAnchor = new GPoint(7,7);  
              map.setCenter(point, 16,G_NORMAL_MAP);
              var marker = new GMarker(point,icon);
              map.addOverlay(marker);
              
              document.getElementById('txt_gps').value = point;
              var pos_komma = document.getElementById('txt_gps').value.substring(1).indexOf(",");
              var lg = document.getElementById('txt_gps').value.substring(1,pos_komma+1);            //cijfer voor de komma
              var str_lengte = document.getElementById('txt_gps').value.length;
              var bg = document.getElementById('txt_gps').value.substring(pos_komma+2,str_lengte-1);//cijfer na de komma
              
              var lg_graden = lg.substring(0,lg.indexOf("."));
              var lg_minuten = lg.substring(lg.indexOf(".")+1);
              //alert(lg);
              var lg_seconden = lg_minuten.substring(2,4);
              //alert(lg_seconden);
              var lg_minuten = lg_minuten.substring(0,2);
              
              
              var bg_graden = bg.substring(0,bg.indexOf("."));
              var bg_minuten = bg.substring(bg.indexOf(".")+1);
              //alert(lg);
              var bg_seconden = bg_minuten.substring(2,4);
              //alert(lg_seconden);
              var bg_minuten = bg_minuten.substring(0,2);
              document.getElementById('txt_lengtegraden').innerHTML = lg_graden + "\260" + lg_minuten + "'" + lg_seconden + '"';
              document.getElementById('txt_breedtegraden').innerHTML = bg_graden + "\260" + bg_minuten + "'" + bg_seconden + '"';
              
              
              //marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
//einde google maps 
function tijd(){
                  if (!document.layers&&!document.all&&!document.getElementById)
                  return
                   var Digital=new Date();
                   var hours=Digital.getHours();
                   var minutes=Digital.getMinutes();
                  

                   if (minutes<=9)
                   minutes="0"+minutes;
           

                   myclock=""+hours+":"+minutes+"";
                   
                   if (document.layers){
                   document.layers.liveclock.document.write(myclock);
                   document.layers.liveclock.document.close();
                   }
                   else if (document.all)
                   liveclock.innerHTML=myclock;
                   else if (document.getElementById)
                   document.getElementById("div_uur").innerHTML=myclock;
                   setTimeout("tijd()",60000);
                   }

function add(dag){
    tabel="tbl_"+dag;
    table=document.getElementById(tabel);
    
    tr=document.createElement("tr");
    td=document.createElement("td");
    amuur=document.createElement("input");
    van=document.createTextNode("van:");
    tot=document.createTextNode(" tot ");
    u1=document.createTextNode(" u ");
    u2=document.createTextNode(" u ");
    ammin=document.createElement("input");
    pmuur=document.createElement("input");
    pmmin=document.createElement("input");
    amuur.className="t_veldblauw";
    pmuur.className="t_veldblauw";
    ammin.className="t_veldblauw";
    pmmin.className="t_veldblauw";
    amuur.size="2";
    pmuur.size="2";
    ammin.size="2";
    pmmin.size="2";
    switch(dag){
    case "ma":
    aantal_ma=aantal_ma+1
    aantal=aantal_ma
    break;
    case "di":
    aantal_di=aantal_di+1
    aantal=aantal_di
        break;
    case "wo":
    aantal_wo=aantal_wo+1;
    aantal=aantal_wo;
        break;
    case "do":
    aantal_do=aantal_do+1;
    aantal=aantal_do;
        break;
    case "vr":
    aantal_vr=aantal_vr+1;
    aantal=aantal_vr;
        break;
    case "za":
    aantal_za=aantal_za+1;
    aantal=aantal_za;
        break;
    case "zo":
    aantal_zo=aantal_zo+1;
    aantal=aantal_zo;
    
    break;
    
    }
    amuur.name="txt_"+ dag + "_am_uur"+aantal;
    pmuur.name="txt_"+ dag + "_pm_uur"+aantal;
    ammin.name="txt_"+ dag + "_am_min"+aantal;
    pmmin.name="txt_"+ dag +  "_pm_min"+aantal;
    amuur.maxLength="2";
    amuur.size="1";
    pmuur.maxLength="2";
    pmuur.size="1";
    pmmin.maxLength="2";
    pmmin.size="1";
    ammin.maxLength="2";
    ammin.size="1";
    //amuur.setAttribute("onkeypress","return limitinput(event, '0123456789', true);");
    //pmuur.setAttribute("onkeypress","return limitinput(event, '0123456789', true);");
    //ammin.setAttribute("onkeypress","return limitinput(event, '0123456789', true);");
    //pmmin.setAttribute("onkeypress","return limitinput(event, '0123456789', true);");
    
    amuur.onkeypress = function (event)
    {
        if (!event)  event = window.event;
      return limitinput(event, '0123456789', true);

    }
    pmuur.onkeypress = function (event)
    {
        if (!event)  event = window.event;
      return limitinput(event, '0123456789', true);

    }
    ammin.onkeypress = function (event)
    {
        if (!event)  event = window.event;
      return limitinput(event, '0123456789', true);

    }
    pmmin.onkeypress = function (event)
    {
        if (!event)  event = window.event;
      return limitinput(event, '0123456789', true);

    }
    td.appendChild(amuur);
    td.appendChild(u1);
    td.appendChild(ammin);
    td.appendChild(tot);
    td.appendChild(pmuur);
    td.appendChild(u2);
    td.appendChild(pmmin);
    tr.appendChild(td);
    var bodyTabel = table.tBodies[0] || document.CreateElement("TBODY");
    bodyTabel.appendChild(tr);
    table.appendChild(bodyTabel);
    //table.appendChild(tr);
    
    
    
    }
function deleten(dag){
switch(dag){
    case "ma":
    if (aantal_ma>1){
    aantal_ma=aantal_ma-1;
    aantal=aantal_ma;
    }else{aantal=0;}
    break;
    case "di":
    if(aantal_di>1){
    aantal_di=aantal_di-1;
    aantal=aantal_di;
    }else{aantal=0;}
        break;
    case "wo":
    if(aantal_wo>1){
    aantal_wo=aantal_wo-1;
    aantal=aantal_wo;
    }else{aantal=0;}
        break;
    case "do":
    if(aantal_do>1){
    aantal_do=aantal_do-1;
    aantal=aantal_do;
    }else{aantal=0;}
        break;
    case "vr":
    if(aantal_vr>1){
    aantal_vr=aantal_vr-1;
    aantal=aantal_vr;
    }else{aantal=0;}
        break;
    case "za":
    if(aantal_za>1){
    aantal_za=aantal_za-1;
    aantal=aantal_za;
    }else{aantal=0;}
        break;
    case "zo":
    if(aantal_zo>1){
    aantal_zo=aantal_zo-1;
    aantal=aantal_zo;
    }else{aantal=0;}
    break;
    
    }

if (aantal>0){
tabel="tbl_"+dag;
table=document.getElementById(tabel);
table.tBodies[0].removeChild(table.getElementsByTagName('tr')[aantal]);
}
}
function copy(dag,gisteren){
tbl_dag="tbl_"+dag;
tbl_gisteren="tbl_"+gisteren;
aantalrij_gisteren = document.getElementById(tbl_gisteren).getElementsByTagName("tr").length;
aantalrij_dag      = document.getElementById(tbl_dag).getElementsByTagName("tr").length;

if(aantalrij_gisteren > aantalrij_dag){
    for(i=0;i<aantalrij_gisteren-aantalrij_dag;i++){
    add(dag);
    }

}

if(aantalrij_gisteren < aantalrij_dag){
    for(i=0;i<aantalrij_dag-aantalrij_gisteren;i++){
    deleten(dag);
    
    }

}
for(i=0;i<aantalrij_gisteren;i++){
    for(j=0;j<4;j++){
        document.getElementById(tbl_dag).getElementsByTagName("tr")[i].getElementsByTagName("input")[j].value=
        document.getElementById(tbl_gisteren).getElementsByTagName("tr")[i].getElementsByTagName("input")[j].value;
    }
}
    
}
function addClass( el , className )
{

 removeClass( el , className );
 var cn = el.className.split( /\W+/ );
 cn.push( className );
 el.className = cn.join(" ");
}

function removeClass( el , className )
{
 var cn = el.className.split( /\W+/ );
 for( var i = 0 ; i < (cn.length) ; i++ ) {
 if( cn[i] == className ) {
 cn[i] = null;
 }
 }
el.className = cn.join(" ");
}
//map op index.php
function showSteden(provincie){
   
GETRequestSteden(provincie);
}
function GETRequestSteden(provincie) {
    createXMLHttpRequest();
          
    var queryString =  "http://www.openingsuren.info/ajaxsteden.php?provincie="+provincie;
    
    
    xmlHttp.onreadystatechange = handleStateChangeSteden;
    xmlHttp.open("GET", queryString, true);
    xmlHttp.send(null);
}
function handleStateChangeSteden() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
         divStedens=document.getElementById('divSteden');
         divStedens.style.display = "block";
         //'175','75' wvl
         //'280','75' ovl
         //,'45','75'anbtwerpen vlaams brabant limburg
         provincie=parseInt(xmlHttp.responseText.substring(0,1));
         switch(provincie){
         case 8:
            divStedens.style.left= '175px';
             divStedens.style.top= '75px';
            break;
         case 9:
            divStedens.style.left= '280px';
             divStedens.style.top= '75px';
            break;
         case 3:
            divStedens.style.left= '160px';
             divStedens.style.top= '60px';
            break;
         case 1:
            divStedens.style.left= '45px';
             divStedens.style.top= '55px';
            break;
         case 2:
            divStedens.style.left= '70px';
             divStedens.style.top= '60px';
            break;
         
         default:
            divStedens.style.left= '45px';
             divStedens.style.top= '75px';
            break;
         }
         divStedens.style.position = 'absolute';
         //divSteden.style.left= posLeft+'px';
         //divSteden.style.top= posTop+'px';
         divStedens.innerHTML= xmlHttp.responseText.substring(1);
         
        }
    }
}
function hideSteden(){
document.getElementById('divSteden').style.display="none";
         
}

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  //var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  //currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  //currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes ;//+ currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("klok").innerHTML = currentTimeString;
}







