// Browser Slide-Show script. With image cross fade effect for those browsers
// that support it.
// Script copyright (C) 2004-2010 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
var FadeDurationMS=1000;
function SetOpacity(object,opacityPct){
	// IE.
	object.style.filter = 'alpha(opacity=' + opacityPct + ')';
	// Old mozilla and firefox
	object.style.MozOpacity = opacityPct/100;
	// Everything else.
	object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO){
	var element=document.getElementById(id);
	var msNow = (new Date()).getTime();
	var opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
	if (opacity>=100)	{
		SetOpacity(element,100);
		element.timer = undefined;
	}	else if (opacity<=0) {
		SetOpacity(element,0);
		element.timer = undefined;
	}	else {
		SetOpacity(element,opacity);
		element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",10);
	}
}
function FadeInImage(foregroundID,newImage,backgroundID){
	var foreground=document.getElementById(foregroundID);
	if (foreground.timer) window.clearTimeout(foreground.timer);
	if (backgroundID)	{
		var background=document.getElementById(backgroundID);
		if (background)	{
			if (background.src)	{
				foreground.src = background.src;	
				SetOpacity(foreground,100);
			}
			background.src = newImage;
			background.style.backgroundImage = 'url(' + newImage + ')';
			background.style.backgroundRepeat = 'no-repeat';
			var startMS = (new Date()).getTime();
			foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "'," + FadeDurationMS + "," + startMS + ",100,0)",10);
		}
	} else {
		foreground.src = newImage;
		SetOpacity(foreground,100);
	}
}
function ForceInImage(foregroundID,newImage,backgroundID){
	var foreground=document.getElementById(foregroundID);
	if (foreground.timer) window.clearTimeout(foreground.timer);
	if (backgroundID)	{
		var background=document.getElementById(backgroundID);
		if (background)	{
			if (background.src)	{
				foreground.src = newImage;	
				SetOpacity(foreground,100);
			}
			background.src = newImage;
			background.style.backgroundImage = 'url(' + newImage + ')';
			background.style.backgroundRepeat = 'no-repeat';
		}
	} else {
		foreground.src = newImage;
		SetOpacity(foreground,100);
	}
}
var slideCache = new Array();
var timerID;
var imageID;
function RunSlideShowWithLinks(pictureID,linkID,imageLinks,displaySecs)
{
  var separator = imageLinks.indexOf(";");
  var nextImage = imageLinks.substring(0,separator);
  if (slideCache[nextImage] && slideCache[nextImage].loaded)
  {
    var futureImages = imageLinks.substring(separator +1,imageLinks.length) + ';' + nextImage;
    separator = futureImages.indexOf(";");
    var nextLink = futureImages.substring(0,separator);
    futureImages= futureImages.substring(separator +1,imageLinks.length) + ';' + nextLink
    separator = futureImages.indexOf(";");
    var nextCaption = futureImages.substring(0,separator);
    futureImages= futureImages.substring(separator +1,imageLinks.length) + ';' + nextCaption;
    imageID=pictureID;
		FadeInImage(pictureID,nextImage,'slideshow');
    document.getElementById(linkID).href = nextLink;
		HideAllShowOne(nextCaption);
    timerID = setTimeout("RunSlideShowWithLinks('"+pictureID+"','"+linkID+"','"+futureImages+"',"+displaySecs+")",
     displaySecs*1000);
    // Identify the next image to cache.
    separator = futureImages.indexOf(";");
    nextImage = futureImages.substring(0,separator);
  } else {
    timerID = setTimeout("RunSlideShowWithLinks('"+pictureID+"','"+linkID+"','"+imageLinks+"',"+displaySecs+")",250);
  }
  // Cache the next image to improve performance.
  if (slideCache[nextImage] == null) {
    slideCache[nextImage] = new Image;
    slideCache[nextImage].loaded = false;
    slideCache[nextImage].onload = function(){this.loaded=true};
    slideCache[nextImage].src = nextImage;
  }		
}
function product_1_over(){
	if(timerID) window.clearTimeout(timerID);
	ForceInImage(imageID,"http://www.endurocide.com/images/frontPage01.jpg","slideshow");
	HideAllShowOne("caption_1");
}
function product_2_over(){
	if(timerID) window.clearTimeout(timerID);
	ForceInImage(imageID,"http://www.endurocide.com/images/frontPage02.jpg","slideshow");
	HideAllShowOne("caption_2");
}
function product_3_over(){
	if(timerID) window.clearTimeout(timerID);
	ForceInImage(imageID,"http://www.endurocide.com/images/frontPage03.jpg","slideshow");
	HideAllShowOne("caption_3");
}
function product_4_over(){
	if(timerID) window.clearTimeout(timerID);
	ForceInImage(imageID,"http://www.endurocide.com/images/frontPage04.jpg","slideshow");
	HideAllShowOne("caption_4");
}
function product_1_out(){
	if(timerID) window.clearTimeout(timerID);
	RunSlideShowWithLinks("slides","slideLink","http://www.endurocide.com/images/frontPage01.jpg;products-1.html;caption_1;"+" http://www.endurocide.com/images/frontPage02.jpg;products-2.html;caption_2;"+"http://www.endurocide.com/images/frontPage03.jpg;products-3.html;caption_3;"+"http://www.endurocide.com/images/frontPage04.jpg;products-4.html;caption_4",6);
}
function product_2_out(){
	if(timerID) window.clearTimeout(timerID);
	RunSlideShowWithLinks("slides","slideLink"," http://www.endurocide.com/images/frontPage02.jpg;products-2.html;caption_2;"+"http://www.endurocide.com/images/frontPage03.jpg;products-3.html;caption_3;"+"http://www.endurocide.com/images/frontPage04.jpg;products-4.html;caption_4;"+"http://www.endurocide.com/images/frontPage01.jpg;products-1.html;caption_1",6);
}
function product_3_out(){
	if(timerID) window.clearTimeout(timerID);
	RunSlideShowWithLinks("slides","slideLink","http://www.endurocide.com/images/frontPage03.jpg;products-3.html;caption_3;"+"http://www.endurocide.com/images/frontPage04.jpg;products-4.html;caption_4;"+"http://www.endurocide.com/images/frontPage01.jpg;products-1.html;caption_1;"+" http://www.endurocide.com/images/frontPage02.jpg;products-2.html;caption_2",6);
}
function product_4_out(){
	if(timerID) window.clearTimeout(timerID);
	RunSlideShowWithLinks("slides","slideLink","http://www.endurocide.com/images/frontPage04.jpg;products-4.html;caption_4;"+"http://www.endurocide.com/images/frontPage01.jpg;products-1.html;caption_1;"+" http://www.endurocide.com/images/frontPage02.jpg;products-2.html;caption_2;"+"http://www.endurocide.com/images/frontPage03.jpg;products-3.html;caption_3",6);
}

