// select box
function GetXmlHttpObject(handler)
{
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
}

function stateChangedHoreca()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("txtResultH").innerHTML= xmlHttp.responseText;
    }
    else {//alert(xmlHttp.status);
    
    }
}

// Will populate data based on input
function horeca_search(url, qStr)
{
    if (url.length==0)
    {
        document.getElementById("txtResultH").innerHTML="";
        return;
    }

    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=url+"ajax.php?"+qStr;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedHoreca;
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

function searchH(address)
{
    hor = document.getElementById("horeRes").value;
    cit = document.getElementById("cityH").value;

    if (cit != "0" || res != "0")
    {

        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
        {
            alert ("Browser does not support HTTP Request");
            return;
        }

        url=address+"ajax.php?hor1="+hor;
        url=url+"&cit="+cit;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=stateChangedII;
        xmlHttp.open("GET",url,true) ;
        xmlHttp.send(null);
    }
    else
    {
        alert('Selecteer een plaatsnaam!');
    }
}

function stateChangedDienstverlening()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("txtResultD").innerHTML= xmlHttp.responseText;
    }
    else {//alert(xmlHttp.status);

    }
}

// Will populate data based on input
function dienstverlening_search(url, qStr)
{
    if (url.length==0)
    {
        document.getElementById("txtResultD").innerHTML="";
        return;
    }

    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=url+"ajax.php?"+qStr;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedDienstverlening;
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

function searchD(address)
{
    res = document.getElementById("dienRes").value;
    cit = document.getElementById("cityD").value;

    if (cit != "0" || res != "0")
    {

        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
        {
            alert ("Browser does not support HTTP Request");
            return;
        }

        url=address+"ajax.php?die1="+res;
        url=url+"&cit="+cit;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=stateChangedII;
        xmlHttp.open("GET",url,true) ;
        xmlHttp.send(null);
    }
    else
    {
        alert('Selecteer een plaats naam!');
    }
}

function stateChangedAccommodatie()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementById("txtResultA").innerHTML= xmlHttp.responseText;
    }
    else {//alert(xmlHttp.status);

    }
}

// Will populate data based on input
function accommodatie_search(url, qStr)
{
    if (url.length==0)
    {
        document.getElementById("txtResultA").innerHTML="";
        return;
    }

    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=url+"ajax.php?"+qStr;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedAccommodatie;
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

// Will populate data based on input
function accommodatie_searchII(url, qStr)
{alert('whatnow');
    
}

function searchA(address)
{
    res = document.getElementById("accoRes").value;
    cit = document.getElementById("cityA").value;

    if (cit != "0" || res != "0")
    {

        xmlHttp=GetXmlHttpObject()
        if (xmlHttp==null)
        {
            alert ("Browser does not support HTTP Request");
            return;
        }

        url=address+"ajax.php?acc1="+res;
        url=url+"&cit="+cit;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=stateChangedII;
        xmlHttp.open("GET",url,true) ;
        xmlHttp.send(null);
    }
    else
    {
        alert('Selecteer een plaatsnaam!');
    }
}

function stateChangedII()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            window.location = xmlHttp.responseText;       
    }
    else {
           // alert(xmlHttp.status);
    }
}

function stateChangedIII()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    	alert('Listing aan favorieten toegevoegd');      
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedIIII()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    	//alert('Removed from Favourites');
    	window.location = xmlHttp.responseText;        
    }
    else {
            //alert(xmlHttp.status);
    }
}

function add_to_favourites(address, qStr)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=address+"ajax.php?"+qStr;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedIII;
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

function remove_from_favourites(address, qStr)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=address+"ajax.php?remove=1&"+qStr;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChangedIIII;
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

function bookmark(url,title)
{
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) 
  {
  	window.external.AddFavorite(url,title);
  } 
  else if (navigator.appName == "Netscape") 
  {
    window.sidebar.addPanel(title,url,"");
  } else 
  {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

$(document).ready(function()
{
	$("#some-element").simpletooltip() 
});

	
