/*
	iLyt: "Lyt" box v1.1 by JACOB GRICE.
	DO NOT MODIFY THIS HEADER OR THIS FILE
*/

/*
	HOW TO POP THE LIGHTBOX:
	

*/

var enableEasyLightboxExit = true;

var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

function setLightBox(width, title, message, button)
{
	document.getElementById('light').innerHTML = '<h2 align="center" style="font-size: 24px; line-height: 1em;">'+title+'</h2>';
	document.getElementById('light').innerHTML += '<p align="center" style="font-size: 13px">'+message+'</p>';
	document.getElementById('light').innerHTML += '<br style="clear:both;" /><p align="center"><a href="javascript:void(0)" onclick="hideLightBox()" style="font-size: 14px;">'+button+'</a></p>';
	document.getElementById('light').style.width = width + 'px';
	var marginLeft = -1 * (width / 2);
	document.getElementById('light').style.marginLeft = marginLeft + 'px';
	updateLightBox();
}

function showLightBox()
{
	document.body.style.overflow = "hidden";
	
	document.getElementById('light').style.visibility = document.getElementById('fade').style.visibility = 'hidden';
	
	setTimeout("showLightBox2(1)", 10);
	
}

function setOpacity(what, value) {
	what.style.opacity = value/10;
	what.style.filter = 'alpha(opacity=' + value*10 + ')';
}


function showLightBox2(stage)
{
	var delay = 1;
	var steps = 3;
	var box = document.getElementById('light');
	var bg = document.getElementById('fade');
	var nextstage = stage + 1;
	bg.innerHTML = '<h2>' + nextstage + '</h2>';
	if(stage == 1)
	{
		bg.style.display = 'block';
		box.style.display = 'block';
		setOpacity(bg, 0);
		setOpacity(box, 0);
		setTimeout("updateLightBox()", delay);
	}
	
	if(stage == 2)
	{
		bg.style.visibility = 'visible';
		box.style.visibility = 'visible';
		
	}
	
	if(stage > 1 && stage <= steps)
	{
		setOpacity(bg, stage * 0.9);
		setOpacity(box, stage * 0.9);
	}
	
	if(stage >= steps)
	{
		setOpacity(box, 10);
		return;
	}
	
	setTimeout("showLightBox2("+nextstage+")", delay);
}

function showLightBoxTemp(ms)
{
	showLightBox();
	setTimeout("hideLightBox()", ms);
}

function tryHideLightBox()
{
	if(enableEasyLightboxExit)
		hideLightBox();
}

function hideLightBox()
{
	document.getElementById('light').style.display = "none";
	document.getElementById('fade').style.display = "none";
	document.body.style.overflow = "auto";
	enableEasyLightboxExit = true;
}

function updateLightBox()
{
	var lightbox = document.getElementById('light');
	var fadebox = document.getElementById('fade');
	
	var docHeight = getDocHeight();
	
	var scrollY = getScrollOffset();
	
	var boxHeight = lightbox.offsetHeight;
	
	var topY = scrollY;
	var centerY = scrollY + ((docHeight / 2) - (boxHeight / 2))
	
	
	if(lightbox.style.top != centerY + "px" || fadebox.style.top != topY + "px")
	{
		lightbox.style.top = centerY + "px";
		fadebox.style.top = topY + "px";
	}
	
	if(lightbox.style.display == "block")
		setTimeout("updateLightBox()", 100);
}

function getScrollOffset()
{
	return document.all? iebody.scrollTop : pageYOffset;
}

function getDocHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
  }
  return myHeight;
}
