var SE_PreLoadTest_Fader = 1;
// Author: Brennan Stehling: http://brennan.offwhite.net/
// Credit: clagnut: http://clagnut.com/sandbox/imagefades/
// Version: 0.1

// Author: Brennan Stehling: http://brennan.offwhite.net/
// Credit: clagnut: http://clagnut.com/sandbox/imagefades/
// Version: 0.1

var SE_Fader_PhotoID = 'propPhoto';
var SE_Fader_ClientID = "";
if (!SE_Fader_Photos)
	var SE_Fader_Photos = new Array();
if (!SE_Fader_ImageObjects)
	var SE_Fader_ImageObjects = new Array();

function SE_Image(src, actualWidth, actualHeight, constrainedWidth, constrainedHeight)
{
    this.src = src;
    this.actualWidth = actualWidth;
    this.actualHeight = actualHeight;
    this.constrainedWidth = constrainedWidth;
    this.constrainedHeight = constrainedHeight;
}

function _SE_Fader_InitImage() 
{
	var image = document.getElementById(SE_Fader_PhotoID);
	_SE_Fader_SetOpacity(image, 0);
	image.style.visibility = "visible";
	_SE_Fader_Fadein(SE_Fader_PhotoID,0);
}

function _SE_Fader_Fadein(objId,opacity) {
	if (document.getElementById) {
		var obj = document.getElementById(objId);
		if (opacity <= 100) {
			_SE_Fader_SetOpacity(obj, opacity);
			opacity += 20;
			window.setTimeout("_SE_Fader_Fadein('"+objId+"',"+opacity+")", 20);
		}
	}
}

function _SE_Fader_SetOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	try {
		obj.style.filter = "alpha(opacity:"+opacity+")";
	}
	catch(e){}
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function SE_Fader_SetImageAttributes(idx, useConstrained)
{
    var elImg = document.getElementById(SE_Fader_PhotoID);
    elImg.src = SE_Fader_ImageObjects[idx].src;
    if (useConstrained)
    {
        elImg.width = SE_Fader_ImageObjects[idx].constrainedWidth;
        elImg.height = SE_Fader_ImageObjects[idx].constrainedHeight;
    }
}

function SE_Fader_NextPhotoFade(hasCount, useConstrained) 
{
    //Assign default values for arguments that are not passed
    if (typeof(useConstrained) == "undefined") {useConstrained = false;}
    if (typeof(hasCount) == "undefined") {hasCount = true;}

	_SE_Fade_CancelSlideShow();
    _SE_Fader_InitImage();
    //for(var i=0;i!=SE_Fader_Photos.length;i++)
    for(var i=0;i!=SE_Fader_ImageObjects.length;i++)
	{
		//if(SE_Fader_Photos[i]==document.getElementById(SE_Fader_PhotoID).src)
		if(SE_Fader_ImageObjects[i].src.toLowerCase() == document.getElementById(SE_Fader_PhotoID).src.toLowerCase() )
		{
			//if (i+1 == SE_Fader_Photos.length)
			if (i+1 == SE_Fader_ImageObjects.length)
			{
				//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[0];
				SE_Fader_SetImageAttributes(0, useConstrained);
				if((hasCount) && (typeof(SE_PD_UpdatePhotoPosition) != 'undefined'))
					SE_PD_UpdatePhotoPosition(1);
				ShowPropInfo(0);
			}
			else
			{
				//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[i+1];
				SE_Fader_SetImageAttributes(i+1, useConstrained);
				if((hasCount) && (typeof(SE_PD_UpdatePhotoPosition) != 'undefined'))
				{
					SE_PD_UpdatePhotoPosition(i+2);
				}
				ShowPropInfo(i+1);
			}
			break;
		}
	}
}

function SE_Fader_PrevPhotoFade(hasCount, useConstrained) 
{
    //Assign default values for arguments that are not passed
    if (typeof(useConstrained) == "undefined") {useConstrained = false;}
    if (typeof(hasCount) == "undefined") {hasCount = true;}

	_SE_Fade_CancelSlideShow();
    _SE_Fader_InitImage();
    //for(var i=0;i!=SE_Fader_Photos.length;i++)
    for(var i=0;i!=SE_Fader_ImageObjects.length;i++)
	{
		//if(SE_Fader_Photos[i]==document.getElementById(SE_Fader_PhotoID).src)
		if(SE_Fader_ImageObjects[i].src==document.getElementById(SE_Fader_PhotoID).src)
		{
			if (i == 0)
			{
				//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[SE_Fader_Photos.length - 1]
				SE_Fader_SetImageAttributes(SE_Fader_ImageObjects.length - 1, useConstrained);
				if((hasCount) && (typeof(SE_PD_UpdatePhotoPosition) != 'undefined'))
					SE_PD_UpdatePhotoPosition(SE_Fader_ImageObjects.length);
					//SE_PD_UpdatePhotoPosition(SE_Fader_Photos.length);

				//ShowPropInfo(SE_Fader_Photos.length - 1);
				ShowPropInfo(SE_Fader_ImageObjects.length - 1);
			}
			else
			{
				//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[i-1];
				SE_Fader_SetImageAttributes(i-1, useConstrained);
				if((hasCount) && (typeof(SE_PD_UpdatePhotoPosition) != 'undefined'))
					SE_PD_UpdatePhotoPosition(i);	
				
				ShowPropInfo(i - 1);
			}
				
			break;
		}
	}
}

var _SE_Fader_SlideShowOn = false;

function SE_Fader_SlideShow()
{
	SE_Fader_Slideshow()
}
function SE_Fader_Slideshow()
{
	if(!_SE_Fader_SlideShowOn)
	{
		_SE_Fader_SlideShowOn = true;
		_SE_Fader_SlideShowFade();
		if (_SE_Fader_SlideShowButton())
			_SE_Fader_SlideShowButton().value = "Stop Slideshow";
	}
	else
	{
		_SE_Fader_SlideShowOn = false;
		if (_SE_Fader_SlideShowButton())
			_SE_Fader_SlideShowButton().value = "Start Slideshow";
	}
}

var _SE_Fader_SlideShowTimeout = 0;
function _SE_Fader_SlideShowFade() 
{
    if(_SE_Fader_SlideShowOn)
	{
		_SE_Fader_InitImage();
		//for(var i=0;i!=SE_Fader_Photos.length;i++)
		for(var i=0;i!=SE_Fader_ImageObjects.length;i++)
		{
			//if(SE_Fader_Photos[i]==document.getElementById(SE_Fader_PhotoID).src)
			if(SE_Fader_ImageObjects[i].src.toLowerCase() ==document.getElementById(SE_Fader_PhotoID).src.toLowerCase())
			{
			    //if (i+1 == SE_Fader_Photos.length)
				if (i+1 == SE_Fader_ImageObjects.length)
				{
					ShowPropInfo(0);
					//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[0]
					SE_Fader_SetImageAttributes(0, false);
				}
				else
				{
					//document.getElementById(SE_Fader_PhotoID).src = SE_Fader_Photos[i+1];
					SE_Fader_SetImageAttributes(i+1, false);
					ShowPropInfo(i+1);
				}
					
				break;
			}
		}
		_SE_Fader_SlideShowTimeout = setTimeout("_SE_Fader_SlideShowFade()","3000");
	}
}

function _SE_Fade_CancelSlideShow()
{
	_SE_Fader_SlideShowOn = false;
	clearTimeout(_SE_Fader_SlideShowTimeout);
}

function _SE_Fader_SlideShowButton()
{
	return  document.getElementById(SE_Fader_ClientID + "_btnSlideShow");
}

function ShowPropInfo(index)
{
	if(document.getElementById("propPhotoHref") != null)
		document.getElementById("propPhotoHref").href = propHref[index];
		
	if (document.getElementById("propPrice") != null)
		document.getElementById("propPrice").innerHTML = propPrice[index];
		
	if (document.getElementById("propAddress") != null)
		document.getElementById("propAddress").innerHTML = propAddress[index];
		
	if (document.getElementById("propCity") != null)
		document.getElementById("propCity").innerHTML = propCity[index];
		
	if (document.getElementById("propBeds") != null)
		document.getElementById("propBeds").innerHTML = propBeds[index];
		
	if (document.getElementById("propBaths") != null)
		document.getElementById("propBaths").innerHTML = propBaths[index];
		
	if (document.getElementById("propSqFt") != null)
		document.getElementById("propSqFt").innerHTML = propSqFt[index];
		
	if (document.getElementById("propLotSize") != null)
		document.getElementById("propLotSize").innerHTML = propLotSize[index];
		
	if (document.getElementById("propDetail") != null)
		document.getElementById("propDetail").href = propHref[index];
		
	if (document.getElementById("propRequestUrl") != null)
		document.getElementById("propRequestUrl").href = propRequestUrl[index];
}



