/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function showMask() {

	var sh = document.body.parentNode.scrollHeight;
	var sw = document.body.parentNode.scrollWidth;
	
	if (document.body.scrollHeight) {
		sh = (document.body.scrollHeight > sh) ? document.body.scrollHeight : sh;
		//sw = (document.body.scrollWidth > sw) ? document.body.scrollWidth : sw;
	}
	
	document.getElementById('overlay').style.height = sh + "px";
	//document.getElementById('overlay').style.width = sw + "px";
	
	
	document.getElementById('overlay').style.display = "block";
	document.getElementById('overlay_content').style.display = "block";
	
	centerDialogWithinView(746,396);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function playVideo(vid) {
	showMask();
	var so = new SWFObject("LBStandalonePlayer.swf", "video", "746", "396", "9", "#FFFFFF");
	so.addParam('wmode', 'transparent');
	so.addVariable('setPath', vid)
	so.write('overlay_content');
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function closePlayer() {
	var ele1 = document.getElementById('overlay_content');
	var ele2 = document.getElementById('overlay');
	
	(ele1.style.display = "block") ? ele1.style.display = "none" : ele1.style.display = "block";
	(ele2.style.display = "block") ? ele2.style.display = "none" : ele2.style.display = "block";
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function handleOnResize() {
var targetDiv	= document.getElementById('overlay_content');            
               
                if (targetDiv == null) {
                return;
                }
               
                if (targetDiv.style.display == 'none' || targetDiv.style.display == '') {
                return;
                }
               
showMask();
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function centerDialogWithinView(width,height) {
var objWidth						= width;				// width of dialog
var objHeight						= height;				// height of dialog

var sw								= getViewportWidth();
var sh								= getViewportHeight();
var scrollX							= getScrollPositionX();
var scrollY							= getScrollPositionY();
	
var centerL							= (sw >> 1) - (objWidth >> 1);
centerL								= (centerL < 0) ? 0 : centerL;	
var centerT							= (sh >> 1) - (objHeight >> 1);
centerT								= (centerT < 0) ? 0 : centerT;

// ADD ANY SCROLLING INPUTS TO THE MIX TO CENTER IT WITHIN SCROLLED VIEW
centerL								+= scrollX;
centerT								+= scrollY;
centerT								-= 15;					// hardcoded visual adjustment since they eye really doesn't think it's centered vertically otherwise

document.getElementById('overlay_content').style.left				= centerL + 'px';
document.getElementById('overlay_content').style.top 				= centerT + 'px';
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getViewportWidth() {
var viewportwidth					= -1;	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined') {
	viewportwidth 					= window.innerWidth;
	} // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
	viewportwidth					= document.documentElement.clientWidth;
	}// older versions of IE
	else {
	viewportwidth 					= document.getElementsByTagName('body')[0].clientWidth;
	}
return viewportwidth;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getViewportHeight() {
var viewportheight					= -1;	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerHeight != 'undefined') {
	viewportheight 					= window.innerHeight;
	} // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
	viewportheight					= document.documentElement.clientHeight;
	}// older versions of IE
	else {
	viewportheight 					= document.getElementsByTagName('body')[0].clientHeight;
	}
return viewportheight;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getScrollPositionX() {
var ox								= (document.body.parentNode.scrollLeft) ? document.body.parentNode.scrollLeft : -1;
	if (ox == -1) {
	ox								= (window.pageXOffset) ? window.pageXOffset : -1;
	}
return ox;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getScrollPositionY() {
var oy								= (document.body.parentNode.scrollTop) ? document.body.parentNode.scrollTop : -1;
	if (oy == -1) {
	oy								= (window.pageYOffset) ? window.pageYOffset : -1;
	}
return oy;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



window.onresize = handleOnResize;
window.onscroll = handleOnResize;
