﻿// JScript File
/*
Interactive Image slideshow
*/
g_fPlayMode = "true";
g_pause = "false";
g_iimg = -1;
g_pausecounter =0;
g_imax = 5;
browserName=navigator.appName; 
opacitervar = 0;
timerID = null;
timerID2 = null;
opacitimer = null;
timer2 = false;
g_ImageTable = new Array();
g_LinkTable = new  Array();
Pic = new Array();
g_dwTimeOutSec=7;
firsttime=true;
Pic[3] = "images/specials/Hat_Rack_Special.jpg";
Pic[2] = "images/specials/Console_Special.jpg";
Pic[0] = "images/specials/Completion_Center.jpg";
Pic[1] = "images/specials/HushKit.jpg";
Pic[4] = "images/specials/doorpost172.jpg";
g_LinkTable[3] = "Display_Parts.aspx?mid=10&mod=44&cp=6";
g_LinkTable[2] = "Display_Parts.aspx?mid=4&mod=17&cp=6";
g_LinkTable[1] = "images/specials/HushKitLinkDes.jpg";
g_LinkTable[0] = "images/specials/CompletionCenter.ppt";
g_LinkTable[4] = "Display_Parts.aspx?mid=4&mod=17&cp=1";
function ChangeImage(fFwd)
{
	if (fFwd=="true")
	{
		if (++g_iimg==g_imax)
			g_iimg=0;
			Update();
	}
	else if(fFwd=="false")
	{
		if (g_iimg==0)
			g_iimg=g_imax;
			g_iimg--;
			Update();
	}
	else
	{
				
	}
}

function getobject(obj)
{
	if (document.getElementById)
	return document.getElementById(obj)
	else if (document.all)
	return document.all[obj]
}

function Update()
{
	changeColor(g_iimg);
	getobject("_div_Slide").style.backgroundImage = "url(" + getobject("_Ath_Slide").src + ")"; 
	getobject("_Ath_Slide").src = g_ImageTable[g_iimg].src;
	opacitervar=0;
	fader();
	OnImgLoad();
}

function fader()
{
	//alert(browserName);
	opacitervar+=3
	if(opacitervar<=100)
	{
		if(browserName=="Netscape")
		{
		getobject("_Ath_Slide").style.MozOpacity=(opacitervar / 100);
		}
		else
		{
		getobject("_Ath_Slide").filters.alpha.opacity=opacitervar;
		getobject("_Ath_Slide").opacity = (opacitervar / 100);
		getobject("_Ath_Slide").KhtmlOpacity = (opacitervar / 100);
		}
		window.setTimeout("fader()", 10);
		
	}
}

function Play()
{
	g_fPlayMode="true";
	OnImgLoad();				
}

function Pause()
{
	g_fPlayMode="pause";
	window.clearTimeout(timerID);
}

function OnImgLoad()
{			
	if(firsttime)
	{
		g_dwTimeOutSec=0;
		firsttime=false;
		for (i = 0; i < 5; i++)
		{
			g_ImageTable[i]=new Image();
			g_ImageTable[i].src=Pic[i];
		}
	}
	else
	{
		g_dwTimeOutSec=9;
	}
	
	if(g_fPlayMode=="true")
	{
		if(timer2==true)
		{
			timerID = window.setTimeout("Tick()", 15*1000);
			timer2=false;
		}
		else
		{
			timerID = window.setTimeout("Tick()", g_dwTimeOutSec*1000);
		}
	}
}

function Tick() 
{
	if (g_fPlayMode=="true")
	{
		Next();
	}
}

function Prev()
{
	ChangeImage("false");
}

function Next()
{
	ChangeImage("true");
}

function setConstant(selectpic)
{
	changeColor(selectpic);
	window.clearTimeout(timerID);
	g_iimg=selectpic-1;
	timer2=true;
	Tick();
}	
	for (i = 0; i < 5; i++)
	{
		g_ImageTable[i]=new Image();
		g_ImageTable[i].src=Pic[i];
	}
	
function changeColor(tdno)
{
	switch(tdno)
	{
		case 0:
			getobject("td0").style.backgroundColor="#990033";
			getobject("td1").style.backgroundColor="#0F107A";
			getobject("td2").style.backgroundColor="#0F107A";
			getobject("td3").style.backgroundColor="#0F107A";
			getobject("td4").style.backgroundColor="#0F107A";
		break;
		case 1:
			getobject("td0").style.backgroundColor="#0F107A";
			getobject("td1").style.backgroundColor="#990033";
			getobject("td2").style.backgroundColor="#0F107A";
			getobject("td3").style.backgroundColor="#0F107A";
			getobject("td4").style.backgroundColor="#0F107A";
		break;
		case 2:
			getobject("td0").style.backgroundColor="#0F107A";
			getobject("td1").style.backgroundColor="#0F107A";
			getobject("td2").style.backgroundColor="#990033";
			getobject("td3").style.backgroundColor="#0F107A";
			getobject("td4").style.backgroundColor="#0F107A";
		break;
		case 3:
			getobject("td0").style.backgroundColor="#0F107A";
			getobject("td1").style.backgroundColor="#0F107A";
			getobject("td2").style.backgroundColor="#0F107A";
			getobject("td3").style.backgroundColor="#990033";
			getobject("td4").style.backgroundColor="#0F107A";
		break;
		case 4:
			getobject("td0").style.backgroundColor="#0F107A";
			getobject("td1").style.backgroundColor="#0F107A";
			getobject("td2").style.backgroundColor="#0F107A";
			getobject("td3").style.backgroundColor="#0F107A";
			getobject("td4").style.backgroundColor="#990033";
		break;
	}
}

function rotatelink()
{
	window.location=g_LinkTable[g_iimg];
}
