
var subdivision_autocomplete_menu;function disableInputs(parentId){$$('#'+parentId+' input').each(function(s){s.disabled=true;});$$('#'+parentId+' select').each(function(s){s.disabled=true;});}
function enableInputs(parentId){$$('#'+parentId+' input').each(function(s){s.disabled=false;});$$('#'+parentId+' select').each(function(s){s.disabled=false;});}
function showCounties(state){$$("#ul_county li[rel="+state+"]").each(function(c_li){$(c_li).show();});showHideCountiesTip();}
function showCities(county){$$("#ul_city li[rel="+county+"]").each(function(c_li){$(c_li).show();});showHideCitiesTip();}
function hideCounties(state){if(state){$$("#ul_county li[rel='"+state+"']").each(function(c_li){if($(c_li).visible()){$(c_li).hide();if(c_li.className!='county_label'){var checkbox=$(c_li).firstDescendant().firstDescendant();if(checkbox.checked==true){hideCities(checkbox.value);}
checkbox.checked=false;}}});}else{$$('#ul_county li[rel]').each(function(c_li){$(c_li).hide();if(c_li.className!='county_label'){var checkbox=$(c_li).firstDescendant().firstDescendant();if(checkbox.checked==true){hideCities(checkbox.value);}
checkbox.checked=false;}});}
showHideCountiesTip();showHideCitiesTip();}
function hideCities(county){if(county){$$("#ul_city li[rel='"+county+"']").each(function(c_li){if($(c_li).visible()){$(c_li).hide();if(c_li.className!='county_label'){var checkbox=$(c_li).firstDescendant().firstDescendant();checkbox.checked=false;}}});}else{$$('#ul_city li[rel]').each(function(c_li){$(c_li).hide();if(c_li.className!='county_label'){var checkbox=$(c_li).firstDescendant().firstDescendant();checkbox.checked=false;}});}
showHideCitiesTip();}
function advancedToggleSearchBySection(section){var id='searchBy_'+section;var searchby_url="?";$($$("#AdvancedSearchForm #SearchBySection")[0]).update('<div class="one_column"><p class="instructions">Loading...</p></div>');var action='get_search_by_inputs_for_'+section;new Ajax.Request(searchby_url,{method:'post',parameters:{controller:'ListingSearch',action:action,product:'Web'},onSuccess:function(transport){searchby_html=transport.responseText;$($$("#AdvancedSearchForm #SearchBySection")[0]).update(searchby_html);},onFailure:function(){alert("The ajax request failed - was trying to retrieve inputs for search by ("+action+")");}});if(id=='searchBy_mls_no'){disableInputs("SearchFormMain");$("SearchFormMain").hide();}else{enableInputs("SearchFormMain");$("SearchFormMain").show();}}
function attachAdvancedSearchEvents()
{advancedToggleSearchBySection($('SelectSearchBy').getValue());$("SelectSearchBy").observe('change',function(){var section=$("SelectSearchBy").getValue();advancedToggleSearchBySection(section);});if($("accept_eula"))
{$('AdvancedSearchSubmit').observe("click",function(click){Event.stop(click);if($('accept_eula').checked==false){alert("Please read our search terms and check the 'Yes I agree to the search terms' box to continue");}else{$('AdvancedSearchForm').submit();}});}
$$('.more_options_search_params').each(function(e){var e=$(e);e.observe('click',function(event){Event.stop(event);showMoreOptionsSearchParams(e);});});}
function showMoreOptionsSearchParams(link_obj)
{var p_name=link_obj.readAttribute('rel');var p_list=link_obj.up('ul#'+p_name);var p_loading=document.createElement('span');Element.extend(p_loading);p_loading.update('Loading...');link_obj.replace(p_loading);var p_ids="##";$$('ul#'+p_name+' li label input:checked').each(function(e){p_ids+=e.value+"##";});new Ajax.Request('?',{method:'post',parameters:{controller:'ListingSearch',action:'get_search_by_inputs_for_dynamic_params',dynamic_params:p_name,ids:p_ids,product:'Web'},onSuccess:function(transport){p_list.update(transport.responseText);},onFailure:function(){alert("The ajax request failed - was trying to retrieve inputs for search by ("+p_name+")");}});}
function showHideCitiesTip(){if(!$$('ul#ul_county').length){$('city_tip').hide();return true;}
var county_is_selected=$$('ul#ul_county li label input:checked').first();var city_tip=$('city_tip');if(city_tip){if(county_is_selected){city_tip.hide();}else{city_tip.show();}}}
function showHideCountiesTip(){if(!$$('ul#ul_state').length){$('county_tip').hide();return true;}
var state_is_selected=$$('ul#ul_state li label input:checked').first();var county_tip=$('county_tip');if(county_tip){if(state_is_selected){$('county_tip').hide();}else{$('county_tip').show();}}}
Event.observe(window,'load',function()
{attachAdvancedSearchEvents();});
