//<![CDATA[

var _rulesAdded = false;

function getBox()
{
	$('modalMovieWindow').style.display = $('modalBackground').style.display = 'block';

	// call once to center everything
	OnWindowResize();
	
	if (window.attachEvent)
		window.attachEvent('onresize', OnWindowResize);
	else if (window.addEventListener)
		window.addEventListener('resize', OnWindowResize, false);
	else
		window.onresize = OnWindowResize;
	
	// we won't bother with using javascript in CSS to take care
	//   keeping the window centered
	if (document.all)
		document.documentElement.onscroll = OnWindowResize;

loadBox();

}


function OnWindowResize()
{
	// we only need to move the dialog based on scroll position if
	//   we're using a browser that doesn't support position: fixed, like < IE 7
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var top = window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0;
	var div = $('modalMovieWindow');
	
	div.style.left = Math.max((left + (GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
	div.style.top = Math.max((top + (GetWindowHeight() - div.offsetHeight) / 2), 0) + 'px';
}

function OnDetailsWindowClick()
{
	$('modalMovieWindow').style.display = $('modalBackground').style.display = 'none';

	if (window.detachEvent)
		window.detachEvent('onresize', OnWindowResize);
	else if (window.removeEventListener)
		window.removeEventListener('resize', OnWindowResize, false);
	else
		window.onresize = null;
}

/* utiltiy functions */

function GetWindowWidth()
{
	var width =
		document.documentElement && document.documentElement.clientWidth ||
		document.body && document.body.clientWidth ||
		document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
		0;
		
	return width;
}

function GetWindowHeight()
{
    var height =
		document.documentElement && document.documentElement.clientHeight ||
		document.body && document.body.clientHeight ||
  		document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  		0;
  		
  	return height;
}

function $(id)
{
	return document.getElementById(id);
}
//]]>
