
﻿function getStateControlValues(){var s=document.getElementById('ctl01_ctl00_ddlState').value;if(s.length>0){var vals=s.split('|');if(vals.length==2){return vals;}else{return null;}}
return null;}
function changeStateAndCities(){try{v=getStateControlValues();if(v!=null){res=ResultSearchCriteria.GetCitiesByStateRegion(v[0],v[1]);if(res.error!==null){_oErrorHandler.ResponseError('PropertyCriteriaControl.GetPropertyTypeByID',response);return;}
lstCities=document.getElementById('ctl01_ctl00_lstCity');if(res!=null&&res.value!=null&&lstCities!=null){lstCities.selectIndex=-1;lstCities.options.length=0;o=res.value.split('|');for(i=0;i<o.length;i++){nvp=o[i].split('~');if(nvp[0].length>0&&nvp[1].length>0){opt=document.createElement("option");opt.text=nvp[0];opt.value=nvp[1];lstCities.options.add(opt);}}}}}
catch(err){_oErrorHandler.Error('NRT.Property.Search.QuickSearch.changeStateAndCities',_oErrorHandler.ERRORTYPE_JS,err);return;}}
function refinePSSearch(){if(parseInt(document.getElementById('ctl01_ctl00_ddlMaxPrice').value)<parseInt(document.getElementById('ctl01_ctl00_ddlMinPrice').value)){alert("Maximum Price cannot be less than the minimum price.");return;}
try{var oSearchCriteria=eval('('+NRT.Utility.getElementByTagNameAndID('hdnSrchCriteria','INPUT').value+')');oSearchCriteria.PageNumber=1;oSearchCriteria.SortColumn="Price_Desc";if(oSearchCriteria!=null){v=getStateControlValues();if(v!=null){oSearchCriteria.StateID=v[0];oSearchCriteria.RegionID=v[1];}
for(i=0;i<oSearchCriteria.CustomCriterias.length;i+=1){oCriteria=oSearchCriteria.CustomCriterias[i];switch(oCriteria.DBParamName){case'@Bathrooms':oCriteria.ControlValue=document.getElementById('ctl01_ctl00_ddlBaths').value;break;case'@Bedrooms':oCriteria.ControlValue=document.getElementById('ctl01_ctl00_ddlBeds').value;break;case'@MaxPrice':oCriteria.ControlValue=document.getElementById('ctl01_ctl00_ddlMaxPrice').value;break;case'@MinPrice':oCriteria.ControlValue=document.getElementById('ctl01_ctl00_ddlMinPrice').value;break;case'@PropertyType':var pt1=null;var pt2=null;var st1=null;var st2=null;lst1=document.getElementById('ctl01_ctl00_chkListPropertyType');if(lst1!=null){pt1=lst1.getElementsByTagName('input');st1=lst1.getElementsByTagName('span');}
lst2=document.getElementById('ctl01_ctl00_chkListLifestyle');if(lst2!=null){pt2=lst2.getElementsByTagName('input');st2=lst2.getElementsByTagName('span');}
vals='';if(pt1!=null&&st1!=null){for(j=0;j<pt1.length;j++){if(pt1[j].checked){vals+=st1[j].getAttribute('ptype')+',';}}}
if(pt2!=null&&st2!=null){for(j=0;j<pt2.length;j++){if(pt2[j].checked){vals+=st2[j].getAttribute('ptype')+',';}}}
if(vals.length>0&&vals.substring(vals.length)==','){vals=vals.substring(0,vals.length-1);}
oCriteria.ControlValue=vals;break;}}
var locationXml='<location id="{id}" name="{nm}" isParent="" type="0" />';var locations='';lstCities=document.getElementById('ctl01_ctl00_lstCity');if(lstCities!=null){for(i=0;i<lstCities.options.length;i++){if(lstCities.options[i].selected){locations+=locationXml.replace("{id}",lstCities.options[i].value).replace("{nm}",lstCities.options[i].text);}}}
if(locations.length>0){oSearchCriteria.LocationXML='<Locations>'+locations+'</Locations>';}else{oSearchCriteria.LocationXML='';}
srchID=SearchController.PersistSearch(oSearchCriteria);window.location='/property/PropertyResults.as'+'px?SearchID='+srchID.value;}}
catch(err){_oErrorHandler.Error('NRT.Property.Search.QuickSearch.performSearch',_oErrorHandler.ERRORTYPE_JS,err);return;}}
