var isOpen = false;
var jsReady = false;

function openExternalLink(anchor) {
  Lightbox.href = anchor.href;
	Lightbox.initialize();
	isOpen = true;	
	Lightbox.start(document.getElementById("modalbox"));
	return false;
}
function closeModal() {
  Lightbox.href = null;
	isOpen = false;
	setTimeout("Lightbox.end()", 200);
}

function openVideo()
{
	Lightbox.initialize();
	isOpen = true;	
	Lightbox.start(document.getElementById("videoplayer-expanded"));
	
	return false;
}

function closeVideo()
{
	isOpen = false;
	
	// this has to be on a timeout or the browser will crash
	// http://tom-lee.blogspot.com/2006/06/flash-8-externalinterface-crash-bug.html
	setTimeout("Lightbox.end()", 200);
}

function toggleVideo()
{
	if(isOpen)
	{
		closeVideo();
	}
	else
	{
		openVideo();
	}
}

function getMovie(movieName)
{
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		return window[movieName];
	}
	else
	{
		return document[movieName];
	}
}


function initLightbox()
{
	jsReady = true;
	Lightbox.initialize();
}

function isReady()
{
	return jsReady;
}

if (window.addEventListener)
{	
	window.addEventListener('load', initLightbox, false);
}
else if (window.attachEvent)
{
	window.attachEvent('onLoad', initLightbox);
}