function xmlhttpShowSearchResults() {

	//var strURL = 'searchresults.php?res=1';
	var strURL = '';
	var totalcheck = 0;
	
	prelease = document.getElementById('prelease').value;	
	count = document.getElementById('totalneighborhood').value;	
	keyword = document.getElementById('keyword').value;	
	rentcount = document.getElementById('totalrent').value;	
	sizecount = document.getElementById('totalsize').value;	
	if(prelease != ''){
		totalcheck++;
		strURL = strURL + "&prelease=" + prelease;
	}
	
	if(keyword != ''){
		totalcheck++;
		strURL = strURL + "&keyword=" + keyword;
	}
	if(count >0){
		strURL = strURL + "&propertyid="
	}
	for (var j = 0; j < count; j++)
	{
		if (document.frmsearch.neighborhood[j].checked == true){ 
			totalcheck++;
			propertyid = document.frmsearch.neighborhood[j].value;
			strURL = strURL + propertyid;
				strURL = strURL  + ",";
		}
   	}
	if(rentcount >0){
		strURL = strURL + "&rentid="
	}
	
	
	for (var j = 0; j < rentcount; j++)
	{
		if (document.frmsearch.rent[j].checked == true){ 
			totalcheck++;
			rentid = document.frmsearch.rent[j].value;
			strURL = strURL + rentid;
			strURL = strURL  + ",";
		}
   	}
	if(sizecount >0){
		strURL = strURL + "&sizeid="
	}
	for (var j = 0; j < sizecount; j++)
	{
		if (document.frmsearch.bedrooms[j].checked == true){ 
			totalcheck++;
			sizeid = document.frmsearch.bedrooms[j].value;
			strURL = strURL + sizeid;
			strURL = strURL  + ",";
		}
   	}
	//alert(totalcheck);
	if(totalcheck == 0){		
		document.location.href = 'index.php';
	}else{


		
		$.ajax({
		   type: "POST",
		   url: "apt-search.php?callback=ApartmentSearch.loadData",
		   cache: false,
		   data: "res=1"+strURL,
		   dataType: "jsonp",
		   success: function(data){			 		
			
			ApartmentSearch.initialize('apt-search.php','apt-search-results.php');		
		   },
		 error:function (xhr, ajaxOptions, thrownError, request, error){
    	  /*alert('xrs.status = ' + xhr.status + '\n' + 
            'thrown error = ' + thrownError + '\n' +
            'xhr.statusText = '  + xhr.statusText + '\n' +
            'request = ' + request + '\n' +
            'error = ' + error);*/
      }  
		 });
	}
	
}
//================================================================
function xmlhttpShowMainSearchResults() {

	var strURL = '/search/index.php?';
//	var strURL = '';
	
	count = document.getElementById('totalneighborhood').value;	
	keyword = document.getElementById('keyword').value;	
	rentcount = document.getElementById('totalrent').value;	
	sizecount = document.getElementById('totalsize').value;	
	prelease = document.getElementById('prelease').value;	
	if(prelease != ''){
		
		strURL = strURL + "&prelease=" + prelease;
	}
	if(keyword != ''){
		strURL = strURL + "&keyword=" + keyword;
	}
	if(count >0){
		strURL = strURL + "&propertyid="
	}
	for (var j = 0; j < count; j++)
	{
		if (document.frmmainsearch.neighborhood[j].checked == true){ 
			propertyid = document.frmmainsearch.neighborhood[j].value;
			strURL = strURL + propertyid;
				strURL = strURL  + ",";
		}
   	}
	if(rentcount >0){
		strURL = strURL + "&rentid="
	}
	
	
	for (var j = 0; j < rentcount; j++)
	{
		if (document.frmmainsearch.rent[j].checked == true){ 
			rentid = document.frmmainsearch.rent[j].value;
			strURL = strURL + rentid;
			strURL = strURL  + ",";
		}
   	}
	if(sizecount >0){
		strURL = strURL + "&sizeid="
	}
	for (var j = 0; j < sizecount; j++)
	{
		if (document.frmmainsearch.bedrooms[j].checked == true){ 
			sizeid = document.frmmainsearch.bedrooms[j].value;
			strURL = strURL + sizeid;
			strURL = strURL  + ",";
		}
   	}
	//alert(strURL);
	document.location.href = strURL;
}
