   /* GLOBAL.JS
    * global javascript file
	* contains useful scripts
	*/
	
   /****************************************** SLIDESHOW - PART ******************************************/	
   var index = 0;            //start index
   var maxIndex = 5;         //maximum index in the image list 
   var imgPrefix = "";       //the prefix of a numbered image e.g.: ./images/aikido/
   var imgExtension = "jpg"; //the extension without dot
   var elementID = "";       //the element ID, in this case the table id 
   
   var intervalID = "";     //interval id
   var intervalTime = 3000; //the delay in milliseconds
   var randomSlide = false; //indicates if the slide show should be radnomized or not


   //this function starts the time interval and calls the every time IMGSLIDE()
   function startInterval( ){
      intervalID = window.setInterval ( 'imgSlide()', intervalTime );
   }//STARTINTERVAL 
   
   //this functions swaps the image; randomly or incrementally depending on >>randomSlide<<
   function imgSlide ( ){
      var oldIndex = index; 
	  
	  //if randomize was selected
	  if ( randomSlide ){
	     //evaluate as long as a new index has been calculated --> no duplicate slide
	     do{
	        index = Math.floor ( Math.random( ) * ( maxIndex + 1 ) );
	     }while ( index == oldIndex );
	  }//IF
	  else{ //incremental slide
		 ++index;
		 if ( index > maxIndex )
		    index = 0; //start again from zero
	  }//ELSE
	  
	  //finally display the image
	  //or/ /document.all.discipline.background = imgPrefix  + index + "." + imgExtension; 
	  document.getElementById( elementID ).background = imgPrefix  + index + "." + imgExtension;
   }//IMGSLIDE
   
   //this function sets a randomly evaluated image for the backround of id
   function setRandomImage ( id, prefix, lastIndex, extension ){
      index = Math.floor ( Math.random( ) * ( lastIndex + 1 ) );	   
	  document.getElementById( id ).background = prefix  + index + "." + extension;
   }//GETRANDOMIMAGE

   //starts the slide - show for id
   function startSlide ( id, prefix, lastIndex, extension, intervalMSec, randomize ){
	   /* global assignemnts */
	   imgPrefix = prefix;
	   maxIndex = lastIndex;
	   imgExtension = extension;
	   intervalTime = intervalMSec;
	   elementID = id;
	   randomSlide = randomize;
	   
	   //START the timer
	   startInterval ( );
	   
	   if ( !randomSlide ){
	      //get random start image
	      index = Math.floor ( Math.random( ) * ( maxIndex + 1 ) );
	   }//IF
	   
	   //fetch the image
       imgSlide ( );
   }//STARTSLIDE
