// rotating banner with corresponding links updated 10/12/04 by Richard Wise and Joe Dawley
// original rotating banner with corresponging links by matthew billings

// 1. drop script in head or script file
// 2. fill out config variables 
// 3. add onLoad="changeBanner();" to <body> 
// 4  make sure link tag has id="bannerLink" and img tag has name="banner" and id="bannerImg"
// 5. general form of use. <a href="#" id="bannerLink"><img src="./img1.gif" name="banner" border="0" id="bannerImg"></a> 



//Config variables
/*var numImages = 11; //number of images to rotate out.
var imageArray = new Array("images/visa_promo.jpg", "images/visa_promo2.jpg", "images/vehicle_promo.jpg", "images/HELOC_promo.jpg", "images/promo-100mortgage.jpg",  "images/promo-interestonly.jpg",  "images/promo-powerchecking.jpg",  "images/promo-premierservice.jpg","images/CD_special.jpg", "images/home_equity.jpeg", "images/vehicle.jpeg"); //the src values for the images
var linkArray = new Array("site/cash_advance.asp", "site/visa_cards.asp", "site/summer_auto.asp", "site/heloc.asp", "site/promo-100mortgage.asp", "site/promo-interestonly.asp", "site/promo-powerpak.asp", "site/promo-premier.asp","site/aboutus_whatsnew.asp", "site/home_equity.asp", "site/vehicle.asp"); //the links you want the images to go to. (make sure links match up with images)
*/
var imageArray = new Array("images/referAFriendPromo.jpg","images/estatementsPromo.jpg", "images/visa.jpg","images/Autopromo.jpg","images/helocpromo.jpg"); //the src values for the images
var linkArray = new Array("javascript:openWin('images/50-50_ReferalForm.pdf');","https://www.myconsumers.org/onlineserv/HB/Signon.cgi", "site/aboutus_whatsnew.asp#onsale","site/aboutus_whatsnew.asp#auto","site/aboutus_whatsnew.asp#CD","site/aboutus_whatsnew.asp#heloc"); //the links you want the images to go to. (make sure links match up with images)
var numImages = imageArray.length; //number of images to rotate out.
var imgElement = "bannerImg";
var linkElement = "bannerLink";  //this is the id you gave your link tag.
var visibleForSeconds = 7; //how many seconds to you want before the banner swaps out;

// Don't edit below // Don't edit below  // Don't edit below  // Don't edit below 
// Don't edit below // Don't edit below  // Don't edit below  // Don't edit below 
// Don't edit below // Don't edit below  // Don't edit below  // Don't edit below 
// Don't edit below // Don't edit below  // Don't edit below  // Don't edit below 



//for random number choosing
function rand(numImages) {
		return Math.ceil((Math.random()* numImages));       
};

//vaiables that shouldn't be edited
var iteratorNum = ( rand(numImages) - 1); //-1 to take into account that array starts at 0
var count = 1; //don't touch. It's an initializer 

	
//the function that does all the work
function changeBanner(){
	//IE4/5
	if( document.all )
	{
		if (document.all[linkElement] != null)
		{
			//new link and image swapping code
			document.all[linkElement].href = linkArray[iteratorNum];
			document.all[imgElement].src = imageArray[iteratorNum];
		}
	}
	else
	//IE6/NS6 thisis the w3c standard to access
	{
		if (document.all[linkElement] != null)
		{
			//new link and image swapping code
			document.getElementById(linkElement).href = linkArray[iteratorNum];
			document.getElementById(imgElement).src = imageArray[iteratorNum];
		}	
	}
		
	//fancypants math stuff
	iteratorNum +=1;
	iteratorNum %= numImages;
	
	//sleeps and then changes banner
	setTimeout('changeBanner()', visibleForSeconds * 1000)

}