// JavaScript Document
var objFadeIn = false;
var intPhotoNo = 0;
var objSlideShowIntervalID = null;

function SlideShowPrevious(objID,CurrentAlpha,TargetAlpha,steps) {
	
	clearTimeout(objSlideShowTimeoutID);
	clearInterval(objSlideShowIntervalID);

	if (intPhotoNo == 0) {
		intPhotoNo = parseInt(arrPhotos.length) - 2;
	}
	else {
		intPhotoNo = intPhotoNo - 2;
	}
	
	SlideShow(objID,CurrentAlpha,TargetAlpha,steps);	
	
}

function SlideShowNext(objID,CurrentAlpha,TargetAlpha,steps) {
	
	clearTimeout(objSlideShowTimeoutID);	
	clearInterval(objSlideShowIntervalID);	
	SlideShow(objID,CurrentAlpha,TargetAlpha,steps);
	
}

function SlideShow(objID,CurrentAlpha,TargetAlpha,steps) {	
	setTimeout('Fade("' + objID + '","'+CurrentAlpha+'",'+TargetAlpha+','+(steps)+')', 0);
	objSlideShowIntervalID = setInterval('Fade("' + objID + '","'+CurrentAlpha+'",'+TargetAlpha+','+(steps)+')', 10000);
}

function Fade(objID,CurrentAlpha,TargetAlpha,steps){

	var obj = document.getElementById(objID);
	
	CurrentAlpha = parseInt(CurrentAlpha);
	if (isNaN(CurrentAlpha)){
		CurrentAlpha = parseInt(obj.style.opacity*100);
		if (isNaN(CurrentAlpha))CurrentAlpha=100;
	}	
	
	var DeltaAlpha=parseInt((CurrentAlpha-TargetAlpha)/steps);
	var NewAlpha = CurrentAlpha - DeltaAlpha;
	
	if (NewAlpha == 100 && (navigator.userAgent.indexOf('Gecko') != -1 && navigator.userAgent.indexOf('Safari') == -1)) NewAlpha = 99.99;
	
	obj.style.opacity = (NewAlpha / 100);
	obj.style.MozOpacity = obj.style.opacity;
	obj.style.KhtmlOpacity = obj.style.opacity;
	obj.style.filter = 'alpha(opacity='+NewAlpha+')';

	if (steps>1){
		setTimeout('Fade("'+objID+'",'+NewAlpha+','+TargetAlpha+','+(steps-1)+')', 0);
	}
	
	if (steps == 1 && TargetAlpha == 0) {
		NewAlpha = '';
		TargetAlpha = 100;
		steps = 10;
		objFadeIn = false;
		if (intPhotoNo < (parseInt(arrPhotos.length) - 1)) {
			intPhotoNo = intPhotoNo + 1;
		}
		else {
			intPhotoNo = 0;
		}
		obj.src = arrPhotos[intPhotoNo];
		Fade('image_id','',100,steps);
		return;
	}
	
}
