secondsBeforeBannerFlip = 30; // How many seconds should we wait before flipping the ads?
var mspause = 1000 * secondsBeforeBannerFlip; // This converts the seconds to milliseconds.
var ads = new Array(); //  // Build up the arrays that contain the rotating ad information.
var aAdLinkLocations; // This will keep track of where our links are on the page that we want to manipulate.
// This will scan though the ad positions that are registered to rotate ads and call the rotation 
// function for each of them.
function flipAds() {
	// At this point, we know that "ads" is a variable which contains an entry
	// for each of the banner positions that have rotating ads.
	for (position in ads) {
		attamptFlip(position);
	}
	timerID = setTimeout("flipAds()", mspause);
}
// Pass in a number and this will return a random number between 0 and the whole integer you pass.
// This is useful for picking a random entry on an array.
function randomIndex(topRange) {
	return Math.round(Math.random()*topRange);
}

// This will instruct all compatible banner positions on the page to show
// the next banner in the rotation without refreshing the page.
function attamptFlip(position) {
	
	// Reset this variable just in case something else changed this variable.
	var aAdLinkLocations = lookUpAdLinks();
	
	// What ad is currently displayed in this position's inventory?
	currentlyDisplayedAdIndex = ads[position][1];
	
	// If there are at least 2 ads to rotate through (AND the ad tag is on the page), we'll try to flip them here...
	// Also, only flit if we have not done the entire set 3 times yet.
	
	if (ads[position][2] < 3 && ads[position][0].length > 1 && eval("typeof document.cpstillad" + position + " != 'undefined'")) {
		
		if (currentlyDisplayedAdIndex < ads[position][0].length-1) {
			ads[position][1]++;
		} else {
			ads[position][1] = 0;
			ads[position][2]++;// Remember the fact we have iterated through this set another time.
		}
		// The next 2 lines will call back to the banner ad server and cache bust and allow you to count this view.
		tmpImg = new Image();
		
		tmpImg.src = ads[position][0][ads[position][1]][2] + cacheBust();
		eval("document.cpstillad" + position + ".src = ads[position][0][ads[position][1]][0];");
		
		document.links[aAdLinkLocations[position]].href = ads[position][0][ads[position][1]][1];
	}
}
// This function will return a new number every time you call it. Good for cache busting.
function cacheBust() {
	x = new Date();
	return x.getTime() + '' + randomIndex(1000);
}
// This will start the image flipping process.
function Start() {
	Reset();
	aAdLinkLocations = lookUpAdLinks(); // This defines the ads.
	tStart   = new Date();
	timerID  = setTimeout("flipAds()", mspause);
}
// The page first needs to build before we can analyize the links so we'll start this after a few 
// seconds.
function DelayedStart() {
	Reset();// Initialize the timer.
	tStart   = new Date();
	timerID  = setTimeout("Start()", 2000);
}
function Reset() {
	// This kills the timer object.
	var timerID = 0;
	var tStart = null;
}
// In order to be able to change the click through URL's, we'll need to find the link
// index of each of the ads. This function will build an associative array of the ad link
// locations. The key is the banner position and the value is the link index on the page.
function lookUpAdLinks() {
	aLinkLocationsX = new Array();
	// Loop over each of the links on this page 
	// searching for the rotating ad positions.
	for (i=1;i<=document.links.length;i++) {
		// If this image object appears to be one of the banner positions, try to figure out which it is.
		if (typeof(document.links[i-1].name) != 'undefined' && document.links[i-1].name.indexOf('cpstilladclick') > -1) {
			aLinkLocationsX['' + document.links[i-1].name.substring(14,document.links[i-1].name.length+1)] = i-1;
		}
	}
	return aLinkLocationsX;
}
// This stops the banner rotations.
function Stop() {
   if (typeof timerID != 'undefined' && timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
   tStart = null;
}
// Pass an array of ads to this function and the SRC of the ad currently running. This function
// will find the index of the current ad..
function findRotationIndex(aAds, position) {
	if (aAds.length == 0 || aAds.length == 1 || eval("typeof document.cpstillad" + position + " == 'undefined'")) {
		return 0;
	} else {
		chosenIndex = null;
		// Find the index of the currently displayed ad.
		for (i=0;i<aAds.length;i++) {
			if (aAds[i][0] == eval("document.cpstillad" + position + ".src")) {
				chosenIndex = i;
				break;
			}
		}
		return chosenIndex;
	}
}
// This will start the rotations after a small amount of time passes.
DelayedStart();

function showNetworkBanner (iposition) {
	switch (iposition) {
		case 1:
			document.write('<table cellspacing="2" cellpadding="2"><tr><td>');
			document.write('<!-- JavaScript Only --><script language=\"JavaScript1.1\" src=\"http://altfarm.mediaplex.com/ad/js/4834-26205-6416-1?mpt=20050225021211&mpvc=\"></scr' + 'ipt><noscript>  <a href=\"http://altfarm.mediaplex.com/ad/ck/4834-26205-6416-1?mpt=20050225021211\">    <img src=\"http://altfarm.mediaplex.com/ad/bn/4834-26205-6416-1?mpt=20050225021211\"alt=\"Click Here\" border=\"0\"></a></noscript>');
			document.write('</td></tr></table>');			ads1 = new Array();
			ads['1'] = new Array(ads1, findRotationIndex(ads1, 1), 0);
			var impressionIMG1=new Image();
			impressionIMG1.src="http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=30632&random=20050225021211";
			break;
		case 2:
			document.write('<table cellspacing="2" cellpadding="2"><tr><td>');
			document.write('<IFRAME SRC=\"http://ad.doubleclick.net/adi/N339.y2m.com/B1510056;sz=468x60;ord=20050225021211?\" WIDTH=470 HEIGHT=62 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=\'#000000\'> <SCRIPT language=\'JavaScript1.1\' SRC=\"http://ad.doubleclick.net/adj/N339.y2m.com/B1510056;abr=!ie;sz=468x60;ord=20050225021211?\"> </SCRIPT> <NOSCRIPT> <A HREF=\"http://ad.doubleclick.net/jump/N339.y2m.com/B1510056;abr=!ie4;abr=!ie5;sz=468x60;ord=20050225021211?\"> <IMG SRC=\"http://ad.doubleclick.net/ad/N339.y2m.com/B1510056;abr=!ie4;abr=!ie5;sz=468x60;ord=20050225021211?\" BORDER=0 WIDTH=468 HEIGHT=60 ALT=\"\"></A> </NOSCRIPT> </IFRAME>');
			document.write('</td></tr></table>');			ads2 = new Array();
			ads['2'] = new Array(ads2, findRotationIndex(ads2, 2), 0);
			var impressionIMG2=new Image();
			impressionIMG2.src="http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=31102&random=20050225021211";
			break;
		case 7:
			document.write('<img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			document.write('<a href="http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=29544&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2F%5BcallingSite%5D%2Fmain.cfm%3Finclude%3Dviewchannel%26channel_id%3D62" target="_self" name="cpstilladclick7"><img src="http://media.collegepublisher.com/media/ads/cram101/125studentresources.gif" border="0" name="cpstillad7"></a>');
			document.write('<br><img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			ads7 = new Array();
			ads7[0] = new Array('http://media.collegepublisher.com/media/images/ads/Tsunami/tsunami_relief_ad.gif', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=28935&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fcpsite.collegepublisher.com%2FTsunamiRelief%2F', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=28935&random=');
			ads7[1] = new Array('http://media.collegepublisher.com/media/ads/cram101/125studentresources.gif', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=29544&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2F%5BcallingSite%5D%2Fmain.cfm%3Finclude%3Dviewchannel%26channel_id%3D62', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=29544&random=');
			ads['7'] = new Array(ads7, findRotationIndex(ads7, 7), 0);
			var impressionIMG7=new Image();
			impressionIMG7.src="http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=29544&random=20050225021211";
			break;
		case 9:
			document.write('<img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			document.write('<a href="http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=29986&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fclk.atdmt.com%2FNYC%2Fgo%2Fy2mxxcha0350000005nyc%2Fdirect%2F01%2F" target="_blank" name="cpstilladclick9"><img src="http://view.atdmt.com/NYC/view/y2mxxcha0350000005nyc/direct/01/" border="0" name="cpstillad9"></a>');
			document.write('<br><img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			ads9 = new Array();
			ads9[0] = new Array('http://view.atdmt.com/NYC/view/y2mxxcha0350000005nyc/direct/01/', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=29986&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fclk.atdmt.com%2FNYC%2Fgo%2Fy2mxxcha0350000005nyc%2Fdirect%2F01%2F', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=29986&random=');
			ads['9'] = new Array(ads9, findRotationIndex(ads9, 9), 0);
			var impressionIMG9=new Image();
			impressionIMG9.src="http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=29986&random=20050225021211";
			break;
		case 10:
			document.write('<img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			document.write('<a href="http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=30932&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fwww.springbreakfla.com" target="_blank" name="cpstilladclick10"><img src="http://media.collegepublisher.com/media/Images/ads/quality_inn/qualityinn125.gif" border="0" name="cpstillad10"></a>');
			document.write('<br><img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			ads10 = new Array();
			ads10[0] = new Array('http://media.collegepublisher.com/media/Images/ads/brokescholar/scholarshipchannel120x240 (2).gif', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=29670&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=main.cfm%3Finclude%3DviewChannel%26channel_id%3D49', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=29670&random=');
			ads10[1] = new Array('http://media.collegepublisher.com/media/Images/ads/hillholiday/125x125AreYouBold.gif', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=30302&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fwww.areyoubold.com%2F', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=30302&random=');
			ads10[2] = new Array('http://media.collegepublisher.com/media/Images/ads/quality_inn/qualityinn125.gif', 'http://admanager2.broadbandpublisher.com/networkBannerServerClickThrough.adp?paperBannerAdId=30932&callingSite=www.dailytrojan.com&timeStamp=20050225021211&redirecturl=http%3A%2F%2Fwww.springbreakfla.com', 'http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=30932&random=');
			ads['10'] = new Array(ads10, findRotationIndex(ads10, 10), 0);
			var impressionIMG10=new Image();
			impressionIMG10.src="http://admanager2.broadbandpublisher.com/networkImpression.adp?pbaid=30932&random=20050225021211";
			break;
	}
}

// total execution time: 2.90 ms
var admanagerIsAvailable = 1;

