
function changeOpac(opacity, id) 
{ 
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function blendimage(divid, imageid, imagefile, millisec) 
{ 
	var speed = Math.round(millisec / 10); 
	var timer = 0; 
	
	//set the current image as background 
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
	
	//make image transparent 
	changeOpac(-1, imageid); 
	
	//make new image 
	document.getElementById(imageid).src = imagefile; 

	//fade in image 
	for(i = 0; i <= 99; i++) 
	{ 
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
		timer++; 
	} 
} 

var slideCache = new Array(); 
var StopSlideShow = false;
var SlideShowProcess;

function RunSlideShow(ObjectIDs,displaySecs) 
{ 

	if (!StopSlideShow)
	{		
			
		var ObjectSeparator = ObjectIDs.indexOf(";"); 
		var nextObjectID = ObjectIDs.substring(0,ObjectSeparator); 
	
		var Image1 = "/images/Site/HomePage/" + nextObjectID + ".jpg";
		
		changeOpac(0, "BlendImage"); 
		blendimage("BlendDiv","BlendImage",Image1,200); 


	
		var FutureObjectID= ObjectIDs.substring(ObjectSeparator+1,ObjectIDs.length)+ ';' + nextObjectID; 

		SlideShowProcess = setTimeout("RunSlideShow('"+FutureObjectID+"',"+displaySecs+")",displaySecs*1000); 

	
		// Cache the next image to improve performance. 
		ObjectSeparator = FutureObjectID.indexOf(";"); 
		nextObjectID = FutureObjectID.substring(0,ObjectSeparator); 

		var Image1 = "/images/Site/HomePage/" + nextObjectID + ".jpg";
		
		if (slideCache[Image1] == null || slideCache[Image1] == "") 
		{ 
			slideCache[Image1] = new Image; 
			slideCache[Image1].src = Image1; 
		} 
		
	}
}


var GlobalOffset = 2;
function LoadThreeWayFadeShow(OffSet)
{

	StopSlideShow = false;
	RunSlideShow

	SlideShowProcess = RunSlideShow('1;2;3;8;4;5;7;9;10;11;12',4);
	
}

function StopSlides()
{
	StopSlideShow = true;
	clearTimeout(SlideShowProcess);

}

function RollOver(obj)
{
	//StopSlides();
	
	if ( (obj.src.indexOf("1a") > 0) || (obj.src.indexOf("2a") > 0) || (obj.src.indexOf("3a") > 0) )
	{
		GlobalOffset = 2;	
	}

	if ( (obj.src.indexOf("1b") > 0) || (obj.src.indexOf("2b") > 0) || (obj.src.indexOf("3b") > 0) )
	{
		GlobalOffset = 3;	
	}
	if ( (obj.src.indexOf("1c") > 0) || (obj.src.indexOf("2c") > 0) || (obj.src.indexOf("3c") > 0) )
	{
		GlobalOffset = 1;	
	}	
	
	if (obj.src.indexOf("Hover") < 0)
		obj.src= obj.src.substring(0,obj.src.length-4) + "Hover.jpg";	
}

function Restore(obj)
{
	//StopSlides();
	
	if ( (obj.src.indexOf("1a") > 0) || (obj.src.indexOf("2a") > 0) || (obj.src.indexOf("3a") > 0) )
	{
		GlobalOffset = 2;	
	}

	if ( (obj.src.indexOf("1b") > 0) || (obj.src.indexOf("2b") > 0) || (obj.src.indexOf("3b") > 0) )
	{
		GlobalOffset = 3;	
	}
	if ( (obj.src.indexOf("1c") > 0) || (obj.src.indexOf("2c") > 0) || (obj.src.indexOf("3c") > 0) )
	{
		GlobalOffset = 1;	
	}	
	
	if (obj.src.indexOf("Hover") > 0)
		obj.src= obj.src.substring(0,obj.src.length-9) + ".jpg";	
}