var curcontentindex=0
var playing = true;

/*var playbtn = new Image();
var pausebtn = new Image();

playbtn.src = "/img/front_page/play_button.gif";
pausebtn.src = "/img/front_page/pause_button.gif"; */

var messages=new Array()

//these variables are to dynamically display the pagination
var cur=0;
var total=0;
var pagination="";

function getElementByClass(classname){
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
	for (i=0; i<alltags.length; i++){
		if (alltags[i].className==classname){
			messages[inc++]=alltags[i]
			//Need to make the first spot visiable
			messages[0].style.display="block";			
		}	
	}
cur=curcontentindex+1;
total=messages.length;
pagination=cur+" of "+total;
var spotcount=document.getElementById("spotcount");
spotcount.innerHTML=pagination;	

// SK 03/09/2007 Make controls visible only when script is run
	document.getElementById("rotateCtrl").style.visibility = "visible";
}

function rotatecontent(whichDir){
	if (messages.length>1) {
		if (whichDir>0) {
			//get current message index (to show it):
			curcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0
			//get previous message index (to hide it):
			prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
			messages[prevcontentindex].style.display="none" //hide previous message
			messages[curcontentindex].style.display="block" //show current message
			cur=curcontentindex+1;
			total=messages.length;
			pagination=cur+" of "+total;
			var spotcount = document.getElementById("spotcount");
			spotcount.innerHTML=pagination;
		} else {
			//get current message index (to show it):
			curcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
			//get next message index (to hide it):
			prevcontentindex=(curcontentindex<messages.length-1)? curcontentindex+1 : 0
			messages[prevcontentindex].style.display="none" //hide previous message
			messages[curcontentindex].style.display="block" //show current message
			cur=curcontentindex+1;
			total=messages.length;
			pagination=cur+" of "+total;
			var spotcount = document.getElementById("spotcount");
			spotcount.innerHTML=pagination;
		}
	}
}

function pauseRotatation(){
	clearInterval(rotateAds);
	playing = false;
}

function startRotation() {
	if (document.all || document.getElementById){
		rotateAds=setInterval("rotatecontent(1)", 15000);
		playing = true;
	}else{
		togglePlay();
	}
}

function togglePlay(){
	if (document.getElementById) imgObj = document.getElementById('play_pause'); // ie5/ns6
	if (playing) {
		pauseRotatation();
//		imgObj.src = playbtn.src;
	}
	else {

		startRotation();
//		imgObj.src = pausebtn.src;
	}
}