var currentTab = 0;

// Here are the primary images
var promoImageArray = new Array("images/your-family-is-our-family.gif",
								"images/pac.gif",
								"images/springAuto.jpg",
								"images/spring2010visa.jpg",
								"images/ServiceCenter.jpg"
								);
// Here are the text images
var promoTextArray = new Array( "images/your-family-is-our-family.gif",
								"images/pac.gif",
								"images/springAuto.jpg",
								"images/spring2010visa.jpg",
								"images/ServiceCenter.jpg"
								);
// Here is the alt text for the promoText images										
var promoAltTextArray = new Array(	"Gift of Membership",
									"PAC",
									"Auto Loan Video",
									"Visa Video",
									"Service Center"
									);
// Here are the URLs for the findOutMoreButton
var findOutMoreButtonURLs = new Array(	"site/member_family.html",
										"site/platinumadv_index.html",
										"http://www.clickvue.com/al/apcu0935.html",
										"https://clickvue.com/cc/apcu0935.html",
										"site/third_party_popup.html?location=http://www.creditunion.net"
										);
// 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",
						"document.tab_4.src",
						"document.tab_5.src"
						);

var openInNewWindow = new Array(false,false,true,true,false);
//vaiables that shouldn't be edited
var iteratorNum = 0;
var numImages = promoImageArray.length; //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/tab-' + eval(tabNum+1) + '-off.gif\"');	
}

function turnOnTab(tabNum)
{
	eval(tab[tabNum] + ' = \"images/tab-' + eval(tabNum+1) + '-on.gif\"');		
}

function goTo(tabNumber)
{
	if (tabNumber == -1)
	{
		goTo(currentTab);
	}
	else
		if (openInNewWindow[tabNumber]){
			//alert('not yet');
			window.open(findOutMoreButtonURLs[tabNumber]);

		}else{
			self.location = findOutMoreButtonURLs[tabNumber];
		}
}
