var bullet = '•';

function setcookie(fieldname, fieldvalue,  displayname, display, ifreplace, cityidsuffix) {
//alert(document.cookie.toString().replace(/\^\^/g,'\n'))
//alert(fieldname + ' | ' + fieldvalue + ' | ' + displayname + ' | ' + display)
//display = display.replace(':', '&#58;')
	var thiscookievals='';
	var cookieval='';
	var thiscookiedisp='';
	var cookiedisp='';
	var fieldvaluechar='';
	var newvalue='';
	var x='';

	if (cityidsuffix != '' && cityidsuffix != undefined) {
		fieldvalueidname = fieldvalue + cityidsuffix
	} else {
		fieldvalueidname = fieldvalue
	}
	
	//these fields are used to store the formatted values with spaces stripped out - because the spaces
	//get lost when moving to store in the server side cookie.
	var cookiefieldvalue='';
	var cookiedisplayname='';
	var cookiedisplay='';
	
	var cookiename="searchcookie";
	
	var dc=document.cookie;
	csearchcookie='';
	//first, lets get the search cookie
	if (dc.length != 0) {
		begin = dc.indexOf(cookiename);
		if (begin != -1) {
			end = dc.indexOf(";", begin);
			if (end == -1) {
				end = dc.length;
			}
			csearchcookie = (dc.substring(begin,end));
		}
	}

	searchfield='^^' + fieldname.toLowerCase() + '|'
	begin = csearchcookie.indexOf(searchfield);
	
	cookiesuffix="";
	cookieprefix=""
	if (begin != -1) {
		cookieprefix=(csearchcookie.substring(0,begin + 2))  // we add two to get the ^^ delimiter
	}
	else
	{
	cookieprefix=csearchcookie;
	}
	
	if (cookieprefix==""){
		cookieprefix="searchcookie=^^";
	}
	
	x=getCookie(fieldname.toLowerCase());
	if (x==null) {
		x='';
		cookiesuffix='^^';
		cvalue='';
		cdisplayvalue=''
	}
	else
	{	
		array = x.split("|");
		cvalue=array[0];
		cdisplayvalue=array[2];
		begin = csearchcookie.indexOf(x);
		cookiesuffix =(csearchcookie.substring(begin + x.length));
	}
	
	newvalue=''

	for (i=0; i<fieldvalue.length; i++) {
		fieldvaluechar = fieldvalue.substring(i,i+1);
		if (fieldvaluechar == ' ') {
			fieldvaluechar = "_";
		}
		newvalue=newvalue+=fieldvaluechar;
	}	
	cookiefieldvalue = newvalue
	
	newvalue=''
	for (i=0; i<displayname.length; i++) {
		fieldvaluechar = displayname.substring(i,i+1);
		if (fieldvaluechar == ' ') {
			fieldvaluechar = "_";
		}
		newvalue=newvalue+=fieldvaluechar;
	}	
	cookiedisplayname = newvalue

	newvalue=''

	for (i=0; i<display.length; i++) {
		fieldvaluechar = display.substring(i,i+1);
		if (fieldvaluechar == ' ') {
			fieldvaluechar = "_";
		}
		newvalue=newvalue+=fieldvaluechar;
	}
	cookiedisplay = newvalue

	if (cookiefieldvalue.length != 0) {

		if (ifreplace==1) {
			document.cookie = cookieprefix + fieldname.toLowerCase() + '|' + cookiefieldvalue + '|' + cookiedisplayname + '|' + cookiedisplay  + cookiesuffix + ';path=/'
		}else{	
			//lets see if this value is already selected
			//add commas to both ends of string so that we can easily find the cookie value we are looking for
			var thiscookievals = ',' + x.substring(0, x.indexOf('|')) + ','
			cookieval = thiscookievals.indexOf(',' + cookiefieldvalue + ',');
			
			var thiscookiedisp = x.substring(x.indexOf('|') + 1, x.length);
			thiscookiedisp = thiscookiedisp.substring(thiscookiedisp.indexOf('|') + 1, thiscookiedisp.length);
			thiscookiedisp = ':' + thiscookiedisp.substring(0, thiscookiedisp.length) + ':'
			cookiedisp = thiscookiedisp.indexOf(':' + cookiedisplay + ':');

			if (cookieval != -1 && cookiedisp != -1) { 
			   //value already exists -- loop through current cookie values and remove unchecked value
				try {
					if (document.getElementById(fieldvalueidname).type == 'checkbox') {
						if (document.getElementById(fieldvalueidname).checked != true) {
							var cvalueArray = cvalue.split(',');
							var newcvalue = ''
							var cdisplayvalueArray = cdisplayvalue.split(':');
							var newcdisplayvalue = ''

							for (var i=0; i < cvalueArray.length; i++) {
								//alert(cookiefieldvalue + '|' + cookiedisplay + '\n' + cvalueArray[i] + '|' + cdisplayvalueArray[i]);
								if (cookiefieldvalue + '|' + cookiedisplay != cvalueArray[i] + '|' + cdisplayvalueArray[i]) {
									newcvalue = newcvalue + cvalueArray[i] + ','
									newcdisplayvalue = newcdisplayvalue + cdisplayvalueArray[i] + ':'
								}
							}
							newcvalue = newcvalue.substring(0, newcvalue.length - 1)
							newcdisplayvalue = newcdisplayvalue.substring(0, newcdisplayvalue.length - 1)
							document.cookie = cookieprefix + fieldname.toLowerCase() + '|' + newcvalue + '|' + cookiedisplayname + '|' + newcdisplayvalue + cookiesuffix + ';path=/'
						}
					}
				}
				catch (e) {}
			}else {
				if (cvalue=='') {
					document.cookie = cookieprefix   + fieldname.toLowerCase() + '|' + cookiefieldvalue + '|' + cookiedisplayname + '|' + cookiedisplay + cookiesuffix + ';path=/'
				}else {
			        document.cookie = cookieprefix + fieldname.toLowerCase() + '|' + cookiefieldvalue + ',' + cvalue + '|' + cookiedisplayname + '|' + cookiedisplay + ':' + cdisplayvalue + cookiesuffix + ';path=/'
				}
			} 
		}
	}else{
		document.cookie = cookieprefix.substring(0,cookieprefix.length - 2) + cookiesuffix + ';path=/'
	}	
	try {
	x=setdisplaybox()
	}
	catch (e){}
}

function getCookie(name){
	var cname = name + "=";
	var dc = document.cookie;
	var cookieprefix = "";
	var fieldvaluechar='';
	var newvalue='';
	var cookiename="searchcookie";
	var returnvalue = '';
	
	
	//first, lets get the search cookie
	if (dc.length != 0) {
		begin = dc.indexOf(cookiename);
		if (begin != -1) {
			end = dc.indexOf(";", begin);
			if (end == -1) {
				end = dc.length;
			}	
			csearchcookie = (dc.substring(begin,end));
		}	
		else
			{
			return null;
			}
			
		//now, lets get the search item	from csearchcookie
		searchfield='^^' + name + '|'
		begin = csearchcookie.indexOf(searchfield);
		if (begin != -1) {
			begin += cname.length;
			end = csearchcookie.indexOf("^^", begin);
			
			if (end == -1) {
				end = dc.indexOf(";", begin);
				if (end == -1) {
					end = dc.length;
				}
			}
			//add 3 to get past the delimiter

			returnvalue = csearchcookie.substring(begin+2,end)
		
			return unescape(returnvalue);
		}	
		else
			{
			return null
			}
	}
return null;
}	

function clearcookies() {
	document.cookie = 'CurrentPropCount=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'searchcookie=????; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'lastmapcoord=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'lastmapmode=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'lastmappingvalue=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'overlay=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'mapload=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
	document.cookie = 'noZoomingTip=; expires=Wed, 1 Aug 2001 00:00:00 UTC; path=/'
}

function setdisplaybox() {
//IF THIS FUNCTION CHANGES, THE FUNCTION BELOW (SETDSPLAYBOXPARENT) NEEDS TO HAVE THE SAME CHANGES APPLIED
//
//  This takes the cookie items and adds them to the display box if the cookie item
//  has a value or the length of the label is greater than zero
//
	var dc=document.cookie;
	var fieldvaluechar='';
	var newvalue='';

	var cookiename="searchcookie";
	csearchcookie='';
	//first, lets get the search cookie
	if (dc.length != 0) {
		begin = dc.indexOf(cookiename);
		if (begin != -1) {
			end = dc.indexOf(";", begin);
			if (end == -1) {
				end = dc.length;
			}	
			csearchcookie = (dc.substring(begin,end));
		}
	}

	var fieldvaluechar='';
	var newvalue='';

//	document.main.selectdisplay.value='';
	document.getElementById("selectdisplay").value='';
//alert('1 - nothing')
	cvalue=csearchcookie;
	if (cvalue.length > 0) {		
		searcharray = cvalue.split("^^");
		if (searcharray.length > 0) {
			for (j=0;j<searcharray.length;j++) {
				searchitem = searcharray[j]
//				alert(searchitem);
				searchelement = searchitem.split("|");
//				alert(searchelement.length)
				if (searchelement.length==4) {
					displayname=searchelement[2];
					//if the value is blank or the label is blank, then dont add it to the select box
					if (searchelement[1].length!=0){
						//now lets replace any underscores with spaces
						newvalue=''
						for (i=0; i<displayname.length; i++) {
							fieldvaluechar = displayname.substring(i,i+1);
							if (fieldvaluechar == '_') {
								fieldvaluechar = " ";
							}
							newvalue=newvalue+=fieldvaluechar;
						}	
						displayname = newvalue
					
						displaytext=searchelement[3];
					
						//now lets replace any underscores with spaces
						newvalue=''
						for (i=0; i<displaytext.length; i++) {
							fieldvaluechar = displaytext.substring(i,i+1);
							if (fieldvaluechar == '_') {
								fieldvaluechar = " ";
							}
							newvalue=newvalue+=fieldvaluechar;
						}
						displaytext = newvalue
					
					//	document.main.selectdisplay.value += displayname + '\r';
						if (displayname.length > 1) {
							document.getElementById("selectdisplay").value += displayname + '\r';
//alert('2 - displayname - ' + displayname)
							k = displaytext.indexOf(':');
							if (k != -1) {
								
	   							thiselement = displaytext.split(":");
	   							for (m=0;m<thiselement.length;m++) {
	  							//	document.main.selectdisplay.value += '  ' + bullet + ' ' + thiselement[m] + '\r';
	  								document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + thiselement[m] + '\r';
//alert('3 - bullet - ' + thiselement[m])
	  								//alert('if:  ' + thiselement[m])
	   							}
	   						}
							else {
							//	document.main.selectdisplay.value +=  '  ' + bullet + ' ' + displaytext  + '\r';
								document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + displaytext  + '\r';
//alert('4 - bullet - ' + displaytext)
								//alert('else:  ' + displaytext)
							}
						}
					}	
				}	
			}
		}
	}
	//for map searches, we need to get the search coordinates (top left, bottom right)
/*	var cookieType = dc.substring(dc.indexOf('lastmapmode'), dc.indexOf(';', dc.indexOf('lastmapmode'))).substring(dc.substring(dc.indexOf('lastmapmode'), dc.indexOf(';', dc.indexOf('lastmapmode'))).indexOf('=') + 1);
	if (cookieType != 'box') {
		var cookiename = "lastmapcoord";
		coordCookie = '';
		//first, lets get the full cookie value
		if (dc.length != 0) {
			begin = dc.indexOf(cookiename);
			if (begin != -1) {
				end = dc.indexOf(";", begin);
				if (end == -1) {
					end = dc.length;
				}	
				coordCookie = (dc.substring(begin,end));
				coordCookie = coordCookie.substring(coordCookie.indexOf('=') + 1, end);
				coordCookie = coordCookie.replace('%3A', ':')
			}
		}

		var arrCoords = coordCookie.split(':');
		if (arrCoords.length == 4) {
			var nCoord = arrCoords[0].substring(0, 8);
			var sCoord = arrCoords[1].substring(0, 8);
			var wCoord = arrCoords[2].substring(0, 9);
			var eCoord = arrCoords[3].substring(0, 9);
			
			document.getElementById("selectdisplay").value += 'Map Coords (NW, SE)\r';
			document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + nCoord + '/' + wCoord + '\r';
			document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + sCoord + '/' + eCoord + '\r';
		}
	} else {
		var cookiename = "lastmappingvalue";
		coordCookie = '';

		if (dc.length != 0) {
			begin = dc.indexOf(cookiename);
			if (begin != -1) {
				end = dc.indexOf(";", begin);
				if (end == -1) {
					end = dc.length;
				}
				coordCookie = (dc.substring(begin,end));
				if (coordCookie.indexOf('=') > -1) {
					coordCookie = coordCookie.substring(coordCookie.indexOf('=') + 1, end);
					coordCookie = coordCookie.replace('%3A', ':')
				}else{
					coordCookie = ''
				}
			}
		}
		if (coordCookie.length > 0) {
			document.getElementById("selectdisplay").value += 'Box Coords. (NW, SE)\r';
			document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + window.frames['mapFrame']._boxCoordN.substring(0, 8) + '/' + window.frames['mapFrame']._boxCoordW.substring(0, 9) + '\r';
			document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + window.frames['mapFrame']._boxCoordS.substring(0, 8) + '/' + window.frames['mapFrame']._boxCoordE.substring(0, 9) + '\r';
		}
	}*/
}

function setdisplayboxParent() {
//IF THIS FUNCTION CHANGES, THE FUNCTION ABOVE (SETDSPLAYBOX) NEEDS TO HAVE THE SAME CHANGES APPLIED
//
//  This takes the cookie items and adds them to the display box if the cookie item
//  has a value or the length of the label is greater than zero
//
	var dc=parent.document.cookie;
	var fieldvaluechar='';
	var newvalue='';

	var cookiename="searchcookie";
	csearchcookie='';
	//first, lets get the search cookie
	if (dc.length != 0) {
		begin = dc.indexOf(cookiename);
		if (begin != -1) {
			end = dc.indexOf(";", begin);
			if (end == -1) {
				end = dc.length;
			}	
			csearchcookie = (dc.substring(begin,end));
		}
	}

	var fieldvaluechar='';
	var newvalue='';

//	document.main.selectdisplay.value='';
	parent.document.getElementById("selectdisplay").value='';
	//alert('1 - nothing')

	cvalue=csearchcookie;
	if (cvalue.length > 0) {		
		searcharray = cvalue.split("^^");
		if (searcharray.length > 0) {
			for (j=0;j<searcharray.length;j++) {
				searchitem = searcharray[j]
//				alert(searchitem);
				searchelement = searchitem.split("|");
//				alert(searchelement.length)
				if (searchelement.length==4) {
					displayname=searchelement[2];
					//if the value is blank or the label is blank, then dont add it to the select box
					if (searchelement[1].length!=0){
						//now lets replace any underscores with spaces
						newvalue=''
						for (i=0; i<displayname.length; i++) {
							fieldvaluechar = displayname.substring(i,i+1);
							if (fieldvaluechar == '_') {
								fieldvaluechar = " ";
							}
							newvalue=newvalue+=fieldvaluechar;
						}	
						displayname = newvalue
					
						displaytext=searchelement[3];
					
						//now lets replace any underscores with spaces
						newvalue=''
						for (i=0; i<displaytext.length; i++) {
							fieldvaluechar = displaytext.substring(i,i+1);
							if (fieldvaluechar == '_') {
								fieldvaluechar = " ";
							}
							newvalue=newvalue+=fieldvaluechar;
						}
						displaytext = newvalue
					
					//	document.main.selectdisplay.value += displayname + '\r';
						if (displayname.length > 1) {
							parent.document.getElementById("selectdisplay").value += displayname + '\r';
							//alert('2 - displayname - ' + displayname)
							k = displaytext.indexOf(':');
							if (k != -1) {
								
	   							thiselement = displaytext.split(":");
	   							for (m=0;m<thiselement.length;m++) {
	  							//	document.main.selectdisplay.value += '  ' + bullet + ' ' + thiselement[m] + '\r';
	  								parent.document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + thiselement[m] + '\r';
									//alert('3 - bullet - ' + thiselement[m])
	  								//alert('if:  ' + thiselement[m])
	   							}
	   						}
							else {
							//	document.main.selectdisplay.value +=  '  ' + bullet + ' ' + displaytext  + '\r';
								parent.document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + displaytext  + '\r';
								//alert('4 - bullet - ' + displaytext)
								//alert('else:  ' + displaytext)
							}
						}
					}	
				}	
			}
		}
	}	
	//for map searches, we need to get the search coordinates (top left, bottom right)
	var cookieType = dc.substring(dc.indexOf('lastmapmode'), dc.indexOf(';', dc.indexOf('lastmapmode'))).substring(dc.substring(dc.indexOf('lastmapmode'), dc.indexOf(';', dc.indexOf('lastmapmode'))).indexOf('=') + 1);
	//alert(getCookies('overlay') + ' :: ' + cookieType)
	//if (getCookies('overlay') == null && cookieType != 'box') {
		var cookiename = "lastmapcoord";
		coordCookie = '';
		//first, lets get the full cookie value
		if (dc.length != 0) {
			begin = dc.indexOf(cookiename);
			if (begin != -1) {
				end = dc.indexOf(";", begin);
				if (end == -1) {
					end = dc.length;
				}	
				coordCookie = (dc.substring(begin,end));
				coordCookie = coordCookie.substring(coordCookie.indexOf('=') + 1, end);
			}
		}
		var arrCoords = coordCookie.split('%3A');
		if (arrCoords.length == 4) {
			var nCoord = arrCoords[0].substring(0, 8);
			var sCoord = arrCoords[1].substring(0, 8);
			var wCoord = arrCoords[2].substring(0, 9);
			var eCoord = arrCoords[3].substring(0, 9);
			
			parent.document.getElementById("selectdisplay").value += 'Map Coords\r';
			parent.document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + nCoord + '/' + wCoord + '\r';
			parent.document.getElementById("selectdisplay").value +=  '  ' + bullet + ' ' + sCoord + '/' + eCoord + '\r';
			//alert('5 - Search Coordinates - ' + nwCoord + '/' + seCoord)
		}
	/*} else {
		var cookiename = "lastmapcoord";
		coordCookie = '';
		//first, lets get the full cookie value
/*		if (dc.length != 0) {
			begin = dc.indexOf(cookiename);
			if (begin != -1) {
				end = dc.indexOf(";", begin);
				if (end == -1) {
					end = dc.length;
				}	
				coordCookie = (dc.substring(begin,end));
				coordCookie = coordCookie.substring(coordCookie.indexOf('=') + 1, end);
				coordCookie = coordCookie.replace('%3A', ':')
			}
		}
		parent.document.getElementById("selectdisplay").value += 'Box Coords\r';
		parent.document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + _boxCoordN.substring(0, 8) + '/' + _boxCoordW.substring(0, 9) + '\r';
		parent.document.getElementById("selectdisplay").value += '  ' + bullet + ' ' + _boxCoordS.substring(0, 8) + '/' + _boxCoordE.substring(0, 9) + '\r';
	}*/
}


//used in search step 2 for setting advanced criteria cookies
var vprev

function setdisplayparameterbox() {

	vtemp = findDOM('parameters',0).options[findDOM('parameters',0).selectedIndex].value + "id";

	if ("" + vprev != "undefined") {
		try {
			findDOM(vprev,1).display='none';
		}catch(e) {}
	}
	try {
		findDOM(vtemp,1).display='block';
	}catch(e) {}
	
	vprev = vtemp;
	findDOM('citydiv',1).display='none';
}

//used in search step 2 for setting advanced criteria cookies
//var vprev2
/*
function setdisplayparameterbox2() {

	var vtemp
	vtemp = findDOM('parameters',0).options[findDOM('parameters',0).selectedIndex].value + "id_2";

	try {
		for (var x=0; x<findDOM('parameters',0).options.length; x++) {
			var vselname = findDOM('parameters',0).options[x].value + "id_2";
			findDOM(vselname,1).display='none';
		}
		findDOM(vtemp,1).display='block';
	}catch(e) {}
	vprev2 = vtemp;
}

*/
var vprev2

function setdisplayparameterbox2() {
	var vtemp
	vtemp = findDOM('parameters',0).options[findDOM('parameters',0).selectedIndex].value + "id_2";

	if ("" + vprev2 != "undefined") {
		try {
			findDOM(vprev2,1).display='none';
		}catch(e) {}
	}
	try {
		findDOM(vtemp,1).display='block';
	}catch(e) {}
	vprev2 = vtemp;
}


//used in search step 2 for setting advanced criteria cookies

function setcookie_selectmultiple(pfieldname, pfieldvalue,  pdisplayname, pdisplay, pifreplace, pifreplacecounts) {
	maincontrol = document.mainsearch[pfieldname.toLowerCase()];
	if (maincontrol == undefined) {
		var isIE = Boolean(document.all);
		maincontrol = document.getElementById(pfieldname.toLowerCase()+"id_2").childNodes[((isIE) ? 0 : 1)];
	}
	
	try {
			if (maincontrol.type=='select-multiple') {
				if (maincontrol.selectedIndex==-1) {
					setcookie(maincontrol.name, '','', '', 1);
					if (maincontrol.name=='cityid') {
						maincontrol[0].selected = true
					}	
				}
				else 
				{
/*					firstreplace=1
					for (var i=0; i < maincontrol.length; i++) {
						if (maincontrol[i].selected == true) {

							if(pifreplacecounts){
								//* 11.11.2003 JMC - this strips out the count ie: Country Club Hills (187) >> Country Club Hills *
								var textval = maincontrol.options[i].text
								
								var replace_pattern =  new RegExp("\\([0-9]+\\)")
								textval = textval.replace(replace_pattern, '')
							}else{
								var textval = maincontrol.options[i].text
							}
							
							setcookie(maincontrol.name, maincontrol.options[i].value,pdisplayname, textval, firstreplace);
							firstreplace=0
						}	
					}
*/
					firstreplace=1
					setcookie(maincontrol.name.toLowerCase(), '', pdisplayname, '', 1);
					for (var i=0; i < maincontrol.length; i++) {
						if (maincontrol[i].selected == true) {

							if(pifreplacecounts){
								//* 11.11.2003 JMC - this strips out the count ie: Country Club Hills (187) >> Country Club Hills *
								var textval = maincontrol.options[i].text
								
								var replace_pattern =  new RegExp("\\([0-9]+\\)")
								textval = textval.replace(replace_pattern, '')
							}else{
								var textval = maincontrol.options[i].text
							}
							
							setcookie(maincontrol.name, maincontrol.options[i].value, pdisplayname, textval, firstreplace);
							firstreplace=0
						}
						//else
						//{
						//setcookie(maincontrol.name, maincontrol.options[maincontrol.selectedIndex].value, pdisplayname, textval, firstreplace);
						//}
					}
				}
				
			//Checkbox support 3.26.2003 JMC - works for single checkbox....
			}else if(maincontrol.type=='checkbox'){
				if(maincontrol.checked){
					setcookie(pfieldname.toLowerCase(), pfieldvalue,  pdisplayname, pdisplay, pifreplace)
				}else{
					setcookie(pfieldname.toLowerCase(), '',  pdisplayname, pdisplay, pifreplace)
				}
			}
			//Check for multiple checkboxes....
			else if(maincontrol.type + '' == 'undefined'){
			
				if (maincontrol[0].type == 'checkbox'){
					//reset cookie
					setcookie(pfieldname.toLowerCase(), '', pdisplayname, pdisplay, pifreplace)
					var searchVal=''
					var displayVal=''

					//recreate cookie...
					for(i=0;i<maincontrol.length;i++){
						if(maincontrol[i].checked){
							//split up the value left of ^ is the actual value right of ^ is the display value
							if(maincontrol[i].value.indexOf('^') > 0){
								searchVal = maincontrol[i].value.substring(0, maincontrol[i].value.indexOf('^'))
								displayVal = maincontrol[i].value.substring(maincontrol[i].value.indexOf('^') + 1, maincontrol[i].value.length)
							}
							setcookie(pfieldname.toLowerCase(), searchVal, pdisplayname, displayVal, pifreplace)
						}
					}
				}
			}
			else
			{
				setcookie(pfieldname.toLowerCase(), pfieldvalue,  pdisplayname, pdisplay, pifreplace)
			}		
		}
	catch(e){};
}
/*
function setcookie_selectmultiple(pfieldname, pfieldvalue,  pdisplayname, pdisplay, pifreplace) {
	maincontrol = document.mainsearch[pfieldname];
	if (maincontrol == undefined) {
		var isIE = Boolean(document.all);
		maincontrol = document.getElementById(pfieldname+"id_2").childNodes[((isIE) ? 0 : 1)];
	}
	try {
			if (maincontrol.type=='select-multiple') {
				if (maincontrol.selectedIndex==-1) {
					setcookie(maincontrol.name, '','', '', 1);
					if (maincontrol.name=='cityid') {
						maincontrol[0].selected = true
					}	
				}
				else 
				{
					firstreplace=1
					for (var i=0; i < maincontrol.length; i++) {
						if (maincontrol[i].selected == true) {
							setcookie(maincontrol.name, maincontrol.options[i].value,pdisplayname, maincontrol.options[i].text, firstreplace);
							firstreplace=0
						}	
					}
				}
			//Checkbox support 3.26.2003 JMC - works for single checkbox....
			}else if(maincontrol.type=='checkbox'){
				
				if(maincontrol.checked){
					setcookie(pfieldname, pfieldvalue,  pdisplayname, pdisplay, pifreplace)
				}else{
					setcookie(pfieldname, '',  pdisplayname, pdisplay, pifreplace)
				}
			}
			//Check for multiple checkboxes....
			else if(maincontrol.type + '' == 'undefined'){

				if (maincontrol[0].type == 'checkbox'){
					//reset cookie
					setcookie(pfieldname, '', pdisplayname, pdisplay, pifreplace)
					var searchVal=''
					var displayVal=''

					//recreate cookie...
					for(i=0;i<maincontrol.length;i++){
						if(maincontrol[i].checked){
							//split up the value left of ^ is the actual value right of ^ is the display value
							if(maincontrol[i].value.indexOf('^') > 0){
								searchVal = maincontrol[i].value.substring(0, maincontrol[i].value.indexOf('^'))
								displayVal = maincontrol[i].value.substring(maincontrol[i].value.indexOf('^') + 1, maincontrol[i].value.length)
							}
							setcookie(pfieldname, searchVal, pdisplayname, displayVal, pifreplace)
						}
					}
				}
			}
			else
			{
				setcookie(pfieldname, pfieldvalue,  pdisplayname, pdisplay, pifreplace)
			}		
		}
	catch(e){};
}
*/

function setHomePageCookies(pValue, pType, pClearCookies){
	//arguments[2] is an optional parameter that determines whether or not to clear the cookies inside this function
	// --- used for quicksearch values in cityselect.asp
	//alert(pValue+'\n'+pType+'\n'+pClearCookies)
	if (pClearCookies) {
		clearcookies();	
	}
	var arrRegionInfo = pValue.split(':');
	if (arrRegionInfo.length > 1) {
		var regionID = arrRegionInfo[0];
		var regionName = arrRegionInfo[1];

		if (pType == 'region') {
			var areaName = arrRegionInfo[4];
			setcookie('areainfo', '-1', 'Area', '', 1);
			setcookie('areainfo', '-1', 'Area', areaName, 1);
		}
		
		if (regionName) {
			setcookie('regioninfo', regionID, 'County', regionName, 1);
		}
		
		var mlsID = arrRegionInfo[2];
		var mlsName = arrRegionInfo[3];

		setcookie('mlsinfo', mlsID, ' ', mlsName, 1);

		if (pType == 'city') {
			var areaName = arrRegionInfo[4];
			//alert(document.cookie);
			setcookie('areainfo', '-1', 'Area', '', 1);
			//alert(document.cookie);
			setcookie('areainfo', '-1', 'Area', areaName, 1);
			//alert(document.cookie);

			var cityID = arrRegionInfo[5];
			var cityName = arrRegionInfo[6];
			setcookie('cityid', cityID, 'City', cityName, 1);
		} else if (pType == 'citynoreplace') {
			var areaName = arrRegionInfo[4];
			setcookie('areainfo', '-1', 'Area', '', 1);
			setcookie('areainfo', '-1', 'Area', areaName, 1);

			var cityID = arrRegionInfo[5];
			var cityName = arrRegionInfo[6];
			setcookie('cityid', cityID, 'City', cityName, 0);
			//alert(document.cookie)
		}
	}

}
