<!--
var sMLSAgent
sMLSAgent = ""



function setLRECookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function removeLRECookie(c_name)
{
	document.cookie = c_name + "=" + "";
}


function changeObjectClass(oObject, oClassName)
{
	document.getElementById(oObject).className = oClassName
}

function showInhouseDetails(ppId)
{
	var vSplit
	var oFind

	for (i = 0; i < vProperties.length; i++)
	{
		vSplit = vProperties[i].split("|")
		if (vSplit[0] == ppId)
		{
			document.getElementById("houseDetails").style.display = "block"
			document.getElementById("houseDetailslower").style.display = "block"
			document.getElementById("ihprop_mls").innerHTML = "<B>MLS ID:</B> " + vSplit[0]
			document.getElementById("ihprop_type").innerHTML = "<B>Type:</B> " + vSplit[1]
			document.getElementById("ihprop_listed").innerHTML = "<B>Listed For:</B> $" + formatNumber(vSplit[2], false, false, false, true) + " <A CLASS='red' STYLE='padding-left: 20px' HREF='" + vSplit[3] + "'><B><U>More Details</U></B></A>"
			document.getElementById("ihprop_desc").innerHTML = "" + vSplit[10]

			document.getElementById("ihprop_icon").innerHTML = vSplit[12]

			document.getElementById("td" + ppId + "a").style.fontWeight = "bold"
			document.getElementById("td" + ppId + "b").style.fontWeight = "bold"
			if (vSplit[5] == "sold") {document.getElementById("soldOverlay").style.display = "block"}
			document.getElementById("ihprop_photo").src = vSplit[4]
		}
		else
		{
			oFind = document.getElementById("td" + vSplit[0] + "a")
			if (oFind != null)
			{
				oFind.style.fontWeight = "normal"
				oFind.style.fontWeight = "normal"
			}
			oFind = document.getElementById("td" + vSplit[0] + "b")
			if (oFind != null)
			{
				oFind.style.fontWeight = "normal"
				oFind.style.fontWeight = "normal"
			}
		}
	}
}

function returnSearchResults()
{
	var vSplit
	var oTable = document.getElementById("displayRecords")
	var oTR
	var oTD
	var sLastClass
	var iCounter
	var findid
	
	clearDisplayRecords()

	sLastClass = "box_body_olive2"
	sInitialHouse = ""
	iCounter = 0

	findid = document.getElementById("findmls").value;
	

	
	
	(sMLSAgent != "")?setLRECookie("agent",sMLSAgent,365):removeLRECookie("agent");
	(sMLSType != "")?setLRECookie("type",sMLSType,365):removeLRECookie("type");
	(sMLSLocation != "")?setLRECookie("location",sMLSLocation,365):removeLRECookie("location");
	(sMLSMinPrice != 0)?setLRECookie("minprice",sMLSMinPrice,365):removeLRECookie("minprice");
	(sMLSMaxPrice != 50000000)?setLRECookie("maxprice",sMLSMaxPrice,365):removeLRECookie("maxprice");
	

	for (i = 0; i < vProperties.length; i++)
	{
		
		vSplit = vProperties[i].split("|")
		if (findid == "")
		{
		if (vSplit[9] == sMLSAgent || sMLSAgent == "")
		{
			if (vSplit[1] == sMLSType || sMLSType == "")
			{
				if (vSplit[11] == sMLSLocation || sMLSLocation == "")
				{
					if (parseInt(vSplit[2]) >= parseInt(sMLSMinPrice))
					{
						//alert("min=" + sMLSMinPrice + " / " + vSplit[2])
						if (parseInt(vSplit[2]) <= parseInt(sMLSMaxPrice))
						{
							iCounter = iCounter + 1
							if (sInitialHouse == "") {sInitialHouse = vSplit[0]}
							oTR = oTable.insertRow(oTable.rows.length)
							oTR.className = sLastClass

							oTD = oTR.insertCell(oTR.cells.length)
							oTD.className = "ihl"
							oTD.id = "td" + vSplit[0] + "a"
							oTD.innerHTML = "<A CLASS='ihll' ONCLICK='showInhouseDetails(\"" + vSplit[0] + "\"); return false;' HREF='" + vSplit[0] + "_mls'>" + vSplit[11] + ": " + vSplit[0] + "</A>"

							oTD = oTR.insertCell(oTR.cells.length)
							oTD.className = "ihl2"
							oTD.id = "td" + vSplit[0] + "b"
							oTD.innerHTML = "$" + formatNumber(vSplit[2], false, false, false, true)

							if (sLastClass == "box_body_olive2") {sLastClass = "box_body_olive3"} else {sLastClass = "box_body_olive2"}
						}
					}
					else
					{
						//alert('price ' + vSplit[2] + ' is less than min price of ' + sMLSMinPrice)
					}
				}
			}
		}
		}
		else
		{
			document.getElementById("agent").options.selectedIndex = 0
			document.getElementById("type").options.selectedIndex = 0
			document.getElementById("location").options.selectedIndex = 0
			document.getElementById("lowprice").options.selectedIndex = 0
			document.getElementById("hiprice").options.selectedIndex = 0
			if (vSplit[0].indexOf(findid) >= 0)
			{
								iCounter = iCounter + 1
								if (sInitialHouse == "") {sInitialHouse = vSplit[0]}
								oTR = oTable.insertRow(oTable.rows.length)
								oTR.className = sLastClass
	
								oTD = oTR.insertCell(oTR.cells.length)
								oTD.className = "ihl"
								oTD.id = "td" + vSplit[0] + "a"
								oTD.innerHTML = "<A CLASS='ihll' ONCLICK='showInhouseDetails(\"" + vSplit[0] + "\"); return false;' HREF='" + vSplit[0] + "_mls'>" + vSplit[11] + ": " + vSplit[0] + "</A>"
	
								oTD = oTR.insertCell(oTR.cells.length)
								oTD.className = "ihl2"
								oTD.id = "td" + vSplit[0] + "b"
								oTD.innerHTML = "$" + formatNumber(vSplit[2], false, false, false, true)
	
								if (sLastClass == "box_body_olive2") {sLastClass = "box_body_olive3"} else {sLastClass = "box_body_olive2"}
			}
		
		
		}
	}

	if (iCounter == 0)
	{
		oTR = oTable.insertRow(oTable.rows.length)
		oTR.className = sLastClass

		oTD = oTR.insertCell(oTR.cells.length)
		oTD.className = "ihl"
		oTD.id = "td" + vSplit[0] + "a"
		oTD.innerHTML = "No results matched your query."
	}

	if (sInitialHouse != "") {showInhouseDetails(sInitialHouse)}

}

function clearDisplayRecords()
{
	var oTable = document.getElementById("displayRecords")

	while (oTable.rows.length > 0)
	{
		for (i = 0; i <= oTable.rows.length; i++)
		{
			oTable.deleteRow(oTable.rows.length - 1);
		}
	}
}

function NewWindow(mypage, myname, w, h, scroll, url, menubar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	if (menubar == 'yes') {winprops = winprops + ',menubar=yes'}
	if (url == '')
	{
		win = window.open(mypage, myname, winprops)
	}
	else
	{
		win = window.open(mypage + '&page=' + url, myname, winprops)
		if (!win.opener)
		{
			win.opener = self
		}
	}
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function correctPNG()
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			img.style.display = "block"
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "visibility: visible; display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
			var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

function replace(sString, sFind, sReplace)
{
	i = sString.indexOf(sFind);
	r = "";
	if (i == -1) return sString;
	r += sString.substring(0, i) + sReplace;
	if (i + sFind.length < sString.length)
	r += replace(sString.substring(i + sFind.length, sString.length), sFind, sReplace);
	return r;
}

function left(sString, n)
{
	if (n <= 0) {return "";}
	else if (n > String(sString).length) {return sString;}
	else {return String(sString).substring(0, n);}
}

function right(sString, n)
{
	if (n <= 0) {return "";}
	else if (n > String(sString).length) {return sString;}
	else {var iLen = String(sString).length; return String(sString).substring(iLen, iLen - n);}
}

function len(sString)
{
	return String(sString).length;
}

function instr(sString, sFind)
{
	for (iInstr = 0; iInstr < len(sString); iInstr++)
	{
		if (sFind == mid(sString, iInstr, 1))
		{
			return iInstr;
		}
	}
	return -1;
}

function mid(sString, iStart, len)
{
	if (iStart < 0 || len < 0) return "";

	var iEnd
	var iLen = String(sString).length;

	if (iStart + len > iLen)
		iEnd = iLen;
	else
		iEnd = iStart + len;

	return String(sString).substring(iStart, iEnd);
}

function addToFavorites()
{
	if (window.external)
	{
		window.external.AddFavorite(curUrl,curPageName)
	}
	else
	{
		alert("Sorry! Your browser doesn't support this function.");
	}
}

function formatNumber(num, decimalNum, bolLeadingZero, bolParens, bolCommas)
{ 
	if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;
	
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;
	
	
	var tmpNumStr = new String(tmpNum);

	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
	{
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
	}
		
	if (bolCommas && (num >= 1000 || num <= -1000))
	{
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0) {iStart = tmpNumStr.length;}

		iStart -= 3;
		while (iStart >= 1)
		{
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	if (bolParens && num < 0) {tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";}

	return tmpNumStr;
}


-->
