// 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="changeBanner2();" 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 imageArray2 = new Array("https://www.northwestgabankonline.com/images/promo_idtheftins.gif"); //the src values for the images
var linkArray2 = new Array("http://nwgb.com/site/products_personal_smartbuy.html"); //the links you want the images to go to. (make sure links match up with images)
var altArray2 = new Array("Get Identity Theft insurance with our Smart Buy package."); //the links you want the images to go to. (make sure links match up with images)
var numImages2 = imageArray2.length; //number of images to rotate out.
var imgElement2 = "bannerImg2";
var linkElement2 = "bannerLink2";  //this is the id you gave your link tag.
var visibleForSeconds2 = 5; //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(numImages2) {
		return Math.ceil((Math.random()* numImages2));
};

//vaiables that shouldn't be edited
var iteratorNum2 = ( rand(numImages2) - 1); //-1 to take into account that array starts at 0
var count2 = 1; //don't touch. It's an initializer


//the function that does all the work
function changeBanner2(){

		//new link and image swapping code
        if (count2 != 1) {
            document.getElementById(linkElement2).href = linkArray2[iteratorNum2];
            document.getElementById(imgElement2).src = imageArray2[iteratorNum2];
            document.getElementById(imgElement2).alt = altArray2[iteratorNum2];
            document.getElementById(imgElement2).title = altArray2[iteratorNum2];
        }
        count2++;

	//fancypants math stuff
	iteratorNum2 +=1;
	iteratorNum2 %= numImages2;

	//sleeps and then changes banner
	setTimeout('changeBanner2()', visibleForSeconds2 * 1000)

}
