/* ----------------------------------------------------------------------
	Methods to switch image layers in VIE Portal software
-----------------------------------------------------------------------	*/
var ___switchingImagesOpacity = 90;
var ___switchingImagesOperator = 1;
var ___switchingImagesCurrentIndex = 0;
var ___switchingImagesMaxIndex = -1;
var ___switchingImagesMode = 0;
var ___switchingImagesProcessId = -1;
var ___switchingImagesLayersPrefixId = '';

function ___startSwitchingImages()
{
	___switchingImagesProcessId = window.setTimeout("___changeSwitchingImages()", 7000);
}

function ___changeSwitchingImages()
{
	___switchingImagesOpacity = 90;
	___switchingImagesOperator = 1;
	___processSwitchingImages(___switchingImagesCurrentIndex,true,true);
}

function ___processSwitchingImages(step, showOtherImages, goNext)
{
	// computing opacity
	if(___switchingImagesOperator==1)
		___switchingImagesOpacity = ___switchingImagesOpacity - 10;
	else
		___switchingImagesOpacity = ___switchingImagesOpacity + 10;

	// change opacity
	___changeSwitchingImageLayerOpacity(___switchingImagesOpacity, ___switchingImagesLayersPrefixId + ___switchingImagesCurrentIndex);
	window.clearTimeout(___switchingImagesProcessId);
	if(step<9)		// decrease current opacity to zero
		___switchingImagesProcessId = setTimeout(function(){___processSwitchingImages(step+1,showOtherImages,goNext)},100);
		
	else		// if match zero, then show next/previous image
	{
		if(showOtherImages)			// --> show next image
			___switchingImagesProcessId = setTimeout(function(){___showOtherSwitchingImageLayer(goNext)},100);
		else
			___switchingImagesProcessId = window.setTimeout("___changeSwitchingImages()", 7000);
	}
}

function ___showOtherSwitchingImageLayer(goNext)
{
	// hide current
	var obj = document.getElementById(___switchingImagesLayersPrefixId + ___switchingImagesCurrentIndex);
	obj.style.left = '-1000px';
	
	// computing index of other image
	if(goNext)
		___switchingImagesCurrentIndex++;
	else
		___switchingImagesCurrentIndex--;
	if(___switchingImagesCurrentIndex>___switchingImagesMaxIndex)
		___switchingImagesCurrentIndex = 0;
	else if(___switchingImagesCurrentIndex<0)
		___switchingImagesCurrentIndex = ___switchingImagesMaxIndex;
	
	// show other image
	obj = document.getElementById(___switchingImagesLayersPrefixId + ___switchingImagesCurrentIndex);
	obj.style.left = '0px';
	
	___switchingImagesOpacity = 10;
	___switchingImagesOperator = 0;
	___processSwitchingImages(1,false,true);
}

function ___changeSwitchingImageLayerOpacity(opacity, objId)
{
	var obj = document.getElementById(objId);
	if(!obj) return;
	obj.style.opacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.KhtmlOpacity = opacity/100;
	obj.style.filter = "alpha(opacity=" + opacity + ")";
}