//
// Property object
//

function Property (prop)
{
  this.addr     = unescape(prop[0]);
  this.city_st  = prop[1];
  this.remarks  = unescape(prop[2]);
  if (this.remarks.length > 80)
      this.remarks = this.remarks.substring(0,80) + " ...";
  this.mls_no   = prop[3];
  this.rooms    = prop[4];
  this.bedrooms = prop[5];
  this.fbaths   = prop[6];
  this.hbaths   = prop[7];
  this.lprice   = prop[8];
  this.sqft     = prop[9];
  this.acre     = prop[10];
  this.ptype    = prop[11];
  this.pidx     = prop[12];
  this.byear    = prop[13];
  this.p_lat    = prop[14] + 0.0;
  this.p_long   = prop[15] + 0.0;
  this.p_cat    = prop[16];
  //
  // if there are any 1/2 baths, add 0.5 to the number of full baths
  //
  this.baths    = Number(this.fbaths) + ( Number(this.hbaths) > 0 ? 0.5 : 0.0 );
  //
  // For map-related data
  //
  this.marker   = null;
  this.point    = null;
  this.id       = null;
  // 
  this.visible  = false;
}

/**
 * Creates HTML bubble
 * @return {String} HTML string
 */
Property.prototype.createBubble = function() {
    var fl = getMLSString(this.mls_no);
	var name = photoDir + '/' +
	    fl.substring(0, 2) + '/' + fl.substring(2, 5) + '/' + fl.substring(5, 8) + '_0.jpg';
	var html = '<table cellpadding="0" cellspacing="0" border="0"><tr><td>';
	html += '<a href="javascript:viewProperty(' + this.mls_no + ');">';
	html += '<img src="' + name +
	    '" alt="view details" height="64" style="border:1px solid #efefef;" hspace="2" vspace="0"></a></td>';
	html += '<td style="font-size:9pt;color:navy;">';
	html += 'MLS# ' + fl + '<br><b>' + formatPrice(this.lprice) + '</b><br>';
	if (this.ptype != "LD") {
		html += this.rooms + '&nbsp;rooms&nbsp;' + this.bedrooms + '&nbsp;bedrooms<br>' + this.fbaths + '&nbsp;full bath';
		if (this.fbaths > 1) html += 's';
	}
	/* html += this.remarks; */
	html += '&nbsp;<a href="javascript:viewProperty(' + this.mls_no + ');">More...</a>';
	html += '</td></tr></table>';
	return html;
}

/**
 * Creates HTML bubble
 * @return {String} HTML string
 */
Property.prototype.createDivControl = function() {
    var fl = getMLSString(this.mls_no);
	var name = photoDir + '/' +
	    fl.substring(0, 2) + '/' + fl.substring(2, 5) + '/' + fl.substring(5, 8) + '_0.jpg';
	var html = '<table cellpadding="0" cellspacing="0" border="0"><tr><td>';
	html += '<a href="javascript:viewProperty(' + this.mls_no + ');">';
	html += '<img src="' + name +
	    '" alt="view details" height="64" style="border:1px solid #efefef;" hspace="2" vspace="0"></a></td>';
	html += '<td style="font-size:9pt;color:navy;">';
	html += 'MLS# ' + fl + '<br><b>' + formatPrice(this.lprice) + '</b><br>';
	if (this.ptype != "LD") {
		html += this.rooms + '&nbsp;rooms&nbsp;' + this.bedrooms + '&nbsp;bedrooms<br>' + this.fbaths + '&nbsp;full bath';
		if (this.fbaths > 1) html += 's';
	}
	/* html += this.remarks; */
	html += '&nbsp;<a href="javascript:viewProperty(' + this.mls_no + ');">More...</a>';
	html += '</td><td><img style="margin-left: 20px; margin-right: 20px; width: 60px;" src="' + localDir + '/images/mapit.png" alt="Map It!"' +
	    ' onmouseover="this.style.cursor=' + "'pointer'" + '"' +
        ' onmouseout="this.style.cursor=' + "'default'" + '"' +
        ' onclick="javascript:mapProperty(' + "'" + getMLSString(this.mls_no) + "'" + ');"/>';

	html += '</td></tr></table>';
	return html;
}


/**
 * Returns full name of property type (e.g. MF -> "Multi-Family")
 * @return {String} property type name string
 */
Property.prototype.typeFullName = function() {
    if (this.ptype == "SF") return "Single Family";
    if (this.ptype == "MF") return "Multi Family";
    if (this.ptype == "CC") return "Condo/Townhouse";
    if (this.ptype == "LD") return "Land";
    return this.ptype;
}

Property.prototype.setGeoMarker = function(marker) {
    this.marker = marker;
}
Property.prototype.setGeoPoint  = function(point) {
    this.point  = point;
}
Property.prototype.setGeoId     = function(id) {
    this.id     = id;
}
Property.prototype.getGeoMarker = function() {
    return this.marker;
}
Property.prototype.getGeoPoint  = function() {
    return this.point;
}
Property.prototype.getGeoId     = function() {
    return this.id;
}
Property.prototype.setVisible   = function(vis) {
    this.visible = vis;
}
Property.prototype.getVisible   = function() {
    return this.visible;
}

