function ResultSet(sObjName, sSort, iPageCount, oState)
{
	this.PageLBound = 0;
	this.Handle = sObjName;
	this.PerPage = iPageCount;
	this.Results = new Array();
	this.StateData = oState;
	this.SortBy = sSort;
}
ResultSet.prototype.Display = function(sExtraData)
{
	var aHTML = new Array();
	
	aHTML.push('<p style="position:relative;text-align:left;"><strong>' + this.Results.length + ' properties met your search criteria.</strong></p>');
	aHTML.push('<form action="/realestate/propertydetails.html" method="post" name="SearchResults" id="SearchResults">');
	aHTML.push('<div class="SearchUtilities">');
	aHTML.push('<table width="96%" cellpadding="0" cellspacing="0" border="0" align="center">');
	aHTML.push('<tr>');
	aHTML.push('<td align="left"><input type="button" class="FormButtons" value="Back to Search" onclick="GetTag(\'ReviseSearch\').submit();"></td>');
	aHTML.push('<td align="right">Listings Per Page:</td>');
	aHTML.push('<td width="20"><form action="/realestate/propertydetails.html" method="post" name="SearchResults" id="SearchResults">');
	aHTML.push('<select name="LPP" id="LPP" class="FormElementInput" onchange="' + this.Handle + '.SetPerPage(this.value);">');
			
	for(var i=10; i<=100; i+=10)
		if(this.PerPage == i)
			aHTML.push('<option value="' + i + '" selected>' + i + '</option>');
		else
			aHTML.push('<option value="' + i + '">' + i + '</option>');
	
	aHTML.push('</select></td>');
	aHTML.push('</tr>');
	aHTML.push('</table>');
	aHTML.push('</div>');
	
	aHTML.push('<div style="overflow:auto;">');
	aHTML.push('<table align="right" cellpadding="0" cellspacing="0" border="0">');
	aHTML.push('<tr>');
	aHTML.push('<td>Sort Listings By&nbsp;</td>');
	aHTML.push('<td><select name="Sort" id="Sort" class="FormElementInput" onchange="' + this.Handle + '.Sort(this.value);">');
	
	if(this.SortBy == "dFeatured")
		aHTML.push('<option value="dFeatured" selected>Featured</option>');
	else
		aHTML.push('<option value="dFeatured">Featured</option>');

	if(this.SortBy == "Community")
		aHTML.push('<option value="Community" selected>Community</option>');
	else
		aHTML.push('<option value="Community">Community</option>');		
	
	if(this.SortBy == "Price")
		aHTML.push('<option value="Price" selected>Price</option>');
	else
		aHTML.push('<option value="Price">Price</option>');
	
	if(this.SortBy == "Type")
		aHTML.push('<option value="Type" selected>Type</option>');
	else
		aHTML.push('<option value="Type">Type</option>');
		
	if(this.SortBy == "BedBaths")
		aHTML.push('<option value="BedBaths" selected>Bedrooms</option>');
	else
		aHTML.push('<option value="BedBaths">Bedrooms</option>');
	
	if(this.SortBy == "SquareFt")
		aHTML.push('<option value="SquareFt" selected>Sq. Ft.</option>');
	else
		aHTML.push('<option value="SquareFt">Sq. Ft.</option>');
	
	if(this.SortBy == "Acreage")
		aHTML.push('<option value="Acreage" selected>Acres</option>');
	else
		aHTML.push('<option value="Acreage">Acres</option>');
	
	aHTML.push('</select>&nbsp;&nbsp;&nbsp;</td>');
	aHTML.push('<td><div class="SearchPaging" id="' + this.Handle + 'Paging">');
	aHTML.push('</div></td></tr></table></div>');
	aHTML.push('<div id="' + this.Handle + 'Div"></div>');
	aHTML.push('<div class="SearchPaging" id="' + this.Handle + 'PagingSub"></div>');
	aHTML.push('<input type="hidden" name="ResultIDs" id="ResultIDs" value="">');
	aHTML.push('<input type="hidden" name="PID" id="PID" value="">');
	
	for(x in this.StateData)
		aHTML.push('<input type="hidden" name="' + x + '" id="' + x + '" value="' + this.StateData[x] + '">');
	
	aHTML.push('</form>');
	
	aHTML.push('<form action="/realestate/search.html" method="post" name="ReviseSearch" id="ReviseSearch">');
	aHTML.push(sExtraData);
	aHTML.push('</form>');
	
	GetTag(this.Handle + 'Container').innerHTML = aHTML.join('\n');
	this.Sort(this.SortBy);
}
ResultSet.prototype.Draw = function(bPaging)
{
	var aHTML = new Array();
	var endCount = ((this.PageLBound + this.PerPage) > this.Results.length)? this.Results.length : (this.PageLBound + this.PerPage);
	
	for(var i=this.PageLBound; i<endCount; i++)
		aHTML.push(this.Results[i].getHTML());
	
	if(bPaging)
	{
		var aPage = new Array();
		var curPage = Math.ceil((this.PageLBound + 1) / this.PerPage);
		var PageCount = Math.ceil(this.Results.length / this.PerPage);

		aPage.push('<table cellpadding="1" cellspacing="0" border="0">');
		aPage.push('<tr>');
		
		if(curPage == 1)
			aPage.push('<td><img src="/DSN/wwwseaislandpropcom/Content/Images/default/icon_bluearrow_left.jpg" class="BlockIMG" border="0"></td>');
		else
			aPage.push('<td><a href="javascript:void(' + this.Handle + '.Prev());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/icon_bluearrow_left.jpg" class="BlockIMG" border="0"></a></td>');
		
		aPage.push('<td>&nbsp;PAGE ' + curPage + ' of ' + PageCount + '&nbsp;</td>');
		
		if(curPage == PageCount)
			aPage.push('<td><img src="/DSN/wwwseaislandpropcom/Content/Images/default/icon_bluearrow_right.jpg" class="BlockIMG" border="0"></td>');
		else
			aPage.push('<td><a href="javascript:void(' + this.Handle + '.Next());"><img src="/DSN/wwwseaislandpropcom/Content/Images/default/icon_bluearrow_right.jpg" class="BlockIMG" border="0"></a></td>');
		
		aPage.push('</tr>');
		aPage.push('</table>');
		
		GetTag(this.Handle + 'Paging').innerHTML = aPage.join('\n');
		GetTag(this.Handle + 'PagingSub').innerHTML = aPage.join('\n');
	}
	
	GetTag(this.Handle + 'Div').innerHTML = aHTML.join('\n');
}
ResultSet.prototype.SetPerPage = function(num)
{
	this.PerPage = parseInt(num);
	this.Draw(true);
}
ResultSet.prototype.Prev = function()
{
	this.PageLBound = parseInt(this.PageLBound - this.PerPage);
	window.location.href = '#top';
	this.Draw(true);
}
ResultSet.prototype.Next = function()
{
	this.PageLBound = parseInt(this.PageLBound + this.PerPage);
	window.location.href = '#top';
	this.Draw(true);
}
ResultSet.prototype.GO = function(RID)
{
	var str = sep = '';
	
	for(var i=0; i<this.Results.length; i++) {
		str += sep + this.Results[i].ID;
		sep = ',';
	}
	
	GetTag('PID').value = RID;
	GetTag('ResultIDs').value = str;

	GetTag('SearchResults').submit();

	window.location.hash = RID;

}
ResultSet.prototype.Sort = function(sortby)
{
	ResultSet.SORTBY = sortby;
	this.Results.sort(ResultSet.sortIt);
	this.SortBy = sortby;
	this.PageLBound = 0;
	this.Draw(true);
}
ResultSet.sortIt = function(a, b)
{
	if(a[ResultSet.SORTBY] > b[ResultSet.SORTBY]) return 1;
	if(a[ResultSet.SORTBY] < b[ResultSet.SORTBY]) return -1;
	return 0;
}
ResultSet.SORTBY = '';

function Result(iID, sName, iPrice, sImage, sType, sAddress, sLeadInText, iSqFt, iAcre, sViews, sBedBaths, sDevelopment, sCommunity, bFeatured, rsParent)
{
	this.ID = iID;
	this.Name = sName;
	this.Image = sImage;
	this.Price = iPrice;
	this.Community = sCommunity;
	this.Development = sDevelopment;
	this.Type = sType;
	this.Address = sAddress;
	this.Desc = sLeadInText;
	this.SquareFt = (iSqFt > 0)? iSqFt : 999999;
	this.Acreage = (iAcre > 0)? iAcre : 999999;
	this.Featured = Boolean(bFeatured);
	this.dFeatured = Boolean(bFeatured)? 0 : 1;
	this.BedBaths = sBedBaths;
	this.Views = sViews;
	
	if(rsParent instanceof ResultSet)
	{
		this.ParentHandle = rsParent.Handle;
		rsParent.Results.push(this);
	}
}
Result.prototype.getHTML = function()
{

	var aHTML = new Array();
	var aViews = this.Views.split(",");
	
	if(this.Featured)
		aHTML.push('<table class="ResultFeatured">');
	else
		aHTML.push('<table class="SearchResult">');
		
	aHTML.push('<tr class="Header">');
	
	if(aViews.length > 0 && aViews[0].length > 0)
		aHTML.push('<td colspan="2"><strong id="ViewsSpan' + this.ID + '" style="float:right;">Views</strong>');
	else
		aHTML.push('<td colspan="2">');
		
	aHTML.push('<strong>' + this.Development + ' - ' + this.Community + '</strong> - [' + this.Type + ']</td>');
	aHTML.push('</tr>');
	aHTML.push('<tr class="Body" valign="top">');	
	aHTML.push('<td width="220" align="center">');
	
	if(this.Image.length > 0)
		aHTML.push('<a href="javascript:void(' + this.ParentHandle + '.GO(' + this.ID + '));"><img src="/DSN/wwwseaislandpropcom/Commerce/ProductImages/' + this.Image + '" border="0" class="BlockIMG" style="margin-top:10px;" alt="' + this.Name + '"></a>');
	else
		aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/ProductImages/Thumb_NoImage.jpg" border="0" class="BlockIMG" style="margin-top:10px;">');
		
	aHTML.push('</td>');
	
	aHTML.push('<td style="padding:0 6px;"><div style="float:right;display:block;position:relative;">');
	
	for(var i=0; i<aViews.length; i++)
		switch(parseInt(aViews[i]))
		{
		case Result.GOLFVIEW:
			aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/searchIcons/golf.gif" border="0" onmouseover="ToolTip(this, \'Golf\');GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'none\';" onmouseout="HideTip(this.lang);GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'inline\';">');
		break;
		case Result.OCEANVIEW:
			aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/searchIcons/ocean.gif" border="0" onmouseover="ToolTip(this, \'Ocean\');GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'none\';" onmouseout="HideTip(this.lang);GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'inline\';">');
		break;
		case Result.MARSHVIEW:
			aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/searchIcons/marsh.gif" border="0" onmouseover="ToolTip(this, \'Marsh/River\');GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'none\';" onmouseout="HideTip(this.lang);GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'inline\';">');
		break;
		case Result.LAKEVIEW:
			aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/searchIcons/lake.gif" border="0" onmouseover="ToolTip(this, \'Lake\');GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'none\';" onmouseout="HideTip(this.lang);GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'inline\';">');
		break;	
		case Result.WOODSVIEW:
			aHTML.push('<img src="/DSN/wwwseaislandpropcom/Commerce/searchIcons/woods.gif" border="0" onmouseover="ToolTip(this, \'Woods\');GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'none\';" onmouseout="HideTip(this.lang);GetTag(\'ViewsSpan' + this.ID + '\').style.display=\'inline\';">');
		break;
		}
		
	aHTML.push('</div>');
	
	if(this.Featured) {
		aHTML.push('<img src="/DSN/wwwseaislandpropcom/Content/Images/default/FeaturedPropLabel.jpg" class="BlockIMG" style="margin-top:10px;">');
		aHTML.push('<p style="margin:2px 0;">')
	} else {
		aHTML.push('<p style="margin:8px 0;">');
	}
	if(this.Price > 0)
		aHTML.push('<strong>$' + FormatNumber(this.Price) + '</strong></p>');
	else
		aHTML.push('<strong>TBA</strong></p>');
		
	if(this.Name.trim() == this.Address.trim() || this.Address.indexOf(this.Name) != -1)
		aHTML.push('<p style="margin-top:0;">' + this.Address.replace(/[\n]+/, '<br>'));
	else
		aHTML.push('<p style="margin-top:0;">' + this.Name + '<br>' + this.Address.replace(/[\n]+/, '<br>'));
		
	aHTML.push('<ul style="margin:0 0 0 17px;padding:0;">');
	
	if(this.BedBaths.length > 0)
		aHTML.push('<li>' + this.BedBaths + '</li>');
	
	if(this.SquareFt != 999999)
		aHTML.push('<li>' + FormatNumber(this.SquareFt) + ' sq. ft.</li>');
	
	if(this.Acreage != 999999)
		aHTML.push('<li>' + this.Acreage + ' acres</li>');
	
	aHTML.push('</ul></p>');
	aHTML.push('<p style="margin-bottom:0;">' + this.Desc.replace(/[\n]+/, '<br>') + '</p>');
	aHTML.push('<input type="button" value="More Details" class="FormButtons" style="float:right;margin:8px;" onclick="' + this.ParentHandle + '.GO(' + this.ID + ');">');
	aHTML.push('</td></tr></table>');
	
	return aHTML.join('\n');
}
Result.prototype.toString = function()
{
	return '[' + this.ID + '] ' + this.Name;
}
Result.GOLFVIEW = 1;
Result.OCEANVIEW = 2;
Result.MARSHVIEW = 3;
Result.LAKEVIEW = 4;
Result.WOODSVIEW = 5;
