function HomeObject()
{
	this.SpecialPhotoIndex = 0;
	this.RotationInterval = 7000;
	this.TimeoutCount = 0;
}

/// <summary>
/// display the next photo.
/// </summary>
HomeObject.prototype.NextSpecialPhoto = function()
{
	var PROGRESS_INTERVAL = 100;

	// convert all characters to lowercase to simplify testing
	var agt = navigator.userAgent.toLowerCase();

	// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	var is_ie	 = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3	= (is_ie && (is_major < 4));
	var is_ie4	= (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
	var is_ie4up  = (is_ie && (is_major >= 4));
	var is_ie5	= (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
	var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
	var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_ie6	= (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

	var WebPhotoFolder = "../WebPhotos/";

	top.HomeObject.TimeoutCount = top.HomeObject.TimeoutCount + PROGRESS_INTERVAL;

	if (top.HomeObject.TimeoutCount > top.HomeObject.RotationInterval) 
	{
		top.HomeObject.TimeoutCount = 0;
		top.HomeObject.SpecialPhotoIndex++;

		var lblSpecial = document.getElementById("lblSpecial");
		if (lblSpecial == null || lblSpecial == "") return;

		var image = document.getElementById("SpecialPropertyPhoto");
		var next = document.getElementById("imgNext");
		var link = document.getElementById("SpecialPropertyLink");
		var list = document.getElementById("lblSpecial").value.split(",");

		if (top.HomeObject.SpecialPhotoIndex > list.length-1) 
		{
			top.HomeObject.SpecialPhotoIndex = 0;
			top.HomeObject.RotationInterval = 2500;
		}
		
		var propertyCode = list[top.HomeObject.SpecialPhotoIndex];
		var item = propertyCode.split(".");
		var agency = (item.length==2) ? item[0] : "Rental";
		var code = (item.length==2) ? item[1] : item[0];
		var imgsrc = WebPhotoFolder + agency + "/" + code + "/[s]" + code + "a.jpg";


		// remove all existing frames from thumbnails.
		for (i=0; i<list.length; i++)
		{
			thumb = document.getElementById("SpecialPropertyPhoto" + list[i]);
			thumb.className = "FrameHidden";
		}


		thumb = document.getElementById("SpecialPropertyPhoto" + propertyCode);

		// if browser is IE5 and up, use filters.
		if (is_ie5up)
		{
			image.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
			image.filters[0].Apply()
			image.filters[0].Play();
		}

		// change the image.
		image.width = 400;
		image.src = imgsrc;
		link.href = "property.aspx?property=" + propertyCode;

		alt = thumb.alt;
		pos = alt.indexOf(";");
		propName = document.getElementById("PropertyNameCell")
		propPrice = document.getElementById("PropertyPriceCell")

		if (propName != null) propName.innerHTML = alt.substring(0,pos);
		if (propPrice != null) propPrice.innerHTML = alt.substring(pos+3);

		// download the next photo also.
		var nextPhotoIndex = top.HomeObject.SpecialPhotoIndex + 1;
		if (nextPhotoIndex > list.length-1) nextPhotoIndex = 0;


		propertyCode = list[nextPhotoIndex];
		item = propertyCode.split(".");
		agency = item[0];
		nextSrc = WebPhotoFolder + agency + "/" + item[1] + "/[s]" + item[1] + "a.jpg";
		next.src = nextSrc;
	}
	
	progress = document.getElementById("SpecialPhotoLoadProgress");
	var percentage = parseInt( ((top.HomeObject.TimeoutCount / top.HomeObject.RotationInterval) * 100) );
	if (percentage > 0)
	{
		var width = parseInt( (400/100) * percentage );
		progress.style.width = width + "px";
		if (!document.all) progress.style.border = "solid 1px #9EFF00";
	}
	else
		progress.style.width = "0px";

	// ensure we are invoked again.
	setTimeout ("top.HomeObject.NextSpecialPhoto()", PROGRESS_INTERVAL);
}

top.HomeObject = new HomeObject();