var map;
var gBounds = new GLatLngBounds();
var gPriceH, gPriceL;
var gDateH, gDateL;
var gZip;
var gCity;
var gSearchAddr;
var arPoints = new Array();

var wth;
var hth;
var xmlHttp = false;
var xmlHttp2 = false;
var urlFile = "./db/gethomessold.php";
var urlCount = "./db/getpages.php";
var urlZipFile = "./db/getZip.php";
var objPoints;
var page = 1;
var pages = 0;
var urlHistory;

/* Create a new XMLHttpRequest object to talk to the Web server */
try {
	xmlHttp = new XMLHttpRequest();
	xmlHttp2 = new XMLHttpRequest();
	} catch (trymicrosoft) {
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
		try {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
			xmlHttp = false;
			xmlHttp2 = false;
		}
	}
}

if ((!xmlHttp) || (!xmlHttp))
	alert("Error initializing XMLHttpRequest and XMLHttpRequest2!");
  
function validForm(){
	var dateL = document.getElementById("ddDateL");
	var dateH = document.getElementById("ddDateH");
	gDateL = dateL.value;
	gDateH = dateH.value;
	if (((gDateL == "-1") && (gDateH != "-1")) || ((gDateL != "-1") && (gDateH == "-1"))){
		alert("--- Date Range Error ---\n\nPlease select both a start date and end date\nOR choose 'All Dates'");
		if (gDateL == "-1"){
			dateL.focus();
			//dateL.select();
			//dateL.select.style = "background-color:red;";
			return false;
		}
		if (gDateH == "-1"){
			dateH.focus();
			//dateH.select();
			//dateH.select.style = "background-color:red;";
			return false;
		}
	}
	var priceL = document.getElementById("ddPriceL");
	var priceH = document.getElementById("ddPriceH");
	gPriceL = priceL.value;
	gPriceH = priceH.value;
	if (((gPriceL == "-1") && (gPriceH != "-1")) || ((gPriceL != "-1") && (gPriceH == "-1"))){
		alert("--- Price Range Error ---\n\nPlease select both a start price and end price\nOR choose 'All Prices'");
		if (gPriceL == "-1"){
			priceL.focus();
			//priceL.select();
			//priceL.select.style = "background-color:red;";
			return false;
		}
		if (gPriceH == "-1"){
			priceH.focus();
			//priceH.select();
			//priceH.select.style = "background-color:red;";
			return false;
		}
	}
	var addr = document.getElementById("txtAddr");
	var strTmp = addr.value.replace(/^\s+/, '');
	gSearchAddr = strTmp.replace(/\s+$/, '');
	var illegalChars = /[^a-zA-Z 0-9]/;
	if (gSearchAddr.length > 0){
		if((gSearchAddr.length < 3) || (illegalChars.test(gSearchAddr))){
			alert("--- Address Error ---\n\nPlease enter three or more letters and/or numbers for the address search.");
			addr.select();
			addr.focus();
			return false;
		}
	}
	if(validZip()){
		return true;
	}
	else
		return false;
}

function validZip(){
	var zip = document.getElementById("ddZip");
	gZip = zip.value;
	illegalChars = /[^0-9]/;
	if (gZip.length > 0){
		if((gZip.length < 5) || (illegalChars.test(gZip))){
			alert("--- Zip Code Error ---\n\nPlease enter five numbers for the zip code.");
			zip.select();
			zip.focus();
			return false;
		}
	}
	return true;

}

function removeDateErr(elem){
	this.style = "";
}

function btnMapProp(){
	page = 1;
	startLoadData();
}

function startLoadData(){
	if (validForm()){
		var url = "";
		//lower date and higher date
		if((gDateL != "-1") && (gDateH != "-1")){
			if (parseInt(gDateL) > parseInt(gDateH))
				url = url + "&dtst=" + gDateH + "&dtend=" + gDateL;
			else
				url = url + "&dtst=" + gDateL + "&dtend=" + gDateH;
		}
		//bedrooms or if extra filters are showing
		if (document.getElementById("trBdrms").className != "trHide"){
			var bdrms = document.getElementById("ddBdrms").value;
			var bdrmsL, bdrmsH;
			if (bdrms != "-1"){
				var arBdrms = bdrms.split('|');
				bdrmsL = parseFloat(arBdrms[0]);
				bdrmsH = parseFloat(arBdrms[1]);
				url = url + "&bdl=" + bdrmsL + "&bdh=" + bdrmsH;
			}
			//sqft
			var sqft = document.getElementById("ddSqft").value;
			var sqftL, sqftH;
			if (sqft != "-1"){
				var arSqft = sqft.split('|');
				sqftL = parseFloat(arSqft[0]);
				sqftH = parseFloat(arSqft[1]);
				url = url + "&sql=" + sqftL + "&sqh=" + sqftH;
			}
			//year built
			var built = document.getElementById("ddBuilt").value;
			if (built != "-1"){
				var arBuilt = built.split('|');
				builtL = parseFloat(arBuilt[0]);
				builtH = parseFloat(arBuilt[1]);
				url = url + "&bltl=" + builtL + "&blth=" + builtH;
			}
			//price
			if (gPriceL != "-1"){
				if(parseInt(gPriceL) > parseInt(gPriceH)){
					var priceL = gPriceH;
					gPriceH = gPriceL;
					gPriceL = priceL;
				}				
				url = url + "&prl=" + gPriceL + "&prh=" + gPriceH;
			}
			if(gSearchAddr.length > 2){
				url = url + "&a=" + escape(gSearchAddr);
			}
		}
		//county
		var county = document.getElementById("ddCounty").value;
		if ((document.getElementById("trCounty").className != "trHide") && (county != "-1")){
			url = url + "&cnt=" + escape(county);
		}
		//city
		var arCity = document.getElementById("ddCity").value.split("|");
		gCity = arCity[0];
		if ((document.getElementById("trCity").className != "trHide") && (gCity != "-1")){
			url = url + "&cty=" + escape(gCity);
		}
		//zip
		if ((document.getElementById("trZip").className != "trHide") && (gZip.length > 4)){
			url = url + "&zip=" + gZip;
		}
		//map boundaries only
		if(document.getElementById("ddFilters").value == "drawn"){
			gBounds = map.getBounds();
			url = url + "&iy=" + gBounds.getSouthWest().lat() + "&ay=" + gBounds.getNorthEast().lat();
			url = url + "&ix=" + gBounds.getSouthWest().lng() + "&ax=" + gBounds.getNorthEast().lng();
		}
		sendLoadData(url, page, 2);
	}
}

//mode 1 is grabbing another page of data
//mode 2 is normal fresh search
function sendLoadData(url, pg, mode){
	
	urlHistory = url;
	searchUrl = urlFile + "?" + url + "&pg=" + pg;
	xmlHttp.open("GET", searchUrl, true);
	xmlHttp.onreadystatechange = processLoadData;
	xmlHttp.send(null);
	if(mode == 2){
		pages = 0;
		countUrl = urlCount + "?" + url;
		xmlHttp2.open("GET", countUrl, true);
		xmlHttp2.onreadystatechange = processCountPages;
		xmlHttp2.send(null);
	}
	document.getElementById("status").innerHTML = "Searching, please wait.."
/*
	newWin = window.open("", "tinyWindow", 'toolbar,width=600,height=100,resizable=yes');
	newWin.document.write("<BR><BR><h4>" + searchUrl + "</h4>");
	newWin.document.close();
*/
}

function processLoadData(){
	//alert("state: " + xmlHttp.readyState + " " + xmlHttp.responseText);
	if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)){
		var jsontext = xmlHttp.responseText;
		//alert(jsontext);
		objPoints= eval( '(' + jsontext + ')' );
		loadData();
	}
} 

function processCountPages(){
	//alert("state: " + xmlHttp.readyState + " " + xmlHttp.responseText);
	if ((xmlHttp2.readyState == 4) && (xmlHttp2.status == 200)){
		var jsontext = xmlHttp2.responseText;
		//alert(jsontext);
		var objPages = eval( '(' + jsontext + ')' );
		pages = parseInt(objPages.pages);
	}
} 

function resizeMap() {
	   // whacky bug fix for Mozilla because it fails to re-size down properly
	 /*** mapTableDIV.style.width = "10px";
	  mapCellDIV.style.width = "10px";
	  mapTableDIV.style.width = "100%";
	  mapCellDIV.style.width = "100%";
	  ***/
	  map.checkResize();
  }

function resizeDiv(){
	document.getElementById("map").width = screen.width - 170;
	map.onResize();
}
// Monitor the window resize event and let the map know when it occurs  
if (window.attachEvent) window.attachEvent("onresize", resizeMap);
else window.addEventListener("resize", resizeMap, false);

function onLoad() {	
	getSize();
	document.getElementById("map").style.width = (wth - 185) + "px";
	document.getElementById("map").style.height = (hth - 100) + "px";
	//map.onResize();
	//drawTable();
	Nifty("ul#nav a","small transparent top");
	Nifty("div#filters", "big top");
	Nifty("div#filters", "big br");
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		//center map in bay area
		map.setCenter(new GLatLng(37.778, -122.366), 10);
		// Center the map on San Francisco
		//map.setCenter(new GLatLng(37.7522, -122.44126321), 12);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.checkResize();
	}
	else
		alert("---  Error  ---\nYour browser can't render the maps used on this website.\nNothing will work as expected.");

}   

function newZip(elem){
//	alert("newZip fired");
	gZip = elem.value;
	if ((elem.value.length == 5) && (validZip())){
		var url = urlZipFile + "?zip=" + elem.value;
		xmlHttp.open("GET", url, true);
	//	alert("url is: " + url);
		xmlHttp.onreadystatechange = processZip;
		xmlHttp.send(null);
	}
}

function processZip(){
	if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)){
		var txtLatLng = xmlHttp.responseText;
		var arZip = txtLatLng.split("|");
		if((arZip[0] == "true") && (arZip[1] == gZip)){
			map.setCenter(new GLatLng(arZip[2], arZip[3]), 13);
		}
		else
			alert("There is no data for this zip code.");
	}
}
function newCity(elem){
	var arCity = elem.value.split("|");
	if(arCity[0] != -1){
		//alert("lat is: " + arCity[1] + " lng is: " + arCity[2]);
		map.setCenter(new GLatLng(arCity[1], arCity[2]), 12);
	}
}

function newCounty(){
/*
	county = document.getElementById("ddCounty").value;
	city = document.getElementById("ddCity").value;
	var html;
	switch (county){
		case "sf":
		map.recenterOrPanToLatLng(new GPoint(-122.44126321, 37.7522));
		map.zoomTo(5);
		html = "";
		break;
		case "alameda":
		map.recenterOrPanToLatLng(new GPoint(-122.131675, 37.671145));
		map.zoomTo(5);
		html = "Select City: <select name=\"mydropdown\"><option value=\"Alameda\">Alameda</option><option value=\"Albany\">Albany</option>";
		html = html + "<option value=\"Berkeley\">Berkeley</option><option value=\"Castro Valley\">Castro Valley</option>";
		html = html + "<option value=\"Dublin\">Dublin</option><option value=\"Emeryville\">Emeryville</option>";
		html = html + "<option value=\"Fremont\">Fremont</option><option value=\"Hayward\">Hayward</option>";
		html = html + "<option value=\"Livermore\">Livermore</option><option value=\"Newark\">Newark</option>";
		html = html + "<option value=\"Oakland\">Oakland</option><option value=\"Piedmont\">Piedmont</option>";
		html = html + "<option value=\"Pleasanton\">Pleasanton</option><option value=\"San Leandro\">San Leandro</option>";
		html = html + "<option value=\"San Lorenzo\">San Lorenzo</option><option value=\"Union City\">Union City</option></select>";
		break;
		default : //alert("default case in ddCounty onChange.");
	}
	city.innerHTML = html;
	*/
}

//center map on point and trigger that markers info window
function clickAddress(lng, lat, pointnum) {
	if (isNaN(lng) | isNaN(lat)) {
		alert("This address has not been mapped");
	} else {
		//map.panTo(new GLatLng(lat, lng));
		GEvent.trigger(arPoints[pointnum], "click");
	}
}

function clearMap(){
	  map.clearOverlays();
	  document.getElementById("message").innerHTML = "";
	  arPoints.length = 0;
}

function resetMap(){
	map.setCenter(new GLatLng(37.7522, -122.44126321), 13);
}

/******
//additive - button is commented out
function addData() {
	prepFilters();
	for(i=0; i<arDates.length; i++){
		var exists = false;
		for(j=0; j< arXMLmapped.length; j++){
			if (arXMLmapped[j] == arDates[i])
				exists = true;
		}
		var label = arDates[i].substring(4,6) + "/" + arDates[i].substring(6,8) + "/" + arDates[i].substring(0,4);
		loadFromXML(arDates[i] + "_sf.xml", label);
		if (!exists) {
			arXMLmapped.push(arDates[i]);
		}
	}	
}
****/

function slashDate(dStr){
	var rslt;
	if (dStr.length == 8){
		return dStr.substr(4,2) +"/" + dStr.substr(6,2) + "/" + dStr.substr(0,4);
	}
	else{
		return dStr;
	}
}

function toggleTR(sel){
	document.getElementById("trCity").className = "trHide";
	document.getElementById("trCounty").className = "trHide";
	document.getElementById("trZip").className = "trHide";
	if (sel.value != "drawn"){
		eval("document.getElementById('" + sel.value+ "').className = ''");
		var elemName = sel.value.substr(2,sel.value.length -2);
		//alert("document.getElementById('" + "dd" + elemName + "').focus();");
		eval("document.getElementById('" + "dd" + elemName + "').focus();");

	}
}
function toggleFilters(check){
	if(check.checked){
		document.getElementById("trPrice").className = "";
		document.getElementById("trBdrms").className = "";
		document.getElementById("trSqft").className = "";
		document.getElementById("trBuilt").className = "";
		document.getElementById("trAddr").className = "";
		document.getElementById("trLabel").className = "";
	}
	else{
		document.getElementById("trPrice").className = "trHide";
		document.getElementById("trBdrms").className = "trHide";
		document.getElementById("trSqft").className = "trHide";
		document.getElementById("trBuilt").className = "trHide";
		document.getElementById("trAddr").className = "trHide";
		document.getElementById("trLabel").className = "trHide";
	}
}

//is the point going to be drawn in the viewable area of the map
function isInViewableBounds(lat, lng){
	return map.getBounds().contains(new GLatLng(lat, lng));
}

function isInPriceRange(price){
	price = parseFloat(price);
	if((price >= priceL) & (price <= priceH))
		return true;
	else
		return false;
}

function isInBdrmsRange(bdrms){
	bdrms = parseFloat(bdrms);
	if((bdrms >= bdrmsL) & (bdrms <= bdrmsH))
		return true;
	else
		return false;
}

function isInSqftRange(sqft){
	sqft = parseFloat(sqft);
	if((sqft >= sqftL) & (sqft <= sqftH))
		return true;
	else
		return false;
}
function onAddrIn(elem, lat, lng){
	if (isInViewableBounds(lat,lng)){
		elem.style.color = 'green';
	}
	else{
		elem.style.color = 'red';
	}
}
function isNumberKey(evt)      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

	return true;

}
//new sidebar table
function drawTable(){
	var recRtnd = "<div id=\"recRtnd\" name=\"recRtnd\"></div></br>";
	var sidehtml = "<table class=\"sortable\" id=\"tblMsg\" name=\"tblMsg\">";
	sidehtml = sidehtml + "<tbody id=\"tblBody\" name=\"tblBody\">";
	sidehtml = sidehtml + "<tr class=\"tblHead\"><th nowrap=\"nowrap\"><a label=\"grid\"></a>Date Sold</th><th nowrap=\"nowrap\">Address</th>";
	sidehtml = sidehtml + "<th nowrap=\"nowrap\">Price</th><th nowrap=\"nowrap\">Bedrooms</th>";
	sidehtml = sidehtml + "<th nowrap=\"nowrap\">Sq Ft</th><th nowrap=\"nowrap\">Year Built</th>";
	sidehtml = sidehtml + "<th nowrap=\"nowrap\">City</th><th nowrap=\"nowrap\">Zip Code</th>";
	sidehtml = sidehtml + "</tr></tbody></table>";
	document.getElementById("message").innerHTML = recRtnd + sidehtml;
}

function loadData(){
	arPoints.length = 0;
	clearMap();
	drawTable();
	sortables_init();
	var intRecRtn = parseInt(objPoints.results);
	var nxtPage = parseInt(objPoints.nxtpage);
	page = parseInt(objPoints.page);
	//This is at the head of the table of results (strTHead goes into div recRtnd)
	//This is at the top of the page (strRecRtn goes into status div)
	var strRecRtn = "";
	var strTHead = "";
	//there's only one page of results available
	if((nxtPage == 0) && (page ==1)){
		if(intRecRtn == 1){
			strRecRtn = "Showing Page 1 of 1 - There is " + intRecRtn + " result<br/>";
			strTHead = "<br/>There is " + intRecRtn + " result shown. <a href=\"searchtips.html#Details\" class=\"q\">?</a>";
		}else{
			strRecRtn = "Showing Page 1 of 1 - There are " + addCommas(intRecRtn) + " results<br/>";
			strTHead = "<br/>There are " + addCommas(intRecRtn) + " results shown. <a href=\"searchtips.html#Details\" class=\"q\">?</a>";
		}
	}else{
		var maxRecs = parseInt(objPoints.max);
		var nextpage = page + 1;
		var prevpage = page - 1;
		strRecRtn = " Showing Page " + page;
		strTHead = "<br/>There are more results than the " + addCommas(intRecRtn) + " shown. <a href=\"searchtips.html#Details\" class=\"q\">?</a><br/>Page " + page;
		if (pages > 0){
			strRecRtn = strRecRtn + " of " + pages;
			strTHead = strTHead + " of " + pages;
		}
		strRecRtn = strRecRtn + " - Not all results were mapped. <br/>Only " + addCommas(intRecRtn) + " results are shown."; 
		strTHead = strTHead + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

		if((page > 1)&&(nxtPage ==1)){
			strRecRtn = strRecRtn + "<br/><a href=\"javascript:sendLoadData('" + urlHistory + "'," + prevpage +",1);\">Previous Page<a/>&nbsp;&nbsp;"
			strRecRtn = strRecRtn + "&nbsp;&nbsp;<a href=\"javascript:sendLoadData('" + urlHistory + "'," + nextpage +",1);\">Next Page<a/>";
			strTHead = strTHead + "<a href=\"javascript:sendLoadData('" + urlHistory + "'," + prevpage +",1);\">";
			strTHead = strTHead + "Previous Page</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:sendLoadData('" + urlHistory + "'," + nextpage +",1);\">Next Page</a>";
		}
		if(page == 1){
			strRecRtn = strRecRtn + "<br/><a href=\"javascript:sendLoadData('" + urlHistory + "'," + nextpage +",1);\">Next Page<a/>";
			strTHead = strTHead + "<a href=\"javascript:sendLoadData('" + urlHistory + "'," + nextpage +",1);\">Next Page</a>";
		}
		if((page > 1)&&(nxtPage ==0)){
			strRecRtn = strRecRtn + "<br/><a href=\"javascript:sendLoadData('" + urlHistory + "'," + prevpage +",1);\">Previous Page<a/>"
			strTHead = strTHead + "<a href=\"javascript:sendLoadData('" + urlHistory + "'," + prevpage +",1);\">";
			strTHead = strTHead + "Previous Page</a>";
		}
	}
	strRecRtn = strRecRtn + "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"javascript:scrollPage();\">See Table</a>";
	document.getElementById("recRtnd").innerHTML  =  strTHead;
	document.getElementById("status").innerHTML = strRecRtn;

	var sidehtml, tblRow;
	var tbl = document.getElementById("tblBody");
	var arrSolds = objPoints.solds;
	
	for (var i = 0; i < arrSolds.length; i++) {
		var objSold = arrSolds[i];
		//alert("objSold: " + objSold.lng);
		try {var iLng = parseFloat(objSold.lng);} 
			catch (ieerror) { break;}
		var iLat = parseFloat(objSold.lat);
		var point = new GLatLng(iLat, iLng);
		var markerSold = createMarker(point, objSold);
		map.addOverlay(markerSold);
		arPoints.push(markerSold);

		var tdDate = document.createElement("TD");
		tdDate.innerHTML = slashDate(objSold.saledt);
		var tdAddr = document.createElement("TD");
		sidehtml = "<a href=\"javascript:clickAddress(" + iLng + "," + iLat + "," + (arPoints.length - 1) + ");\" onMouseOver=\"onAddrIn(this,";
		tdAddr.innerHTML = sidehtml + iLat + "," + iLng + ");\" onMouseOut=\"this.style.color=''\">" + objSold.addr + "</a>";				
		tdAddr.setAttribute("align","right");
		tdAddr.setAttribute("nowrap", "nowrap");
		
		var tdPrice = document.createElement("TD");
                tdPrice.setAttribute("align", "right");
		tdPrice.innerHTML = "$" + addCommas(objSold.price);
		
		var tdBdrms = document.createElement("TD");
		if (objSold.bdrms == "-1") 
			sidehtml = "";
		else
			sidehtml = objSold.bdrms;
		tdBdrms.innerHTML = sidehtml;
		tdBdrms.setAttribute("align", "center");
		
		var tdSqft = document.createElement("TD");
		if (objSold.sqft == "-1") 
			sidehtml = "";
		else
			sidehtml = addCommas(objSold.sqft);
		tdSqft.innerHTML = sidehtml;
		tdSqft.setAttribute("align", "right");
		
		var tdBuilt = document.createElement("TD");
		if (objSold.built == "-1") 
			sidehtml = "";
		else
			sidehtml = objSold.built;
		tdBuilt.innerHTML = sidehtml;
		tdBuilt.setAttribute("align", "center");
		
		var tdCity = document.createElement("TD");
                tdCity.setAttribute("align", "right");
		tdCity.innerHTML = objSold.city;
		tdCity.setAttribute("nowrap", "nowrap");
		
		var tdZip = document.createElement("TD");
                tdZip.setAttribute("align", "right");
		tdZip.innerHTML = objSold.zip;
		
		var newTr = document.createElement("TR");
		newTr.appendChild(tdDate);
		newTr.appendChild(tdAddr);
		newTr.appendChild(tdPrice);
		newTr.appendChild(tdBdrms);
		newTr.appendChild(tdSqft);
		newTr.appendChild(tdBuilt);
		newTr.appendChild(tdCity);
		newTr.appendChild(tdZip);
		tbl.appendChild(newTr); 

	} 
	if (arPoints.length == 0){
		var newTr = document.createElement("TR");
		newTr.setAttribute("class", "sortable");
		
		var tdNone = document.createElement("TD");
		tdNone.setAttribute("colspan", "8");
		tdNone.innerHTML = "None Found";
		newTr.appendChild(tdNone);
		
		tbl.appendChild(newTr); 
	}
}


function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

// Creates a marker whose info window displays the given info for the sold house
function createMarker(point, objSold) {
	var marker = new GMarker(point);
	// Show this marker's index in the info window when it is clicked
	var html = "<div id=\"popup\"><a href=\"http://maps.a9.com/?mapMode=m&mapBvr=&ypLoc=" + objSold.addr + " " + objSold.city + " CA\">" + objSold.addr + "</a><br>";
	html = html + "Closing Price: $" + addCommas(objSold.price) + "<br>";
	if (objSold.bdrms != "-1")  html = html + "Bedrooms: " + objSold.bdrms + "<br>";	
	if (objSold.sqft != "-1")  html = html + "SqFt: " + addCommas(objSold.sqft) + "<br>";	
	if (objSold.built != "-1")  html = html + "Year Built: " + objSold.built + "<br>";	
	html = html + "Date: " + slashDate(objSold.saledt) + "<br>";
	html = html + "City: " + objSold.city + "<br>";
	html = html + "Zip Code: " + objSold.zip;
	html = html + "</div>";
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
	return marker;
}
function getSize(){
    var x, y, msg='';

    // for all except Explorer
    if (self.innerHeight) {
      x = self.innerWidth;
           y = self.innerHeight;
      msg += 'self.innerHeight/Width: '
           + y + ', ' + x + 'px';

    // Explorer 6 Strict Mode
    } else if (document.documentElement
            && document.documentElement.clientHeight) {
      x = document.documentElement.clientWidth;
      y = document.documentElement.clientHeight;
      msg += 'document.documentElement.clientHeight/Width: '
           + y + ', ' + x + 'px';

    // other Explorers
    } else if (document.body) {
           x = document.body.clientWidth;
           y = document.body.clientHeight;
      msg += 'document.body.clientHeight/Width: '
           + y + ', ' + x + 'px';
    }
    wth = x;
    hth = y;
  } 
  
  function scrollPage(){
  	window.scrollBy(0,500);	
  }
  /**
  function seeSource(){
	var tblsrc = document.getElementById("tblBody").innerHTML;
	newWin = window.open("", "tinyWindow", 'toolbar,width=600,height=100,resizable=yes');
	newWin.document.write("<BR><BR><pre>" + tblsrc + "</pre><BR><HR>" + tblsrc);
	newWin.document.close();
  
  }
  **/
