// Copyright 2000-2011, Scott Greaves
// Setup

// ad array
var adFirst = new Array();
adFirst[0] = "Ely MN, http://www.ely.org, ElySnowmobilingWebAd.jpg";

var adListOne = new Array();
adListOne[0] = "Continental Ski &amp; Bike, http://www.continentalski.com, continental-ski.jpg";
adListOne[1] = "Stone Harbor Wilderness Supply, http://www.stoneharborws.com, stone-harbor.jpg";
adListOne[2] = "UMD Stores, http://www.umdstores.com, umd-stores.jpg";
adListOne[3] = "iFan Sports Network, http://www.ifan.tv, ifan.jpg";
adListOne[4] = "Red Rock Radio Winterfest, http://www.tpwinterfest.com, red-rock-radio.jpg";
adListOne[5] = "Whole Foods Co-Op, http://www.wholefoods.coop, whole-foods-coop.jpg";
adListOne[6] = "KUMD Radio, http://www.kumd.org, kumd.jpg";
adListOne[7] = "North Shore Scenic Rail Road, http://www.lsrm.org, north-shore-scenic-rail-road.jpg";
adListOne[8] = "Steger Mukluks, http://www.mukluks.com, steger-mukluks.jpg";
adListOne[9] = "Wintercraft, http://www.wintercraft.com, wintercraft.jpg";
adListOne[10] = "Wintergreen, http://www.wintergreennorthernwear.com, wintergreen.jpg";
adListOne[11] = "Orthopaedic Associates, http://oaduluth.com/about, oad0811-2.swf";
adListOne[12] = "Ely MN, http://www.ely.org, ElyXCSkiWebAd.jpg";
adListOne[13] = "Visit Thunder Bay, http://www.visitthunderbay.com, thunder-bay.jpg";
adListOne[14] = "Northlands News Center, https://my.textcaster.com/asa/Default.aspx?ID=a9af3a36-0b39-4e2c-aba7-b59a79fb9cb7, ncc.jpg";
adListOne[14] = "Freeze Yer Gizzard Blizzard Run, http://www.freezeyergizzardrun.com, IFallsWebAd.jpg";

// rotate ad group
function ads(adGroup, firstAd){
	var theList =  eval("adList"+adGroup);
	var theI = theList.length;
	var whichAd = getCookie('currentAd');
	if (whichAd == "") {
		whichAd = Math.round(Math.random()*(theI-1));
	}
	whichAd = parseInt(whichAd);

	for (i=0;i<4;i++) {
		var theDiv = 'ad'+i;
		if (firstAd >=0) {
			var theVars = adFirst[firstAd].split(", ");
			var theType = theVars[2].substring(theVars[2].length-3);
			firstAd = -1;
		} else {
			var theVars = theList[whichAd].split(", ");
			var theType = theVars[2].substring(theVars[2].length-3);
			whichAd = (whichAd == (theI-1)) ? 0 : whichAd+1;
		}
		if (theType == 'swf') {
			var theCode = '<object type="application/x-shockwave-flash" data="/images/ads/' + theVars[2] + '?clickTAG=' + theVars[1] + '" width="300" height="200" onClick="_gaq.push([\'_trackPageview\', \'/bannerads/' + theVars[0] + '/' + theVars[2] + '\']);"><param  name="movie" value="/images/ads/' + theVars[2] + '" /><a href="' + theVars[1] + '" target="_blank"><img src="/images/ads/' + theVars[2] + '" width="300" height="200" alt="' + theVars[0] + '" /></a></object>';
		} else {
			var theCode = '<a href="' + theVars[1] + '" onClick="_gaq.push([\'_trackPageview\', \'/bannerads/' + theVars[0] + '/' + theVars[2] + '\']);" target="_blank"><img src="/images/ads/' + theVars[2] + '" width="300" height="200" alt="' + theVars[0] + '"></a>';
		}
		document.getElementById(theDiv).innerHTML = theCode;
	}
	setCookie('currentAd', whichAd);
}
