/**
 * The Slide Show Class
 * @class
 * @scope public
 */
function SlideShow( imgPath,imgSrc,imgAlt,width,height,styleClass,amtOfTime,amtOfBlendTime ) {
	//save a reference to oThis object
	var oThis 					= this;
	
	/**
     * slide show image variables 
     * @scope private
     */
	oThis.oImage 			= null;
	oThis.oImageName		= "IMG";
	oThis.oImgPath 			= imgPath; 
	oThis.oImgSrc			= imgSrc;
	oThis.oImgAlt			= imgAlt;
	oThis.oImgArr			= new Array();
	oThis.oImgAlpha 		= 0;
	oThis.oImgArr[0] 		= new Image();
	oThis.oImgArr[0].src 	= oThis.oImgPath + oThis.oImgSrc[0]; 
	/**
     * browser detection variables
     * @scope private
     */  
	oThis.oIE4 				= document.all;
	oThis.oNS4 				= document.layers;
	oThis.oNS6 				= document.getElementById && !document.all;
	/**
     * timer variables 
     * @scope private
     */
	oThis.oTID				= null;
	oThis.oAmtOfTime  		= amtOfTime;
	oThis.oAmtOfBlendTime 	= amtOfBlendTime;
	/**
     * slide show layer variables
     * @scope private
     */
	oThis.layer1			= null;
	oThis.layer2			= null;
	oThis.layerID1			= "D1";
	oThis.layerID2			= "D2";
	/**
     * slide show dimension variables
     * @scope private
     */
	oThis.width 			= width; 
	oThis.height 			= height;
	/**
     * slide show style class
     * @scope private
     */
	oThis.styleClass 		= styleClass;
	/**
     * slide show style class
     * @scope private
     */
	oThis.id				= "SlideShow";
	/**
     * current layer
     * @scope private
     */
    oThis.curLayer	 		= oThis.layerID1;
	/**
     * the container
     * @scope private
     */
    oThis.container	 		= null;
	/**
     * the layer
     * @scope private
     */
    oThis.layer	 			= null;
	/**
     * current reference to the image
     * @scope private
     */
    oThis.cur 		 		= 0;

    // initialize the control
    oThis.Init();
    
}
/**
 * initializes the slide show
 * @scope private
 */
SlideShow.prototype.Init 				= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	/* Preload the Images */
	for( i=0; i < oThis.oImgSrc.length; i++ )  {
		oThis.oImgArr[i] = new Image();
		oThis.oImgArr[i].src = oThis.oImgPath + oThis.oImgSrc[i]; 
	}
};
/**
 * start the slide show
 * @scope protected
 */
SlideShow.prototype.Start 				= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	oThis.layer	= document.getElementById( oThis.id );
	oThis.layer.style.width = oThis.width;
	oThis.layer.style.height = oThis.height;
	oThis.layer.className = oThis.styleClass;
	
	if ( oThis.oIE4 || oThis.oNS6 )  { 
		/* create the layers */
		oThis.container = document.createElement( "div" );
		oThis.container.className = "Container";
		oThis.container.style.width = oThis.width;
		oThis.container.style.height = oThis.height;
		oThis.layer1 = document.createElement( "div" );
		oThis.layer1.id = oThis.layerID1;
		oThis.layer1.className = "Layers";
		oThis.layer1.style.width = oThis.width;
		oThis.layer1.style.height = oThis.height;
		oThis.layer2 = document.createElement( "div" );
		oThis.layer2.id = oThis.layerID2;
		oThis.layer2.className = "Layers";
		oThis.layer2.style.width = oThis.width;
		oThis.layer2.style.height = oThis.height;
		oThis.layer2.innerHTML =  "<img alt='"+oThis.oImgAlt[0]+"' src='"+oThis.oImgPath+oThis.oImgSrc[0]+"'>";
		oThis.container.appendChild( oThis.layer1 );
		oThis.container.appendChild( oThis.layer2 );
		oThis.layer.appendChild( oThis.container );
	}
	else  {
		/* add innerHTML to the old school browsers */
		oThis.layer.innerHTML = "<img name='"+oThis.oImageName+"' alt='"+oThis.oImgAlt[0]+"' src='"+oThis.oImgPath+oThis.oImgSrc[0]+"'>";
	}

	oThis.Auto();
};
/**
 * automate the slide show
 * if internet explorer 4 or above or netscape 6 or above, 
 * do the alpha blending, otherwise just go to the next picture
 * @scope private
 */
SlideShow.prototype.Auto				= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	if( oThis.oIE4 || oThis.oNS6 )	{
		oThis.oImgAlpha = 25;
		oThis.oImage = document.getElementById( oThis.curLayer );
		oThis.oImage.innerHTML = "<img alt='"+oThis.oImgAlt[oThis.cur]+"' src='"+oThis.oImgPath+oThis.oImgSrc[oThis.cur]+"'>";
		if( oThis.oImage.filters ) {
		  if( oThis.oImage.filters.alpha) {		  
		    oThis.oImage.filters.alpha.opacity = oThis.oImgAlpha;
		  }
		} else {
		  oThis.oImage.style.MozOpacity = oThis.oImgAlpha / 101;
		}
		oThis.oImage.style.zIndex++;
		oThis.SetInterval( ".AlphaBlend()" );
	}else  {
		/* Ummm ... next image please ( old school browsers ) */
		tempIMG = eval( "document.images." + oThis.oImageName );
		tempIMG.src = oThis.oImgArr[oThis.cur].src;
		oThis.SetTimer( ".NoAlphaBlend()" );
	}
	
	/* A fully functional counter here. */
	oThis.cur = ( oThis.cur + 1 ) % oThis.oImgSrc.length;
};
/**
 * clear the timer
 * @scope private
 */
SlideShow.prototype.ClearTimer			= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	if( oThis.oTID != null ) { clearTimeout( oThis.oTID ); }
};
/**
 * clear the interval
 * @scope private
 */
SlideShow.prototype.ClearInterval		= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	if( oThis.oTID != null ) { clearInterval( oThis.oTID ); }
};
/**
 * set the timer
 * @scope private
 */
SlideShow.prototype.SetTimer	= function ( oFunc )  { 
	//save a reference to oThis object
	var oThis = this;
	oThis.refFunc = oThis.id + oFunc;
	oThis.ClearTimer();
	oThis.oTID = setTimeout( oThis.refFunc, oThis.oAmtOfTime );
}
/**
 * set the interval
 * @scope private
 */
SlideShow.prototype.SetInterval	= function ( oFunc )  { 
	//save a reference to oThis object
	var oThis = this;
	oThis.refFunc = oThis.id + oFunc;
	
	oThis.oTID = setInterval( oThis.refFunc, oThis.oAmtOfBlendTime );
}
/**
 * alpha blending is not available for this browser
 * @scope private
 */
SlideShow.prototype.NoAlphaBlend	= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	oThis.SetTimer( ".Auto()" );
};
/**
 * alpha blending is not available for this browser
 * if alpha is less than 100, increase alpha (opacity), 
 * otherwise go to the next after (amtOfTime) seconds 
 * @scope private
 */
SlideShow.prototype.AlphaBlend				= function ()  { 
	//save a reference to oThis object
	var oThis = this;
	
	if ( oThis.oImgAlpha < 100 ) {
		oThis.oImgAlpha += 25;
		if( oThis.oImage.filters ) {
		  if( oThis.oImage.filters.alpha) {		  
		    oThis.oImage.filters.alpha.opacity = oThis.oImgAlpha;
		  }
		} else {
		  oThis.oImage.style.MozOpacity = oThis.oImgAlpha / 101;
		}
	} else {
		oThis.ClearInterval();
		if( oThis.curLayer == oThis.layerID1 )  {
			oThis.curLayer = oThis.layerID2;
			//oThis.layer.className = oThis.styleClass;
		}
		else { 
			oThis.curLayer = oThis.layerID1;
			//oThis.layer.className = oThis.styleClass + "Overlay";
		}

		oThis.SetTimer( ".Auto()" );
	}
};
