var PropertyFormValidator={FREE_TEXT_BLANK_VALUE:"Enter Location",freeTextHasBlankValue:false,firstFocus:true,bindValidationEvents:function(freeTextId,countryId,mlsId){$(document).ready(function(){PropertyFormValidator.handleBlankUserLocation(freeTextId,countryId,mlsId);
PropertyFormValidator.bindOnCountryChange(freeTextId,countryId)
})
},handleBlankUserLocation:function(freeTextId,countryId,mlsId){if(($("#"+countryId).val()==""||$("#"+freeTextId).val()=="")&&$("#"+mlsId).val()==""){$("#"+freeTextId).val(PropertyFormValidator.FREE_TEXT_BLANK_VALUE);
PropertyFormValidator.freeTextHasBlankValue=true;
$("#"+freeTextId).focus(function(){if(PropertyFormValidator.firstFocus){$(this).val("");
PropertyFormValidator.freeTextHasBlankValue=false;
PropertyFormValidator.firstFocus=false
}})
}},bindOnCountryChange:function(freeTextId,countryId){var previousCountry=$("#"+countryId).val();
$("#"+countryId).change(function(){PropertyFormValidator.freeTextHasBlankValue=false;
PropertyFormValidator.firstFocus=false;
if($("#"+countryId).val()!=1&&previousCountry==1){$("#"+freeTextId).val("")
}previousCountry=$("#"+countryId).val();
if($("#propertyLocation input").length>0){$("#propertyLocation input").val("")
}else{$("#globalPropertyLocation input").val("")
}})
},validateForm:function(freeTextId,countryId,mlsId,minPriceId,maxPriceId){var country=$("#"+countryId).val();
if(country==""){alert("Please enter a search criteria.");
return false
}if(country==1||country==9){if((jQuery.trim($("#"+freeTextId).val())==""&&jQuery.trim($("#"+mlsId).val())=="")||(PropertyFormValidator.freeTextHasBlankValue&&jQuery.trim($("#"+mlsId).val())=="")){alert("Please enter a search criteria.");
return false
}}var minPrice=$.trim($("#"+minPriceId).val()).toLowerCase();
while(minPrice.indexOf(",")!=-1){minPrice=minPrice.replace(",","")
}minPrice=((minPrice==""||minPrice=="any")?0:parseInt(minPrice));
if(isNaN(minPrice)){alert("Please enter a valid min price.");
return false
}var maxPrice=$.trim($("#"+maxPriceId).val()).toLowerCase();
while(maxPrice.indexOf(",")!=-1){maxPrice=maxPrice.replace(",","")
}maxPrice=((maxPrice==""||maxPrice=="any")?0:parseInt(maxPrice));
if(isNaN(maxPrice)){alert("Please enter a valid max price.");
return false
}if(minPrice>0&&maxPrice>0&&minPrice>=maxPrice){alert("Max price must be greater than min price.");
return false
}if(PropertyFormValidator.freeTextHasBlankValue){$("#"+freeTextId).val("")
}return true
}};
