﻿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("*")
var alltags=document.getElementsByTagName("div")
    //alert(alltags.length);
	for (i=0; i<alltags.length; i++)
	{
		if (alltags[i].className==classname)
		{
			messages[inc++]=alltags[i]
			if(inc!=1)
			    messages[inc-1].style.display="none";
			 else			
			    messages[0].style.display="block";	//Need to make the first spot visiable		 
		}	
	}
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
if(document.getElementById("rotateCtrl")!=null)
	document.getElementById("rotateCtrl").style.visibility = "visible";
}

function rotatecontent(whichDir)
{
    
	if (messages.length>0) 
	{
	  
	    if (whichDir>0) // for particular
		{
		    if(blStopIndicators == true)// Added by durgesh check if pause button is clicked
			{
			//get current message index (to show it):
			curcontentindex=whichDir-1
			//get previous message index (to hide it):
			prevcontentindex=(curcontentindex==0)? messages.length-1 : curcontentindex-1
			for(j=0;j<messages.length;j++)
			    messages[j].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;
			getElementByClassForRotateElements('featRotateIndicators',whichDir)
			
		    }
			
		} 
		else if (whichDir==0) // for next
		{
			//get current message index (to show it):
			if(blStopIndicators == true)// Added by durgesh check if pause button is clicked
			{
			//alert(blStopIndicators);
			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;
			//alert(curcontentindex-1);
			
			RotateIndicators();
			
			}
		} 
		else // for previous
		{
			//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;
			//getElementByClassForRotateElements('featRotateIndicators',whichDir)
			
		}
	}
}
//Added by durgesh for Indicator rotation
function RotateIndicators()
{
    if(temp < BanCountref || temp == BanCountref)
			{
			    temp++;
			    if(temp > BanCountref)
			    {
			        temp=1;
			    }
			    getElementByClassForRotateElements("featRotateIndicators",temp);
			}
			else
			{
			    temp=temp+1;
			    getElementByClassForRotateElements("featRotateIndicators",temp);
			}
}
//Added by durgesh for Banner count
var myarry = new Array();
var temp=1;
var BanCountref;
function getBannercount(str)
	{
	BanCountref=str;
	
	}
	//Added by durgesh for indicator rotations
function getElementByClassForRotateElements(classname, strTagId)
    {   
   if(blStopIndicators ==true)
   {
    var alltags=document.getElementsByTagName("a")
    for (i=0; i<alltags.length; i++)
	{
		if (alltags[i].className=='indicator')
		{	
             alltags[i].className="indicator";		
			 
		}
		if(alltags[i].className=='indicator active')
		{
		    alltags[i].className="indicator";		
		}
		
	}
    var indicatoractive=document.getElementById(strTagId);
	indicatoractive.className="indicator active";		
   
	}
	  
		
		
	
	}
var blStopIndicators=true;//This variable for stop/start Indicator

function pauseRotatation(){
    blStopIndicators=true;   
	clearInterval(rotateAds);
	playing = false;
	
}

function startRotation() { 

    blStopIndicators=false;
	if (document.all || document.getElementById){
		rotateAds=setInterval("rotatecontent("+ temp +")", 0);
		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;
	}
}
