/*
 * author@ShuvoRim
 * http://www.shuvorim.tk
 * shuvorim@hotmail.com
 * (c)ShuvoRim Pvt. Ltd. 2002 - 03
 * All rights reserved.
 * --------------------------------------------------
 * visit our web site for more free Java applications
 * and applets. Thank you for using our program.
 */


 //declaring necessary local variables

 var img = new Array(24);	//array to hold the images
 var start = null;		//start pointer
 var counter = 1;		//counts the image sequences
 var delayTime = null;		//user defined delay time of the slide show
 var tempo = 4;			//temporary variable for holding the delay


 if(document.images) //pre-load all the images before starting the show
 {

/* change the looping condition if you want to add or remove images. Do not load too many images, it will slow down the page loading time [e.g. 20 or above images]. Please use appropriate image extensions, if you aren't using ".jpg" images. */

   for(i = 1; i < 24; i++)
   {

     img[i] = new Image();
     img[i].src = "killisport/lk" + i + ".jpg";

   }

 }


 //function for getting the user defined delay time

 function getDelayTime(dlTime)
 {

   var temp = parseInt(dlTime);		//parsing the delay time string to integer

   if(temp != NaN)			//if the temp variable is not equal to a NaN
    delayTime = temp * 1000;		//then multiply temp by 1000 miliseconds

   else					//default
    delayTime = 4000;			//using the default delay time - 4 seconds

 }


 //function for changing the images
 //this function is used for auto slide show

 function anim()
 {

   try
   {

     if(counter < 24)
     document.initPic.src = img[counter++].src;	//setting the next image

     else
     {

       clearInterval(start);	//clearing the interval

       with(document.form1)
       {

	 stShow.disabled = false;	//enabling the 'Start' button
	 btnBack.disabled = false;	//enabling the 'Back' button
	 btnNext.disabled = false;	//enabling the 'Next' button
	 spShow.disabled = true;	//disabling the 'Stop' button

       }

     }

   }

   catch(exception)
   {

     //catch the error and do nothing!

   }

 }


 //function for starting the slide show
 //'Start' button calls it whenever clicked

 function slide()
 {

   getDelayTime(document.form1.delay.value);	//getting user defined delay time

   with(document.form1)
   {

     start = setInterval("anim()", delayTime);	//setting the page interval
     stShow.disabled = true;			//disabling the 'Start' button
     btnBack.disabled = true;			//disabling the 'Back' button
     btnNext.disabled = true;			//disabling the 'Next' button
     spShow.disabled = false;			//enabling the 'Stop' button

   }

 }


 //function for the 'Back' button

 function back()
 {

   try
   {

     if(counter > 1)
      document.initPic.src = img[--counter].src;

   }

   catch(exception)
   {

     //catch the error and do nothing!

   }

 }


 //function for the 'Next' button

 function next()
 {

   try
   {

     if(counter < 24)
      document.initPic.src = img[++counter].src;

   }

   catch(exception)
   {

     //catch the error and do nothing!

   }

 }


 //function to stop the slide show

 function stopSlide()
 {

   clearInterval(start);			//clearing the interval

   with(document.form1)
   {

     stShow.disabled = false;		//enabling the 'Start' button
     btnBack.disabled = false;		//enabling the 'Back' button
     btnNext.disabled = false;		//enabling the 'Next' button
     spShow.disabled = true;		//disabling the 'Stop' button

   }
 }


 //function for increasing the delay time

 function incDelay()
 {

   tempo++;		//increasing the value of the temporary variable

   if(tempo >= 30)	//not more than to 30 seconds
    tempo = 30;		//set tempo 30 again

   document.form1.delay.value = tempo;

 }


 function decDelay()
 {

   tempo--;		//decreasing the value of the temporary variable

   if(tempo <= 1)	//not less than to 1 second
    tempo = 1;		//set tempo 1 again

   document.form1.delay.value = tempo;

 }

