var refreshTime = 500000; 
var numAds = 6;

function makeAd() {
	this.width = ''
	this.height = ''
	this.src = ''
	this.href = ''
	this.mouseover = ''
	this.sponsor = ''
}

var ads = new Array()
for(var i = 1; i <= numAds; i++) { ads[i] = new makeAd() }
i = 1;
ads[i].width = "220"           
ads[i].height = "100"                    
ads[i].src = "graphics/spons/tucker.gif"  			    
ads[i].href = "http://www.tuckereng.com/"           	   
ads[i].mouseover = "Tucker Engineering"         
ads[i].sponsor = "Sponsor"               
i++
ads[i].width = "220"           
ads[i].height = "100"                    
ads[i].src = "graphics/spons/wilcox.gif"  			    
ads[i].href = "http://www.wilcoxind.com/"           	   
ads[i].mouseover = "Wilcox Industries"         
ads[i].sponsor = "Sponsor"               
i++
ads[i].width = "220"           
ads[i].height = "100"                    
ads[i].src = "graphics/spons/CEPS.gif"  			    
ads[i].href = "http://www.ceps.unh.edu/"           	   
ads[i].mouseover = "UNH College of Engineering and Physical Sciences"         
ads[i].sponsor = "Sponsor"               
i++
ads[i].width = "220"           
ads[i].height = "100"                    
ads[i].src = "graphics/spons/unhme.gif"  			    
ads[i].href = "http://www.unh.edu/mechanical-engineering/"           	   
ads[i].mouseover = "UNH Mechanical Engineering"         
ads[i].sponsor = "Sponsor"                            
i++
ads[i].width = "220"           
ads[i].height = "100"                    
ads[i].src = "graphics/spons/fuji.gif"  			    
ads[i].href = "http://www.fujifilmusa.com/"           	   
ads[i].mouseover = "FujiFILMS"         
ads[i].sponsor = "Sponsor"               
i++

var myCode = '';
do { var n= Math.floor(Math.random() * (numAds + 1) + 1); } 
	while(n > numAds);
do { var nn= Math.floor(Math.random() * (numAds + 1) + 1); } 
	while(nn > numAds);
var current_ad = n;
var current_ad2 = nn;
myCode = getCode(n);
if (nn == n)
	nn = n - 1;
if (n == 1)
	nn = n + 1;
var myCode2 = getCode(nn);

function getCode(adNumber){
	var tempCode = ""
	tempCode += ('<a href="'+ ads[adNumber].href +'" \n')
	tempCode += ('onMouseOver="status=\''+ ads[adNumber].mouseover +'\';return true" \n')
	tempCode += ('onMouseOut="status=\'\'"> \n')
	tempCode += ('<img src="' + ads[adNumber].src + '" width=' + ads[adNumber].width)
	tempCode += (' onLoad="setTimeout(\'newAd();\',' + refreshTime + ');"')
	tempCode += ('\n height=' + ads[adNumber].height + ' border=0 >')
	//tempCode += ('<br>Sponsored by: <b>' + ads[adNumber].sponsor + '</b>') //delete this line if you don't want any text to be displayed under your banner
	tempCode += ('</a>')
	return tempCode;
}

function newAd(){
	current_ad++;
	if (current_ad > numAds)
		current_ad = 1;
	if (document.all){
	   write(getCode(current_ad));
	   }
}

function write(text){
	if (document.layers) {
		document.bannerAd.document.write(text)
		document.bannerAd.document.close();
		}
	else
		if (document.all)
			document.all.bannerAd.innerHTML = text
	
}
