function submitResult()
{
 
var len = document.form.length*1;
var start = 0;
var string = '';
while (start < len)
{
// fitler empty & non necessary names

if (document.form.elements[start].value!='' && ( document.form.elements[start].name != 'showField' 
&& document.form.elements[start].name != 'submit'
&& document.form.elements[start].name != 'reset'
&& document.form.elements[start].name != 'populateAlert' 
&& document.form.elements[start].name != 'cityAlert' )
)
{
if (document.form.elements[start].type == 'select-multiple' || document.form.elements[start].type == 'select-one')
{
var thisStartPoint = 0;
while (thisStartPoint < document.form.elements[start].length)
{
if (document.form.elements[start].options[thisStartPoint].selected == true)
{
string += document.form.elements[start].name + "=" + document.form.elements[start].options[thisStartPoint].value  + "&" ;
}
thisStartPoint++;
}// end while for select box
}
else if  (document.form.elements[start].type == "checkbox" || document.form.elements[start].type == "radio")
{
if(document.form.elements[start].checked == true)
{
string += document.form.elements[start].name  + "=" + document.form.elements[start].value + "&" ;
}
}
else
{ // is a text
string += document.form.elements[start].name  + "=" + document.form.elements[start].value + "&" ;
}
}

start++;
}



stringLength = 1*string.length - 1;

string = string.substring(0, stringLength);

testString = encodeURI(string);

if (testString.length <=2000)
{
window.location = "results.php?" + string;
} // end if
else
{
outPutString = "Your number of selections exceeds the 2000 character limit, please deselect some items";
}//end else

string = "results.php?"+string;
document.getElementById("IDX-searchWarning").innerHTML = outPutString;
 } // end function to redirect



function changeRentalPrices(lowprice, highprice, propType)
{
if (document.form.ajaxInformant.options[document.form.ajaxInformant.selectedIndex].value == propType)
{
document.form.lowPrice.value = lowprice;
document.form.highPrice.value = highprice;
}// end if
}// end function for changing default prices

function checkForExist2()
{
firstelement = false;
secondelement = false;
formlength = document.form.elements.length;
start = 0;
while (start < formlength)
{
if (document.form.elements[start].name == 'cityAlert')
{

firstelement = true;
}

if (document.form.elements[start].name == 'populateAlert')
{

secondelement = true;
}
start++;
}
if (firstelement == true && secondelement == true)
{
if ( (typeof specialRentalLowPrice != "undefined") && (typeof specialRentalHighPrice != "undefined") )
{
changeRentalPrices(specialRentalLowPrice, specialRentalHighPrice,'rnt')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialResidentialLowPrice != "undefined") && (typeof specialResidentialHighPrice != "undefined") )
{
changeRentalPrices(specialResidentialLowPrice,specialResidentialHighPrice,'sfr')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialMultiFamilyLowPrice != "undefined") && (typeof specialMultiFamilyHighPrice != "undefined") )
{
changeRentalPrices(specialMultiFamilyLowPrice, specialMultiFamilyHighPrice,'mfr')
clearInterval(checkForFormLoad2);
}
if ( (typeof specialMobileHomeLowPrice != "undefined") && (typeof specialMobileHomeHighPrice != "undefined") )
{
changeRentalPrices(specialMobileHomeLowPrice,  specialMobileHomeHighPrice,'mh')
clearInterval(checkForFormLoad2);
}
if ( (typeof specialLotsLandLowPrice != "undefined") && (typeof specialLotsLandHighPrice != "undefined") )
{
changeRentalPrices( specialLotsLandLowPrice,specialLotsLandHighPrice,'ld')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialCommercialLowPrice != "undefined") && (typeof specialCommercialHighPrice != "undefined") )
{
changeRentalPrices(specialCommercialLowPrice, specialCommercialHighPrice,'com')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialBusinessLowPrice != "undefined") && (typeof specialBusinessHighPrice != "undefined") )
{
changeRentalPrices(specialBusinessLowPrice, specialBusinessHighPrice,'bo')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialRentalIncomeLowPrice != "undefined") && (typeof specialRentalIncomeHighPrice != "undefined") )
{
changeRentalPrices(specialRentalIncomeLowPrice, specialRentalIncomeHighPrice,'ri')
clearInterval(checkForFormLoad2);
}

if ( (typeof specialFarmLowPrice != "undefined") && (typeof specialFarmHighPrice != "undefined") )
{
changeRentalPrices(specialFarmLowPrice, specialFarmHighPrice,'frm')
clearInterval(checkForFormLoad2);
}


}
}

function showHideTopField(field)
{
if (field == "cityField")
{
document.getElementById("IDX-searchPage-cityField").style.display = 'block';
document.getElementById("IDX-searchPage-countyField").style.display = 'none';
document.getElementById("IDX-searchPage-zipCodeField").style.display = 'none';
document.form.county.selectedIndex = 0;
document.form.county.options[0].selected = null;
document.form.zipCode.selectedIndex = 0;
document.form.zipCode.options[0].selected = null;
}
if (field == "countyField")
{
document.getElementById("IDX-searchPage-cityField").style.display = 'none';
document.getElementById("IDX-searchPage-countyField").style.display = 'block';
document.getElementById("IDX-searchPage-zipCodeField").style.display = 'none';
document.form.city.selectedIndex = 0;
document.form.city.options[0].selected = null;
document.form.zipCode.selectedIndex = 0;
document.form.zipCode.options[0].selected = null;
}
if (field == "zipCodeField")
{
document.getElementById("IDX-searchPage-cityField").style.display = 'none';
document.getElementById("IDX-searchPage-countyField").style.display = 'none';
document.getElementById("IDX-searchPage-zipCodeField").style.display = 'block';
document.form.city.selectedIndex = 0;
document.form.city.options[0].selected = null;
document.form.county.selectedIndex = 0;
document.form.county.options[0].selected = null;
}
} 
// end


var textReplaceTimer = 0;
function replaceText()
{
var sHTML = document.getElementById("IDX-cityLabel");
if(sHTML)
{
sHTML = sHTML.innerHTML;
if(sHTML == "Select by City")
{
clearInterval(textReplaceTimer);
textReplaceTimer = 0;
}
if(document.getElementById('IDX-cityLabel'))
{
document.getElementById("IDX-cityLabel").innerHTML = "Select by City";
document.getElementById("IDX-countyLabel").innerHTML = "Select by County";
document.getElementById("IDX-zipCodeLabel").innerHTML = "Select by Zipcode";
}
else
return false;
}
}

textReplaceTimer = setInterval("replaceText()", 250);


checkForFormLoad2 = setInterval('checkForExist2()', 250);
