
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) {
		// Ever since we integrated the web 2.0 libraries, the generic handling on js objects has changed.
		// At this stage in the code, we need to see if the associative array is numeric.
		if (IsNumeric(position)) {
			attemptFlip(position);
		}
	}
	timerID = setTimeout("flipAds()", mspause);
}
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
// 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 tell you if a given ad is allowed to display on the page.
// Pass in an array containing sections where this ad can run.
// This function will check the js enviornment for a section name
// variable and inform you as to whether or not this ad can appear
// on this page.
// Returns true or false.
function adCanAppearInThisSection(asectionrestrictions) {
	canappear = false;
	if (asectionrestrictions.length == 0) {
		canappear = true;
	} else if (asectionrestrictions.length > 0 && typeof isectioncategoryid != 'undefined') {
		thissectionname = isectioncategoryid;
	
		// Loop over each section name passed.
		for(i=0;i<asectionrestrictions.length;i++) {
			thistestsection = asectionrestrictions[i];
			if (thissectionname.indexOf(thistestsection + ',')>-1) {
				canappear = true;
			}
		}
	
	} else {
		canappear = false;
	}
	return canappear;
}

function frontpagerequirementspass(bfrontpageonly) {
	if (bfrontpageonly == 0) {
		return true;
	} else {
		theloc = document.URL;
		// If this is the front page, return true; 
		 if(theloc.match(/^http(?:s|)\:\/\/(?:media\.|)(?:www|[a-zA-Z_0-9\-]+?)\.[a-zA-Z_0-9\-]+?\.\w{2,3}\/??(?:home)*?\/??(?:index\.cfm)*?$/)){
		    return true;
		} else {
		    return false;
		}
	}
}

// This will instruct all compatible banner positions on the page to show
// the next banner in the rotation without refreshing the page.
function attemptFlip(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];
	
	// Determine how many *still* images are available for this position. We'll use this when deciding whether or not we want to 
	// try to rotate below.
	numberOfStillImagesForThisPosition = 0;
	
	// Loop over each ad in this position.
	for (i=0; i < ads[position][0].length;i++) {
		adTypeInThisPosition = ads[position][0][i][3];
		if(adTypeInThisPosition == 'stillimage') {
			numberOfStillImagesForThisPosition++;
		}
	}
	
	// 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 flip if we have not done the entire set 3 times yet. If there were mixed advertising types (rich media and still image ads)
	// placed in this position, we'll have a rotation problem. We will only rotate to the next ad if the current one was a still image.
	// That's why we only proceed if the DOM image name is defined. In other words, when the ad that got spit out was a rich media ad, 
	// no DOM image name gets defined. When they are defined, they are named like "cpstillad1", "cpstillad2" etc.
	// Further, we can only flip if there are at least 2 still images.
	//if (ads[position][2] < 3 && ads[position][0].length > 1 && eval("typeof document.cpstillad" + position + " != 'undefined'") && numberOfStillImagesForThisPosition > 1) {
	if (ads[position][2] < 3 && eval("typeof document.cpstillad" + position + " != 'undefined'") && numberOfStillImagesForThisPosition > 1) {
		
		// We now know that there is another still image that we can rotate to. Find the "next" still image in our array.
		// If we have not reached the end of the list of ads for this position, increment the ad index we're on by 1.
		// As a reminder, "ads[position][1]" is the index of the "current" ad we're displaying in this position.
		if (ads[position][1] < ads[position][0].length-1) {
			ads[position][1]++;
		} else {
			ads[position][1] = 0;
		}
		
		// If the "next" ad we just picked above is not a still image, keep trying to find the next still image.
		while(ads[position][0][ads[position][1]][3] != 'stillimage') {
			if (ads[position][1] < ads[position][0].length-1) {
				ads[position][1]++;
			} else {
				ads[position][1] = 0;
			}
		}
		
		// Remember the fact we have iterated through this set another time.
		ads[position][2]++;
		
		// The next 3 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];");
		
		// This will set the click through URL for the ad we just flipped to the appropriate click through URL.
		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;
}
// Takes a url like "http://www.example.com:81/" and returns "www.example.com:81"
function cleanBaseHref(baseHrefIn){ 
	baseHrefOut = baseHrefIn;
	baseHrefOut =  replaceSubstring(baseHrefOut, "http://", "");
	baseHrefOut =  replaceSubstring(baseHrefOut, "/", "");	
	return escape(baseHrefOut);
}	
function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function
// 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();

// Resolves timestamp variable in addition to resolving values for all of the other optional values that you pass after richmedia.
function resolveSimpleVars(richmedia, redirectURL, ibanner_ad_id, ipaper_id) {
	argv = resolveSimpleVars.arguments;
	argc = resolveSimpleVars.arguments.length;
	redirectURL = (argc > 1) ? argv[1] : '';
	ibanner_ad_id = (argc >2) ? argv[2] : '';
	ipaper_id = (argc >3) ? argv[3] : '';
	stringout = richmedia; // This input param is the only required input. If you don't pass the other optional values, they won't get resolved.
	
	basicClickThrough = redirectURL;
	
	stringout = replaceSubstring(stringout, "[BAS-CLICKTHROUGH]", escape(basicClickThrough));
	stringout = replaceSubstring(stringout, "[BAS-CLICKTHROUGH-PLAIN]", basicClickThrough);
	stringout = replaceSubstring(stringout, "[BAS-FLASHCLICKTHROUGH]", replaceSubstring(basicClickThrough, "&", "!"));
	stringout = replaceSubstring(stringout, "[ID]", ibanner_ad_id);
	stringout = replaceSubstring(stringout, "[paperid]", ipaper_id);
	stringout = replaceSubstring(stringout, "[timestamp]", makeTimeStamp());
	trimmedbasehref = basehref.substring(7,basehref.length-1);
	stringout = replaceSubstring(stringout, "[callingSite]", trimmedbasehref);
	return stringout;
}

function makeTimeStamp() {
	pcdateobject=new Date();
	timestamp=pcdateobject.getTime();
	return timestamp.toString();
}

// Pick a banner ad that should be running for the given position. This will randomly pick one out of the array.
// It will output plain <IMG> tags for plain image display or output direct rich media source code.
// Only display a tag when there is at least one banner that is eligible to be displayed.
function pickAnAdForThisPositionAndDisplayIt(aAdsForPosition, position) {
	if (aAdsForPosition.length > 0) {
		 indexOfBannerToStartWith = randomIndex(aAdsForPosition.length-1);
		 chosenBanner = aAdsForPosition[indexOfBannerToStartWith];
		 stillCreative = chosenBanner[0];
		 clickThrough = chosenBanner[1];
		 impressionLink = chosenBanner[2];
		 type = chosenBanner[3];
		 richmediacode = chosenBanner[4];
		 pbaid = chosenBanner[5];
		 ibanner_ad_id = chosenBanner[6];
		 ipaper_id = chosenBanner[7];
		if (type == 'stillimage') {
		 	document.write('<img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
			document.write('<a href="' + resolveSimpleVars(clickThrough, clickThrough, ibanner_ad_id, ipaper_id) + '" target="_blank" name="cpstilladclick' + position + '"><img src="' + resolveSimpleVars(stillCreative, clickThrough, ibanner_ad_id, ipaper_id) + '" border="0" name="cpstillad' + position + '"></a>');
			document.write('<br><img src="http://media.collegepublisher.com/media/images/blank.gif" border="0" height="2"><br>');
		} else {
			document.write(resolveSimpleVars(richmediacode, clickThrough, ibanner_ad_id, ipaper_id));
		}
		
		// Increment the impressions counter for this ad. 
		newimageobject = new Image();
		eval('impressionIMG' + position + '= newimageobject');
		eval('impressionIMG' + position + '.src = "http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=' + pbaid + '&random=" + cacheBust()');
	}	
}
		
// This function is used to count the number of ads that are registered in a given position.
function getAdsInTag (iposition) {
	switch(iposition) {
		case 9:
			return 2;
			break;
			case 10:
			return 2;
			break;
			case 11:
			return 3;
			break;
			case 12:
			return 1;
			break;
			case 13:
			return 6;
			break;
			case 21:
			return 1;
			break;
		
		default:
			return 0;
			break;
	}
}
// This function is is called directly by the newspaper website. A number is passed into this function which represents
// which national ad position the front end needs an advertisement for.
function showNetworkBanner (iposition) {
	adDisplayed = 0;
	
	switch (iposition) {
	
		case 9:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition9 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition9.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=71864&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=71864&random=' + cacheBust() + '', 'richmedia', '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="120" height="240">\n\n	<param name="movie" value="http://media.collegepublisher.com/media/Images/ads/ford/2006/Ford_mtvU_120x240.swf?clickTAG=http://www.fordcollegehq.com?cid=CSPP06_120x240">\n\n	<param name="quality" value="high">\n\n	<param name="wmode" value="opaque" />\n\n	<embed src="http://media.collegepublisher.com/media/Images/ads/ford/2006/Ford_mtvU_120x240.swf?clickTAG=http://www.fordcollegehq.com?cid=CSPP06_120x240" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="120" height="240"></embed>\n\n</object>', 71864, '833', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition9.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=114026&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=114026&random=' + cacheBust() + '', 'richmedia', '<iframe src="http://view.atdmt.com/M0N/iview/cnoccssc0220000003m0n/direct/01?click=" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" allowtransparency="true" width="120" height="240">\n<scr'+'ipt language="JavaScript" type="text/javascript">\ndocument.write(\'<a href="http://clk.atdmt.com/M0N/go/cnoccssc0220000003m0n/direct/01/" target="_blank"><img src="http://view.atdmt.com/M0N/view/cnoccssc0220000003m0n/direct/01/"/></a>\');\n</scr'+'ipt><noscript><a href="http://clk.atdmt.com/M0N/go/cnoccssc0220000003m0n/direct/01/" target="_blank"><img border="0" src="http://view.atdmt.com/M0N/view/cnoccssc0220000003m0n/direct/01/" /></a></noscript></iframe>', 114026, '934', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition9, 9);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['9'] = new Array(aAdsForPosition9, findRotationIndex(aAdsForPosition9, 9), 0);
			
			adDisplayed=1;
			
			break;

		case 10:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition10 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition10.push(new Array('http://media.collegepublisher.com/media/Images/ads/Y2MHouse/Book Channel2_120x240.gif', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=90172&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F%5BcallingSite%5D%2Fbooks%20', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=90172&random=' + cacheBust() + '', 'stillimage', '', 90172, '872', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition10.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=140070&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=140070&random=' + cacheBust() + '', 'richmedia', '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="120" height="240">\n\n	<param name="movie" value="http://media.collegepublisher.com/media/Images/ads/mtvU/mtvU_Woodies120x240.swf">\n\n	<param name="quality" value="high">\n\n	<param name="wmode" value="opaque" />\n\n	<embed src="http://media.collegepublisher.com/media/Images/ads/mtvU/mtvU_Woodies120x240.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="120" height="240"></embed>\n\n</object>', 140070, '1018', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition10, 10);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['10'] = new Array(aAdsForPosition10, findRotationIndex(aAdsForPosition10, 10), 0);
			
			adDisplayed=1;
			
			break;

		case 11:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition11 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition11.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=136041&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=136041&random=' + cacheBust() + '', 'richmedia', '<IFRAME id="butterballid" SRC="http://ad.doubleclick.net/adi/N339.y2m.com/B2024774.3;sz=728x90;ord=[timestamp]?" WIDTH=728 HEIGHT=90 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=\'#000000\'> <scr'+'ipt language=\'JavaScript1.1\' SRC="http://ad.doubleclick.net/adj/N339.y2m.com/B2024774.3;abr=!ie;sz=728x90;ord=[timestamp]?"> </scr'+'ipt> <NOSCRIPT> <A HREF="http://ad.doubleclick.net/jump/N339.y2m.com/B2024774.3;abr=!ie4;abr=!ie5;sz=728x90;ord=[timestamp]?"> <IMG SRC="http://ad.doubleclick.net/ad/N339.y2m.com/B2024774.3;abr=!ie4;abr=!ie5;sz=728x90;ord=[timestamp]?" BORDER=0 WIDTH=728 HEIGHT=90 ALT=""></A> </NOSCRIPT> </IFRAME> \n', 136041, '998', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition11.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=112923&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=112923&random=' + cacheBust() + '', 'richmedia', '<scr'+'ipt language=\'JavaScript1.1\' SRC="http://ad.doubleclick.net/adj/N2335.Y2M.com/B1996821.3;sz=728x90;ord=[timestamp]?">\n</scr'+'ipt>\n<NOSCRIPT>\n<A HREF="http://ad.doubleclick.net/jump/N2335.Y2M.com/B1996821.3;sz=728x90;ord=[timestamp]?">\n<IMG SRC="http://ad.doubleclick.net/ad/N2335.Y2M.com/B1996821.3;sz=728x90;ord=[timestamp]?" BORDER=0 WIDTH=728 HEIGHT=90 ALT="Click Here"></A>\n</NOSCRIPT>', 112923, '932', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition11.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=130438&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=130438&random=' + cacheBust() + '', 'richmedia', '<iframe src="http://view.atdmt.com/AVE/iview/y2mxxlev0130000017ave/direct;wi.728;hi.90/01?click=" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" allowtransparency="true" width="728" height="90">\n<scr'+'ipt language="JavaScript" type="text/javascript">\ndocument.write(\'<a href="http://clk.atdmt.com/AVE/go/y2mxxlev0130000017ave/direct;wi.728;hi.90/01/" target="_blank"><img src="http://view.atdmt.com/AVE/view/y2mxxlev0130000017ave/direct;wi.728;hi.90/01/"/></a>\');\n</scr'+'ipt><noscript><a href="http://clk.atdmt.com/AVE/go/y2mxxlev0130000017ave/direct;wi.728;hi.90/01/" target="_blank"><img border="0" src="http://view.atdmt.com/AVE/view/y2mxxlev0130000017ave/direct;wi.728;hi.90/01/" /></a></noscript></iframe>', 130438, '985', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition11, 11);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['11'] = new Array(aAdsForPosition11, findRotationIndex(aAdsForPosition11, 11), 0);
			
			adDisplayed=1;
			
			break;

		case 12:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition12 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition12.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=140738&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=140738&random=' + cacheBust() + '', 'richmedia', '<scr'+'ipt language=\'JavaScript1.1\' SRC="http://ad.doubleclick.net/adj/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?">\n</scr'+'ipt>\n<NOSCRIPT>\n<A HREF="http://ad.doubleclick.net/jump/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?">\n<IMG SRC="http://ad.doubleclick.net/ad/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?" BORDER=0 WIDTH=300 HEIGHT=250 ALT="Click Here"></A>\n</NOSCRIPT>', 140738, '1020', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition12, 12);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['12'] = new Array(aAdsForPosition12, findRotationIndex(aAdsForPosition12, 12), 0);
			
			adDisplayed=1;
			
			break;

		case 13:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition13 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=130418&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=130418&random=' + cacheBust() + '', 'richmedia', '<iframe src="http://view.atdmt.com/AVE/iview/y2mxxlev0130000020ave/direct;wi.300;hi.250/01?click=" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" allowtransparency="true" width="300" height="250">\n<scr'+'ipt language="JavaScript" type="text/javascript">\ndocument.write(\'<a href="http://clk.atdmt.com/AVE/go/y2mxxlev0130000020ave/direct;wi.300;hi.250/01/" target="_blank"><img src="http://view.atdmt.com/AVE/view/y2mxxlev0130000020ave/direct;wi.300;hi.250/01/"/></a>\');\n</scr'+'ipt><noscript><a href="http://clk.atdmt.com/AVE/go/y2mxxlev0130000020ave/direct;wi.300;hi.250/01/" target="_blank"><img border="0" src="http://view.atdmt.com/AVE/view/y2mxxlev0130000020ave/direct;wi.300;hi.250/01/" /></a></noscript></iframe>', 130418, '984', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://view.atdmt.com/OVM/view/y2mxxpin0010000029ovm/direct/01/', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=121996&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2Fclk%2Eatdmt%2Ecom%2FOVM%2Fgo%2Fy2mxxpin0010000029ovm%2Fdirect%2F01%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=121996&random=' + cacheBust() + '', 'stillimage', '', 121996, '966', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://media.collegepublisher.com/media/Images/ads/nyu/nyu spring fall 06.gif', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=114891&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2Fwww%2Enyu%2Eedu%2Fspring%2Ein%2Eny%2F61L', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=114891&random=' + cacheBust() + '', 'stillimage', '', 114891, '936', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=135419&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=135419&random=' + cacheBust() + '', 'richmedia', '<IFRAME SRC="http://ad.doubleclick.net/adi/N339.y2m.com/B2024774.2;sz=300x250;ord=[timestamp]?" WIDTH=300 HEIGHT=250 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=\'#000000\'> <scr'+'ipt language=\'JavaScript1.1\' SRC="http://ad.doubleclick.net/adj/N339.y2m.com/B2024774.2;abr=!ie;sz=300x250;ord=[timestamp]?"> </scr'+'ipt> <NOSCRIPT> <A HREF="http://ad.doubleclick.net/jump/N339.y2m.com/B2024774.2;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?"> <IMG SRC="http://ad.doubleclick.net/ad/N339.y2m.com/B2024774.2;abr=!ie4;abr=!ie5;sz=300x250;ord=[timestamp]?" BORDER=0 WIDTH=300 HEIGHT=250 ALT=""></A> </NOSCRIPT> </IFRAME> \n', 135419, '997', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=112381&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=112381&random=' + cacheBust() + '', 'richmedia', '<scr'+'ipt language=\'JavaScript1.1\' SRC="http://ad.doubleclick.net/adj/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?">\n</scr'+'ipt>\n<NOSCRIPT>\n<A HREF="http://ad.doubleclick.net/jump/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?">\n<IMG SRC="http://ad.doubleclick.net/ad/N2335.Y2M.com/B1996821.4;sz=300x250;ord=[timestamp]?" BORDER=0 WIDTH=300 HEIGHT=250 ALT="Click Here"></A>\n</NOSCRIPT>', 112381, '931', '873'));
			}
//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition13.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=73793&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=73793&random=' + cacheBust() + '', 'richmedia', '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="250">\n\n	<param name="movie" value="http://media.collegepublisher.com/media/Images/ads/ford/2006/mtvU_300x250Final.swf?1&clickTAG=http://www.fordcollegehq.com?cid=CSPP06_300x250">\n\n	<param name="quality" value="high">\n\n	<param name="wmode" value="opaque" />\n\n	<embed src="http://media.collegepublisher.com/media/Images/ads/ford/2006/mtvU_300x250Final.swf?1&clickTAG=http://www.fordcollegehq.com?cid=CSPP06_300x250" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="300" height="250"></embed>\n\n</object>', 73793, '837', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition13, 13);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['13'] = new Array(aAdsForPosition13, findRotationIndex(aAdsForPosition13, 13), 0);
			
			adDisplayed=1;
			
			break;

		case 21:
			// This array will take up a collection of each still ad for this position. 
			aAdsForPosition21 = new Array();

//			The given ad may only appear in the following section categories.
			asectionrestrictions = new Array();

			//Each array added below will contain STILL CREATIVE,STILL CLICKTHROUGH, IMPRESSION LINK, TYPE (richmedia|still), RICHMEDIA CODE, IBANNER_AD_ID, ipaper_id in that order.

			// If there is no sectionname or section_name variable, any ad may be displayed.
			
			if (adCanAppearInThisSection(asectionrestrictions) && frontpagerequirementspass(0)) {
				aAdsForPosition21.push(new Array('http://', 'http://admanager3.collegepublisher.com/runtime/nationalClickThrough.cfm?paperBannerAdId=73241&callingSite=' + cleanBaseHref(basehref) + '&timeStamp=' + makeTimeStamp() + '&redirectURL=http%3A%2F%2F', 'http://admanager3.collegepublisher.com/runtime/nationalImp.cfm?pbaid=73241&random=' + cacheBust() + '', 'richmedia', '<!-- JavaScript Only -->\n<scr'+'ipt language="JavaScript1.1" src="http://altfarm.mediaplex.com/ad/js/4834-34472-6416-1?mpt=[timestamp]&mpvc=">\n</scr'+'ipt>\n<noscript>\n  <a href="http://altfarm.mediaplex.com/ad/ck/4834-34472-6416-1?mpt=[timestamp]">\n    <img src="http://altfarm.mediaplex.com/ad/bn/4834-34472-6416-1?mpt=[timestamp]"\nalt="Click Here" border="0">\n</a>\n</noscript>', 73241, '826', '873'));
			}

			// Call the command that will select an ad in this position and draw it to the screen.
			pickAnAdForThisPositionAndDisplayIt(aAdsForPosition21, 21);

			// The array we register in the 'ads' array contains the following items on each index:
			// [0] - The array of ads for this position number
			// [1] - The index of the ad that we will *begin* the rotation with. It is a stateful way of remember the current ad in this position.
			// [2] - A zero. This becomes a counter for how many times we've rotated ads in this position.
			ads['21'] = new Array(aAdsForPosition21, findRotationIndex(aAdsForPosition21, 21), 0);
			
			adDisplayed=1;
			
			break;

		}
	return adDisplayed;
}
var admanagerIsAvailable = 1;
