var step = 0;
var intDelay = 10;
var myInterval;
var step_amount = 12;
var background_transparency = 60;
var close = true;
var animation = false;

function initPopup()
{
	setOpacity("background", background_transparency);
	setOpacity("win", 0);
	setOpacity("content", 100);
	
	reSized();
}

function reSized() 
{
    var arrayPageSize = this.getPageSize();
	var temp = accessObj("win");
	temp.style.width = arrayPageSize[0] + 'px';
	temp.style.height = arrayPageSize[1] + 'px';

	arrayPageSize = getWindowSize();
	var temp = accessObj("cTable");
	temp.style.height = arrayPageSize[1] + 'px';
}

function disableClose()
{
	if (!animation)
		close = false;
}

function showDetail(current_link, header, subHeader, bodyText, readMore)
{
	clearInterval(myInterval);
	var cHolder = accessObj("cHolder");
	cHolder.innerHTML = "<img src=\""+current_link+"\"><h3>"+header+"</h3><h2>"+subHeader+"</h2><p>"+bodyText+"</p><a href=\""+readMore+"\">Read more</a>";
	step = 0;
	openDiv("win");
	myInterval = setInterval("fadeInStep()", intDelay);
	close = true;
	animation = true;
}

function fadeInStep()
{
    step += step_amount;
    setOpacity("win", step);
    if (step >= 100)
    {
		clearInterval(myInterval);
		animation = false;
    }
}

function fadeOutStart()
{
	// alert("out");
	clearInterval(myInterval);
	if (close)
	{
		step = 100;
		myInterval = setInterval("fadeOutStep()", intDelay);
		animation = true;
	}
	close = true;
}

function fadeOutStep()
{
    step -= step_amount;
    setOpacity("win", step);
    if (step <= 0)
    {
		clearInterval(myInterval);
		closeDiv("win");
		animation = false;
    }
}