// global var die het einde aangeeft van de te zoeken periodes
// -- deze datum staat ook HuBO en zou gelijk moeten zijn 
// overige globals i.v.m. taalkeuze
var endDate = "20101231";
var t_meerinfo = "meer informatie";
var v_meerinfo = "meer info";
var t_infoprijs = "meer informatie en prijzen";


// functie om een nieuw window te openen
function loadwindow(url,w,h) {
   window.open(url,"","width="+w+", height="+h+", scrollbars=1, resizable=1");
}

// functie om de print-versie van een pagina aan te roepen
function printdit() {
   destination = document.location.href;
   destination = destination.replace(".html","-print.html");
   if (destination) newwindow=window.open(destination,'printversie','height=400,width=650');
}

// functie om de huidige dag te bepalen
function currentDate() {
   var currentTime = new Date()
   var month = currentTime.getMonth() + 1;
   if (month<10) month="0"+month;
   var day = currentTime.getDate(); 
   if (day < 10) day="0"+day;
   var year = currentTime.getFullYear();
   var today =(year +""+ month +""+ day);
   return today;
}

// helper functie om een form te creeren
function getNewSubmitForm(){
   var submitForm = document.createElement("FORM");
   document.body.appendChild(submitForm);
   submitForm.method = "POST";
   return submitForm;
}

// helper functie om elementen aan de form toe te voegen
function createNewFormElement(inputForm, elementName, elementValue){
   var newElement = document.createElement("INPUT");
   newElement.setAttribute('name',elementName);
   newElement.setAttribute('value',elementValue);
   newElement.setAttribute('type','hidden');
   inputForm.appendChild(newElement);
   return newElement;
}

// functie creert de form vanaf home naar meer info, voegt elementen toe en verstuurd het
function submitForm(id){
   var submitForm = getNewSubmitForm();
   createNewFormElement(submitForm, "DEOBTID", "1");
   createNewFormElement(submitForm, "DETAAL", "N");
   createNewFormElement(submitForm, "DEZOPER", "N");
   createNewFormElement(submitForm, "DEAANTA", "1");
   createNewFormElement(submitForm, "DEOBJID", id);
   createNewFormElement(submitForm, "DESTART", currentDate());
   createNewFormElement(submitForm, "DEEINDE", endDate);
   submitForm.action= "/huisjes/details.php";
   submitForm.submit();
}

// functie om huisjes op homepage te tonen
function toonhuis(p1,id1,l1,p2,id2,l2,p3,id3,l3) {
    document.write(
         "<tr>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p1+"</big></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p2+"</big></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p3+"</big></td><td class=\"round4\"></td>"
        +"</tr>"
        +"<tr>"
        +"   <td class=\"round8\"></td><td class=\"body2\"><center><img src=\"/huisjes/pics/"+id1+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body2\"><center><img src=\"/huisjes/pics/"+id2+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body2\"><center><img src=\"/huisjes/pics/"+id3+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"</tr>"
        +"<tr>"
        +"   <td class=\"round8\"></td><td class=\"body2\">"+l1+"</td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body2\">"+l2+"</td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body2\">"+l3+"</td><td class=\"round4\"></td>"
        +"</tr>"
        +" <tr>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"javascript:submitForm("+id1+")\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"javascript:submitForm("+id2+")\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"javascript:submitForm("+id3+")\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"</tr>");
}

// functie om de arrangementen te tonen
function toonarrang (kop,tekst,img,w,h,link) {
   document.write (
         "<center>"
        +"  <table class=\"arrang1\" cellspacing=\"0\" cellpadding=\"0\">"
        +"     <tr>"
        +"        <td class=\"round1\"></td><td class=\"round2\"></td><td class=\"round3\"></td>"
        +"     </tr>"
        +"     <tr>"
        +"        <td class=\"round8\"></td>"
        +"        <td>"
        +"           <table class=\"arrang2\" cellspacing=\"0\"; cellpadding=\"0\">" 
        +"              <tr>"
        +"                 <td rowspan=\"2\" class=\"arrangtext\">"
        +"                    <p><b>"+kop+"</b></p>"
        +"                    <p>"+tekst+"</p>"
        +"                 </td>"
        +"                 <td class=\"arrangpic\">"
        +"                    <img src=\""+img+"\" width=\""+w+"\" height=\""+h+"\" style=\"padding:2px; margin-bottom:4px;\";><br>"
        +"                 <td>"
        +"              </tr>"
        +"              <tr>"
        +"                 <td class=\"arrangknop\">"
        +"                    <a href=\""+link+"\" class=\"button\" title=\""+t_meerinfo+"\">"+v_meerinfo+"</a>"
        +"                 </td>"
        +"              </tr>"
        +"           </table>"
        +"        </td>"
        +"        <td class=\"round4\"></td>"
        +"     </tr>"
        +"     <tr>"
        +"        <td class=\"round7\"></td><td class=\"round6\"></td><td class=\"round5\"></td>"
        +"     </tr>"
        +"  </table>"
        +"</center>");
}

// functie om boten op homepage te tonen
function toonboot(p1,id1,l1,p2,id2,l2,p3,id3,l3) {
    document.write(
         "<tr>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p1+"</big></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p2+"</big></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td width=\"170\"><big>"+p3+"</big></td><td class=\"round4\"></td>"
        +"</tr>"
        +"<tr>"
        +"   <td class=\"round8\"></td><td class=\"body\"><center><img src=\"/boten/pics/"+id1+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body\"><center><img src=\"/boten/pics/"+id2+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body\"><center><img src=\"/boten/pics/"+id3+"/THUMB.jpg\"></center></td><td class=\"round4\"></td>"
        +"</tr>"
        +"<tr>"
        +"   <td class=\"round8\"></td><td class=\"body\">"+l1+"</td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body\">"+l2+"</td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td class=\"body\">"+l3+"</td><td class=\"round4\"></td>"
        +"</tr>"
        +" <tr>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"/boten/lijst2.php?id=3\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"/boten/lijst2.php?id=1\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"   <td class=\"round8\"></td><td height=\"28\"><center><a href=\"/boten/lijst2.php?id=2\" class=\"button\" title=\""+t_infoprijs+"\">"+v_meerinfo+"</a></center></td><td class=\"round4\"></td>"
        +"</tr>");
}
