// JavaScript Document

function HideDIV(d) { 
	HidePopUp(d); 
}
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }

function ShowPopUp(divId) {
		centerPopup(divId);
		loadPopup(divId);

		setFlashMovie();
}

function HidePopUp(divId) {
		disablePopup(divId);
}

var popupStatus = 0;
function loadPopup(id) {
		if (popupStatus == 0) {
			$(".maskPage, #maskDiv").css({
				"opacity": "0.7"
			});
			$(".maskPage, #maskDiv").fadeIn("slow");
			$("#" + id).fadeIn("slow");
			popupStatus = 1;
		}
}

function disablePopup(id) {
		if (popupStatus == 1) {
			$(".maskPage, #maskDiv").fadeOut("slow");
			$("#" + id).fadeOut("slow");
			popupStatus = 0;
		}
}

function centerPopup(id) {
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var divCtrl = document.getElementById(id);
		var popupHeight = divCtrl.style.height.replace('px', '');
		var popupWidth = divCtrl.style.width.replace('px', '');

		$("#" + id).css({
			"position": "fixed",
			"top": windowHeight / 2 - popupHeight / 2,
			"left": windowWidth / 2 - popupWidth / 2
		});

		$(".maskPage, #maskDiv").css({
			"height": windowHeight
		});
}

function setFlashMovie()
{
		var flashMovie = getFlashMovie("myFlashMovie");
		flashMovie.Play();
}

function getFlashMovie(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}
