var thumbLinks	= new Array();

function hideOverlay(imgID)
{
	clearImg	= $(imgID);
	clearImg.style.opacity	= 0;
	clearImg.style.filter	= 'alpha(opacity:'+0+')';
}

function showOverlay(imgID)
{
	clearImg	= $(imgID);
	clearImg.style.opacity	= .1;
	clearImg.style.filter	= 'alpha(opacity:'+10+')';
}

function galleryDisp(img, imgWidth, imgHeight, caption, media)
{
	var overLay		= $('overLay');
	var imgDisplay	= $('imgDisplay');
	var	winWidth	= getWidth();
	var winHeight	= getHeight();

	if(imgWidth > (winWidth * .8))
	{
		var oldWidth	= imgWidth;
		imgWidth		= winWidth * .8;
		var adjFactor	= imgWidth/oldWidth;
		imgHeight		= imgHeight * adjFactor;
	}
	if(imgHeight > (winHeight * .8))
	{
		var oldHeight	= imgHeight;
		imgHeight		= winHeight * .8;
		var hghtFactor	= imgHeight/oldHeight;
		imgWidth		= imgWidth * hghtFactor;
	}
	var leftPos		= imgWidth/2;
	var topPos		= (imgHeight/2)+25;
	var divHeight	= (topPos*2);
	var imgUnderTop	= (imgHeight/1)+2;
	overHeight		= document.body.scrollHeight;
	overWidth		= document.body.scrollWidth;
	caption			= caption.replace(/\[/g, "<");
	caption			= caption.replace(/\]/g, " />");
	overLay.style.position		= 'absolute';
	overLay.style.top			= '0';
	overLay.style.left			= '0';
	overLay.style.width			= '100%';
	overLay.style.height		= overHeight+'px';
	overLay.style.opacity		= '.85';
	overLay.style.background	= '#ffffff';
	overLay.style.filter		= 'alpha(opacity:'+85+')';
	overLay.style.display		= 'block';
	
	overLay.onclick = function()
	{
		closeOver();
	}
	
	imgDisplay.style.position	= 'absolute';
	imgDisplay.style.top		= '50%';
	imgDisplay.style.left		= '50%';
	imgDisplay.style.margin		= '-'+topPos+'px 0px 0px -'+leftPos+'px';
	imgDisplay.style.width		= imgWidth+'px';
	imgDisplay.style.height		= divHeight+'px';
	imgDisplay.style.minHeight	= divHeight+'px';
	imgDisplay.style.display	= 'block';
	imgDisplay.style.border		= '3px solid #84cdd6';
	imgDisplay.style.background	= "#ffffff url(\'/graphics/loading.gif\') center center no-repeat";
	var capWidth				= (imgWidth*1)-95;
	if(media == 'vid')
	{
		imgDisplay.innerHTML = "<a id=\"videoPlay\" href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Plugin to see video.</a><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+imgWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px;\">"+caption+"</div></div>";
		loadVideo('videoPlay', img, imgWidth, imgHeight);
		videoReady();
	}else{
		imgDisplay.innerHTML = "<img src=\""+img+"\" width=\""+imgWidth+"\" height=\""+imgHeight+"\" alt=\"\" /><div id=\"imgUnder\" style=\"position: absolute; top: "+imgUnderTop+"px; left: 0px; width: "+imgWidth+"px\"><img id=\"closeButton\" src=\"http://"+location.host+"/graphics/close.png\" height=\"20\" width=\"64\" style=\"float:right; margin: 8px 12px 0px 8px;\" /><div id=\"caption\" style=\"width:"+capWidth+"px;\">"+caption+"</div></div>";
	}
	$('closeButton').onclick = function()
	{
		closeOver();
	}
	function closeOver()
	{
		imgDisplay.style.position	= 'static';
		imgDisplay.style.width		= '0px';
		imgDisplay.style.height		= '0px';
		imgDisplay.style.display	= 'none';
		imgDisplay.innerHTML		= "";
		
		overLay.style.position		= 'static';
		overLay.style.width			= '0px';
		overLay.style.height		= '0px';
		overLay.style.display		= 'none';
		return false;
	}
	return false;
}

function loadVideo(divID, vidFile, imgWidth, imgHeight)
{
	var flashvars = 
	{
		autostart:"false",
		duration: 0,
		file: vidFile,
		bufferlength: 5,
		frontcolor: "716d6c",
		lightcolor: "716d6c",
		screencolor: "2b2b2b",
		autostart: "true",
		displayclick: "play",
		repeat: "none"
	}
	var params = 
	{
		allowfullscreen:"true", 
		allowscriptaccess:"always"
	}
	var attributes =
	{
		id:"vid",
		name:"vid"
	}
	swfobject.embedSWF("/scripts/player.swf", divID, imgWidth, imgHeight, '9.0.124', '/scripts/expressInstall.swf', flashvars, params, attributes);
}

function videoReady()
{
	player = window.document['mpl'];
}

	/*var so = new swfobject('/scripts/player.swf','mpl','10','10','9');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','false');
	so.addParam('flashvars','&duration=33&file=/media/phuket_beach_club_sound.mp3&image=/graphics/phuket_beach_club_sound.gif&title=Click to turn off sound&frontcolor=FFFFFF&lightcolor=FFFFFF&screencolor=FFFFFF&controlbar=none&autostart=true&displayclick=play&repeat=none&stretching=exactfit');
	so.write(divID);
	*/

function getWidth()
{
	var winWidth = 0;
	if (self.innerHeight)
	{
		winWidth	= self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		winWidth	= document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		winWidth	= document.body.clientWidth;
	}
	return winWidth;
}


function getHeight()
{
	var winHeight = 0;
	if (self.innerHeight)
	{
		winHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		winHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		winHeight = document.body.clientHeight;
	}
	return winHeight;
}