//********************************************
// Document: casket.js 
// author: Jay Grubb
// last update: April 15 2004 (1)
// HTML 4.01 Transitional validated: Oct 15 2002 
//     @ http://validator.w3.org/check/referer
// Browser: MSIE 5.0> or Nav4.0>
//
// Preload images 
//********************************************

//*********
// variables
//
var cMaxImg=22 ;			      // number of images
var pictBuffer=new Array() ;  // buffer of preloaded images 
var data=new Array(22);	 	 	// image file name
var curphoto ;						// cur index to file name 
var timerId ;						// pointer to Timeout handle
var attempt ;   					// number of attempts to load an image

//*********
// Initialize the variable to preload images
//
data[0]=["../common/images/title.gif"] ;
data[1]=["images/pine.jpg"] ;
data[2]=["images/memorial.jpg"] ;
data[3]=["images/18guagesilver.jpg"] ;
data[4]=["images/solidpoplar.jpg"] ;
data[5]=["images/solidpoplar.jpg"] ;
data[6]=["images/solidpoplar.jpg"] ;
data[7]=["images/20gaugesealer.jpg"] ;
data[8]=["images/artfirefighter.jpg"] ;
data[9]=["images/solidmaple.jpg"] ;
data[10]=["images/20gaugelastsupper.jpg"] ;
data[11]=["images/arthunter.jpg"] ;
data[12]=["images/solidmahogany.jpg"] ;
data[13]=["images/32ozcopper.jpg"] ;
data[14]=["images/artrace.jpg"] ;
data[15]=["images/doveroak.jpg"] ;
data[16]=["images/bronze.jpg"] ;
data[17]=["images/artgolf.jpg"] ;
data[18]=["images/solidhickory.jpg"] ;
data[19]=["images/stainless.jpg"] ;
data[20]=["images/artmountian.jpg"] ;
data[21]=["images/solidcherry.jpg"] ;

//*********
// function: load
// preloads images and increments graphic bar
//
function load() {
// wait til the picture loaded last time is loaded before
// loading a new one
   if(curphoto>0) {
	     if(!pictBuffer[curphoto-1].complete && ++attempt<2000)
          return;
	}
	 attempt=0;
   // load the image into memory
	 pictBuffer[curphoto]=new Image() ;
	 pictBuffer[curphoto].src=data[curphoto] ;
   // end the timer and show the images
   if(curphoto>=data.length) {
       clearInterval(timerId) ;
			 timerId=-1 ;
			 curphoto=0 ;
	 }
}	     
	 
//*********
// function: preload
// preloads images and adjusts image size to screen resolution
//
function preload() {
     curphoto=0; // index to data
     attempt=0;
		 // load the images every fifty milisecond
     timerId=setInterval("load()",50) ;
		 document.images["titleimg"].width=GetSizeAdj(378,true) ;
		 document.images["titleimg"].height=GetSizeAdj(45,false) ;
}

//*********
// function: cancelTimer
// Cancels the timer stopping the slide show.
//
function cancelTimer() {
    // If the timer is going, stop the timer 
    if(timerId>0) 
        clearTimeout(timerId) ;
    // clear the timer handle
    timerId=-1 ;
}
