var currentTab = 0;

// Here are the primary images
var promoImageArray = new Array("images/BPP_FREE.jpg",
								"images/Mortgage-Banner.jpg",
								"images/NCUA-Vid-356x129.jpg"								
								);
// Here are the text images
var promoTextArray = new Array(	"images/BPP_FREE.jpg",
								"images/Mortgage-Banner.jpg",
								"images/NCUA-Vid-356x129.jpg"								
								);
// Here is the alt text for the promoText images										
var promoAltTextArray = new Array(	"Online Bill Payment",
									"2nd Mortgage",
									"NCUA Video"
									);
// Here are the URLs for the findOutMoreButton
var findOutMoreButtonURLs = new Array(	"site/online.html#onlinebillpay",
										"site/loans_home.html#homeeq",
										"https://www.sunwestfcu.org/images/NCUA30.wmv"
										);
// Here are the tab objects (Dont worry about this unless you add tabs)
var tab = new Array(	"document.tab_1.src",
						"document.tab_2.src",
						"document.tab_3.src"						
						);

//vaiables that shouldn't be edited
var iteratorNum = 0;
var numImages = 3; //number of images to rotate out.
var visibleForSeconds = 6; //how many seconds to you want before the banner swaps out;
var timer;

function startPromo()
{
	showTab(0);
	changePromo();
}

//the function that does all the work
function changePromo()
{
	//fancypants math stuff
	iteratorNum +=1;
	iteratorNum %= numImages;
	
	//sleeps and then changes banner
	timer = setTimeout('showTab(iteratorNum); changePromo();', visibleForSeconds * 1000);
}

function setPause(duration)
{
	clearTimeout(timer);
	//sleeps and then changes banner
	timer = setTimeout('showTab(iteratorNum); changePromo();', duration * 1000);
}

function showTab(tabNumber)
{
	// Change the tab images
	turnOffTab(currentTab);	// Turn off current tab
	turnOnTab(tabNumber);	// Turn on clicked tab
	currentTab = tabNumber;	// Set new tabNumber
	iteratorNum = tabNumber;

	if (document.all) //IE4/5
	{
		document.all["promoImage"].src = promoImageArray[tabNumber];		// Switch promoImage
		//document.all["promoText"].src = promoTextArray[tabNumber];		// Switch promoText
		//document.all["promoText"].alt = promoAltTextArray[tabNumber];	// Switch promoText alt text
		//document.all["findOutMoreButton"].href = findOutMoreButtonURLs[tabNumber];	// Switch findOutMoreButton URL	
	}
	else //IE6/NS6 thisis the w3c standard to access
	{
		document.getElementById("promoImage").src = promoImageArray[tabNumber];		// Switch promoImage
		//document.getElementById("promoText").src = promoTextArray[tabNumber];		// Switch promoText
		//document.getElementById("promoText").alt = promoAltTextArray[tabNumber];	// Switch promoText alt text
		//document.getElementById("findOutMoreButton").href = findOutMoreButtonURLs[tabNumber];	// Switch findOutMoreButton URL	
	}
}

function turnOffTab(tabNum)
{
	eval(tab[tabNum] + ' = \"images/numbers_' + eval(tabNum+1) + '_off.gif\"');	
}

function turnOnTab(tabNum)
{
	eval(tab[tabNum] + ' = \"images/numbers_' + eval(tabNum+1) + '_on.gif\"');		
}

function goTo(tabNumber)
{
	if (tabNumber == -1)
	{
		goTo(currentTab);
	}
	else
		self.location = findOutMoreButtonURLs[tabNumber];
}