// JavaScript Document
function getListCbox(elem,val){
	var boxes = elem;
	glist=""
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			if (glist.length > 1) {
				glist=glist+","

			}//ends IF
			if (val=="v"){
				glist=glist+boxes[i].value
			}
			if (val=="a"){
				glist=glist+boxes[i].alt
			}
		}//ends IF
	}
	return glist;
}
function getListSEL(elem,val){
	var boxes = elem;
	glist=""
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].selected == true){
			if (glist.length > 1) {
				glist=glist+","

			}//ends IF
			if (val=="v"){
				glist=glist+boxes[i].value
			}
			if (val=="a"){
				glist=glist+boxes[i].alt
			}
			if (val=="i"){
				glist=glist+boxes[i].innerHTML
			}
		}//ends IF
	}
	return glist;
}
function idxrSetCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+";";
}
function idxrSetCookie2(name, value, days, path, domain) {
		if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = date
	}
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") ;
  document.cookie = curCookie;
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}
function change2Multi(){
	document.getElementById("searchType").value="m"
	document.getElementById("singleLink").style.display="none"
	document.getElementById("multiLink").style.display="block"
	document.getElementById("countyListoff").style.display="none"
	document.getElementById("countyList").style.display="block"
}
function change2MultiSF(){
	document.getElementById("searchTypeSF").value="m"
	document.getElementById("singleLinkSF").style.display="none"
	document.getElementById("multiLinkSF").style.display="block"
	document.getElementById("districts").style.display="block"
	document.getElementById("searchTextSF").src="http://www.fixedrateproperties.com/qs_bar/district_page_03m.jpg"
}
function change2Single(){
	var boxes = document.IDXRmapForm.idxrcnty;
	for (i = 0; i < boxes.length; i++){
			boxes[i].checked = false
	}	
	document.getElementById("searchType").value="s"
	document.getElementById("singleLink").style.display="block"
	document.getElementById("multiLink").style.display="none"
	document.getElementById("countyList").style.display="none"
	document.getElementById("countyListoff").style.display="block"
}
function change2SingleSF(){
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	for (i = 0; i < boxes.length; i++){
			boxes[i].checked = false
	}
	document.getElementById("searchTypeSF").value="s"
	document.getElementById("singleLinkSF").style.display="block"
	document.getElementById("multiLinkSF").style.display="none"
	document.getElementById("districts").style.display="none"
	document.getElementById("searchTextSF").src="http://www.fixedrateproperties.com/qs_bar/district_page_03.jpg"
}
function setCounty(countyID){
	var boxes = document.IDXRmapForm.idxrcnty;
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].value == countyID){
			if (boxes[i].checked == true) {newSetting=false} else {newSetting= true}
			boxes[i].checked = newSetting
		}//ends IF
	}
	if (document.getElementById("searchType").value=="s"){
		doSearch(countyID)
	}
}
function setCountySF(countyID){
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].value == countyID){
			if (boxes[i].checked == true) {newSetting=false} else {newSetting= true}
			boxes[i].checked = newSetting
		}//ends IF
	}
	if (document.getElementById("searchTypeSF").value=="s"){
			url="http://www.fixedrateproperties.com/county_home_search.html?county="+countyID
			window.open(url,"_self")
	}
}
function setCountySF_add(countyID){
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].value == countyID){
			if (boxes[i].checked == true) {newSetting=false} else {newSetting= true}
			boxes[i].checked = newSetting
		}//ends IF
	}
	if (document.getElementById("searchTypeSF").value=="s"){
			doSearchSF(countyID)
	}
}
function doMultiSearch(){
	var boxes = document.IDXRmapForm.idxrcnty;
	countyID=""
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			if (countyID.length > 1) {
				countyID=countyID+","

			}//ends IF
			countyID=countyID+boxes[i].value
		}//ends IF
	}
	doSearch(countyID)
}
function doMultiSearchSF(){
	doSearchSF()
}
function back2County() {
	document.getElementById("customSfarMap").style.display="none"
	document.getElementById("customMainMap").style.display="block"
}
function doSearchSF(county){
	document.getElementById("customSfarMap").style.display="none"
	document.getElementById("customCriteria").style.display="block"
	 setupCustomCriteria()
}
function doSearch(countyID){
	//reset sfmap options
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	for (i = 0; i < boxes.length; i++){
			boxes[i].checked = false
	}
 document.getElementById("customMainMap").style.display="none"
 if (countyID.indexOf("222") > -1) {
//if (countyID.indexOf("222-remove") > -1) {
 	document.getElementById("customSfarMap").style.display="block"
	//reset main map if only san francisco is selected
	var boxes = document.IDXRmapForm.idxrcnty;
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].value == "222"){
			boxes[i].checked = false
		}
	}
 }
 else
 {
	 document.getElementById("customCriteria").style.display="block"
	 setupCustomCriteria()
 }
}
function setupCustomCriteria() {
	//read counties
	var boxes = document.IDXRmapForm.idxrcnty;
	countyID=""
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			if (countyID.length > 1) {
				countyID=countyID+","

			}//ends IF
			countyID=countyID+boxes[i].alt
		}//ends IF
	}
	//read districts if needed
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	districtID=""
	for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			if (districtID.length > 1) {
				districtID=districtID+","

			}//ends IF
			districtID=districtID+boxes[i].value
		}//ends IF
	}
	//turn on county lists
	var boxes = document.IDXRmapForm.idxrcnty;
	if (countyID.length > 1){
		for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			countyName=boxes[i].alt
			countyTable=countyName+"Cities"
			countyTableMulti=countyName+"Multi"
			if (boxes[i].alt== "lake"){countyNameDisplay="Lake"}
			if (boxes[i].alt== "marin"){countyNameDisplay="Marin"}
			if (boxes[i].alt== "mendocino"){countyNameDisplay="Mendocino"}
			if (boxes[i].alt== "monterey"){countyNameDisplay="Monterey"}
			if (boxes[i].alt== "napa"){countyNameDisplay="Napa"}
			if (boxes[i].alt== "sanbenito"){countyNameDisplay="San Benito"}
			if (boxes[i].alt== "sanmateo"){countyNameDisplay="San Mateo"}
			if (boxes[i].alt== "santaclara"){countyNameDisplay="Santa Clara"}
			if (boxes[i].alt== "santacruz"){countyNameDisplay="Santa Cruz"}
			if (boxes[i].alt== "solano"){countyNameDisplay="Solano"}
			if (boxes[i].alt== "sonoma"){countyNameDisplay="Sonoma"}
			if (boxes[i].alt== "yolo"){countyNameDisplay="Yolo"}
			if (boxes[i].alt== "sanfrancisco"){countyNameDisplay="San Francisco"}
			document.getElementById(countyTable).style.display="block";
			if (countyID.indexOf(",") > -1 || districtID.length > 2) {
				document.getElementById(countyTableMulti).innerHTML='<b>'+countyNameDisplay+' County</b>'
				document.getElementById('county').innerHTML="Multi-County"
			}
			if (countyID.indexOf(",") == -1 && districtID.length < 2){
				document.getElementById('county').innerHTML=countyNameDisplay
				document.getElementById("selectTitle").innerHTML="Select one or more Cities, or Enter a Zip Code Below."	
				document.getElementById("cnTitle").innerHTML="Cities"
			}
		}//ends IF
	}
	}
	//turn on district lists
	var boxes = document.IDXRmapFormSF.idxrcntySF;
	if (districtID.length > 1){
		for (i = 0; i < boxes.length; i++){
		if (boxes[i].checked == true){
			districtName=boxes[i].value
			districtTable=districtName
			districtTableMulti=districtName+"Multi"
			if (boxes[i].value== "district01"){districtNameDisplay="Northwest District"}
			if (boxes[i].value== "district2"){districtNameDisplay="Central West District"}
			if (boxes[i].value== "district3"){districtNameDisplay="Southwest District"}
			if (boxes[i].value== "district4"){districtNameDisplay="Twin Peaks West District"}
			if (boxes[i].value== "district5"){districtNameDisplay="Central District"}
			if (boxes[i].value== "district6"){districtNameDisplay="Central North District"}
			if (boxes[i].value== "district7"){districtNameDisplay="North District"}
			if (boxes[i].value== "district8"){districtNameDisplay="Northeast District"}
			if (boxes[i].value== "district9"){districtNameDisplay="Central East District"}
			if (boxes[i].value== "district10"){districtNameDisplay="Southeast District"}
			if (boxes[i].value== "district11"){districtNameDisplay="San Mateo NW District"}
			document.getElementById(districtTable).style.display="block";
			if (districtID.indexOf(",") > -1 ) {
				document.getElementById(districtTableMulti).innerHTML='<b>San Francisco County - '+districtNameDisplay+'</b>'
				document.getElementById('county').innerHTML="San Francisco County - Multi-District"
				document.getElementById("selectTitle").innerHTML="Select one or more Neighborhoods, or Enter a Zip Code Below."	
				document.getElementById("cnTitle").innerHTML="Neighborhoods"
			}
			if (districtID.indexOf(",") == -1 && countyID.length < 2){
				document.getElementById('county').innerHTML="San Francisco County - "+districtNameDisplay
				document.getElementById("selectTitle").innerHTML="Select one or more Neighborhoods, or Enter a Zip Code Below."	
				document.getElementById("cnTitle").innerHTML="Neighborhoods"
			}
			if (countyID.length > 2) {
				document.getElementById(districtTableMulti).innerHTML='<b>San Francisco County - '+districtNameDisplay+'</b>'
				document.getElementById('county').innerHTML="Multi-County"
				document.getElementById("selectTitle").innerHTML="Select one or more Cities/Neighborhoods, or Enter a Zip Code Below."	
				document.getElementById("cnTitle").innerHTML="Cities<br>and<br>Neighborhoods"
			}
		}//ends IF
		}	
	}
	if (countyID.indexOf("sanfrancisco") > -1){setSFARpType()}
}
function setSFARpType(){
		var boxes = document.SearchForm2.ptypedd;
		for (i = 0; i < boxes.length; i++){
			if (boxes[i].value != "CND"){
				boxes[i].selected=false
			}
			else
			{
				boxes[i].selected=true
			}//ends IF
		}	
}
function setType(ptype){
	if (ptype=="SFR"){
		document.getElementById("propertyCategory").value="RES"
		document.getElementById("PropertyType").value="SFR"
		document.getElementById("bedrooms").disabled=false
		document.getElementById("squareFeetsel").disabled=false
		document.getElementById("fullBaths").disabled=false
		document.getElementById("lotAcres").disabled=true
	}
		if (ptype=="SFRCND"){
		document.getElementById("propertyCategory").value="RES"
		document.getElementById("PropertyType").value="SFR,CND"
		document.getElementById("bedrooms").disabled=false
		document.getElementById("squareFeetsel").disabled=false
		document.getElementById("fullBaths").disabled=false
		document.getElementById("lotAcres").disabled=true
	}
		if (ptype=="CND"){
		document.getElementById("propertyCategory").value="RES"
		document.getElementById("PropertyType").value="CND"
		document.getElementById("bedrooms").disabled=false
		document.getElementById("squareFeetsel").disabled=false
		document.getElementById("fullBaths").disabled=false
		document.getElementById("lotAcres").disabled=true
	}
		if (ptype=="LL"){
		document.getElementById("propertyCategory").value="LL"
		document.getElementById("PropertyType").value="LL"
		document.getElementById("bedrooms").disabled=true
		document.getElementById("squareFeetsel").disabled=true
		document.getElementById("fullBaths").disabled=true
		document.getElementById("lotAcres").disabled=false
		
	}
		if (ptype=="RI"){
		document.getElementById("propertyCategory").value="RI"
		document.getElementById("PropertyType").value="RI"
		document.getElementById("bedrooms").disabled=true
		document.getElementById("squareFeetsel").disabled=true
		document.getElementById("fullBaths").disabled=true
		document.getElementById("lotAcres").disabled=true
	}
}
function subForm(){
	document.SearchForm2.submit()
}
function checkTag(tagName){
	readStatus=""
	if (document.getElementById(tagName)){
		readStatus="can read"
	}
	if (readStatus != "can read"){
		xText=document.getElementById("ihfSearchFormIDXR").innerHTML
		stID=xText.indexOf('name="'+tagName+'"')
		xText=xText.substr(0,stID-1)+" id='"+tagName+"' "+xText.substr(stID)
		document.getElementById("ihfSearchFormIDXR").innerHTML=xText
		readStatus="can not read"
	}
} //end function addTag
function readSearchProfile(){
	pageURL=document.URL
	if (pageURL.indexOf("&spid=") > -1){
		cityText=document.getElementById("ihfSearchFormIDXR").innerHTML
				//get cities
		if (document.form10.cityID) {
				checkTag("cityID")
				var boxes = document.form10.cityID;
				cities=""
				citiesID=""
				counties=""
				countiesID=""
				for (i = 0; i < boxes.length; i++){
					if (boxes[i].selected == true){
						if (cities.length > 1) {
							cities=cities+","
							citiesID=citiesID+","
						}//ends IF
						cities=cities+boxes[i].innerHTML
						citiesID=citiesID+boxes[i].value
						countyinfo=getCounty(boxes[i].value)
						countyID=countyinfo.substr(0,3)
						county=countyinfo.substr(3)
						if (counties.indexOf(county) == -1) {
							if (counties.length > 2){
								counties=counties+","+county
								countiesID=countiesID+","+countyID
							} else {
								counties=county
								countiesID=countyID
							}
						}
					}//ends IF
				}
		}
				//get zip codes
		checkTag("zip")
		var boxes = document.form10.zip;
		zipcodes=""
		for (i = 0; i < boxes.length; i++){
			if (boxes[i].selected == true){
				if (zipcodes.length > 1) {
					zipcodes=zipcodes+","
				}//ends IF
				zipcodes=zipcodes+boxes[i].value
			}//ends IF
		}	
		if (document.form10.MLSArea) {
			mlsarea=""
			districts=""
			districtsID=""
			var boxes = document.form10.MLSArea;
			for (i = 0; i < boxes.length; i++){
				if (boxes[i].selected == true){
					if (cities.length > 1) {
					cities=cities+","
				}//ends IF
					if (mlsarea.length > 1) {
						mlsarea=mlsarea+","
					}//ends IF
					districtinfo=getDistrict(boxes[i].value)
					districtID=districtinfo.substr(0,districtinfo.indexOf(","))
					districtName=districtinfo.substr(districtinfo.indexOf(",")+1)
					if (districts.indexOf(districtName) == -1) {
						if (districts.length > 2){
							districts=districts+","+districtName
							districtsID=districtsID+","+districtID
						} else {
							districts=districtName
							districtsID=districtID
						}
					}
					mlsarea=mlsarea+boxes[i].value
				}//ends IF
			}
			counties="San Francisco"
		}
		modifySearch="y"
		//get property type
		checkTag("PropertyType")
		PropertyType=document.getElementById("PropertyType").value
		if (PropertyType == "LL"){propertyCategory="LL"}
		if (PropertyType == "RI"){propertyCategory="RI"}
		//get searchProfileID
		checkTag("searchProfileID")
		searchProfileID=document.getElementById("searchProfileID").value
		//get min list price
		checkTag("minListPrice")
		minPrice=document.getElementById("minListPrice").value
		//get max list price
		checkTag("maxListPrice")
		maxPrice=document.getElementById("maxListPrice").value
		if (minPrice.indexOf(",") > -1){minPrice=minPrice.substr(0,minPrice.indexOf(","))+minPrice.substr(minPrice.indexOf(",")+1)}
		if (minPrice.indexOf(",") > -1){minPrice=minPrice.substr(0,minPrice.indexOf(","))+minPrice.substr(minPrice.indexOf(",")+1)}
		if (maxPrice.indexOf(",") > -1){maxPrice=maxPrice.substr(0,maxPrice.indexOf(","))+maxPrice.substr(maxPrice.indexOf(",")+1)}
		if (maxPrice.indexOf(",") > -1){maxPrice=maxPrice.substr(0,maxPrice.indexOf(","))+maxPrice.substr(maxPrice.indexOf(",")+1)}
		if (PropertyType.indexOf("SFR") > -1 || PropertyType.indexOf("CND") > -1){
			checkTag("bedrooms")
			bedrooms=document.getElementById("bedrooms").value
			checkTag("bathCount")
			fullbaths=document.getElementById("bathCount").value
		}
		if (PropertyType.indexOf("SFR") > -1 || PropertyType.indexOf("CND") > -1 || PropertyType.indexOf("RI") > -1){
			checkTag("squareFeet")
			tagName="squareFeet"
			if (document.getElementById(tagName)){
				squareFeet=document.getElementById("squareFeet").value
			}
		}
		if (PropertyType.indexOf("LL") > -1 ){
			checkTag("lotAcres")
			lotAcres=document.getElementById("lotAcres").value
		}	

		sendEmailYN="0"
		checkTag("sendEmailYN")
		if (document.getElementById("sendEmailYN").checked==true) {
			sendEmailYN="1"
		}
	}
} //end function readSearchProfile
function getCounty(cityID){
	cityCounties="Lake,162,164,172,420,466,468,499,520,551,962,Marin,69,83,193,234,283,299,348,404,422,455,476,533,554,593,611,629,646,739,792,807,818,836,856,906,935,940,1024,Mendocino,28,86,116,182,201,240,270,354,481,482,527,543,599,702,726,736,763,2682,955,1013,1031,Monterey,135,136,223,255,303,530,576,622,624,669,692,802,862,890,895,897,Napa,25,31,14409,74,115,154,218,595,639,731,902,1032,SanMateo,44,68,95,102,176,213,254,263,304,362,383,438,504,546,555,570,586,671,698,734,761,762,810,819,832,898,1029,SanBenito,41,385,616,770,823,891,947,SantaClara,122,210,324,513,514,517,556,574,583,590,677,822,831,844,854,917,SantaCruz,5,3864,37,70,89,96,132,192,253,287,445,475,495,508,518,771,846,857,860,888,992,1000,Solano,71,187,237,272,284,347,775,775,911,964,967,Sonoma,81,82,115,121,144,167,195,246,301,308,315,323,326,344,356,357,370,413,423,573,641,695,699,773,784,797,851,863,886,859,5794,969,982,1018,Yolo,131,281,1020,1027,SanFrancisco,222"
matchCity=','+cityID+','
cityPosition=cityCounties.indexOf(matchCity)
if (cityPosition > 0) {thisCountyName="Lake";thisCountyID="201"}
if (cityPosition > 45) {thisCountyName="Marin";thisCountyID="205"}
if (cityPosition > 158) {thisCountyName="Mendocino";thisCountyID="207"}
if (cityPosition > 253) {thisCountyName="Monterey";thisCountyID="211"}
if (cityPosition > 326) {thisCountyName="Napa";thisCountyID="212"}
if (cityPosition > 379) {thisCountyName="San Mateo";thisCountyID="225"}
if (cityPosition > 494) {thisCountyName="San Benito";thisCountyID="219"}
if (cityPosition > 531) {thisCountyName="Santa Clara";thisCountyID="227"}
if (cityPosition > 606) {thisCountyName="Santa Cruz";thisCountyID="228"}
if (cityPosition > 700) {thisCountyName="Solano";thisCountyID="232"}
if (cityPosition > 750) {thisCountyName="Sonoma";thisCountyID="233"}
if (cityPosition > 893) {thisCountyName="Yolo";thisCountyID="241"}
if (cityPosition > 916) {thisCountyName="San Francisco";thisCountyID="222"}
thisCountyInfo=thisCountyID+thisCountyName
return thisCountyInfo
}//end function getCounty
function getDistrict(mlsAREA){
	areaDistricts="district01,Central Richmond,Inner Richmond,Jordan Park/Laurel Heights,Lake,Outer Richmond,Sea Cliff,Lone Mountain,"
	areaDistricts=areaDistricts+"district2,Golden Gate Heights,Outer Parkside,Outer Sunset,Parkside,Central Sunset,Inner Sunset,Inner Parkside,"
	areaDistricts=areaDistricts+"district3,Lake Shore,Merced Heights,Pine Lake Park,Stonestown,Lakeside,Merced Manor,Ingleside Heights,Ingleside,Oceanview,"
	areaDistricts=areaDistricts+"district4,Balboa Terrace,Diamond Heights,Forest Hill,Forest Knolls,Ingleside Terrace,Midtown Terrace,St. Francis Wood,Miraloma Park,Forest Hill Extension,Sherwood Forest,Monterey Heights,Mount Davidson Manor,Westwood Highlands,Westwood Park,Sunnyside,West Portal,"
	areaDistricts=areaDistricts+"district5,Glen Park,Haight Ashbury,Noe Valley,Twin Peaks,Parnassus/Ashbury Heights,Buena Vista Park,Corona Heights,Clarendon Heights,Duboce Triangle,Eureka Valley/Dolores Heights,Mission Dolores,"
	areaDistricts=areaDistricts+"district6,Anza Vista,Hayes Valley,Lower Pacific Heights,Western Addition,Alamo Square,North Panhandle,"
	areaDistricts=areaDistricts+"district7,Marina,Pacific Heights,Presidio Heights,Cow Hollow,"
	areaDistricts=areaDistricts+"district8,Downtown,Financial District,Nob Hill,North Beach,Russian Hill,Van Ness/Civic Cente,Van Ness/Civic Center,Telegraph Hill,North Waterfront,Tenderloin,"
	areaDistricts=areaDistricts+"district9,Bernal Heights,Inner Mission,Mission Bay,Potrero Hill,South of Market,South Beach,Central Waterfront,"
	areaDistricts=areaDistricts+"district10,Bayview,Crocker Amazon,Excelsior,Outer Mission,Visitacion Valley,Portola,Silver Terrace,Mission Terrace,Hunters Point,Bayview Heights,"
	areaDistricts=areaDistricts+"district11,Original Daly City,Serramonte,Southern Hills,Westlake #1/Olympic,Westlake Heights,Westlake Highlands,Westlake Knolls,Broadmoor,Westlake Terrace,St. Francis Heights,Westlake Palisades,Blossom Valley,Crown Colony,Colma,Brisbane,Bayridge/Linda Vista,"
matchArea=','+mlsAREA+','
areaPosition=areaDistricts.indexOf(matchArea)
//document.write(matchArea+"<br>")
if (areaPosition > areaDistricts.indexOf("district01")) {thisDistrictID="district01";thisDistrictName="Northwest"}
if (areaPosition > areaDistricts.indexOf("district2")) {thisDistrictID="district2";thisDistrictName="Central West"}
if (areaPosition > areaDistricts.indexOf("district3")) {thisDistrictID="district3";thisDistrictName="Southwest"}
if (areaPosition > areaDistricts.indexOf("district4")) {thisDistrictID="district4";thisDistrictName="Twin Peaks West"}
if (areaPosition > areaDistricts.indexOf("district5")) {thisDistrictID="district5";thisDistrictName="Central"}
if (areaPosition > areaDistricts.indexOf("district6")) {thisDistrictID="district6";thisDistrictName="Central North"}
if (areaPosition > areaDistricts.indexOf("district7")) {thisDistrictID="district7";thisDistrictName="North"}
if (areaPosition > areaDistricts.indexOf("district8")) {thisDistrictID="district8";thisDistrictName="Northeast"}
if (areaPosition > areaDistricts.indexOf("district9")) {thisDistrictID="district9";thisDistrictName="Central East"}
if (areaPosition > areaDistricts.indexOf("district10")) {thisDistrictID="district10";thisDistrictName="Southeast"}
if (areaPosition > areaDistricts.indexOf("district11")) {thisDistrictID="district11";thisDistrictName="San Mateo NW"}
returnDistrictInfo=thisDistrictID+","+thisDistrictName
return returnDistrictInfo
}//end function getCounty
function setupCities(){
	if (counties.indexOf(",") > -1) {
		document.getElementById("county").innerHTML="Multi-County/District"
	}
	else
	{
		document.getElementById("county").innerHTML=counties
		if (counties == "San Francisco") {
			document.getElementById("county").innerHTML=counties+" - "+districts+" District"
		}
	}
	setupCustomCriteria()
	var boxes = document.SearchForm2.cityID
	for (i = 0; i < boxes.length; i++){
		cityCode=","+boxes[i].value+","
		citiesIDtemp=","+citiesID+","
		if (citiesIDtemp.indexOf(cityCode) > -1){
			boxes[i].checked = true
		}//ends IF
	}
	var boxes = document.SearchForm2.MLSArea
	for (i = 0; i < boxes.length; i++){
		cityCode=","+boxes[i].alt+","
		citiesIDtemp=","+mlsarea+","
		boxes[i].value=boxes[i].alt
		if (citiesIDtemp.indexOf(cityCode) > -1){
			boxes[i].checked = true
		}//ends IF
	}
	
} //end function setupCities
function swapMLSArea() {
	var boxes = document.SearchForm2.MLSArea
	for (i = 0; i < boxes.length; i++){
		boxes[i].value=boxes[i].alt
	}
}
// function used to select all cities/districts on search pages
function selectAllCities(cityList){
		currentPage=document.URL
	swapD="n"
	if (currentPage.indexOf("_home_") > -1) {
		var boxes = document.form10.cityID;
		swapD="y"
	}
	if (currentPage.indexOf("_home_") == -1) {
		var boxes = document.SearchForm2.cityID;
		swapD="y"
	}	
	for (i = 0; i < boxes.length; i++){
		cityValue=","+boxes[i].value+","
		if (cityList.indexOf(cityValue) > -1){
			boxes[i].checked=true
		}//ends IF
	}
}
// function used to de-select all cities/districts on search pages
function deSelectAllCities(cityList){
		currentPage=document.URL
	swapD="n"
	if (currentPage.indexOf("_home_") > -1) {
		var boxes = document.form10.cityID;
		swapD="y"
	}
	if (currentPage.indexOf("_home_") == -1) {
		var boxes = document.SearchForm2.cityID;
		swapD="y"
	}	
	for (i = 0; i < boxes.length; i++){
		cityValue=","+boxes[i].value+","
		if (cityList.indexOf(cityValue) > -1){
			boxes[i].checked=false
		}//ends IF
	}
}
// function used to select all cities/districts on search pages
function selectAllDistricts(districtList){
	currentPage=document.URL
	swapD="n"
	if (currentPage.indexOf("_home_") > -1) {
		var boxes = document.form10.MLSArea;
		swapD="y"
	}
	if (currentPage.indexOf("_home_") == -1) {
		var boxes = document.SearchForm2.MLSArea;
		swapD="y"
	}	
	for (i = 0; i < boxes.length; i++){
		districtValue=","+boxes[i].value+","
		if (districtList.indexOf(districtValue) > -1  ){
			boxes[i].checked=true
		}//ends IF
	}
}
// function used to select all cities/districts on search pages
function deSelectAllDistricts(districtList){
	currentPage=document.URL
	swapD="n"
	if (currentPage.indexOf("_home_") > -1) {
		var boxes = document.form10.MLSArea;
		swapD="y"
	}
	if (currentPage.indexOf("_home_") == -1) {
		var boxes = document.SearchForm2.MLSArea;
		swapD="y"
	}	
	for (i = 0; i < boxes.length; i++){
		districtValue=","+boxes[i].value+","
		if (districtList.indexOf(districtValue) > -1  ){
			boxes[i].checked=false
		}//ends IF
	}
}
//ihomefinder function
function changeClass(obj,clsName){
				obj.className=clsName;
				obj.style.cursor='hand';
}
