// 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 braces.
// Logos should be 141x58 pixels, and placed in k:\htdocs\images\logos

var logoArray = new Array(
//	["accumen.gif", "http://www.acumenbioscience.com/acumen/"],
	["bangs.gif", "http://www.bangslabs.com/"],
	["bd.gif", "http://www.bd.com/"],
	["bc.gif", "http://www.beckmancoulter.com/"],
	["caltag.gif", "http://www.caltag.com/"],
	["chroma.gif", "http://www.chroma.com/"],
//	["cosmic.gif", "http://www.ipass.net/grc/"],
//	["cytopeia.gif", "http://www.cytopeia.com/"],
	["dakocyto.gif", "http://www.dakocytomation.com/"],
//	["eprogen.gif", "http://www.eprogen.com/"],
	["flocyt.gif", 	"http://www.flocyte.com/"],
//	["gsk.gif", "http://www.gsk.com/index.htm"],
//	["helix.gif", "http://www.helixresearch.com/"],
	["icyt.gif", "http://www.i-cyt.com/"],
	["mprobes.gif", "http://www.probes.com/"],
	["phoenix.gif", "http://www.phnxflow.com/"],
	["polysci.gif", "http://www.polysciences.com/shop/"],
	["sphero.gif", "http://www.spherotech.com/"],
	["treestar.gif", "http://www.treestar.com/"],
//	["union.gif", "http://www.unionbio.com/"],
//	["verity.gif", "http://www.vsh.com/"],
	["cellsignal.gif", "http://www.cellsignal.com/"],
	["dukesci.gif", "http://www.dukescientific.com/company/company.asp?s=10&ss=1010"],
	["cellsciences.gif", "http://www.cellsciences.com/"],
	["streck1.gif", "http://www.streck.com/new.php"],
	["CD-Chex-Plus-BC-web-Banner.jpg", "http://www.streck.com/products/immunology/cdchex_plusbc.asp"]
//	["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);
	
}
//=========================