// JScript File
/*
Interactive Image slideshow
*/

g_fPlayMode = "true";
g_pause = "false";
g_iimg = -1;
g_pausecounter =0;
g_imax = 4;
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[0] = "images/ImageRotator/ag.jpg";
Pic[1] = "images/ImageRotator/loans.jpg";
Pic[2] = "images/ImageRotator/turbotax.jpg";
Pic[3] = "images/ImageRotator/texts.jpg";
g_LinkTable[0] = "aglending.php";
g_LinkTable[1] = "";
g_LinkTable[2] = "http://turbotax.intuit.com/affiliate/firstbank";
g_LinkTable[3] = "messengeronlinebanking.php";
Play();
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()
{
	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+=2;
	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 < 4; 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 confirmation(img) 
{
	if (img == 'http://turbotax.intuit.com/affiliate/firstbank')
	{
		var answer = confirm("Please be advised that you are leaving First Bank &amp; Trust Company\'s website. This link is provided as a courtesy. First Bank &amp; Trust Company does not endorse or control the content of third party websites.")
		if (answer)
		{
			window.location = g_LinkTable[g_iimg];
		}
		else
		{
		}
	}
	else
	{
		window.location = g_LinkTable[g_iimg];
	}
}


function setConstant(selectpic)
{
	window.clearTimeout(timerID);
	g_iimg=selectpic-1;
	timer2=true;
	Tick();
}	
	for (i = 0; i < 4; i++)
	{
		g_ImageTable[i]=new Image();
		g_ImageTable[i].src=Pic[i];
	}
	
function rotatelink()
{
	confirmation(g_LinkTable[g_iimg]);
}