

function Property ()
{
	return this;
}
Property.prototype.point = null;
Property.prototype.name = null;
Property.prototype.direct_url = null;
Property.prototype.home_id = null;
Property.prototype.address = null;
Property.prototype.price = null;
Property.prototype.beds = null;
Property.prototype.baths = null;
Property.prototype.city = null;
Property.prototype.main_photo_id = null;
Property.prototype.main_photo_version = null;
Property.prototype.status = null;
Property.prototype.gbase = null;
Property.prototype.gbase_image = null;

Property.prototype.lat = null;

Property.prototype.lng = null;

Property.prototype.matches = null;
Property.prototype.visible = false;
Property.prototype.show = function(show)
{


    if (!show)
    {
        //if (this.visible)
        //{
        //    //this.marker.images[0].property = null;
        //    //map.removeOverlay(this.marker);
		//	var farPoint = new GLatLng(-10,-10 );
		//	this.marker.setPoint(farPoint);
        //}
    }
    else
    {
        if (!this.visible)
        {
			
            map.addOverlay(this.marker);
 
        }
    }
    this.visible = show;
}
Property.prototype.register = function ()
{	

	this.point = new GPoint(this.lng, this.lat);

	if (this.gbase == 'True'){
		if (this.matches == 'True') {
			var marker = new GMarker(this.point, {icon:propertyGbaseIcon,zIndexProcess:setZIndexGB});
		} else {
			var marker = new GMarker(this.point, propertyOffGbaseIcon); //zindex is set to default
		}
	}
	else {
		
		if (this.matches == 'True') {
			var marker = new GMarker(this.point, {icon:propertyIcon,zIndexProcess:setZIndexHBO});
		} else {
			var marker = new GMarker(this.point, {icon:propertyOffIcon,zIndexProcess:setZIndexHBO2});
		}
	}

	GEvent.bind(marker, "click", this, this.showPropertyInfo);
	marker.tooltip = this.name;

	this.marker = marker;


	GEvent.addListener(this.marker,"mouseover", function() {
		myshowTooltip(marker);
	});  

	GEvent.addListener(this.marker,"mouseout", function() {
		document.getElementById("tooltip").style.visibility="hidden";
	}); 


	properties[this.direct_url] = this;	

	var bodyText = "<div class=\"mouseoverinfowindow\">";
	
	if (this.gbase == "True")
		bodyText += "<div><img height=90 width=120 src="+ this.gbase_image +"></div>";
	else
		bodyText += "<div><img height=90 width=120 src=/show_photos/img_showthumbnail.asp?metro_id=" + metroId + "&home_id=" + this.home_id + "&main_photo_id=" + this.main_photo_id + "&main_photo_version=" + this.main_photo_version + "&Status=" + this.status + "></div>";

	bodyText = bodyText + "<div><b>Price: $" + this.price + "<br>";	
	bodyText = bodyText + this.beds + " beds / " + this.baths + " baths</b><br>";
	//bodyText = bodyText + "<small>(click <img id=\"houseicon\" src=\"/media/house"
	//if ( ! (this.matches == 'True')) {bodyText = bodyText + "off";}
	//bodyText = bodyText + "icon.png\"> for more info)</small></div></div>";
	
	bodyText = bodyText + "<small>(click <img id=\"houseicon\" src=\"" + marker.getIcon().image + "\"> for more info)</small></div></div>";

	bodyText = bodyText + "<iframe style='width:0px; height:0px; border: 0px' src='recordmaphit.asp?homeid=" + this.home_id + "'></iframe>";

	this.marker.bodyHtml = bodyText;


	this.show(true);  
}
Property.prototype.showPropertyInfo = function ()
{	
	var divInfo = document.createElement("div");
	var divTitle = document.createElement("div");
	var divBody = document.createElement("div");

    divInfo.className = "infowindow";
	divTitle.className = "infowindowtitle";
	divTitle.innerHTML = this.address;
	
	divBody.className = "infowindowbody";

    
	var bodyText = "";
	
	if (this.gbase == "True")
		bodyText += "<img height=90 width=120 id=thumbnail src="+ this.gbase_image +">";
	else
		bodyText += "<img height=90 width=120 id=thumbnail src=/show_photos/img_showthumbnail.asp?metro_id=" + metroId + "&home_id=" + this.home_id + "&main_photo_id=" + this.main_photo_id + "&main_photo_version=" + this.main_photo_version + "&Status=" + this.status + ">";

	bodyText = bodyText + "Price: $" + this.price + "<br>";	
	bodyText = bodyText + this.beds + " beds / " + this.baths + " baths<br>";
	bodyText = bodyText + this.city + "<br><br>";

	if (this.gbase == "True")
		bodyText = bodyText + "<a target=\"_top\" href=home_view.asp?snippet=" + this.direct_url + ">view property</a><br><br>";
	else
		bodyText = bodyText + "<a target=\"_top\" href=home_view.asp?homeid=" + this.direct_url + ">view property</a><br><br>";
		

	divBody.innerHTML = bodyText;

	divInfo.appendChild(divTitle);
	divInfo.appendChild(divBody);

	if (!this.marker.point) {  		
		this.marker.point = this.marker.getPoint(); 
	}
	map.openInfoWindow(this.marker.point,divInfo);



	//var strUrl = "recordmaphit.asp?homeid=" + this.home_id;
	//GDownloadUrl(strUrl, function(data, responseCode) {
	//})
}

Property.prototype.handlePropertyClick = function ()
{
	map.centerAndZoom(this.marker.point, 3);
}

function setZIndexHBO(m){
 	return 0;
}
function setZIndexHBO2(m){
	return -2;	
}
function setZIndexGB(m){
	return -1;	
}