/*  Copyright Tomasz Szypilo  |  www.szepa.com */
var vOpacity, vOpacityStep, vOpacityStart, timerID, vRefreshRate;
var divInfo;
vOpacityStart = 10;
vOpacityStep = 5;
vOpacity = vOpacityStart;
vRefreshRate = 50;

function addEvent(object, type, handler)
{
	if (object.addEventListener) {
		object.addEventListener(type, handler, false);
	} else if (object.attachEvent) {
		object.attachEvent(['on',type].join(''),handler);
	} else {
		object[['on',type].join('')] = handler;
	}
}

function funCountDown()
{
	if(timerID)
		window.clearTimeout(timerID);

	timerID = window.setTimeout('funImageShow(-' + vOpacityStep + ')', vRefreshRate);
}

function funOnLoad()
{
	var vTable			= document.getElementById("tblList");
	var tdShowParent	= document.getElementById("tdShowParent");
	var imgLoad			= document.getElementById("imgLoad");
	divInfo				= document.getElementById("divInfo");
	if(divInfo)
		divInfo.innerHTML = "";
	
	if(vTable && imgLoad && tdShowParent && (0<=vOpacity && vOpacity <= 100))
	{
		var filter = "alpha(opacity=" + vOpacity + ")"
		var opacity = "." + vOpacity;
		
		var hlnk = document.createElement("a");
		hlnk.id	= "hlnkEntry";
		hlnk.title = 'Click to enter';
		hlnk.style.cursor = 'hand';
		addEvent(hlnk,'click',function() { 
			funCountDown()
		});
		
		var imag = new Image;
		imag.id = "imgShow";
		imag.style.filter = filter;
		imag.style.opacity = opacity;
		
		imag.onload = function() {
			imgLoad.style.visibility = 'hidden';
				
			timerID = window.setTimeout('funImageShow(' + vOpacityStep + ')', vRefreshRate);
		};					
		hlnk.appendChild(imag);
		tdShowParent.appendChild(hlnk);
		
		imag.src = src;
	}
}

function funImageShow(value)
{
	vOpacity = vOpacity + value;

	var imgShow = document.getElementById("imgShow");
	if(100<vOpacity)
		funTicTac();
		
	if(imgShow && (vOpacityStart<=vOpacity && vOpacity <= 100))
	{
		var filter = "alpha(opacity=" + vOpacity + ")";
		var opacity = "." + vOpacity;

		if(imgShow.style.filter)
			imgShow.style.filter = filter;
			
		if(imgShow.style.opacity && vOpacity < 100)
			imgShow.style.opacity = opacity;
		
		timerID = window.setTimeout("funImageShow(" + value + ")", vRefreshRate);
	}
	else if(timerID)
	{
		window.clearTimeout(timerID);
		
		if(100<=vOpacity)
			vOpacity = 100;
		else if(vOpacity<=vOpacityStart)
		{
			window.location = "listGalleries.aspx";
		}
	}
}
var vTicTacCount = 0;
var vTicTacMax = 5;
var vtdInfo;
function funTicTac()
{
	vTicTacCount+=1;

	var sInfo = "";
	for(var i=0;i<=(vTicTacMax-vTicTacCount);i++)
		sInfo = sInfo + ((i%5)?".":"<font color='red'>.</font>");
		
	//#334531
	divInfo.innerHTML = sInfo;
	
	if(vTicTacMax<=vTicTacCount-1)
	{
		if(timer)
			window.clearTimeout(timer);
			
		funCountDown();
	}
	else
		timer = window.setTimeout("funTicTac()", 1000); // 1-second interval
}			
