// logos.js - rotating sponsor banners for PUCL pages
// To use, include  <a href="javascript:goSpons()"> <img src="../images/logos/filler.gif" name=logo> </a>

// Modified from original by Steve Kelley 18 June 2004
//========================================================================================================

// Add or delete logo - website pairs here.  Mind the commas, and the square brackets.
// Logos should be 141x58 pixels, and placed in k:\htdocs\images\logos

var logoArray = new Array(
	["streck1.gif", "http://www.streck.com/products/immunology/default.asp"],
	["CD-Chex-Plus-BC-web-Banner.jpg", "http://www.streck.com/products/immunology/cdchex_plusbc.asp"]

//	Old banners for Streck lab
//	["streck2.gif", "http://www.streck.com/products/immunology/cytochex_bct.asp"]
//	["streck1.gif", "http://www.streck.com/new.php"],
//	["streck2.gif", "http://www.streck.com/singleitem.php?productcode=cytochexbct"]
);
//======================

var timer;
var currentIndex = -1;	//initialize the rotation index
var interval = 5000; 	//the rotation interval in milliseconds
var numbanners = logoArray.length;
var logodir = "../../images/logos/";

//======================
// Call this AFTER the href and img have been defined in the source

function start_banners() {

	//stop current rotation, if any;
	clearInterval(timer);

	//set the global variable with the new list

	var theRandom = Math.random();

	//reset the counter
	var scale = numbanners - 1;
	currentIndex = Math.round(theRandom * scale);;

	if(numbanners == 1) {
		// if it is only one logo, no need to do swapping
		swap();
	}
	else {
		// set the timer to execute a swap at the given interval
		clearInterval(timer);
		swap();
		timer = setInterval("swap()",interval);
	}
}
//=========================
// This displays the next logo in the list, in <img src... name=logo> and <img src... name=logo2> tags

function swap() {
	//up the counter
	if((currentIndex + 1) < numbanners) { currentIndex++; }
	else { currentIndex = 0; }

	//change the logo
	document.logo.src = logodir + logoArray[currentIndex][0];
	// document.logo2.src = logodir + logoArray[currentIndex][0];
}
//========================
// This function opens the appropriate website matched to the currently displaying logo

function goSpons() {
		//set the page string
		var goHere = logoArray [currentIndex][1];

		//open the window
		document.location = (goHere);
	
}
//=========================