// JavaScript Document
function photoGallery(aryImages, strImageName, oPhotoGallery){
	
	this._oPhotoGallery = oPhotoGallery;
	this._aryPhotos = aryImages;
	//this._aryPhotosWidths = new Array(this._aryPhotos.length);
	//this._aryPhotosHeight = new Array(this._aryPhotos.length);
	this._imgTagName = strImageName;
	this._intCurrentIndex = 0;
	this._intPlaySpeed = 7000; // 7 Seconds
	this._showFilter = true;
	this._bolAllowResize = true;
	this._intTimeOutID = 0;
	
	this.setImgAltTag('Loading Image(s)');	

	this.preloadImages(this._aryPhotos)
	
	this.setImgAltTag('');
	
	this.moveFirst()
	
}


photoGallery.prototype.setImgAltTag = function(strMsg) { //v3.0
  
	eval("document." + this._imgTagName + ".alt = '" + strMsg + "';");	
}



photoGallery.prototype.preloadImages = function(aryImages) { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=aryImages; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


photoGallery.prototype.play = function(){ 
  
	this.changePhoto("next"); 
	
	if(this._intTimeOutID != 0){
		clearTimeout(this._intTimeOutID);
	}
	
	this._intTimeOutID = setTimeout(this._oPhotoGallery + ".play()", this._intPlaySpeed); 
	
}


photoGallery.prototype.moveFirst = function(){

	this.setImgSrc(0);
	
	this._intCurrentIndex = 0;
}


photoGallery.prototype.setImgSrc = function(intImageIndex){

	eval("document." + this._imgTagName + ".src = '" + this._aryPhotos[intImageIndex] + "';");
}


photoGallery.prototype.changePhoto = function(strDirection){
						  
	if(strDirection == "previous"){
		if(this._intCurrentIndex != 0){
			this._intCurrentIndex--;
		}
		else{
			this._intCurrentIndex = this._aryPhotos.length - 1;
		}
	}else if(strDirection == "next"){
		if(this._intCurrentIndex < this._aryPhotos.length - 1){
			this._intCurrentIndex++;
		}
		else{
			this._intCurrentIndex = 0;
		}
	}
	
	this.setImgSrc(this._intCurrentIndex);
	
	if(document.all && this._showFilter){
	
		eval("document." + this._imgTagName + ".style.filter = \"revealTrans(duration=1.0,transition=7) blendTrans(duration=1.5)\""); 
		//eval("document.imgPhoto.style.filter = \"Fade(duration=1.0,overlap=0.5)gradientWipe(duration=1000, gradientsize=5.5)\""); 
		// Fade(duration=1.0,overlap=0.5)gradientWipe(duration=1000, gradientsize=5.5)
		eval("document." + this._imgTagName + ".filters(0).Apply();")
		eval("document." + this._imgTagName + ".filters(1).Apply();")
		
		eval("document." + this._imgTagName + ".filters(0).Play();")
		eval("document." + this._imgTagName + ".filters(1).Play();")
		
	}
	
  }