// JavaScript Document

		var fadebgcolor="white";

	////NO need to edit beyond here/////////////
		 
		var fadearray=new Array(); //array to cache fadeshow instances
		var fadeclear=new Array(); //array to cache corresponding clearinterval pointers
		
		// Defines the function fadeshow()... 
		function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
			this.pausecheck=pause; // stores whether or not to pause onmouseover.
			this.mouseovercheck=0; // mouse NOT initially over.
			this.delay=delay; // stores value of delay between pictures.
			this.degree=0; //initial opacity degree (0%).
			this.curimageindex=0; // initializes current image index to 0.
			this.nextimageindex=1; // initializes next image index to 0.
			fadearray[fadearray.length]=this; // stores current fadeshow instance.
			this.slideshowid=fadearray.length-1; // calculates current instance's slideshowid (as an array index ?? one less ??).
			this.canvasbase="canvas"+this.slideshowid; // canvasbase a string that is a unique id/name????
			this.curcanvas=this.canvasbase+"_0"; // curcanvas is a string same as canvasbase but with suffix _0 ???
			if (typeof displayorder!="undefined")
				theimages.sort(function() {return 0.5 - Math.random();}); // default displayorder is random array order.
			this.theimages=theimages;
			this.imageborder=parseInt(borderwidth);
			this.postimages=new Array(); //preload images
			for (p=0;p<theimages.length;p++){
				this.postimages[p]=new Image()
				this.postimages[p].src=theimages[p][0]
			}
			 
			var fadewidth=fadewidth+(this.imageborder*2);
			var fadeheight=fadeheight+(this.imageborder*2);
			 
			document.write(
					'<div id="master'+this.slideshowid+'" style="position:relative; width:'+fadewidth+'px; height:'+fadeheight+'px; overflow:hidden;">'+
						'<div id="'+this.canvasbase+'_0" style="position:absolute; width:'+fadewidth+'px; height:'+fadeheight+'px; top:0; left:0; filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity:.1; -khtml-opacity:.1; opacity:.1; background-color:'+fadebgcolor+'; text-align:center;"></div>'+
						'<div id="'+this.canvasbase+'_1" style="position:absolute; width:'+fadewidth+'px; height:'+fadeheight+'px; top:0; left:0; filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity:.1; -khtml-opacity:.1; opacity:.1; background-color:'+fadebgcolor+'; text-align:center;"></div>'+
					'</div>');
			
			this.startit();
		} // END function fadeshow().
		
		
		// function fadepic()...
		function fadepic(obj){
			if (obj.degree<100){
				obj.degree+=5;
				if (obj.tempobj.filters&&obj.tempobj.filters[0]){
					if (typeof obj.tempobj.filters[0].opacity=="number") { //if IE6+
						obj.tempobj.filters[0].opacity=obj.degree;
					} else { //else if IE5.5-
						obj.tempobj.style.filter="alpha(opacity="+obj.degree+")";
					} // END if/else.
				} // END if.
				obj.tempobj.style.MozOpacity=obj.degree/100;
				obj.tempobj.style.KhtmlOpacity=obj.degree/100;
				obj.tempobj.style.opacity=obj.degree/100;
			} else {
				clearInterval(fadeclear[obj.slideshowid]);
				obj.nextcanvas = (obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1";
				obj.tempobj = document.getElementById(obj.nextcanvas);
				obj.populateslide(obj.tempobj, obj.nextimageindex);
				obj.nextimageindex = (obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0;
				setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay);
			} // END if/else.
		} // END function fadepic().
		
		
		fadeshow.prototype.populateslide=function(picobj, picindex){
			var slideHTML="";
			if (this.theimages[picindex][1]!="") { //if associated link exists for image
				slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">';
			} // END if.
			slideHTML+='<img src="'+this.postimages[picindex].src+'" style="height:100%;width:auto;" border="'+this.imageborder+'px">';
			if (this.theimages[picindex][1]!="") { //if associated link exists for image
				slideHTML+='</a>';
			} // END if.
			picobj.innerHTML=slideHTML;
		}
		 
		 
		fadeshow.prototype.rotateimage=function(){
			if (this.mouseovercheck==1) {
				var cacheobj=this;
				setTimeout(function(){cacheobj.rotateimage();}, 100); // do this function again soon, maybe next time no mouseover.
			} else {
				this.resetit(); // 
				var crossobj = this.tempobj = document.getElementById(this.curcanvas);
				crossobj.style.zIndex++;
				fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50);
				this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0";
				this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0;
			} // END if/else.
		} // END function rotateimage().
		
		
		// I THINK THIS FUNCTION SETS UP THE NEXT IMAGE TO FADE IN...
		fadeshow.prototype.resetit=function(){
			this.degree=0;
			var crossobj = document.getElementById(this.curcanvas);
			if (crossobj.filters&&crossobj.filters[0]) {
				if (typeof crossobj.filters[0].opacity=="number") { //if IE6+
					crossobj.filters[0].opacity=this.degree;
				} else { //else if IE5.5-
					crossobj.style.filter="alpha(opacity="+this.degree+")";
				} // END if/else.
			} // END if.
			crossobj.style.MozOpacity=this.degree/100;
			crossobj.style.KhtmlOpacity=this.degree/100;
			crossobj.style.opacity=this.degree/100;
		} // END function resetit().
		 
		 
		fadeshow.prototype.startit=function(){
			// POSSIBLY MOVE THIS INTO CONSTRUCTOR OF fadeshow() ???????			
			var crossobj = document.getElementById(this.curcanvas);
			this.populateslide(crossobj, this.curimageindex);
			if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
				var cacheobj = this;
				var crossobjcontainer = document.getElementById("master"+this.slideshowid);
				crossobjcontainer.onmouseover = function(){cacheobj.mouseovercheck=1};
				crossobjcontainer.onmouseout = function(){cacheobj.mouseovercheck=0};
			} // END if.
			this.rotateimage();
		} // END function startit().
		 