//START QUICK SEARCH FUNCTIONS
function quickSearch(){
var area = document.frm_nav_props.area.options[document.frm_nav_props.area.selectedIndex].value;	
var lower_acres = document.frm_nav_props.acres_min.options[document.frm_nav_props.acres_min.selectedIndex].value;
var beds = document.frm_nav_props.beds.options[document.frm_nav_props.beds.selectedIndex].value;
var baths = document.frm_nav_props.baths.options[document.frm_nav_props.baths.selectedIndex].value;
var lower_price = document.frm_nav_props.lower_price.value;
var upper_price = document.frm_nav_props.upper_price.value;
var targ = "processMLS.asp?Process=quick_search&area="+area+"&lower_price="+lowerPrice +"&upper_price="+upperPrice+"&lower_acres="+lower_acres+"&beds="+beds+"&baths="+baths+"&ms="+new Date().getTime();

}


var preDivContent;
var schoolset;
var address2,mls2,price2,class2,type2,sqrft2,img2,id;
var user_id = "";
var areaProcess = "";

//START GOOGLE MAP FUNCTIONS
function hideMap(){
	document.getElementById("mapit").innerHTML = "";
}

function loadMap(address){	
	if (GBrowserIsCompatible()) {
		address2 = address;
		//document.getElementById("mapit").innerHTML = "<span class='hide'>|<a  href='javascript:hideMap();'>Hide this map</a>|</span><br><div id='map' style='width: 500px; height: 300px'></div>";
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		
		var geocoder = new GClientGeocoder();
	  if (geocoder) {
		geocoder.getLatLng(
		  address,
		  function(point) {
			if (!point) {
			  alert(address + " not found");
			} else {
			  map.setCenter(point, 13);
			  var icon = new GIcon();
				icon.image = "http://wdidx.com/legacy/rwc/icon/go-home.ico";
				icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
				icon.iconSize = new GSize(30, 30);
				icon.shadowSize = new GSize(34, 30);
				icon.iconAnchor = new GPoint(6, 20);
				icon.infoWindowAnchor = new GPoint(5, 1);
			  var marker = new GMarker(point,icon);
			  map.addOverlay(marker);
			  //marker.openInfoWindowHtml(address);
			 // 	  marker.openInfoWindowHtml("<div align='left'>MLS Number: <b>" + mls2 + "</b><br>Price: <b>"  + price2 +"</b><br>Class: <b>"  + class2 + "</b><br>Type: <b>"  + type2 +"</b><br>Aprx Sqrft: <b>"  + sqrft2 +"</b><br>More details</div>");
	  
		/*GEvent.addListener(marker, "click", function() {
    		marker.openInfoWindowHtml("<div align='left'>MLS Number: <b>" + mls2 + "</b><br>Price: <b>"  + price2 +"</b><br>Class: <b>"  + class2 + "</b><br>Type: <b>"  + type2 +"</b><br>Aprx Sqrft: <b>"  + sqrft2 +"</b><br>More details</div>");
		});*/
		
			}
		  }
		);
	  }
		self.scrollTo(0, 100);
	}
}

function showAddress(address) {
	
}

function addToMap(response)
{
	var icon = new GIcon();
	icon.image = "http://durangomountainhome.com/icon/House-1.ico";
	icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	icon.iconSize = new GSize(12, 20);
	icon.shadowSize = new GSize(22, 20);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
      // Retrieve the object
    var  place = response.Placemark[0];

      // Retrieve the latitude and longitude
   var point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);

	map.setCenter(point, 16);
      // Create a marker
	var marker = new GMarker(point,icon);
      // Add the marker to map
    map.addOverlay(marker);
	  
      // Add address information to marker
	
	  marker.openInfoWindowHtml("<div align='left'>MLS Number: <b>" + mls2 + "</b><br>Price: <b>"  + price2 +"</b><br>Class: <b>"  + class2 + "</b><br>Type: <b>"  + type2 +"</b><br>Aprx Sqrft: <b>"  + sqrft2 +"</b><br>More details</div>");
	  
		GEvent.addListener(marker, "click", function() {
    		marker.openInfoWindowHtml("<div align='left'>MLS Number: <b>" + mls2 + "</b><br>Price: <b>"  + price2 +"</b><br>Class: <b>"  + class2 + "</b><br>Type: <b>"  + type2 +"</b><br>Aprx Sqrft: <b>"  + sqrft2 +"</b><br>More details</div>");
		});
	  
}
   
function showSchoolProps(){
	document.getElementById("school_search").innerHTML = preDivContent
	document.getElementById("school_search").style.background='url() center center no-repeat';
	schoolset = 1;
}

function hideSchoolProps(){
	preDivContent = document.getElementById("school_search").innerHTML
	document.getElementById("school_search").style.background='url(http://wdidx.com/legacy/rwc/images/school.jpg) center right no-repeat';
	startSchoolContent = "<a style='padding-right:200px; padding-top:20px; padding-bottom:20px;' class='hide' href='javascript:showSchoolProps()'>Click here for school search</a>"
	document.getElementById("school_search").innerHTML = startSchoolContent
	schoolset = 0;
}

function AddArea(area){
	if(document.getElementById('selectedAreas').options[0].value == "1"){
		document.getElementById('selectedAreas').options[0] = null;
	}
	var boxLength = document.getElementById('selectedAreas').length;
	var selectedItem = document.getElementById('availableAreas').selectedIndex;
	var selectedText = document.getElementById('availableAreas').options[selectedItem].text;
	var selectedValue = document.getElementById('availableAreas').options[selectedItem].value;
	var i;
	var isNew = true;
	
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = document.getElementById('selectedAreas').options[i].text;
			if (thisitem == selectedText) {
				isNew = false;
				break;
			}
		}
	}
	
	/* Make sure the VALUE is valid */
	if (selectedValue.length < 1) {
		isNew = false;
	}

	if (isNew) {
		//navigator.userAgent.indexOf("")
		/* Added By: Dan L. - 06/04/2006 */
		/* Do W3C DOM Support Test (not supported by Safari) */
		if ((document.getElementById && document.createElement) && (navigator.userAgent.toLowerCase().indexOf("safari") <= -1)) {
			var newElem = document.createElement("OPTION")
			newElem.text = document.getElementById('availableAreas').options[selectedItem].text;
			newElem.value = document.getElementById('availableAreas').options[selectedItem].value;
			document.getElementById('selectedAreas').options.add(newElem);
		} else {
			newoption = new Option(selectedText, selectedValue, false, false);
			document.getElementById('selectedAreas').options[boxLength] = newoption;
		}
	}
	areaProcess = areaProcess + selectedValue +"~";
}

function AddFeaturArea(){
	areaProcess = areaProcess + document.getElementById('areaProcess').value +"~";
}

//Clean up after multi area search
function RemoveArea(){
	var boxLength = document.getElementById('selectedAreas').length;
	arrSelected = new Array();
	var count = 0;
	for (i = 0; i < boxLength; i++) {
		if (document.getElementById('selectedAreas').options[i].selected) {
			arrSelected[count] = document.getElementById('selectedAreas').options[i].value;}
			count++;
		}
	var x;
	for (i = 0; i < boxLength; i++) {
		for (x = 0; x < arrSelected.length; x++) {
			if (document.getElementById('selectedAreas').options[i].value == arrSelected[x]) {
				replaceVal = document.getElementById('selectedAreas').options[i].value+"~";
				areaProcess = areaProcess.replace(replaceVal,"");
				document.getElementById('selectedAreas').options[i] = null;
			}
		}
		boxLength = document.getElementById('selectedAreas').length;
	}
	
	if(boxLength < 1){
		if ((document.getElementById && document.createElement) && (navigator.userAgent.toLowerCase().indexOf("safari") <= -1)) {
			var newElem = document.createElement("OPTION")
			newElem.text = "*No Area Selected*";
			newElem.value =1;
			newElem.style.color="red";
			document.getElementById('selectedAreas').options.add(newElem);
		} else {
			newoption = new Option("*No Area Selected*", 1, false, false);
			newoption.style.color="red";
			document.getElementById('selectedAreas').options[0] = newoption;
		}
	}
}

//Create search properties based on db tables
function SearchProperties(id,search_type,watcher){
	
switch(search_type){
		case("residential"):{
						var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("commercial"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top ';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("land"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("farm_ranch"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("multifamily"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("lease"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("timesharefractional"):{
			var targ = "processMLS.asp?Process=search_props&id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		default:{			
			var targ = "search_props.asp?id="+id+"&search_type="+search_type+"&ms="+new Date().getTime();
			break;
		}
	}
	
	if(watcher == true){
		targ +="&watcher=true";
	}
	var http = getHTTPObject(); // We create the HTTP Object
	http.open('GET', targ, false);
	http.send(null);
	
	strHTML = http.responseText;
	document.getElementById("divSearch_Props").innerHTML = strHTML;
	
	
	 if(search_type != "commercial" && search_type != "lease"){
	 	hideSchoolProps();
	 }
}



function save_SearchProps(search_type){
	//alert(strHTML);
	var id = document.frm_nav_props.id.value;
	var limiter = "";
	//var search_type = thisType;
	setCookie('search_type', search_type);	
	setCookie('area_list', document.getElementById('selectedAreas').innerHTML);
	setCookie('area_process', areaProcess);
	
	var type = document.frm_nav_props.type.options[document.frm_nav_props.type.selectedIndex].value;
	setCookie('type', type);
	
	var lower_acres = document.frm_nav_props.acres_min.options[document.frm_nav_props.acres_min.selectedIndex].value;
	setCookie('lower_acres', lower_acres);
	var upper_acres = document.frm_nav_props.acres_max.options[document.frm_nav_props.acres_max.selectedIndex].value;
	setCookie('upper_acres', upper_acres);
	
	var sortit = document.frm_nav_props.sort.options[document.frm_nav_props.sort.selectedIndex].value;
	setCookie('sortit', sortit);
	
	if(search_type!="land"){
		var lower_sqf = document.frm_nav_props.sqft_min.options[document.frm_nav_props.sqft_min.selectedIndex].value;
		setCookie('lower_sqf', lower_sqf);
		var upper_sqf = document.frm_nav_props.sqft_max.options[document.frm_nav_props.sqft_max.selectedIndex].value;
		setCookie('upper_sqf', upper_sqf);
	}
	
	switch(search_type){
		case("residential"):{
			var title = "Residential";
			if (schoolset==1){
				showSchoolProps();
				setCookie('schoolset', schoolset);
				var high_school = document.frm_nav_props.high_school.options[document.frm_nav_props.high_school.selectedIndex].value;
				setCookie('high_school', high_school);
				var mid_school = document.frm_nav_props.mid_school.options[document.frm_nav_props.mid_school.selectedIndex].value;
				setCookie('mid_school', mid_school);
				var elem_school = document.frm_nav_props.elem_school.options[document.frm_nav_props.elem_school.selectedIndex].value;
				setCookie('elem_school', elem_school);
			}
			var beds = document.frm_nav_props.beds.options[document.frm_nav_props.beds.selectedIndex].value;
			setCookie('beds', beds);
			var baths = document.frm_nav_props.baths.options[document.frm_nav_props.baths.selectedIndex].value;
			setCookie('baths', baths);
			var garage = document.frm_nav_props.garage.options[document.frm_nav_props.garage.selectedIndex].value;
			setCookie('garage', garage);
			break;
		}
		case("commercial"):{
			var title = "Commercial";
			break;
		}
		case("land"):{
			var title = "Land";
			break;
		}
		case("farm_ranch"):{
			var title = "Farm & Ranch";
			break;
		}
		case("multifamily"):{
			var title = "Multi-Family";
			if (schoolset==1){
				showSchoolProps();
				setCookie('schoolset', schoolset);
				var high_school = document.frm_nav_props.high_school.options[document.frm_nav_props.high_school.selectedIndex].value;
				setCookie('high_school', high_school);
				var mid_school = document.frm_nav_props.mid_school.options[document.frm_nav_props.mid_school.selectedIndex].value;
				setCookie('mid_school', mid_school);
				var elem_school = document.frm_nav_props.elem_school.options[document.frm_nav_props.elem_school.selectedIndex].value;
			}
			setCookie('elem_school', elem_school);
			var beds = document.frm_nav_props.beds.options[document.frm_nav_props.beds.selectedIndex].value;
			setCookie('beds', beds);
			var baths = document.frm_nav_props.baths.options[document.frm_nav_props.baths.selectedIndex].value;
			setCookie('baths', baths);
			var garage = document.frm_nav_props.garage.options[document.frm_nav_props.garage.selectedIndex].value;
			setCookie('garage', garage);
			break;
		}
		case("lease"):{
			var title = "Lease";
			break;
		}
		case("timesharefractional"):{
			var title = "Timeshare";
			break;
		}
		default:{			
			var title = "";
			break;
		}
	}
	
	var lower_price = document.frm_nav_props.lower_price.value;
	setCookie('lower_price', lower_price);
	var upper_price = document.frm_nav_props.upper_price.value;
	setCookie('upper_price', upper_price);
	var thisSort = document.frm_nav_props.sort.options[document.frm_nav_props.sort.selectedIndex].value;
	setCookie('thisSort', thisSort);
	for (var i=0; i < document.frm_nav_props.sort_type.length; i++)
   {
   if (document.frm_nav_props.sort_type[i].checked)
      {
      var sort_type = document.frm_nav_props.sort_type[i].value;
	  setCookie('sort_type', sort_type);
      }
   }
	
	document.getElementById("saved").innerHTML = "<a class='hide' href=javascript:LoadSearchProperties('"+search_type+"','"+user_id+"');>Load Saved Search Properties</a>";		
}

function LoadSearchProperties(search_type,id){
	//var search_type = thisType;
	SearchProperties(user_id,search_type);
	
	if(getCookie('type') == null){
		document.frm_nav_props.type.value = "Any Type";
	}else{
		document.frm_nav_props.type.value = getCookie('type');
	}
	
	document.getElementById('selectedAreas').innerHTML = getCookie('area_list');
	areaProcess = setCookie('area_process');

	document.frm_nav_props.sort.value=getCookie('sortit');

	document.frm_nav_props.acres_min.value=getCookie('lower_acres');
	document.frm_nav_props.acres_max.value=getCookie('upper_acres');
	
	if(search_type!="land"){
		document.frm_nav_props.sqft_min.value=getCookie('lower_sqf');
		document.frm_nav_props.sqft_max.value=getCookie('upper_sqf');
	}	
	
	switch(search_type){
		case("residential"):{
			if(getCookie('schoolset') == 1){
			showSchoolProps();
			document.frm_nav_props.high_school.value=getCookie('high_school');
			document.frm_nav_props.mid_school.value=getCookie('mid_school');
			document.frm_nav_props.elem_school.value=getCookie('elem_school');
			}
			document.frm_nav_props.beds.value=getCookie('beds');
			document.frm_nav_props.baths.value=getCookie('baths');
			document.frm_nav_props.garage.value=getCookie('garage');
			
			break;
		}
		case("commercial"):{
			break;
		}
		case("land"):{
			break;
		}
		case("farm_ranch"):{
			break;
		}
		case("multifamily"):{
			if(getCookie('schoolset') == 1){
				showSchoolProps();
			document.frm_nav_props.beds.value=getCookie('beds');
			document.frm_nav_props.baths.value=getCookie('baths');
			document.frm_nav_props.garage.value=getCookie('garage');
			}
			break;
		}
		case("lease"):{
			break;
		}
		case("timesharefractional"):{
			break;
		}
		default:{
			break;
		}
	}
	
	document.frm_nav_props.lower_price.value=getCookie('lower_price');
	document.frm_nav_props.upper_price.value=getCookie('upper_price');
	document.frm_nav_props.sort.value=getCookie('thisSort');
	
	
	
   if (getCookie('sort_type') == "DESC")
      {
     document.frm_nav_props.sort_type[1].checked="true";
      }else{
	  document.frm_nav_props.sort_type[0].checked="true";
	  }
	
	switch(search_type){
		case("residential"):{
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("commercial"):{
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top ';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("land"):{
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("farm_ranch"):{
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("multifamily"):{
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("lease"):{
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		case("timesharefractional"):{
			document.getElementById("li_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/left_on.gif) no-repeat left top';
			document.getElementById("li_lease").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_land").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			document.getElementById("li_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/left.gif) no-repeat left top';
			
			document.getElementById("a_timesharefractional").style.background='url(http://wdidx.com/legacy/rwc/images/right_on.gif) no-repeat right top';
			document.getElementById("a_lease").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_multifamily").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_commercial").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_land").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_farm_ranch").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			document.getElementById("a_residentail").style.background='url(http://wdidx.com/legacy/rwc/images/right.gif) no-repeat right top';
			break;
		}
		default:{			
			break;
		}
	}
}


//Generate properties
function DisplayPropertyType(search_type){
	if(document.getElementById("areaProcess").value.length > 0){
		areaProcess = document.getElementById("areaProcess").value;
		//alert("in")
	}
	if(areaProcess ==""){
		alert("Please select the area you want to search");
		return;
	}
	/* Setup our variables: */
	var page = 1;
	var records = 10;
	var upper_limit = 50;
	var id = document.frm_nav_props.id.value;
	var limiter = "";
	//var search_type = thisType;
	var type = document.frm_nav_props.type.options[document.frm_nav_props.type.selectedIndex].value;
	
	var area = areaProcess;
	if(search_type!="lease"){
	var lower_acres = document.frm_nav_props.acres_min.options[document.frm_nav_props.acres_min.selectedIndex].value;
	var upper_acres = document.frm_nav_props.acres_max.options[document.frm_nav_props.acres_max.selectedIndex].value;
	}
	if(search_type!="land"){
		var lower_sqf = document.frm_nav_props.sqft_min.options[document.frm_nav_props.sqft_min.selectedIndex].value;
		var upper_sqf = document.frm_nav_props.sqft_max.options[document.frm_nav_props.sqft_max.selectedIndex].value;
		if(document.frm_nav_props.high_school){
			var high_school = document.frm_nav_props.high_school.options[document.frm_nav_props.high_school.selectedIndex].value;
			var mid_school = document.frm_nav_props.mid_school.options[document.frm_nav_props.mid_school.selectedIndex].value;
			var elem_school = document.frm_nav_props.elem_school.options[document.frm_nav_props.elem_school.selectedIndex].value;
		}
	}
	
	switch(search_type){
		case("residential"):{
			var title = "Residential";		
			var beds = document.frm_nav_props.beds.options[document.frm_nav_props.beds.selectedIndex].value;
			var baths = document.frm_nav_props.baths.options[document.frm_nav_props.baths.selectedIndex].value;
			var garage = document.frm_nav_props.garage.options[document.frm_nav_props.garage.selectedIndex].value;
			
			break;
		}
		case("commercial"):{
			var title = "Commercial";
			break;
		}
		case("land"):{
			var title = "Land";
			break;
		}
		case("farm_ranch"):{
			var title = "Farm & Ranch";
			break;
		}
		case("multifamily"):{
			var title = "Multi-Family";
			var beds = document.frm_nav_props.beds.options[document.frm_nav_props.beds.selectedIndex].value;
			var baths = document.frm_nav_props.baths.options[document.frm_nav_props.baths.selectedIndex].value;
			var garage = document.frm_nav_props.garage.options[document.frm_nav_props.garage.selectedIndex].value;
			break;
		}
		case("lease"):{
			var title = "Lease";
			break;
		}
		case("timesharefractional"):{
			var title = "Timeshare";
			break;
		}
		default:{			
			var title = "";
			break;
		}
	}
	
	var lower_price = document.frm_nav_props.lower_price.value;
	var upper_price = document.frm_nav_props.upper_price.value;
	var thisSort = document.frm_nav_props.sort.options[document.frm_nav_props.sort.selectedIndex].value;
	
	for (var i=0; i < document.frm_nav_props.sort_type.length; i++)
   {
   if (document.frm_nav_props.sort_type[i].checked)
      {
      var sort_type = document.frm_nav_props.sort_type[i].value;
      }
   }
	
	var visitor_name,visitor_email,visitor_phone
	if(document.frm_nav_props.capture.value == "1"){
		visitor_name = document.frm_nav_props.visitor_name.value;
		visitor_email = document.frm_nav_props.visitor_email.value;
		visitor_phone = document.frm_nav_props.visitor_phone.value;
	}
	
	var targ = "processMLS.asp?Process=display_props&id="+id+"&search_type="+search_type+"&sort="+thisSort+"&sort_type="+sort_type+"&area="+area+"&type="+type+"&lower_price="+lower_price +"&upper_price="+upper_price+"&lower_acres="+lower_acres+"&upper_acres="+upper_acres+"&lower_sqf="+lower_sqf+"&upper_sqf="+upper_sqf+"&beds="+beds+"&baths="+baths+"&garage="+garage+"&upper_limit="+upper_limit+"&high_school="+high_school+"&mid_school="+mid_school+"&elem_school="+elem_school+"&page="+page+"&records="+records+"&vname="+visitor_name+"&vemail="+visitor_email+"&vphone="+visitor_phone+"&ms="+new Date().getTime();
	//alert(targ);
		switch(search_type){
		case("residential"):{
			var title = "Residential";			
			break;
		}
		case("commercial"):{
			var title = "Commercial";
			break;
		}
		case("land"):{
			var title = "Land";
			break;
		}
		case("farm_ranch"):{
			var title = "Farm & Ranch";
			break;
		}
		case("multifamily"):{
			var title = "Multi-Family";
			break;
		}
		case("lease"):{
			var title = "Lease";
			break;
		}
		case("timesharefractional"):{
			var title = "Timeshare";
			break;
		}
		default:{			
			var title = "";
			break;
		}
	}
	
	var http = getHTTPObject(); // We create the HTTP Object 
	http.open('GET', targ, false);
	http.send(null);
	strHTML = http.responseText;
		 var date = new Date();
	var curDate = null;
	

	document.getElementById("divBottom").innerHTML = "<span class='page_header'><strong>" + title + " Search Results</strong></span><br>"+strHTML;		

	window.location.hash="PROPERTIES";

}



function DisplayThisPage(morepages,id, searchType, thisSort, sortType, area, type, lowerPrice, upperPrice, beds, baths, garage, lower_acres, upper_acres, lower_sqf, upper_sqf, page, records, upper_limit, high_school, mid_school, elem_school){
	var targ = "processMLS.asp?Process=display_props&id="+id+"&search_type="+searchType+"&sort="+thisSort+"&sort_type="+sortType+"&area="+area+"&type="+type+"&lower_price="+lowerPrice +"&upper_price="+upperPrice+"&lower_acres="+lower_acres+"&upper_acres="+upper_acres+"&lower_sqf="+lower_sqf+"&upper_sqf="+upper_sqf+"&beds="+beds+"&baths="+baths+"&garage="+garage+"&upper_limit="+upper_limit+"&high_school="+high_school+"&mid_school="+mid_school+"&elem_school="+elem_school+"&page="+page+"~"+morepages+"&records="+records+"&ms="+new Date().getTime();
		switch(searchType){
		case("residential"):{
			var title = "Residential";			
			break;
		}
		case("commercial"):{
			var title = "Commercial";
			break;
		}
		case("land"):{
			var title = "Land";
			break;
		}
		case("farm_ranch"):{
			var title = "Farm & Ranch";
			break;
		}
		case("multifamily"):{
			var title = "Multi-Family";
			break;
		}
		case("lease"):{
			var title = "Lease";
			break;
		}
		case("timesharefractional"):{
			var title = "Timeshare";
			break;
		}
		default:{			
			var title = "";
			break;
		}
	}
	
	var http = getHTTPObject(); // We create the HTTP Object 
	http.open('GET', targ, false);
	http.send(null);
	strHTML = http.responseText;
		 var date = new Date();
	var curDate = null;
	

	document.getElementById("divBottom").innerHTML = "<span class='page_header'><strong>" + title + " Search Results</strong></span><br>"+strHTML;		

	window.location.hash="PROPERTIES";
	//DisplayLeftNav(id,searchType, thisSort, sortType, area,type,lowerPrice,upperPrice,beds,baths,garage,page,records);
}

function LoadPage(navType, id,capture,def_search_type){
	//alert("navType: "+navType + " id: " + id + " capture: " + capture + " def_search_type: "+ def_search_type);
	var http = getHTTPObject(); // We create the HTTP Object
	var strHTML;
	user_id = id;
	if(def_search_type == undefined){
		def_search_type = "residential";
	}
	
	if((navType == "0") || (navType == "1")) {
		/*Load Disclaimer - This has been modified for a newer agreement.
		*/
		//Disclaimer accepted load search default residential
		var targ = "processMLS.asp?Process=nav_properties&id="+id+"&capture="+capture+"&ms="+new Date().getTime();
			http.open('GET', targ, false);
			http.send(null);
			
			strHTML = http.responseText;
			document.getElementById("divHeader").innerHTML = strHTML;
			SearchProperties("'"+id+"'",def_search_type);
	}else if(navType == "2"){
		//LOAD REALTY WATCH
		var targ = "processMLS.asp?Process=nav_properties&watcher=true&id="+id+"&ms="+new Date().getTime();
		//alert(targ);
			http.open('GET', targ, false);
			http.send(null);
			
			strHTML = http.responseText;
			document.getElementById("divHeader").innerHTML = strHTML;
			SearchProperties("'"+id+"'",def_search_type,true);
	}else{
		return;
	}
	

	//http.open('GET', targ, false);
	//http.send(null);
	
	//strHTML = http.responseText;
	//document.getElementById("divHeader").innerHTML = strHTML;
	if(getCookie('search_type') != null){
		if(document.getElementById("saved")){
		document.getElementById("saved").innerHTML = "<a href=javascript:LoadSearchProperties('"+getCookie('search_type')+"','"+user_id+"');>Load Saved Search Properties</a>";
		}
	}
	
	disp_save_prop();
	

}

function prop_display(id,search_type,mls_number){
	//var sort = document.frm_nav_props.sort.value
	var http = getHTTPObject(); // We create the HTTP Object
	if(id == ""){
		id = 59;
	}
	//alert("ID "+id+" Search" + searchType + " MLS number " + mls_number);
	
	if(search_type ==""){
		search_type ="mls_number"
	}
	
	if(mls_number == "mls_number"){
		if(document.frm_nav_props.mlsnum.value == ""){
			alert("Please enter the MLS number");
			document.frm_nav_props.mlsnum.style.background="#EEAAAA";
			return;
		}
		mls_number = document.frm_nav_props.mlsnum.value;
	}
	
	var targ = "processMLS.asp?process=mls_listing_detail&id="+id+"&search_type="+search_type+"&mls_number="+mls_number+"&ms="+new Date().getTime();
	var strHTML;
	http.open('GET', targ, false);
	http.send(null);
	strHTML = http.responseText;
	//alert(strHTML);
	document.getElementById("divMiddle").innerHTML = strHTML;
	window.location.hash="LISTING_DETAILS";
	if(search_type == "mls_number"){
		alert("Search Complete");
	}else{
	}
}

function del_save_prop(save_num){
	switch (save_num){
		case(1):{
			Delete_Cookie('mls_num1','','');
			break;
		}
		case(2):{
			Delete_Cookie('mls_num2','','');
			break;
		}
		case(3):{
			Delete_Cookie('mls_num3','','');
			break;
		}
		case(4):{
			Delete_Cookie('mls_num4','','');
			break;
		}
		case(5):{
			Delete_Cookie('mls_num5','','');
			break;
		}
		default:{		
			break;
		}
	}
	disp_save_prop();
}

function disp_save_prop(){
	
if(getCookie('mls_num1') != null || getCookie('mls_num2') != null || getCookie('mls_num3') != null || getCookie('mls_num4') != null || getCookie('mls_num5') != null ){
	innHTML="<span class='hide'>Saved Listings</span><table width='100%'><tr class='saved_prop_title' bgcolor='#EEEEEE'> <td align='center' >MLS#</td><td align='center' >Class</td><td align='center' >City</td><td align='center' >Price</td><td ></td></tr>";
	
	if(getCookie('mls_num1') != null){
		innHTML = innHTML+"<tr class='saved_prop_info' bgcolor='#FAFAFA'><td align='center'><a href=javascript:prop_display('"+getCookie('id')+"','"+getCookie('thisClass1')+"','"+getCookie('mls_num1')+"'); >"+getCookie('mls_num1')+"</a></td><td align='center' valign='top' >"+getCookie('thisClass1')+"</td><td valign='top' align='center' >"+getCookie('city1')+"</td><td valign='top' align='center' >$"+CurrencyFormatted(getCookie('price1'))+"</td><td valign='top' bgcolor='#FAFAFA' id='remove'><a href='javascript:del_save_prop(1);'>Remove</a></td></tr>";
	}
	if(getCookie('mls_num2') != null){
		innHTML = innHTML+"<tr class='saved_prop_info' bgcolor='#FAFAFA'><td align='center'><a href=javascript:prop_display('"+getCookie('id')+"','"+getCookie('thisClass2')+"','"+getCookie('mls_num2')+"'); >"+getCookie('mls_num2')+"</a></td><td align='center' valign='top' >"+getCookie('thisClass2')+"</td><td valign='top' align='center' >"+getCookie('city2')+"</td><td valign='top' align='center' >$"+CurrencyFormatted(getCookie('price2'))+"</td><td valign='top' bgcolor='#FAFAFA' id='remove'><a href='javascript:del_save_prop(2);'>Remove</a></td></tr>";
	}
	if(getCookie('mls_num3') != null){
		innHTML = innHTML+"<tr class='saved_prop_info' bgcolor='#FAFAFA'><td align='center'><a href=javascript:prop_display('"+getCookie('id')+"','"+getCookie('thisClass3')+"','"+getCookie('mls_num3')+"'); >"+getCookie('mls_num3')+"</a></td><td align='center' valign='top' >"+getCookie('thisClass3')+"</td><td valign='top' align='center' >"+getCookie('city3')+"</td><td valign='top' align='center' >$"+CurrencyFormatted(getCookie('price3'))+"</td><td valign='top' bgcolor='#FAFAFA' id='remove'><a href='javascript:del_save_prop(3);'>Remove</a></td></tr>";
	}
	if(getCookie('mls_num4') != null){
		innHTML = innHTML+"<tr class='saved_prop_info' bgcolor='#FAFAFA'><td align='center'><a href=javascript:prop_display('"+getCookie('id')+"','"+getCookie('thisClass4')+"','"+getCookie('mls_num4')+"'); >"+getCookie('mls_num4')+"</a></td><td align='center' valign='top' >"+getCookie('thisClass4')+"</td><td valign='top' align='center' >"+getCookie('city4')+"</td><td valign='top' align='center' >$"+CurrencyFormatted(getCookie('price4'))+"</td><td valign='top' bgcolor='#FAFAFA' id='remove'><a href='javascript:del_save_prop(4);'>Remove</a></td></tr>";
	}
	if(getCookie('mls_num5') != null){
		innHTML = innHTML+"<tr class='saved_prop_info' bgcolor='#FAFAFA'><td align='center'><a href=javascript:prop_display('"+getCookie('id')+"','"+getCookie('thisClass5')+"','"+getCookie('mls_num5')+"'); >"+getCookie('mls_num5')+"</a></td><td align='center' valign='top' >"+getCookie('thisClass5')+"</td><td valign='top' align='center' >"+getCookie('city5')+"</td><td valign='top' align='center' >$"+CurrencyFormatted(getCookie('price5'))+"</td><td valign='top' bgcolor='#FAFAFA' id='remove'><a href='javascript:del_save_prop(5);'>Remove</a></td></tr>";
	}
		innHTML=innHTML+"</table>";
		if(document.getElementById("saved_props")){
			document.getElementById("saved_props").innerHTML = innHTML;
		}
}else{
	if(document.getElementById("saved_props")){
		document.getElementById("saved_props").innerHTML = "";
	}
}
		
}

function save_prop(id,mls_num, thisClass, city, price){

	if(getCookie('mls_num1') == null){
		setCookie('id', id);
		setCookie('mls_num1', mls_num);
		setCookie('thisClass1', thisClass);
		setCookie('city1', city);
		setCookie('price1', price);
		
	}else if(getCookie('mls_num2') == null){
		setCookie('mls_num2', mls_num);
		setCookie('thisClass2', thisClass);
		setCookie('city2', city);
		setCookie('price2', price);
		
	}else if(getCookie('mls_num3') == null){
		setCookie('mls_num3', mls_num);
		setCookie('thisClass3', thisClass);
		setCookie('city3', city);
		setCookie('price3', price);
		
	}else if(getCookie('mls_num4') == null){
		setCookie('mls_num4', mls_num);
		setCookie('thisClass4', thisClass);
		setCookie('city4', city);
		setCookie('price4', price);
		
	}else if(getCookie('mls_num5') == null){
		setCookie('mls_num5', mls_num);
		setCookie('thisClass5', thisClass);
		setCookie('city5', city);
		setCookie('price5', price);
		
	}else{
		alert("5 saved listings allowed.  Remove one to add another");
		return;
	}
	disp_save_prop();
}

function clear_prop(){
	//alert(strHTML);
	document.getElementById("divMiddle").innerHTML = "";
}
function hide_SearchProps(){
	//alert(strHTML);
	document.getElementById("divSearch_Props").innerHTML = "";
}
function loadButtons(){
		var http = getHTTPObject(); // We create the HTTP Object
		var strHTML;
		var targ = "LoadButtons.htm";
		http.open('GET', targ, false);
		http.send(null);
	
		strHTML = http.responseText;
		document.getElementById("divBottom").innerHTML = strHTML;
}
function DisplayLeftNav(id, searchType, thisSort, sortType, area, type, lowerPrice, upperPrice, beds, baths, garage, page, records){
	var targ = "nav_mlsnum_side.asp?id="+id+"&search_type="+searchType+"&sort="+thisSort+"&sort_type="+sortType+"&area="+area+"&type="+type+"&lower_price="+lowerPrice +"&upper_price="+upperPrice +"&page="+page+"&records="+records+"&beds="+beds+"&baths="+baths+"&garage="+garage+"&ms="+new Date().getTime();
		
	var http = getHTTPObject(); // We create the HTTP Object
	http.open('GET', targ, false);
	http.send(null);
	
	strHTML = http.responseText;
	document.getElementById("divLeftBottom").innerHTML = strHTML;
}
function ClearDivs(){
	document.getElementById("divTitle").innerHTML = "";
	document.getElementById("divHeader").innerHTML = "";
	document.getElementById("divLeftTop").innerHTML = "";
	document.getElementById("divMiddleTop").innerHTML = "";			
	document.getElementById("divRightTop").innerHTML = "";
	document.getElementById("divLeftMiddle").innerHTML = "";
	document.getElementById("divMiddle").innerHTML = "";
	document.getElementById("divRightMiddle").innerHTML = "";
	document.getElementById("divLeftBottom").innerHTML = "";
	document.getElementById("divMiddleBottom").innerHTML = "";
	document.getElementById("divRightBottom").innerHTML = "";
	//document.getElementById("divBottom").innerHTML = ""; THIS WILL CLEAR BUTTONS
	document.getElementById("divFooter").innerHTML = "";
	
}
function ShowDivs(){
	document.getElementById("divTitle").innerHTML = "divTitle";
	document.getElementById("divHeader").innerHTML = "divHeader";
	document.getElementById("divLeftTop").innerHTML = "divLeftTop";
	document.getElementById("divMiddleTop").innerHTML = "divMiddleTop";			
	document.getElementById("divRightTop").innerHTML = "divRightTop";
	document.getElementById("divLeftMiddle").innerHTML = "divLeftMiddle";
	document.getElementById("divMiddle").innerHTML = "divMiddle";
	document.getElementById("divRightMiddle").innerHTML = "divRightMiddle";
	document.getElementById("divLeftBottom").innerHTML = "divLeftBottom";
	document.getElementById("divMiddleBottom").innerHTML = "divMiddleBottom";
	document.getElementById("divRightBottom").innerHTML = "divRightBottom";
	//document.getElementById("divBottom").innerHTML = ""; THIS WILL CLEAR BUTTONS
	document.getElementById("divFooter").innerHTML = "divFooter";
}
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name, value) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+365);
    document.cookie= name + "=" + escape(value) + "; expires=" + exdate.toUTCString();
}

function Delete_Cookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function CurrencyFormatted(amount){
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function hide_props(){	
	document.getElementById("divBottom").innerHTML = "";
	window.location.hash = "HEADER";	
}

function save_arealist(){
	var objCheckBoxes = document.forms["frm_nav_props"].elements["areas"];
	var thecookie = "";
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	// set the check value for all check boxes
	for(var i = 0; i < countCheckBoxes; i++){
		if(objCheckBoxes[i].checked == true && objCheckBoxes[i].value!="undefined"){
			thecookie = thecookie+objCheckBoxes[i].value+"~"
		}
	}
	setCookie('custom_areas', thecookie);
	setCookie('set_custom_areas',1);
	alert("Custom areas saved successfully!")
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
 	w = window.open(theURL,winName,features);
	w.focus();
}
