	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, June 2006
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
var interval = 15000;

function slideShow(objectName,domId,thumbnails,timerInterval){
	
	this.opacitySpeed = 2;	// Speed of opacity - switching between large images - Lower = faster
	this.opacitySteps = 10; 	// Also speed of opacity - Higher = faster
	this.timerInterval = timerInterval;
	
	/* Don't change anything below here */
	this.thumbnails = thumbnails;
	this.DHTMLgoodies_largeImage = document.getElementById(domId).getElementsByTagName('IMG')[0];
	this.DHTMLgoodies_imageToShow = false;
	this.DHTMLgoodies_currentOpacity = 100;
	this.objectName = objectName;
	this.currentUnqiueOpacityId = false;
	this.browserIsOpera = navigator.userAgent.indexOf('Opera')>=0?true:false;
	this.loop = 1;
	
	this.startShow = function (){
		if(this.thumbnails[this.loop] == null)
			this.loop = 0;
		this.showPreview(this.thumbnails[this.loop]);
		this.timerInterval = Math.random()  * interval;
		this.loop ++;
		setTimeout(this.objectName+'.startShow()',this.timerInterval);
	}

	
	this.showPreview = function(imagePath)
	{
		this.DHTMLgoodies_imageToShow = imagePath;
		var tmpImage = new Image();
		tmpImage.src = imagePath;
		this.currentUnqiueOpacityId = Math.random();
		this.moveOpacity(this.opacitySteps*-1,this.currentUnqiueOpacityId);
	}
	
	this.setOpacity = function()
	{
		if(document.all)
		{
			this.DHTMLgoodies_largeImage.style.filter = 'alpha(opacity=' + this.DHTMLgoodies_currentOpacity + ')';
		}else{
			this.DHTMLgoodies_largeImage.style.opacity = this.DHTMLgoodies_currentOpacity/100;
		}		
	}
	
	this.moveOpacity = function(speed,uniqueId)
	{
		
		if(this.browserIsOpera){
			this.DHTMLgoodies_largeImage.src = this.DHTMLgoodies_imageToShow;
			return;
		}
		
		this.DHTMLgoodies_currentOpacity = this.DHTMLgoodies_currentOpacity + speed;
		if(this.DHTMLgoodies_currentOpacity<=5 && speed<0){
		
			var tmpParent = this.DHTMLgoodies_largeImage.parentNode; 
			this.DHTMLgoodies_largeImage.parentNode.removeChild(this.DHTMLgoodies_largeImage);
			this.DHTMLgoodies_largeImage = document.createElement('IMG');
			tmpParent.appendChild(this.DHTMLgoodies_largeImage);
			this.setOpacity();
			this.DHTMLgoodies_largeImage.src = this.DHTMLgoodies_imageToShow;
		
			speed=this.opacitySteps;
		}
		if(this.DHTMLgoodies_currentOpacity>=99 && speed>0)this.DHTMLgoodies_currentOpacity=99;		
		this.setOpacity();	
		if(this.DHTMLgoodies_currentOpacity>=99 && speed>0)return;
		if(uniqueId==this.currentUnqiueOpacityId)setTimeout(this.objectName+'.moveOpacity(' + speed + ',' + uniqueId + ')',this.opacitySpeed);		
	}
	
	
}
