// JScript File

var i;

function ChangeSlide(Index)
{   
   i = Index - 1; 
  // alert(i + 'change' );
}

hdnImageText  = document.getElementById(hiddenImageText);
hdnLinkURL  = document.getElementById(hiddenLinkURL);


var varProdCode = new Array(3);
   
//alert(hdnImageText.value);
var s = hdnImageText.value.split(",");
var linkURL = hdnLinkURL.value.split(",");
   
//end of setHiddenFieldClientId
		
var imgtext = new Array(s.length);
var links = new Array(linkURL.length);


for(i=0;i<=s.length-1;i++)
{
    imgtext[i] = s[i];
    links[i] = linkURL[i];
}

theimage = new Array(s.length);

for(i=0 ; i< s.length ; i++ )
{
    theimage[i] = [imgtext[i], links[i], varProdCode[i]];	
   // alert(i);		
}

//playspeed=225000;// The playspeed determines the delay for the "Play" button in ms
playspeed=5000;// The playspeed determines the delay for the "Play" button in ms
linksperline=2; // For the text links
playdiffernce=500; // The speed that the autoplay speed is changed by. 1000=1sec

dotrans=1; // if value = 1 then there are transitions played in IE
transtype='revealtrans';// 'blendTrans' or 'revealtrans'
transattributes='1';// duration=seconds,transition=#<24
//#####
//key that holds where in the array currently are
i=-1;

//alert("hi"+i);

//###########################################
window.onload=function()
{
    //preload images into browser
    preloadSlide();

    //set transitions
    GetTrans();

    //set the first slide
    SetSlide(i);

}

//###########################################
function SetSlide(num) 
{	
   
	//alert(num);
	
	//alert(document.form1.HomePageCenter1_hdnSlideIndex.value);
	//too big
	i=num%theimage.length;
	//alert("hi");
	//too small
	
	//if(i<1)i=theimage.length-1;

	//switch the image
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Apply()')
	{
	document.images.imgslide.src=theimage[i][0];
	//alert(i);
//	if(i==0)
//	{
//	    document.images.imgslide.useMap ='#Map11';
//	}
//	else if(i==1)
//	{
//	    document.images.imgslide.useMap ='#Map12';
//	}
//	else if(i==2)
//	{
//	    document.images.imgslide.useMap ='#Map13';
//	}
//	else if(i==3)
//	{
//	    document.images.imgslide.useMap ='#Map14';
//	}
//	else if(i==4)
//	{
//	    document.images.imgslide.useMap ='#Map15';
//	}
	//alert('test1');
    //alert("hi");
        for(t=0 ; t < 4 ; t++)
        {
            if(i != t)
                {
                    eval("document.images.Slide"+t).src="../Images/Buttons/"+t+".gif";
                }
                else
                {                   
                    eval("document.images.Slide"+ t).src="../Images/Buttons/"+ t +"-mo.gif";                   
                }
        }
	}
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()')

	
	//if they have the speed timer
	if(document.forms[0].slidespeed)
		SetSpeed(0);

}


//###########################################
function PlaySlide() 
{
	//alert(i + 'play slide');	
	
	if (!window.playing) 
	{
		PlayingSlide(i);
		if(document.forms[0].play)
			document.forms[0].play.value="   Stop   ";
	}
	else 
	{
		playing=clearTimeout(playing);
		if(document.forms[0].play)
			document.forms[0].play.value="   Play   ";
	}
	// if you have to change the image for the "playing" slide
	if(document.images.imgPlay)
	{
		setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
		imgStop=document.images.imgPlay.src
		//alert("called");
	}

}


//###########################################
function PlayingSlide(num) 
{		
   // alert(i + 'play slide');	
   //num=i;
	playing=setTimeout('PlayingSlide(i);SetSlide(i);', playspeed);
	
	
	  i  = parseInt(i) + 1;
	        
	 if(i == "4")
        {
          //alert("hi");
            i=0;	
         }   
}


//###########################################
function SetSpeed(num)
{
	if(playspeed+num>0)
	{
		playspeed+=num;
		document.forms[0].slidespeed.value=playspeed;
	}
}


//###########################################
//desc: picks the transition to apply to the images
function GetTrans()
{
			dotrans=1;
			transtype='revealtrans';			
			document.imgslide.style.filter = "revealTrans(duration=1)";

//	}

}
//###########################################
function preloadSlide() 
{
	for(k=0;k<theimage.length;k++) 
		theimage[k][0]=new Image().src=theimage[k][0];
}
