function LoadUrl(theMinRent, theMaxRent,theBedroom)
{
   var url = "&Rent_Minimum=" + theMinRent + "&Rent_Maximum=" + theMaxRent;
   
   if(theBedroom==1)
   {
        url += "&onebdrm=1";
   }
   else if(theBedroom==2)
   {
        url += "&twobdrm=1";
   
   }
   else if(theBedroom==3)
   {
        url += "&threebdrm=1";
   
   } 
    else if(theBedroom==4)
   {
        url += "&fourbdrm=1";
   
   }else if(theBedroom==5)
   {
        url += "&fivebdrm=1";
   
   }
    else if(theBedroom==6)
   {
        url += "&sixbdrm=1";
   
   }
   
   return url;

}

// Determine whether to do a zipcode search or city/state
//     zipcode overrides city/state
function deterLoad()
{
    //alert(window.document.FindControl("city"));
    stateControl = window.document.forms[0].state;
    cityControl = window.document.forms[0].city;
    zipControl = "";
    radiusControl = window.document.forms[0].Radius;
    minRentControl = window.document.forms[0].minRent;
    maxRentControl = window.document.forms[0].maxRent;
    bedRoomControl = window.document.forms[0].Bedroom;

    theCity = cityControl.value;
    theState = stateControl.options[stateControl.selectedIndex].value;
    theZip = "";
    theRad = radiusControl.options[radiusControl.selectedIndex].value;
    theMinRent = minRentControl.options[minRentControl.selectedIndex].value;
    theMaxRent = maxRentControl.options[maxRentControl.selectedIndex].value;
    theBedroom = bedRoomControl.options[bedRoomControl.selectedIndex].value;
    
    if(parseFloat(theMinRent) > parseFloat(theMaxRent))
    {    
        alert("The min rent must be smaller than max rent.");
        return false;
    }
    var url = LoadUrl(theMinRent, theMaxRent,theBedroom)
    
    if (theZip.length > 0)
    {  
       return loadZS(theZip,theRad,url);
    }
    else if ( theState != "")
    {

       return loadQS(theCity, theState,theRad,url);
    }
    else
    {
        alert("Please enter a \"city and state\".");
        return false;
    }
}


function ValidateZip(WebSearchFrm)
{
   if(WebSearchFrm.txtZipCode.value == "") 
   { 
      alert('Missing ZIP information. Please enter a ZIP code to post a listing') 
      WebSearchFrm.txtZipCode.focus(); 
      return false; 
   } 
 
 
   if (!IsNumeric(WebSearchFrm.txtZipCode.value)) 
   { 
      alert('Please enter only numbers in the Zip Code') 
      WebSearchFrm.txtZipCode.focus(); 
      return false; 
      } 
 
 return true;
}

function loadQS(theCity, theState, radius, url)
{
var theCity;
var theState;
var radius;
var bool;
	if(radius == '5' || radius == '10' || radius == '20') {
		if(theCity == ""){
		alert("Please enter a City");
		document.qs.city.focus();
		return false;
		}
	}
bool = validateForm(theState);
if (bool == "n")
{
  return false;
}
else
{

theCity = escape(theCity);

  var qString;
  if(radius == '5' || radius == '10' || radius == '20'){
	qString = "http://www.rentalhomesplus.com/results.aspx?page=results&stype=city&city=" + theCity + "&state=" + theState + "&rad=" + radius + url;
	}
  else{
	qString = "http://www.rentalhomesplus.com/results.aspx?page=results&stype=city&city=" + theCity + "&state=" + theState + url;
	}
	window.document.location = qString;
  return false;
}

}


function validateForm(st)
{
var daState = st;

if (daState == "")
{
	alert("Please Select a State from the menu")
	return("n");
}

else
{
return("y");
}
}


function loadZS(theZip,rad,url)
{
	var bool;

	
	theZip = escape(theZip);

	if(theZip.length < 5)
	{
		alert("Please enter one/multiple 5 digit zip code/s seperated by commas");
		return false;
	}
	
	var qString;
	if(rad == '5' || rad == '10' || rad == '20'){
      qString  = "http://www.rentalhomesplus.com/results.aspx?page=results&stype=zip&zip=" + theZip + "&rad=" + rad + url;
	}
	else{
	  qString = "http://www.rentalhomesplus.com/results.aspx?page=results&stype=zip&zip=" + theZip +url;
	  }
	window.document.location = qString;
	return false;
}
