var setDefaultClick = function ( p_src, p_default ) { if (p_src.value == p_default) { p_src.value = ""; } }
var setDefaultBlur = function ( p_src, p_default ) { if (p_src.value == "") { p_src.value = p_default; } }
var updatePropertyType = function ( p_obj ) { var frm = p_obj.form; for ( var i=0; i < p_obj.options.length; i++ ) { var field = p_obj.options[i].value; if (field != "") { frm[field].value = (i == p_obj.selectedIndex) ? "Y" : ""; } } } var quickSearch = function ( frm ) { if ( document.getElementById( 'temp_address' ) ) { if ( frm.temp_address && frm.temp_address.value != "Address" ) { frm.address.value = frm.temp_address.value; } } if ( document.getElementById( 'temp_zip_code' ) ) { if ( frm.temp_zip_code && frm.temp_zip_code.value != "Zip" ) { frm.zip_code.value = frm.temp_zip_code.value; } } if ( document.getElementById( 'temp_property_id' ) ) { if ( frm.temp_property_id && frm.temp_property_id.value != "MLS Number" ) { frm.property_id.value = frm.temp_property_id.value; } } frm.submit(); }
// this is set to yes after all the variables have been loaded city_county_loaded = "no"; city_page_load_first_run = "Y"; county_page_load_first_run = "Y"; useall = true; allfactor = 1;
// when all the variables have been loaded via the external js file the city_county_loaded variable will be set to yes. // then we can move on var checkDataLoad = function () { if ( city_county_loaded == "no" ) { setTimeout ("checkDataLoad();", 250); } else { stateToggle(); updateCounties(); updateCities(); } }
// Checks to see if state_list has more than one state - if not, disable the state dropdown var stateToggle = function () { if ( document.searchForm.state.length == 1 ) { document.searchForm.state.disabled = true; document.searchForm.state.style.display = "none"; } }
// checks the current state (if one is defined) and populates the list of counties in the select box var updateCounties = function () {
f = document.searchForm;
// blank the select box RemoveAll(f.county);
if (useall){ AddToSelect(f.county,"- County -",""); }
// loop over the array of states, adding them to the dropdown if( counties.length > 0 ) {
for ( x=0; x < counties.length; x++ ) { // a little test to make sure only the right counties show up if a state is chosen use_this_county = 1; chosen_state = f.state.options[f.state.selectedIndex].value; if ( states[x] != chosen_state ) { use_this_county = 0; } // if the state matches, or if there is no state, add it to the select if ( use_this_county == 1 ) { AddToSelect(f.county,counties[x],counties[x]); //Set the Default County to selected if one is present if ( f.DefaultCounty.value.toLowerCase() == counties[x].toLowerCase() ) { SelectOption(f.county, counties[x], true); } } } // select the first one if ( f.DefaultCounty.value == "" ) { f.county.selectedIndex=0; } } else { // There are no counties, so disable the selection box f.county.disabled = true; f.county.style.display = "none"; } if ( county_page_load_first_run == "Y" ) { county_page_load_first_run = "N"; if ( "" != '' ) { SelectOption( f.county, "", "" ); } else if ( "" != '' ) { SelectOption( f.county, "", "" ); } } else{ // populate the city list //RemoveAll(f.chosencities); updateCities(); } } // this function accepts a county name and returns the index of that county // from within the js array that contains the city data var getCountyIndex = function ( countyname ) { chosen_state = f.state.options[f.state.selectedIndex].value; for ( x=0; x < counties.length; x++ ) { if ( counties[x] == countyname && states[x] == chosen_state ) { return(x); } } } // update the city dropdown according to chosen county or 'all' for a given state var updateCities = function () { // blank the dropdown RemoveAll( f.citylist ); f.city.value = ""; AddToSelect(f.citylist, "- City -", ""); // get the county array index countySelectIndex = f.county.selectedIndex - allfactor; // less than zero if they chose 'all' if ( countySelectIndex < 0 ) { // now we choose which index points to the chosen state chosen_state = f.state.options[f.state.selectedIndex].value; chosen_state_index = listfind(state_list, chosen_state, ","); // loop over the state/city array and build the list if ( chosen_state_index > 0 ) { for ( x=0; x < all_array[chosen_state_index].length; x++ ) { AddToSelect(f.citylist, all_array[chosen_state_index][x], all_array[chosen_state_index][x]); } } else{ // this will only happen if the admin puts a state in the list for a given market and there happen // to be no cities in the db that match. this will be VERY rare, if ever. alert("No Cities in this state") } } else{ // pull back the index for the chosen county countyIndex = getCountyIndex(f.county.options[f.county.selectedIndex].value); // loop over the county/city array and add to city select for ( x=0; x < cities[countyIndex].length; x++ ) { AddToSelect(f.citylist, cities[countyIndex][x], cities[countyIndex][x]); } } } var listfind = function ( thelist, thevalue, delim ) { if (! delim){ delim = ","; } l = listlen(thelist, delim); listpos = -1; for (var x = 1; x < l; x++){ listelement = listgetat(thelist,x,delim); if (listelement == thevalue){ listpos = x; break; } } return listpos; } document.onload = checkDataLoad();