// JavaScript Document

bnrArray = new Array(
new Array(
    'ad1.gif',
	'Resources.aspx',
	'I mage of books.  The banner reads, Annotated Bibliography, A collection of resources about SDT programs'
	),
    new Array(
	'ad2.gif',
	'granteelistings.aspx',
	'Image of a map of the United States.  The banner reads, Drug testing grantees, find one in your area'
	),
	new Array(
	'ad3.gif',
	'events.aspx',
	'Image of a handheld calendar device.  The banner reads, Calendar of Events, where can you find SDTI in action?'
	),
	new Array(
	'ad4.gif',
	'FAQ.aspx',
	'Image of a street sign.  The banner reads, FAQs, find answers to your important questions.'
	),
    new Array(
	'ad5.gif',
	'TAForm.aspx',
	'Image of a help desk. The banner reads, Technical Assitance Request, How can we help you?'
	),
	new Array(
	'ad6.gif',
	'StateInformation.aspx',
	'Image of a purple swirl pattern. The banner reads, Student Drug Testing in your state, find out more...'
	),
	new Array(
	'ad7.gif',
	'Resources.aspx?res=shops',
	'Image of people at a workshop. The banner reads, Bring and SDTI Workshop to your District'
	)
);

var prd=5000;
var tmr;
var sts=0;
var idx=0;
var ida='homeRBa';
var idi='homeRBimg';

function bnrInit()
{
	idx=mod(new Date().getSeconds(),bnrArray.length);
	document.write('<a href="'+bnrArray[idx][1]+'" id="'+ida+'">');
	document.write('<img src="images/'+bnrArray[idx][0]+'" alt="'+bnrArray[idx][2]+'" id="'+idi+'" width="396" height="165" border="0">');
	document.write('</a>');
	bnrStart();
}

function bnr(step,e)
{
	if(step=='0')
	{
		if(sts==1){bnrStop();}else{bnrStart();}
		e.src=(sts==1?'images/stop.gif':'images/play.gif');
		e.title=(sts==1?'Stop Banners':'Start Banners');
	}
	else if(sts==1){bnrStep(step);}
	else if(sts==0){bnrStep(step);bnrStop();}
}

function bnrStart()
{
	idx++;
	if(idx>=bnrArray.length){idx=0;}
	document.getElementById(ida).href=bnrArray[idx][1];
	document.getElementById(idi).src='images/'+bnrArray[idx][0];
	document.getElementById(idi).alt=bnrArray[idx][2];
	tmr=setTimeout('bnrStart()',prd);
	sts=1;
}

function bnrStop()
{
	clearTimeout(tmr);
	sts=0;
}

function bnrStep(step)
{
	bnrStop();
	if(step=='-1')
	{
		if(idx==1){idx=bnrArray.length-1;}
		else if(idx==0){idx=bnrArray.length-2;}
		else{idx-=2;}
	}
	bnrStart();
}

function mod(X,Y)
{
	return(X-Math.floor(X/Y)*Y);
}