
// ####################################
// ########## Listing Object ##########
// ####################################

var selListing = 0;
var maxListingCount = 0;


function Listing()
{
    this.VEShapeLayer = typeof _listingLayer != 'undefined' ? _listingLayer : null;
    
    // VEShapeLayer
    this.VEShape = null;
    this.GridRow = null;
    this.ListingID = null;
    this.MlsListingID = null;
    this.MlsID = null;
    this.PropertyType = null;
    this.ListingStatus = null;
    this.Latitude = null;
    this.Longitude = null;
    this.ListingPrice = null;
    this.Bedrooms = null;
    this.Bathrooms = null;
    this.SquareFeet = null;
    this.Acres = null;
    this.Units = null;
    this.YearBuilt = null;
    this.InsertDate = null;
    this.LastUpdateDate = null;
    this.Address = null;
    this.City = null;
    this.Region = null;
    this.PostalCode = null;
    this.PhotoAtHbm = null;
    this.PhotoCount = null;
    this.ListBrokerID = null;
    this.ListAgentID = null;
    this.ListAgentInfo = null;
    this.VirtualTourUrl = null;
    this.Description = null;
    this.NumberOfDays = null;
    this.MetroAreaID = null;
    this.HasOpenHouse = null;
    this.UserRating = null;
    this.EntityID = null;
    this.MLSPropertyStatus = null;
    this.ForeclosureRelated = null;
    this.ShortSaleRelated = null;
    this.RealEstateOwnedRelated = null;
    this.NotesLastUpdatedDate = null;
    this.IsAuthenticated = false;
    this.CloneMlsId = null;
    //this.NoteCount = null;
}

Listing.prototype.Populate = function Listing$Populate(listingItems, mlsID, clonedMLSID, metroArea) {

    this.ListingID = listingItems[0];       //internal ID
    this.MlsListingID = listingItems[1];    //PropertyID
    this.MlsID = mlsID;                     //TerritoryID
    this.PropertyType = listingItems[3];
    this.ListingStatus = listingItems[4];
    this.Latitude = listingItems[5];
    this.Longitude = listingItems[6];
    this.ListingPrice = listingItems[7];
    this.Bedrooms = listingItems[8];
    this.Bathrooms = listingItems[9];
    this.SquareFeet = listingItems[10];
    this.Acres = listingItems[11];
    this.Units = listingItems[12];
    this.YearBuilt = listingItems[13];
    this.InsertDate = listingItems[14];
    this.LastUpdateDate = listingItems[15];
    this.Address = listingItems[16];
    this.City = listingItems[17];
    this.Region = listingItems[18];
    this.PostalCode = listingItems[19];
    //Bunch of features
    this.PhotoAtHbm = listingItems[36];
    this.PhotoCount = listingItems[37];
    this.ListBrokerID = listingItems[38];
    this.ListAgentID = listingItems[39];
    this.ListAgentInfo = listingItems[40];
    this.VirtualTourUrl = listingItems[41];
    this.Description = listingItems[42];
    this.NumberOfDays = listingItems[43];
    this.HasOpenHouse = listingItems[44];
    this.UserRating = listingItems[45];
    this.EntityID = listingItems[46];
    this.MLSPropertyStatus = listingItems[47];
    this.ForeclosureRelated = listingItems[48];
    this.ShortSaleRelated = listingItems[49];
    this.RealEstateOwnedRelated = listingItems[50];
    this.NotesLastUpdatedDate = listingItems[51];
    //this.NoteCount = listingItems[52];
    this.MetroAreaID = MetroAreaID; //from variable on home page
    this.IsAuthenticated = IsAuthenticated;  //local variable on mapsearch.aspx
    this.ClonedMlsID = clonedMLSID;
}
Listing.prototype.DisplayShapeArray = function(array) 
{
     this.VEShapeLayer.AddShape(array);
}
Listing.prototype.DisplayGridArray = function(array)
{
    document.getElementById('divGrid').innerHTML = array.join('');
}
Listing.prototype.DisplayListArray = function(array)
{
    document.getElementById('divList').innerHTML = array.join('');
}

Listing.prototype.ValidLatOrLon = function( latitude, longitude ) {
    if ( this.Latitude == "NaN" || this.Longitude == "NaN" ) return false;
    return true;    
}

Listing.prototype.GetLatLong = function()
{
    if( !this.ValidLatOrLon( this.Latitude, this.Longitude ) ) return null;
    
    return new VELatLong(this.Latitude, this.Longitude);
}

Listing.prototype.GetShape = function() 
{ 
    var photoUrl = getPhotoURL(this.MlsListingID, this.ClonedMlsID, this.PhotoAtHbm, this.PhotoCount);

    if( !this.ValidLatOrLon( this.Latitude, this.Longitude ) ) return null;
        
    this.VEShape = new VEShape(VEShapeType.Pushpin, new VELatLong(this.Latitude, this.Longitude));
    this.VEShape.SetTitle("LOAD:"+this.ListingID+","+this.EntityID);  //Use this for ajax version of hover box
    this.VEShape.SetCustomIcon(this.GetIcon());
    return this.VEShape;
} 
Listing.prototype.GetIcon = function(){
    if(this.UserRating>0){return "../App_Themes/Default/Images/Map/icon_notebook.png";}
    if(this.UserRating==0){return "../App_Themes/Default/Images/Map/icon_discard.png";}
    if(!(IsNullOrEmpty(this.ListAgentID))){
        if(this.ListAgentID==ListAgentID){return "../App_Themes/Default/Images/Map/icon_agent.gif";}
    }
    if(!(IsNullOrEmpty(this.ListBrokerID))){
        if(this.ListBrokerID==ListBrokerID){return "../App_Themes/Default/Images/Map/icon_broker.gif";}
    }
    if(this.NumberOfDays<=2){return "../App_Themes/Default/Images/Map/icon_new.png";}
    if(this.EntityID>0){
        if(this.HasOpenHouse=="True"){return "../CompanySpecificImages/"+this.EntityID+"/OpenHouse.png";}
        return "../CompanySpecificImages/"+this.EntityID+"/BankOwned.png";
    }
    if(this.HasOpenHouse=="True"){return "../App_Themes/Default/Images/Map/icon_openhouse.png";}
    if(this.VirtualTourUrl!=""){return "../App_Themes/Default/Images/Map/icon_virtualtour.png";}

    return "../App_Themes/Default/Images/Map/icon_listing.gif";
}
Listing.prototype.GetGridRowData = function(n)
{
    var className;
    if(isEven(n)){className="gridRow";}else{className="gridRowAlt";}
    var addr = escape(this.getAddress()+'<br />'+this.City+',&nbsp;'+this.Region+'&nbsp;'+this.PostalCode);
    var row = "<div onmouseover=\"displayPhotoForGrid(" + n + ", '" + this.MlsListingID + "', '" + this.MlsID + "', '" + this.PhotoAtHbm + "', '" + this.PhotoCount + "', '" + addr + "','"+this.ListingID + "', '" + this.ClonedMlsID+ "', '"+this.MetroAreaID+ "');"
        + "displaySummary('" + this.ListingPrice + "', '" + this.City + "', '" + this.SquareFeet + "', '" + this.Bedrooms + "', '" + this.Bathrooms + "', '" + escape(this.ListAgentInfo) + "');"
        + "this.className='gridRowHighlight';\""
        + " onmouseout=\"this.className='"+className+"';hideAddressHover();\" onclick=\"popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\"" //+ "clearSummary();\""
        + " class=\""+className+"\">&nbsp;&nbsp;&nbsp;" + this.Bedrooms + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='display:inline-block;width:20px;'>" + this.Bathrooms + "</span>&nbsp;&nbsp;&nbsp;&nbsp;" + this.ListingPrice + "</div>";
	return row;
}
Listing.prototype.GetListRowData = function(n)
{
    //var className;
    //if(isEven(n)){className="listRow";}else{className="listRowAlt";}
    var addr = this.getAddress()+'&nbsp;'+this.City+',&nbsp;'+this.Region+'&nbsp;'+this.PostalCode;
	var row = "<div id=\"divListRow_"+this.ListingID+"\" class=\"listRowAlt\" style=\"position:relative;width:595px;height:110px;\" onmouseover=\"showColumn('"+this.ListingID+"');\">"
	+"<div style=\"width:595px;height:20px;\">"
	    +"<span style=\"font-size:1.2em;font-weight:bold;margin-left:5px;float:left;\">"+addr+"</span>"
	    +"<span style=\"float:right;margin-right:25px;\">"
	        +"<a href=\"javascript:setRating('"+this.ListingID+"','1', '1');\"><img id=\""+this.ListingID+"_Star_1\" style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/fav_star_" + (this.UserRating >= 1 ? "rollover" : "normal") +".png\" onmouseover=\"toggleStarsOver('"+this.ListingID+"','1');\" onmouseout=\"toggleStarsOut('"+this.ListingID+"');\" /></a>"
            +"<a href=\"javascript:setRating('"+this.ListingID+"','2', '1');\"><img id=\""+this.ListingID+"_Star_2\" style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/fav_star_" + (this.UserRating >= 2 ? "rollover" : "normal") +".png\" onmouseover=\"toggleStarsOver('"+this.ListingID+"','2');\" onmouseout=\"toggleStarsOut('"+this.ListingID+"');\" /></a>"
            +"<a href=\"javascript:setRating('"+this.ListingID+"','3', '1');\"><img id=\""+this.ListingID+"_Star_3\" style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/fav_star_" + (this.UserRating >= 3 ? "rollover" : "normal") +".png\" onmouseover=\"toggleStarsOver('"+this.ListingID+"','3');\" onmouseout=\"toggleStarsOut('"+this.ListingID+"');\" /></a>"
            +"<a href=\"javascript:setRating('"+this.ListingID+"','4', '1');\"><img id=\""+this.ListingID+"_Star_4\" style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/fav_star_" + (this.UserRating >= 4 ? "rollover" : "normal") +".png\" onmouseover=\"toggleStarsOver('"+this.ListingID+"','4');\" onmouseout=\"toggleStarsOut('"+this.ListingID+"');\" /></a>"
            +"<a href=\"javascript:setRating('"+this.ListingID+"','5', '1');\"><img id=\""+this.ListingID+"_Star_5\" style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/fav_star_" + (this.UserRating >= 5 ? "rollover" : "normal") +".png\" onmouseover=\"toggleStarsOver('"+this.ListingID+"','5');\" onmouseout=\"toggleStarsOut('"+this.ListingID+"');\" /></a>"
	    +"</span>"
	+"</div>"
	
	+"<div style=\"float:left;width:100px;height:75px;\">"
	    +"<div style=\"position:relative;\">"
	        +"<a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\"><img align=\"top\" width=\"100\" height=\"75\" src=\""+getPhotoURL(this.MlsListingID, this.ClonedMlsID, this.PhotoAtHbm, this.PhotoCount)+"\" style=\"border:1px solid gray;z-index:5;\"></a>"
	        +"<div style=\"position:absolute;top:0px;left:0px;z-index:6;\"><a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\">"+this.getBanner("_sm")+"</a></div>"
	    +"</div>"
	+"</div>"
	
	+"<div style=\"float:left;width:485px;height:77px;margin-top:-1px;\">"
        +"<div style=\"height:20px;margin-top:10px;margin-left:5px;\">"
	        +"<div style=\"font-size:1.2em;font-weight:bold;float:left;\">"+this.ListingPrice+"</div>"
	        +"<div style=\"float:right;margin-right:25px;font-weight:bold;\">"+this.InsertDate+"</div>"
        +"</div>"
        +"<div style=\"clear:both;margin-left:5px;line-height:15px;height:15px;\">"+this.getFeatures()+"</div>"
	    +"<div style=\"margin-left:5px;line-height:10px;height:10px;\">Courtesy of "+this.ListAgentInfo+"</div>"
	    
        +"<div style=\"margin-left:5px;width:70px;float:left;\">"+this.getRating("_LIST")+"</div>"
	    +"<div style=\"float:left;\">"+this.getDiscard("_LIST")+"</div>"

        +"<div style=\"float:left;height:20px;width:65px;text-align:right;\">"
        +"<span style=\"float:right\">"+this.GetNotesIcon()+"</span>"
        +"<span style=\"float:right;line-height:20px;\"><a href=\"javascript:showListViewNotes('"+this.ListingID+"','"+this.MlsListingID+"');\" style=\"color:#333333;text-decoration:none;\">Notes</a></span>"
        
	    +"</div>"

        +"<div style=\"float:left;margin-left:15px;\">"
        +"<span style=\"margin-left:10px;line-height:20px;\">Status: "+this.MLSPropertyStatus+"</span>"
        +"</div>"

        + "<div class=\"divMLSlogoList\" style=\"margin-left:15px;height:25px;width:70px;float:left;\">" + MLSLogo + "</div>"
        
	    +"<div style=\"float:right;margin-right:20px;\">"
        +"<a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\"><img style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/btn_details.png\" /></a>"
	    +"</div>"

        +"<input type=\"hidden\" id=\"rating_"+this.ListingID+"\" value=\""+this.UserRating+"\" />"
	+"</div>"
	+"<div id=\"divNotes_"+this.ListingID+"\" style=\"clear:both;width:550px;height:112px;margin-left:5px;display:none;padding-top:5px;\">"+this.getNotes()+"</div>"
	
	+"</div>"
	return row;
}
Listing.prototype.GetListColumnData = function(n) {
    var column = "<div id=\"divListColumn_" + this.ListingID + "\" style=\"position:absolute;top:0px;left:0px;display:none;\">"
    + this.GetListColumnDataInnerHtml(n)
	+ "</div>";
    return column;
}

Listing.prototype.GetListColumnDataInnerHtml = function(n) {
    var innerHtml = "<style type=\"text/css\">"
    + "#miniMap_" + this.MlsListingID + " .MSVE_PoweredByLogo{display:none;}"
	+ "#miniMap_" + this.MlsListingID + " .MSVE_PoweredByLogo_ie{display:none;}"
	+ "#miniMap_" + this.MlsListingID + " .MSVE_CopyrightBackground{background-color:transparent;}"
	+ "</style>"
	+ "<div id=\"miniMap_" + this.MlsListingID + "\" style=\"position:absolute;top:0px;width:0px;width:165px;height:125px;border:1px solid gray;z-index:7;display:none;\"></div>"

    + "<div style=\"width:165px;height:145px;\">"
	    + "<div style=\"position:relative;\">"
	    + "<a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\"><img id=\"Photo_" + this.MlsListingID + "\" align=\"top\" width=\"165\" height=\"125\" src=\"" + getPhotoURL(this.MlsListingID, this.ClonedMlsID, this.PhotoAtHbm, this.PhotoCount) + "\" style=\"border:1px solid gray;z-index:5;\"></a>"
	    + "<div style=\"position:absolute;top:0px;left:0px;z-index:6;\"><a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\">" + this.getBanner() + "</div></a>"
	    + "</div>"

	    + "<div style=\"height:20px;width:167px;background-color:#636dab;font-size:.8em;font-weight:bold;color:#FFFFFF;\">"
	    + this.getPhotoLinks()
	    + "&nbsp;&nbsp;<a id=\"a_miniMap_" + this.MlsListingID + "\" style=\"text-decoration:none;color:#FFFFFF;font-size:.75em;font-weight:bold;\" href=\"javascript:toggleMiniMap('" + this.MlsListingID + "','" + this.Latitude + "','" + this.Longitude + "');\">View Map</a>"
	    + "</div>"
	+ "</div>"
	+ "<div style=\"width:160px;text-align:center;color:#8c91b7;font-size:.8em;font-weight:bold;overflow:hidden;margin-top:10px;\">" + this.getAddress() + "</div>"
	+ "<div style=\"width:160px;text-align:center;overflow:hidden;\"><span style=\"font-size:.8em;font-weight:bold;color:#abaaa8;\">|&nbsp;</span><span style=\"font-size:.8em;font-weight:bold;color:#333333;\">" + this.ListingPrice + "</span><span style=\"color:#abaaa8;\">&nbsp;|</span></div>"
	+ "<div style=\"width:160px;text-align:center;overflow:hidden;\"><span style=\"font-size:.8em;font-weight:bold;color:#abaaa8;\">|&nbsp;</span><span style=\"font-size:.8em;font-weight:bold;color:#333333;\">" + this.Bedrooms + "&nbsp;Bed</span><span style=\"color:#abaaa8;\">&nbsp;|&nbsp;</span><span style=\"font-size:.8em;font-weight:bold;color:#333333;\">" + this.Bathrooms + "&nbsp;Bath</span><span style=\"color:#abaaa8;\">&nbsp;|</span></div>"
	+ "<div style=\"margin-top:10px;margin-left:10px;color:#333333;width:145px;height:110px;font-size:.7em;font-weight:bold;overflow:hidden;\">"
	+ this.GetDescription()
	+ "<a style=\"color:#fb9600;text-decoration:none;\" href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\">&nbsp;more></a>"
	+ "</div>"

	+ "<div style=\"height:25px;width:165px;\">"
        + "<div style=\"width:70px;float:left;font-size:.8em;\">" + this.getRating("_COL") + "</div>"

        + "<div style=\"font-size:.8em;\">" + this.getDiscard("_COL") + "</div>"
    + "</div>"


    + "<div style=\"width:165px;margin-top:15px;text-align:center;\">"
    + "<a href=\"javascript:popUpCenteredWindow(\'ListingDetail.aspx?LID=" + this.ListingID+"&MLSID="+this.MlsID+"&MetroAreaID="+this.MetroAreaID + "\');\"><img style=\"margin:0px;\" src=\"../App_Themes/Default/Images/Map/btn_viewDetails.png\" /></a>"
	+ "</div>"

	+ "<div style=\"width:165px;margin-top:15px;font-size:.8em;text-align:center;\">"
	+ "MLS#: " + this.MlsListingID
	+ "</div>"

	+ "<div style=\"width:165px;margin-top:15px;text-align:right;\">"
	+ "<div style=\"font-size:.6em;\">Courtesy of " + this.ListAgentInfo + "</div>"
	+ "</div>"

	+ "<div style=\"height:15px;width:25px;margin-top:10px;\">" + MLSLogo + "</div>";
    return innerHtml;
}
Listing.prototype.GetDescription = function() {
    if(IsNullOrEmpty(this.Description)) {
        return "";
    }
    if(this.Description.length>120) {
        return this.Description.substring(0, 120);
    }
    return this.Description;
}
Listing.prototype.GetNotesIcon = function() {
    //if(this.NotesLastUpdatedDate!="1/1/0001 12:00:00 AM") {
            return "<a style=\"margin-left:3px;\" href=\"javascript:showListViewNotes('"+this.ListingID+"','"+this.MlsListingID+"');\"><img style=\"margin-top:3px;\" src=\"../App_Themes/Default/Images/notes.png\"></a>"
       //}
       // else {
       //    return "<a style=\"margin-left:3px;\" href=\"javascript:showListViewNotes('"+this.ListingID+"','"+this.MlsListingID+"');\"><img style=\"margin-top:3px;\" src=\"../App_Themes/Default/Images/notes_white.png\"></a>"
       //}
}
Listing.prototype.displayFirstPhoto = function(n)
{
    var addr = escape(this.getAddress()+'<br />'+this.City+',&nbsp;'+this.Region+'&nbsp;'+this.PostalCode);
    displayPhotoForGrid(n,this.MlsListingID,this.MlsID,this.PhotoAtHbm,this.PhotoCount,addr,this.ListingID,this.ClonedMlsID,this.MetroAreaID);
    displaySummary(this.ListingPrice,this.City,this.SquareFeet,this.Bedrooms,this.Bathrooms,escape(this.ListAgentInfo));
}

Listing.prototype.getRating = function(opt) {
    var html;
    var listingID = this.ListingID;
    var userRating = this.UserRating;

    return this.getRatingFor( opt, listingID, userRating);
}

Listing.prototype.getRatingFor = function( opt, listingID, userRating ){
html="<div id=\"divFavorite_Remove"+listingID+opt+"\" style=\"display:" + (userRating > 0 ? "block" : "none") +"\">"
    +"<span style=\"float:right;\">"
    +"<a href=\"javascript:setFavorite('"+listingID+"','-1','"+opt+"');\">"
    +"<img id=\"ratingStarLeft\" align=\"middle\" src=\"../App_Themes/Default/Images/Map/fav_star_rollover.png\" alt=\"Remove From Favorites\">"
    +"</a>"
    +"</span>"

    +"<span style=\"margin-left:3px;line-height:20px;\">"
    +"<a href=\"javascript:setFavorite('"+listingID+"','-1','"+opt+"');\" style=\"color:#333333;text-decoration:none;\">Favorite</a>"
    +"</span>"
    +"</div>"

    +"<div id=\"divFavorite_Add" + listingID+opt+"\" style=\"display:" + (!(userRating > 0) ? "block" : "none") + "\">"
    +"<span style=\"float:right;\">"
    +"<a href=\"javascript:setFavorite('"+listingID+"','1','"+opt+"');\">"
    +"<img id=\"ratingStarLeft\" align=\"middle\" src=\"../App_Themes/Default/Images/Map/fav_star_normal.png\" onmouseover=\"toggleStar(this);\" onmouseout=\"toggleStar(this);\" alt=\"Add To Favorites\"></a>"
    +"</span>"

    +"<span style=\"margin-left:3px;line-height:20px;\">"
    +"<a href=\"javascript:setFavorite('"+listingID+"','1','"+opt+"');\" style=\"color:#333333;text-decoration:none;\">Favorite</a>"
    +"</span>"
    +"</div>"
    return html;
}

Listing.prototype.SwitchRating = function(listingID, userRating ){
    this.SwitchRatingFor( '_LIST', listingID, userRating );
    this.SwitchRatingFor( '_COL', listingID, userRating );

}
Listing.prototype.SwitchRatingFor = function(opt, listingID, userRating ){

    var favRemove = $("divFavorite_Remove"+listingID+opt);
    if( favRemove !== undefined && favRemove != null ) favRemove.style.display = userRating > 0 ? "block" : "none";
    var favAdd = $("divFavorite_Add"+listingID+opt);
    if( favAdd !== undefined && favAdd != null ) favAdd.style.display = !userRating > 0 ? "block" : "none";

}

Listing.prototype.getDiscard = function(opt) {
    var html;
    html="<div id=\"divDiscard_" + this.ListingID +opt+ "\" style=\"width:65px;float:left;margin-left:10px;display:" + (this.UserRating != 0 ? "block" : "none") +"\">"
        +"<span style=\"float:right;\">"
        +"<a href=\"javascript:setDiscard('" + this.ListingID + "', '0','"+opt+"');\">"
        +"<img style=\"margin-top:3px;\" src=\"../App_Themes/Default/Images/Map/discard.png\" alt=\"Discard\"></a>"
        +"</span>"
        
        +"<span style=\"margin-left:3px;line-height:20px;\">"
        +"<a href=\"javascript:setDiscard('" + this.ListingID + "', '0','"+opt+"');\" style=\"color:#333333;text-decoration:none;\">Discard</a>"
        +"</span>"
    +"</div>"
    
    +"<div id=\"divUnDiscard_" + this.ListingID +opt+ "\" style=\"width:80px;float:left;margin-left:10px;display:" + (this.UserRating == 0 ? "block" : "none") +"\">"
        +"<span style=\"float:right;\">"
        +"<a href=\"javascript:setDiscard('" + this.ListingID + "', '-1','"+opt+"');\">"
        +"<img style=\"margin-top:3px;\" src=\"../App_Themes/Default/Images/Map/undiscard.png\" alt=\"Un-Discard\"></a>"
        +"</span>"
        
        +"<span style=\"margin-left:3px;line-height:20px;\">"
        +"<a href=\"javascript:setDiscard('" + this.ListingID + "', '-1','"+opt+"');\" style=\"color:#333333;text-decoration:none;\">UnDiscard</a>"
        +"</span>"
    +"</div>"
    return html;
}
Listing.prototype.getFeatures = function() {
    var html='';
    if((this.PropertyType==null) || (this.PropertyType=="House") || (this.PropertyType=="Condo")) {
        html= this.PropertyType+"&nbsp;&nbsp;|&nbsp;&nbsp;"+this.Bedrooms+" Bed&nbsp;&nbsp;|&nbsp;&nbsp;"+this.Bathrooms+" Bath&nbsp;&nbsp;|&nbsp;&nbsp;";
        if(this.SquareFeet!="0"){html+=this.SquareFeet+" SqFt&nbsp;&nbsp;|&nbsp;&nbsp;";}
        html+="Year: "+this.YearBuilt+"&nbsp;&nbsp;|&nbsp;&nbsp;MLS#: "+this.MlsListingID;
    }
    if(this.PropertyType=="Multi") {
        html= this.PropertyType+"&nbsp;&nbsp;|&nbsp;&nbsp;"+this.Units+" Units&nbsp;&nbsp;|&nbsp;&nbsp;Year: "+this.YearBuilt+"&nbsp;&nbsp;|&nbsp;&nbsp;MLS#: "+this.MlsListingID;
    }
    if(this.PropertyType=="Land") {
        html= this.PropertyType+"&nbsp;&nbsp;|&nbsp;&nbsp;"+this.Acres+" Acres&nbsp;&nbsp;|&nbsp;&nbsp;MLS#: "+this.MlsListingID;
    }
    return html;
}
Listing.prototype.getNotes = function() {
    var html;
    html="<span style=\"font-weight:bold;\">My Notes</span><span id=\"divNoteUpdateMessage_"+this.ListingID+"\" style=\"font-weight:bold;color:green;margin-left:10px;width:200px;\"></span><br />"
	    +"<textarea id=\"txtBuyerNotes_"+this.ListingID+"\" style=\"width:510px;height:50px;\"></textarea>"
	    +"<br />"
	    +"<a href=\"javascript:addNoteToNotebook('"+this.ListingID+"','"+this.MlsID+"', 'txtBuyerNotes_"+this.ListingID+"',0,'"+this.UserRating+"','opt');\">"
	    +"<img src=\"../App_Themes/Default/Images/button_saveinfo.png\" style=\"float:right;margin-top:5px;margin-right:30px;\"></a>"
	    +"<div id=\"divLONotes_"+this.ListingID+"\" style=\"display:none;height:35px;margin-top:15px;margin-bottom:5px;\"></div>"
	    +"<div id=\"divAgentNotes_"+this.ListingID+"\" style=\"display:none;height:35px;margin-bottom:5px;\"></div>"
    return html;
}
Listing.prototype.getBanner = function(opt) {
    if(opt===undefined){opt="";}

    if(!(HoverFlagExceptions.split(",").has(this.MlsID))) {
        //Open house
        if(this.HasOpenHouse=="True"){return "<img src=\"../App_Themes/Default/Images/banner_openhouse"+opt+".png\" />";}
        
        //New
        if(this.NumberOfDays<=1){return "<img src=\"../App_Themes/Default/Images/banner_new"+opt+".png\" />";}
         
        //Foreclosure    
        if(this.EntityID>0){return "<img src=\"../App_Themes/Default/Images/banner_foreclosure"+opt+".png\" />";}
    }
    return "";
}
Listing.prototype.getPhotoLinks = function() {
    var html;
    if(this.PhotoCount<=1){
        html="<span style=\"margin-left:25px;\"></span>";
    }
    else {
        html="<div style=\"float:left;\"><a href=\"javascript:togglePhoto('"+this.MlsListingID+"','"+this.PhotoCount+"','L');\"><img src=\"../App_Themes/Default/Images/Map/arrow_white_LT.png\"></a>"
	    +"<a href=\"javascript:togglePhoto('"+this.MlsListingID+"','"+this.PhotoCount+"','R');\"><img src=\"../App_Themes/Default/Images/Map/arrow_white_RT.png\"></a>"
	    +"</div>"
	    +"<div style=\"height:20px;background-color:#4552a0;float:left;margin-left:10px;line-height:20px;\">&nbsp;<span id=\""+this.MlsListingID+"_Photo_1\">1</span><span> of </span><span id=\""+this.MlsListingID+"_Photo_2\">"+this.PhotoCount+"</span>&nbsp;</div>"
	    
	}
	return html;
}
Listing.prototype.getAddress = function() {
    var address = this.Address;
    if (IsNullOrEmpty(address)) {
        address = "<a href=\"javascript:StartRegistration('RequestAddress', '', '', "+this.ListingID+", '');\">Request Address</a>";
    }
    return address;
}