function goOverlay(what, x, y)
{
	fade  = .8;
	timer = 2000;
	if (what != '' && x != '' && y != '')
	{
		$(document.body).append("<div id=\"overlayBG\"></div><div id=\"flashOverlay\"></div>");
		$("div#overlayBG").show(1, function() {
			$("body").css("overflow", "hidden");
			$("html").css("overflow", "hidden");
			$(this).fadeTo("normal", fade, function() {
				if ($.platform.mac && $.browser.mozilla)
				{
					// make changes to Firefox on Mac to fix Flash bug
					$(this).fadeTo(0, 100);
					$(this).css("background-image", "url(/Documents/TNAHat25/home/bg_trans.png)");
					$(this).css("background-repeat", "repeat");
					$(this).css("background-color", "transparent");
				}
				var overlay = $("div#flashOverlay");
				overlay.show(1, function() { 
					overlay.html('<script type="text/javascript">var s1 = new SWFObject("'+what+'","single","'+x+'","'+y+'","8", "#000000");s1.useExpressInstall("/Documents/TNAHat25/home/expressinstall.swf");s1.write("flashOverlay");posOverlay();</scr'+'ipt>');
					$(window).resize(posOverlay);
//						setTimeout('goVideo("' + video + '", "' + picture + '")', timer);
				});
			});
		});
	}
}

function goVideo(video, picture)
{
	var overlayVideo = $("div#flashVideo");
//		overlayVideo.append('<iframe id="i1" width="320" height="240" border="0"></iframe>');
	overlayVideo.html('<script type="text/javascript">var s2 = new SWFObject("/Documents/TNAHat25/home/flvplayer.swf","single","320","240","8", "#000000");s2.addParam("allowfullscreen","true");s2.addVariable("file","'+ video + '");s2.addVariable("image","'+ picture + '");s2.addVariable("autostart","true");s2.addVariable("enablejs","true");s2.write("flashVideo");</scr'+'ipt>');
	$(overlayVideo).css("margin", "150px 0 0 450px");
}

function closeOverlay()
{
//		$("iframe#i1").empty().hide();
//		$("div#flashVideo").empty().hide();
	$("div#flashOverlay").hide(1, function() {
		$("div#overlayBG").fadeTo("normal", 0, function() {
			$(this).hide();
			$("body", "html").css("overflow", "auto");
			$(this).remove();
		});
		$(this).remove();
		$(window).unbind("resize");
	});
}

function posOverlay() 
{
	var docWidth      = $(document.body).width();
	var docHeight     = getWindowHeight();
	var overlayWidth  = 792;
	var overlayHeight = 603;
	var overlayXPos   = (docWidth  > overlayWidth)  ? parseInt((docWidth - overlayWidth) / 2)   : 0;
	var overlayYPos   = (docHeight > overlayHeight) ? parseInt((docHeight - overlayHeight) / 2) : 0;
	var overlay       = $("div#flashOverlay");
	var overlayVideo  = $("div#flashVideo");
	overlay.css("left", overlayXPos);
	overlay.css("top",  overlayYPos);

	window.scrollTo(0,0);

//		overlayVideo.css("left", overlayXPos);
//		overlayVideo.css("top",  overlayYPos);
	
//			$("div#overlayBG").css("height", docHeight + "px");
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

$(function() {
	var userOSAgent = navigator.userAgent.toLowerCase();

	// add platform check
	jQuery.platform = {
			mac: /mac/.test(userOSAgent),
			osx: /mac os x/.test(userOSAgent),
			win: /win/.test(userOSAgent),
			linux: /linux/.test(userOSAgent)
	}
	
	$('.pageContent').find('ul li a[@href$=pdf]').attr('target', '_blank');
});
