function Search_Reset(pHome)
{
  Search_Select_Reset('searchPlaats');
	Search_Select_Reset('searchWijk');
	Search_Select_Reset('searchWoningType');
	Search_Select_Reset('searchInrichting');
	Search_Select_Reset('searchAantalSlaapkamers');
	Search_Select_Reset('searchMaxHuur');

	if (!pHome) { Search_Submit();	}
}

function Search_Select_OnChange(pID, pHome)
{
  // Op de homepage wordt het formulier niet meteen ge'submit
	// Op de zoekpagina wel
  
	if (pHome) {
		var itemPlaats = Search_Select_GetValue('searchPlaats');
		var itemWijk = Search_Select_GetValue('searchWijk');
		var itemWoningType = Search_Select_GetValue('searchWoningtype');
		var itemInrichting = Search_Select_GetValue('searchInrichting');
		var itemAantalSlaapkamers = Search_Select_GetValue('searchAantalSlaapkamers');
		var itemMaxHuur = Search_Select_GetValue('searchMaxHuur');

    // Aantal bijwerken via Ajax
    ajaxpack.getAjaxRequest('/ajax/zoekresultaat_aantal.asp', 'itemPlaats=' + itemPlaats + '&itemWijk=' + itemWijk + '&itemWoningType=' + itemWoningType + '&itemInrichting=' + itemInrichting + '&itemAantalSlaapkamers=' + itemAantalSlaapkamers + '&itemMaxHuur=' + 	itemMaxHuur, Search_Select_OnChange_Process, 'txt');
}
  else {
	  Search_Submit();
	}
}

function Search_Select_GetValue(pID)
{
  var el = document.getElementById(pID);
	if (el) {
		if (el.selectedIndex > 0) {
  	  return el.options[el.selectedIndex].value;
		} else {
		  return '';
		}
	}
}

function Search_Select_Reset(pID)
{
  var el = document.getElementById(pID);
	if (el) { el.selectedIndex = 0; }
}

function Search_Submit()
{
  document.getElementById('frmSearch').submit()
}

function Search_Select_OnChange_Process() {
    var myajax=ajaxpack.ajaxobj;
    var myfiletype=ajaxpack.filetype;
    if (myajax.readyState == 4) { //if request of file completed
      if (myajax.status==200 || window.location.href.indexOf("http")==-1) { //if request was successful or running script locally
        var result;
				      
        if (myfiletype=="txt")
          result = myajax.responseText
        else
          result = myajax.responseXML
        
				eval(result);
      }
    }
}