﻿// JScript File

hdnImageText  = document.getElementById(hiddenImageText);
hdnLinkURL  = document.getElementById(hiddenLinkURL);
   
var varProdCode = new Array(4);
   
//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);
var i;

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]];			
}

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=0;


//###########################################
window.onload=function()
{
    //preload images into browser
    preloadSlide();

    //"jump to" box
    //for (y=0;y<theimage.length;y++) 
    //{
    //  document.forms[0].imgComboBox[y]=new Option(theimage[y][2]);
    //}

    //set transitions
    GetTrans();

    //set the first slide
    SetSlide(0);

}

//###########################################
function SetSlide(num) 
{
	//too big
	i=num%theimage.length;
	//too small
	if(i<0)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];
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()')

	//if drop down box
	

	//if they want name of current slide
    //document.getElementById('slidebox').innerHTML=theimage[i][2];

	//if they want current slide number and total
    //document.getElementById('slidecount').innerHTML= "Image "+(i+1)+" of "+theimage.length;

	//if they have the speed timer
	if(document.forms[0].slidespeed)
		SetSpeed(0);

}


//###########################################
function PlaySlide() 
{
	if (!window.playing) 
	{
		PlayingSlide(i+1);
		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) 
{
	playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
}


//###########################################
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()
{
//		if((document.forms[0].trans && document.forms[0].trans.selectedIndex == 0) || (!document.forms[0].trans && dotrans==0))
//		{
//			dotrans=0;
//		}
//		else if ((document.forms[0].trans && document.forms[0].trans.selectedIndex == 1) || (!document.forms[0].trans && transtype == 'blendTrans'))
//		{
//			dotrans=1;
//			transtype='blendTrans';
//			document.imgslide.style.filter = "blendTrans(duration=1,transition=1)";
//		}
//		else
//		{
			dotrans=1;
			transtype='revealtrans';
			//if(document.forms[0].trans) transattributes = document.forms[0].trans[document.forms[0].trans.selectedIndex].value;
			//document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")";
			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];
}

