// -------------------------------------------------------------------
// Drop-in Slideshow Script- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: March 9th, 2007
// -------------------------------------------------------------------
var _dropinslideshowcount=0;
function dropinslideshow(imgarray, w, h, delay,catID){
	this.id="_dropslide"+catID+(++_dropinslideshowcount);this.createcontainer(parseInt(w), parseInt(h));this.delay=delay;this.imgarray=imgarray;var preloadimages=[];
	for (var i=0; i<imgarray.length; i++){preloadimages[i]=new Image();preloadimages[i].src=imgarray[i][0];}
	this.animatestartpos=parseInt(h)*(-1);this.slidedegree=10;this.slidedelay=30;this.activecanvasindex=0 ;this.curimageindex=0;this.zindex=100;this.isMouseover=0;this.init();}
dropinslideshow.prototype.createcontainer=function(w, h){
 document.write('<div id="'+this.id+'" style="position:relative; width:'+w+'px; height:275px; overflow:hidden;padding-left:10px">');
	document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:0;"></div>');
	document.write('<div style="position:absolute; width:'+w+'px; height:'+h+'px; top:-'+h+'px;"></div>');
	document.write('</div>');
	this.slideshowref=$(this.id);this.canvases=[];this.canvases[0]=this.slideshowref.childNodes[0];this.canvases[1]=this.slideshowref.childNodes[1];}
dropinslideshow.prototype.populatecanvas=function(canvas, imageindex){
    var imagepath = $('ImageServerPathError').value;
	var imageHTML='<div> <a href="'+this.imgarray[imageindex][1]+'"> <img src="'+ imagepath + "GetThumbNail.ashx?ImgFilePath="+ escape(this.imgarray[imageindex][0]) + '&width=300" width="300" height="225" style="border: 0" /></a>';
	if (this.imgarray[imageindex][1]!=""){
		imageHTML+='<p><a href="'+this.imgarray[imageindex][1]+'" target="'+this.imgarray[imageindex][2]+'">'+ this.imgarray[imageindex][3]+'</a></p>';
		imageHTML+='</div>';}
	canvas.innerHTML=imageHTML;
}
dropinslideshow.prototype.animateslide=function(){
if (this.curimagepos<0){ 
	this.curimagepos=this.curimagepos+this.slidedegree;
	this.activecanvas.style.top=this.curimagepos+"px";}
else{clearInterval(this.animatetimer);this.activecanvas.style.top=0;this.setupnextslide();var slideshow=this;setTimeout(function(){slideshow.rotateslide()}, this.delay);}}
dropinslideshow.prototype.setupnextslide=function(){this.activecanvasindex=(this.activecanvasindex==0)? 1 : 0;this.activecanvas=this.canvases[this.activecanvasindex];this.activecanvas.style.top=this.animatestartpos+"px";this.curimagepos=this.animatestartpos;this.activecanvas.style.zIndex=(++this.zindex);this.curimageindex=(this.curimageindex<this.imgarray.length-1)? this.curimageindex+1 : 0;this.populatecanvas(this.activecanvas, this.curimageindex);}
dropinslideshow.prototype.rotateslide=function(){var slideshow=this;if (this.isMouseover){setTimeout(function(){slideshow.rotateslide()}, 50);}else{this.animatetimer=setInterval(function(){slideshow.animateslide()}, this.slidedelay)}}
dropinslideshow.prototype.init=function(){var slideshow=this;this.populatecanvas(this.canvases[this.activecanvasindex], 0);this.setupnextslide();this.slideshowref.onmouseover=function(){slideshow.isMouseover=1};this.slideshowref.onmouseout=function(){slideshow.isMouseover=0};setTimeout(function(){slideshow.rotateslide()}, this.delay);}
