// JavaScript Document
//This document lists all the advert images and URL's and rotates them automatically.
//Starting with a randomly

/***************top ad animation**********************/
MM_preloadImages('adverts/bop-poly.jpg','adverts/contract.jpg' ,'adverts/sportbop.jpg','adverts/nw.jpg', 'adverts/mcfalls.jpg', 'adverts/sir-ed.jpg', 'adverts/go4it.jpg', 'adverts/kiwisport.jpg');
adImages = new Array('adverts/bop-poly.jpg','adverts/contract.jpg', 'adverts/sportbop.jpg','adverts/nw.jpg','adverts/mcfalls.jpg', 'adverts/sir-ed.jpg', 'adverts/go4it.jpg', 'adverts/kiwisport.jpg');
adURLs = new Array('www.boppoly.ac.nz','www.sportbop.co.nz/coaching/coachforce.aspx','www.sportbop.co.nz/coaching/coachforce.aspx', 'www.newworld.co.nz', 'www.mcfallfuel.co.nz', 'www.waikato.ac.nz/about/hillary/');
thisAd = Math.floor(Math.random()*7);
imgCt = adImages.length;
var thisTopUrl;
var thisTopPic

function rotateTop(){
	if (document.images){
		thisAd++;
		if(thisAd == imgCt){
			thisAd = 0;
		}
			document.topAd.src=adImages[thisAd];
			thisTopPic=adImages[thisAd];
			thisTopUrl=adURLs[thisAd];
			setTimeout("rotateTop()",20*1000);
	}
}

/***************bottom ad animation**********************/
MM_preloadImages('adverts/lion.jpg','adverts/nzct.jpg','adverts/pub.jpg','adverts/south.jpg','adverts/grassroots.jpg', 'adverts/cotton.jpg', 'adverts/morefm.jpg' );

adImages2 = new Array('adverts/lion.jpg','adverts/nzct.jpg','adverts/pub.jpg','adverts/south.jpg','adverts/grassroots.jpg', 'adverts/cotton.jpg', 'adverts/morefm.jpg');

adURLs2 = new Array('www.lionfoundation.org.nz','www.nzct.org.nz','www.pubcharity.org.nz','www.southerntrust.org.nz','www.grassrootstrust.co.nz', 'www.cottontraders.co.nz', 'www.morefm.co.nz');
thisAd2 = Math.floor(Math.random()*7);
imgCt2 = adImages2.length;
var thisBottomUrl;
var thisBottomPic
function rotateBottom(){
	if (document.images){
		thisAd2++;
		if(thisAd2 == imgCt2){
			thisAd2 = 0;
		}
			document.bottomAd.src=adImages2[thisAd2];
			thisBottomPic=adImages2[thisAd2];
			thisBottomUrl=adURLs2[thisAd2];
			setTimeout("rotateBottom()",20*1000);
	}
}

function startAds(){
	rotateTop();
	document.bottomAd.src=adImages2[thisAd2];
	thisBottomUrl=adURLs2[thisAd2];
	setTimeout("rotateBottom()",10*1000);
}

function topClick(){
	top.location='http://www.netballmagic.co.nz/clickthrough.php?url='+thisTopUrl+'&picname='+thisTopPic;
}

function bottomClick(){
	top.location='http://www.netballmagic.co.nz/clickthrough.php?url='+thisBottomUrl+'&picname='+thisBottomPic;
}
