﻿// ####################################
// ########## Sold Search Object ##########
// ####################################

function SoldSearch()
{
    this.ZoomLevel = null;
    this.Latitude = null;
    this.Longitude = null;
    this.MonthsBack = 24;
    this.PriceMin = null;
    this.PriceMax = null;
    this.Radius = null;
    this.SearchPriority = null;
    this.PropertyType = null;
}
SoldSearch.prototype.SetZoomLevel = function(value)
{
	this.ZoomLevel = value;
}
SoldSearch.prototype.SetLatLong = function(latitude, longitude)
{
	this.Latitude = latitude;
	this.Longitude = longitude;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.SetMonthsBack = function(value)
{
	this.MonthsBack = value;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.SetPrice = function(minvalue, maxvalue)
{
	this.PriceMin = minvalue;
	this.PriceMax = maxvalue;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.SetRadius = function(value)
{
	this.Radius = value;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.SetSearchPriority = function(value)
{
	this.SearchPriority = value;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.SetPropertyType = function(value)
{
	this.PropertyType = value;
	this.ShowSoldCriteria();
}
SoldSearch.prototype.ShowSoldCriteria = function()
{	
	var searchResults = (!(IsNullOrEmpty(this.PropertyType)))?"<a href=\"javascript:_searchSold.SetPropertyType(null);removeOption('SoldProp');\"><img src=\"../App_Themes/Default/Images/Map/icon_tiny_x.png\" border=\"0\"></a>&nbsp;&nbsp;"+this.GetPropertyTypeName(this.PropertyType)+"<br>":"";
		searchResults += (this.PriceMin!=null)?"<a href=\"javascript:_searchSold.SetPrice(null,null);removeOption('SoldPrice');\"><img src=\"../App_Themes/Default/Images/Map/icon_tiny_x.png\" border=\"0\"></a>&nbsp;&nbsp;"+"$"+addCommas(this.PriceMin)+" - "+"$"+addCommas(this.PriceMax)+"<br>":"";
        searchResults += (!(IsNullOrEmpty(this.MonthsBack)))?"<a href=\"javascript:_searchSold.SetMonthsBack(null);removeOption('SoldMonths');\"><img src=\"../App_Themes/Default/Images/Map/icon_tiny_x.png\" border=\"0\"></a>&nbsp;&nbsp;Up to "+this.MonthsBack+" months back<br>":"";
	document.getElementById('divSoldResults').innerHTML ='';
	document.getElementById('divSoldResults').innerHTML = searchResults;
	document.getElementById('divSoldResults').style.display='block';
	GetSolds();
}
SoldSearch.prototype.GetPropertyTypeName = function(value) { 
    switch(value)
	    {
	    case 1:
	        return "House";
	      break    
	    case 2:
	        return "Condo/Townhome";
	      break
	    case 3:
	        return "All";
	      break
	    case 4:
	        return "Multi-Family";
	      break
	    }
}