// Jeff Green 12/21/2008 Lightbox for dynamic video display.  Tested on IE7/Firefox 3/Safari/Chrome.  
// Tweaked for generic use in standard HTML, jg 2/16/09
// JQuery Rocks.
var VideoOn = false;

$(window).resize(function(){ 
	if (VideoOn) {
		blockerautoadjust();
		popvideoposition();
	}
});
if (!$.browser.mozilla) {
	// In Firefox, the video does not move with its parent frame, therefore enable this feature for only other browsers.
	$(window).scroll(function(){
		if (VideoOn) {
			popvideoposition();
		}
	});
}
function showvideo(w, h, src, title) { 
	setpopvideosize(w, h);
	popvideoposition();
	// load content
	$('.popvideo-nav.left').html(title);
	var embedmagic = '<embed id="player" class="popvideo" src="player.swf" FlashVars="contentPath=#" quality="high" scale=noscale bgcolor="#F0F0F0" name="player" salign="lt" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	$('.popvideo.wrapper > div.popvideo').html(embedmagic.replace('#', src));
	// display
	$('#popvideo-blocker-wrapper').show(1, function(){$('.popvideo.wrapper').fadeIn("fast", function(){$('.popvideo').show();});});	
	blockerautoadjust();
	VideoOn = true;
}
function blockerautoadjust() {
	$('#popvideo-blocker').css('height', $(document).height());
}
function setpopvideosize(w, h) {
	$('.popvideo').css('width', w+'px');
	$('.popvideo').css('height', h+'px');
}
function popvideoposition() {
	var vOffset = ($.browser.msie || $.browser.mozilla) ? document.documentElement.scrollTop : document.body.scrollTop; //FF3 and IE7 support documentElement.scrollTop
	$('.popvideo.wrapper').css('top', Math.max( ($(window).height() / 2) * 0.90 - ($('.popvideo.wrapper').outerHeight() / 2), '15' ) + vOffset + 'px');
	$('.popvideo.wrapper').css('left', ($(window).width() / 2) - ($('.popvideo.wrapper').outerWidth() / 2));		
}
function hidevideo() {
	$('.popvideo.wrapper > div.popvideo').html('');
	// setTimeout allows IE7 time to display the correct bgcolor after the change above removes <EMBED>.
	setTimeout("$('.popvideo.wrapper').fadeOut('normal', function(){$('#popvideo-blocker-wrapper').hide(1,function(){VideoOn=false;});})", 5);
	return false;
}