function onloadaction() {
  /*
  if (document.formulier_init.pr.value=="aanbieders") {
    menu(query);  
  }
  if (document.formulier_init.nr) {
    if (document.formulier_init.nr.value%10 > 2) {
      var nr=document.formulier_init.nr.value-1;
      var id="item_"+nr; 
      document.getElementById(id).scrollIntoView(true);
    }
  }
  */
  //if (document.formulier_init.naar) ablog(0,"pag");
  if (document.formulier_init.anker) {
    startboodschap(document.formulier_init.anker.value,document.formulier_init.aan.value,document.formulier_init.duur.value);
    //alert("boodschap:"+document.formulier_init.anker.value+";"+document.formulier_init.aan.value+";"+document.formulier_init.duur.value);
  }
}

function openmenu(veld) {
  var query=document.formulier_init.ajaxquery.value;
  if (query) {query+="&veld="+veld;} else {query="veld="+veld;}
  //if (document.formulier_init.pr.value) {query+="&pr="+document.formulier_init.pr.value;} else {query+="pr=aanbieders";}
  var xmlhttp = new XMLHttpRequest();
  //alert(query);
  var deurl="http://"+location.hostname+"/zoeken-menu-aj.php?"+query;
  if (xmlhttp) {
    xmlhttp.open("GET",deurl,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        var response=xmlhttp.responseText;
        //alert(response);
        if (response) {
          var id="meer_"+veld;
          document.getElementById(id).innerHTML="<a href=\"javascript:sluitmenu('"+veld+"')\" class='line'>minder</a>";
          document.getElementById(veld).innerHTML=response;
          document.getElementById(veld).style.marginTop="10px";
          document.getElementById(veld).style.width="200px";
          document.getElementById(veld).style.height="auto";
          document.getElementById(veld).style.maxHeight="400px";
          document.getElementById(veld).style.visibility="visible";
          document.getElementById(veld).style.overflow="auto";
        }
      }
    }
    xmlhttp.send(null);
  }
}

function sluitmenu(veld) {
  var id="meer_"+veld;
  document.getElementById(id).innerHTML="<a href=\"javascript:openmenu('"+veld+"')\"><u>meer</u> ></a>";
  document.getElementById(veld).innerHTML="";
  document.getElementById(veld).style.marginTop="0";
  document.getElementById(veld).style.width="0";
  document.getElementById(veld).style.height="0";
  document.getElementById(veld).style.visibility="hidden";
  
}

function zoeken(veld) {
  if (document.formulier.elements[veld].value) {
    var deurl="http://"+location.hostname+"/";
    if (document.formulier.elements["soort"]) deurl+=document.formulier.soort.value+"/";
    if (document.formulier.elements["land"]) deurl+=document.formulier.land.value+"/";
    if (document.formulier.elements["acc_soort"]) deurl+=document.formulier.acc_soort.value+"/";
    if (document.formulier.elements["vervoer"]) deurl+=document.formulier.vervoer.value+"/";
    location.href=deurl;
  }
}

function presentatie(veld) {
  if (veld=="pr") {
    var pr="pa";
    var radio=document.formulier_pr.elements["pr"];
    for(i=0; i<radio.length; i++) {if (radio[i].checked) pr=radio[i].value;}
    document.formulier_go.elements["pr"].value=pr;
    document.formulier_go.elements["ord"].value="";
  } else {
    document.formulier_go.elements["ord"].value=document.formulier_pr.elements["ord"].value;
  }
  go();
}

function openmeer(id) {
  document.getElementById(id).style.marginTop="10px";
  document.getElementById(id).style.width="200px";
  document.getElementById(id).style.height="auto";
  document.getElementById(id).style.maxHeight="400px";
  document.getElementById(id).style.visibility="visible";
  document.getElementById(id).style.overflow="auto";
  var idm="meer_"+id;
  document.getElementById(idm).innerHTML="<a href=\"javascript:sluitmeer('"+id+"')\" class='line'>minder</a>";
}

function sluitmeer(id) {
  document.getElementById(id).style.marginTop="0";
  document.getElementById(id).style.width="0";
  document.getElementById(id).style.height="0";
  document.getElementById(id).style.visibility="hidden";
  var idm="meer_"+id;
  document.getElementById(idm).innerHTML="<a href=\"javascript:openmeer('"+id+"')\"><u>meer</u> ></a>";
}

function opentabel(nr,aantal) {
  var id="tabel_"+nr;
  document.getElementById(id).style.height="auto";
  document.getElementById(id).style.visibility="visible";
  id="link_"+nr;
  document.getElementById(id).innerHTML="<a href='javascript:sluittabel("+nr+","+aantal+")' class='line'>Toon minder aanbieders</a>";
}

function sluittabel(nr,aantal) {
  var id="tabel_"+nr;
  document.getElementById(id).style.height="0";
  document.getElementById(id).style.visibility="hidden";
  id="link_"+nr;
  document.getElementById(id).innerHTML="<a href='javascript:opentabel("+nr+","+aantal+")'>Toon alle "+aantal+" aanbieders</a>";
}


function openatabel(aantal) {
  var id="atabel";
  document.getElementById(id).style.height="auto";
  document.getElementById(id).style.visibility="visible";
  id="alink";
  document.getElementById(id).innerHTML="<a href='javascript:sluitatabel("+aantal+")'>Toon minder aanbieders</a>";
}

function sluitatabel(aantal) {
  var id="atabel";
  document.getElementById(id).style.height="0";
  document.getElementById(id).style.visibility="hidden";
  id="alink";
  document.getElementById(id).innerHTML="<a href='javascript:openatabel("+aantal+")'>Toon alle "+aantal+" aanbieders</a>";
}

function itemaan(nr,i) {
  var id="itemregel_"+nr+"_"+i;
  document.getElementById(id).style.backgroundColor="#ffffff";
}

function itemuit(nr,i) {
  var id="itemregel_"+nr+"_"+i;
  document.getElementById(id).style.backgroundColor="#ecf7fc";
}

function beoordeling(nr,acco) {
  var id="cb_"+nr;
  var x=document.getElementById(id).offsetLeft;
  var y=document.getElementById(id).offsetTop;
  if (document.getElementById(id).offsetParent) {
    var parent=document.getElementById(id).offsetParent;
    x+=parent.offsetLeft;
    y+=parent.offsetTop;
    while (parent.offsetParent) {
      parent=parent.offsetParent;
      x+=parent.offsetLeft;
      y+=parent.offsetTop;
    }
  }
  var posx=x-250;
  var posy=y;

  var xmlhttp = new XMLHttpRequest();
  if (xmlhttp) {
    var deurl="http://"+location.hostname+"/zoeken-beoordeling-aj.php?nr="+nr+"&acco="+acco;
    xmlhttp.open("GET",deurl,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        var response=xmlhttp.responseText;
        if (response) {
          document.getElementById(id).innerHTML=response;
          document.getElementById(id).style.left=posx+"px";
          document.getElementById(id).style.top=posy+"px";
          document.getElementById(id).style.width="236px";
          document.getElementById(id).style.height="auto";
          document.getElementById(id).style.visibility="visible";
        }
      }
    }
    xmlhttp.send(null);
  }
 
}

function beoordeling_uit(nr) {
  var id="cb_"+nr;
  var x=document.getElementById(id).offsetLeft;
  var y=document.getElementById(id).offsetTop;
  if (document.getElementById(id).offsetParent) {
    var parent=document.getElementById(id).offsetParent;
    x+=parent.offsetLeft;
    y+=parent.offsetTop;
    while (parent.offsetParent) {
      parent=parent.offsetParent;
      x+=parent.offsetLeft;
      y+=parent.offsetTop;
    }
  }
  var posx=x+250;
  var posy=y;
  document.getElementById(id).innerHTML="";
  document.getElementById(id).style.left=posx+"px";
  document.getElementById(id).style.top=posy+"px";
  document.getElementById(id).style.width="0px";
  document.getElementById(id).style.height="0px";
  document.getElementById(id).style.visibility="hidden";
}

function acco() {
  var selObj=document.formulier.elements["accommodatie"];
  if (selObj.value) {
    var waarden=selObj.value.split("_");
    var deurl="http://"+location.hostname+"/"+waarden[1]+"/";
    for (var i=0; i<document.formulier_go.elements.length; i++) {
      if (document.formulier_go.elements[i].name==selObj.id) {
        document.formulier_go.elements[i].value=waarden[0];
      } else {
        document.formulier_go.elements[i].disabled=true;
      }
    }
    document.formulier_go.action=deurl;
    document.formulier_go.submit();
  }
}

function item_naar(nr,aid,volgnr) {
  ablog(0,"door");
 
  var xmlhttp = new XMLHttpRequest();
  var ajaxquery=document.formulier_item.ajaxquery.value;
  var deurl="http://"+location.hostname+"/zoeken-naar-aj.php?nr="+nr+"&is=0&aid="+aid+"&volgnr="+volgnr+"&"+ajaxquery;
  if (xmlhttp) {
    xmlhttp.open("GET",deurl,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        var response=xmlhttp.responseText;
        //alert(response);
        if (response) {
          var id="item_"+nr;
          document.getElementById(id).innerHTML=response;
        }
      }
    }
    xmlhttp.send(null);
  }
  
} 

function item_alt(nr,iid) {
  var ajaxquery=document.formulier_item.ajaxquery.value;
  var deurl="http://"+location.hostname+"/zoeken-alt-aj.php?nr="+nr+"&iid="+iid+"&"+ajaxquery;
  var xmlhttp = new XMLHttpRequest();
  if (xmlhttp) {
    xmlhttp.open("GET",deurl,true);
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        var response=xmlhttp.responseText;
        if (response) {
          var id="item_"+nr;
          document.getElementById(id).innerHTML=response;
        }
      }
    }
    xmlhttp.send(null);
  }
} 

