// JavaScript Document

// "timer" is the vaiable that sets the time each
// ad is displayed, in [seconds].
timeBetweenAds=5;

// "noOfAds" is the variable that tells the script
// how many ads to rotate through.


// "playState" is the control variable for the play
// and pause button.
playState="true";

// This function sets all ads to display=none and
// then makes the next ad in the rotation visible
// with display=block.
function nextAd(ad){
	//for all modern browsers
	if(document.getElementById){
		for(i=1;i<(noOfAds+1);i++){
			document.getElementById('rotAd'+i).style.display='none';
			document.getElementById('nav'+i).style.backgroundColor='#fff';
		}
		document.getElementById('rotAd'+ad).style.display='block';
		document.getElementById('nav'+ad).style.backgroundColor='#ccc';
	}
	// for older Netscape Browsers
	else if(document.layers){
		for(i=1;i<(noOfAds+1);i++){
			document.layers['rotAd'+i].style.display='none';
			document.layers['nav'+i].style.backgroundColor='#fff';
		}
		document.layers['rotAd'+ad].style.display='block';
		document.layers['nav'+ad].style.backgroundColor='#ccc';
	}
	// for IE4
	else if(document.all){
		for(i=1;i<(noOfAds+1);i++){
			document.all['rotAd'+i].style.display='none';
			document.all['nav'+i].style.backgroundColor='#fff';
		}
		document.all['rotAd'+ad].style.display='block';
		document.all['nav'+ad].style.backgroundColor='#ccc';
	}
}

// "adCnt" begins the rotation with the first ad
adCnt=1;

// Controls the rotation and increments the ad
function nextAdNum(){
	adCnt=adCnt+1;
	if(adCnt>noOfAds){
		adCnt=1;
	}
	nextAd(adCnt);
}

// Creates a variable that contains the interval
// used by the add rotation so that it can be reset
// when the user presses one of the buttons.
timer=timeBetweenAds*1000;
function rotAdTimer(){
	rotAdInt=window.setInterval('nextAdNum()',timer);
}
function stopAdTimer(){
	window.clearInterval(rotAdInt);
}
function playPause(){
        if(playState){
                stopAdTimer();
                playState=false;
	        if(document.getElementById){
                        document.getElementById('navPP').style.backgroundColor="#ccc";
                }else if(document.layers){
                        document.layers['navPP'].style.backgroundColor="#ccc";
                }else if(document.all){
                        document.all['navPP'].style.backgroundColor="#ccc";
                }
        }else if(!playState){
                stopAdTimer();
                rotAdTimer();
                playState=true;
	        if(document.getElementById){
                        document.getElementById('navPP').style.backgroundColor="#fff";
                }else if(document.layers){
                        document.layers['navPP'].style.backgroundColor="#fff";
                }else if(document.all){
                        document.all['navPP'].style.backgroundColor="#fff";
                }
        }
}
//Starts the rotaion as soon as the page is finished loading.
rotAdTimer();

//--------------------------------------------------
// Copyright 2006-2007 javascript-array.com
//
// Drop down menu script
//
// ------------------------------------------------

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;
