var isOpen = false;
var jsReady = false;
var publisherId = 1719803748;
var playerId = 1811456994;
function openExternalLink(anchor)
{
	return openExternalURL(anchor.href);
}

function openExternalURL(href)
{
	Lightbox.href = 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(vidID)
{
	hideSelects("hidden");
	
	text1 = "<a id='videoplayer-expanded' href='/hk/en/swf/videoplayer/videoplayer.swf?videoId=" + vidID + "&publisherId=" + publisherId + "&playerId=" + playerId + "' width='570' height='400'></a>";
	
	id = "videoPlayer";
	writeReelplayer(text1, id)
	
	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);

	//getMovie("videoplayer").highResClosed();
	
	hideSelects(" ");
}

function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].className = visibility;
	}
}

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);
}

function writeReelplayer(text, id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = text;
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
	
}

if (window.addEventListener)
{	
	window.addEventListener('load', initLightbox, false);
}
else if (window.attachEvent)
{
	window.attachEvent('onLoad', initLightbox);
}
