<!--
function rotateReNorthAds() {
  reNorthAdIndex = Math.floor(Math.random() * renorthads.length);
  var imagesource = renorthads[reNorthAdIndex].getSrc();
  window.document.getElementById("renorthimage").src = imagesource;
  window.document.getElementById("renorthimageurl").href=renorthads[reNorthAdIndex].getUrl();
  reNorthTimer = setTimeout("rotateReNorthAds()", 30000);
}

function showRandomAdsOnLoad(){
  bannerAdIndex = Math.floor(Math.random() * bannerAds.length);
  rightColAdIndex = Math.floor(Math.random() * rightColAds.length);

  window.document.getElementById("bannerAdSrc1").src = bannerAds[bannerAdIndex].src1;
  window.document.getElementById("bannerAdUrl1").href = bannerAds[bannerAdIndex].url1;
  window.document.getElementById("bannerAdSrc2").src = bannerAds[bannerAdIndex].src2;
  window.document.getElementById("bannerAdUrl2").href = bannerAds[bannerAdIndex].url2;
  window.document.getElementById("bannerAdSrc3").src = bannerAds[bannerAdIndex].src3;
  window.document.getElementById("bannerAdUrl3").href = bannerAds[bannerAdIndex].url3;

  window.document.getElementById("rightColAdSrc1").src = rightColAds[rightColAdIndex].src;
  window.document.getElementById("rightColAdUrl1").href = rightColAds[rightColAdIndex].url;
}

// Global variables for keeping track of rotated ads
// adCount - the number of ads that have been displayed
// adCycles - the number of times the script has cycled through all ads
// adUses - an array containing the number of times each ad was used
// maxMisses - the number of times the script will attempt to try picking a random
//   number that has not been choosen already, when that time is reached it
//   will iterate through all ads and pick one that has not been picked in that cycle.
var adCount = 0;
var adCycles = 0;
var adUses = new Array();
var maxMisses = 100;

function rotatePrAds() {
  var validIdx = 0;
  var numMisses = 0;
  while (validIdx <= 0) {
    // choose a random number based on the number of ads.
  	PrAdIndex = Math.floor(Math.random() * (PrAds.length-1));
  	// check to make sure that the ad has not been used in the current cycle
  	if (typeof(adUses[PrAdIndex]) == "undefined") {
  		adUses[PrAdIndex] = 1;
  		validIdx = 1;
  	} else {
  		if (adUses[PrAdIndex] <= adCycles) {
  			// increment the number of uses for this ad
  			adUses[PrAdIndex] = adUses[PrAdIndex] + 1;
  			validIdx = 1;
  		} else {
  			// we were not able to determine a number randomly, so increment the misses
  			// if we hit maxMisses then iterate through adUses and find the next ad that 
  			// has not been used.
  			numMisses = numMisses + 1;
  			if (numMisses > maxMisses) {
  				for (i = 0; i < PrAds.length; i++) {
  					if (typeof(adUses[i]) == "undefined") {
						adUses[i] = 1;
						PrAdIndex = i;
						validIdx = 1;	
						break;
  					} else {
  						if ( adUses[i] <= adCycles) {
							adUses[i] = adUses[i] + 1;
							PrAdIndex = i;
							validIdx = 1;	
							break;
						}
  					}
  				}
  			}
  		}
  	}
  }
  // Increment the ad counter, so that we know when we ran through the cycle.
  adCount = adCount + 1;
  if ((adCount % PrAds.length) == 0) {
  	// we ran through a cycle so increment adCycles
  	adCycles = adCycles + 1;
  }
  
  // this is old code that remains unchanged
  var imagesource = PrAds[PrAdIndex].getSrc();
  if(document.getElementById("primage")) { // iffed by CW 5/10 - only do if primage exists
  	window.document.getElementById("primage").src = imagesource;
  	window.document.getElementById("primageurl").href=PrAds[PrAdIndex].getUrl();
  }
// GMb 04/19/07 Commented this out because we do not want the print ads to rotate any more
//PrTimer = setTimeout("rotatePrAds()", 10000);
}

function ecnPopUp(address)
{
  newWin = window.open(address, this.target, this.settings);
  newWin.focus();
  return false;
} 
var newwindow;
function ecnPopper(url)
{
       var winFeatures="toolbar=no,status=no,menubar=no,location=no,scrollbars=yes,resizable=yes"
	newwindow=window.open(url,'name',winFeatures);
	if (window.focus) {newwindow.focus()}
}
function ecnToggleWeeklies() {
   var sub = document.getElementById('ecn_nav_sub');
   if (sub.style.display != 'block')
   {
      sub.style.display = 'block';
   }else{
      sub.style.display = 'none';
   }
}
sfHover = function() {
	var sfEls = document.getElementById("topnav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace("sfhover", "");
		}
	}
}

function cleanupStory() {
	var ps = document.getElementsByTagName('p');
	for (i in ps) {
		var p = ps[i];
		var ptext = p.innerHTML;
		if (ptext) {
			ptext = ptext.replace(/([12357])(\xe2\xd1|\u2019\xd1|\xe2&Ntilde;|\u2019&Ntilde;|&acirc;&Ntilde;|&#8217;&Ntilde;)([2348])/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$3<\/span>");
			ptext = ptext.replace(/&lt;(\d+)\/(\d+)&gt;/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$2<\/span>");
			ptext = ptext.replace(/<(\d+)\/(\d+)>/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$2<\/span>");
			// fix mdashes from old system
			//ptext = ptext.replace(/\-\-|\|/g, "&mdash;");
			// strip characters
			ptext = ptext.replace(/\xac/g,"");
			p.innerHTML = ptext;
		}
	}
}
/* This can be used for testing purposes, simply add "&testing=true" to the end of the url
and it should use this function to do the clean up */
function cleanupStoryTest() {
	var ps = document.getElementsByTagName('p');
	for (i in ps) {
		var p = ps[i];
		var ptext = p.innerHTML;
		if (ptext) {
			ptext = ptext.replace(/([12357])(\xe2\xd1|\u2019\xd1|\xe2&Ntilde;|\u2019&Ntilde;|&acirc;&Ntilde;|&#8217;&Ntilde;)([2348])/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$3<\/span>");
			ptext = ptext.replace(/&lt;(\d+)\/(\d+)&gt;/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$2<\/span>");
			ptext = ptext.replace(/<(\d+)\/(\d+)>/g,"<span class=\"superscript\">$1<\/span>/<span class=\"subscript\">$2<\/span>");
			// fix mdashes from old system
			ptext = ptext.replace(/\-\-|\|/g, "&mdash;");
			// strip characters
			ptext = ptext.replace(/\xac/g,"");
			p.innerHTML = ptext;
		}
	}
}

-->