var selectedState = "";
var openrealty = {
	
	// goes to OpenRealty
	searchProperties: function(){
	//	var st = $("#search_state:checked").val();
		var st = selectedState.toLowerCase();
		var type = $("#search_property_type").val();
		var location = $("#search_location").val();
		var minbeds = $("#beds-min").val();
		var maxbeds = $("#beds-max").val();
		var minsqft = $("#sqft-min").val();
		var maxsqft = $("#sqft-max").val();
		var extra = "";
		
		
		if((type == "" || st == "")){ // && $("#search_location option:selected").text() != "All Cities"
			alert("Please complete complete all the information before continuing. ");
		} else {
			
			var searchString = "/leasing/index.php?action=searchresults&state[]="+st+"&pclass[]="+type;
			
			if( location != ""){
				searchString += "&city[]="+location;
			}
			
			if( $("#extras").val() == "sqft" ){
				if(minbeds != ""){
					extra = "&sqft-min="+minsqft+"&sqft-max="+maxsqft;
				}
			} else if( $("#extras").val() == "beds" ){
				if(minsqft != ""){
					extra = "&beds-min="+minbeds+"&beds-max="+maxbeds;
				}
			} 
 			window.location = searchString+extra;
		}
	},
	
	// goes to WP place page
	searchPropertiesWP: function(){
		var st = $("#search_state:checked").val();
		var type = $("#search_property_type").val();
		var location = $("#search_location").val();
		
		if(type == "" || location == "" || st == ""){
			alert("Please complete complete all the information before continuing. ");
		} else {
			var searchString = "/"+type+"/"+location;
			window.location = searchString;
		}
	}
}
