// JavaScript random sponsor display
// Roland Jaeckel, 11/25/2003
// Sponsor definition:
// image name pipe (|) URL
var sponsors = new Array;
sponsors[0] = 'aquafina|http://www.aquafina.com/';
sponsors[1] = 'korg|http://www.free2rock.com/';
sponsors[2] = 'pepsi|http://www.pepsi.com/';
sponsors[3] = 'constellation|http://www.newenergy.com/';
sponsors[4] = 'dr-pepper|http://www.drpepper.com/';
sponsors[5] = 'gatorade|http://www.gatorade.com/';
sponsors[6] = 'john-hancock|http://www.jhancock.com/';
sponsors[7] = 'nantucket|http://www.juiceguys.com/';
sponsors[8] = 'citizensbank|http://www.citizensbank.com/home/';
sponsors[9] = 'snapple|http://www.snapple.com/';
sponsors[10] = 'ticketmaster|http://www.ticketmaster.com/';
sponsors[11] = 'qdoba|http://www.qdoba.com';
sponsors[12] = 'yoohoo|http://www.drinkyoo-hoo.com/';
sponsors[13] = 'best-buy|http://www.bestbuy.com/';
sponsors[14] = 'SullivanTire|http://www.sullivantire.com/';
sponsors[15] = 'barnes|http://bu.bkstore.com/';
sponsors[16] = 'hotel-commonwealth|http://www.hotelcommonwealth.com/';
sponsors[17] = 'fitrec|http://www.bu.edu/fitrec/';
sponsors[18] = 'volvo|http://www.bostonvolvo.com';
sponsors[19] = 'dunkindonuts|http://www.dunkindonuts.com';




// get correct link offset
var j=0;
var offset = 0;
while (j<document.links.length){
   if(document.links[j].href.indexOf('#00#') >0 ){
      offset = j;
	  break;
	}
   j++;
}

// shuffle
fisherYates(sponsors);
var i = 0;
// read source from sp01 image
var path=new String(document.images['sp01'].src);
// get the path to the graphics folder
path = path.substring(0,path.lastIndexOf("/")+1);
while (i<5){
	// split info on pipe
	var tempArray = sponsors[i].split("|")
	// set image
	document.images['sp0'+i].src = path+tempArray[0]+'.gif'; 
	// set link
	document.links[offset+i].href = tempArray[1];
	// set Google Analytics Tracker
	document.links[offset+i].onClick = "javascript:urchinTracker('/homepage_sponsor/" + document.links[offset+i].href + "');";
	i++; 
}			


// Fisher-Yates randomize shuffle
function fisherYates ( myArray ) {
  var i = myArray.length;
  var century = false;
  while ( i-- ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}
