
// ShowOverlay() and HideOverlay() functions ---------------------------------------------------

function HideOverlay() {

	var objOverlay = document.getElementById("overlay");
	objOverlay.style.display = 'none';
	showSelectBoxes();
	showFlash();

	if (document.getElementById("overlayContent"))
    	document.getElementById("overlayContent").style.display = 'none';
	if (document.getElementById("moreInfoOverlay"))
	    document.getElementById("moreInfoOverlay").style.display = 'none';
	if (document.getElementById("promoOverlay"))
	    document.getElementById("promoOverlay").style.display = 'none';
	
	var objPromo = document.getElementById("promoText");
	if (objPromo) objPromo.innerHTML = '&nbsp;';
}

function ShowOverlay() {

	var objOverlay = document.getElementById("overlay");
	if (!objOverlay)
	{
        // Create the overlay that the content will appear over 
        var objBody = document.getElementsByTagName("body").item(0);
        var objNewOverlay = document.createElement("div");
        objNewOverlay.setAttribute('id','overlay');
        objNewOverlay.style.display = 'none';
        objNewOverlay.style.zIndex = '100';
        objNewOverlay.style.background = '#000000';
        objNewOverlay.style.position = 'absolute';
        objNewOverlay.style.top = '0px';
        objNewOverlay.style.opacity = '0.5';
        objNewOverlay.style.filter="alpha(opacity=50)";
        objNewOverlay.style.overflow="hidden";
        objNewOverlay.onclick = function() { HideOverlay(); }
        objBody.appendChild(objNewOverlay);
        objOverlay = objNewOverlay;
	}
	var arrayPageSize = getPageSize();
    objOverlay.style.left = "0px";
    objOverlay.style.top = "0px";	
	objOverlay.style.height = (arrayPageSize[1]) +"px";
	objOverlay.style.width = (arrayPageSize[2]) +"px";
	objOverlay.style.display = 'block';
	hideSelectBoxes();
	hideFlash();
}

// ShowOverlay() support functions -------------------------------------------------------------

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}

// learnMore XMLHTTP request code and callback function ----------------------------------------

var xmlhttp;

function learnMore(expID)
{
xmlhttp=null
// Firefox
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
// IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  var url = "/GetMoreInfo.aspx?ExpID=" + expID;
  xmlhttp.onreadystatechange=learnMoreCallback;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
    //alert("Your browser does not support XMLHTTP.")
  }
}

function learnMoreCallback()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
    //alert(xmlhttp.responseText);
    var objMoreInfo = document.getElementById("moreInfoText");
    ShowOverlay();
    objMoreInfo.innerHTML = xmlhttp.responseText;
    document.getElementById("moreInfoOverlay").style.display = 'block';
    
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
}

// getPromo XMLHTTP request code and callback function -----------------------------------------

function getPromo(promoID)
{
xmlhttp=null
// Firefox
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
// IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  var url = "/GetPromo.aspx?PromoID=" + promoID;
  xmlhttp.onreadystatechange=getPromoCallback;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  //alert("Your browser does not support XMLHTTP.")
  }
}

function getPromoCallback()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
    //alert(xmlhttp.responseText);
    var objPromo = document.getElementById("promoText");
    ShowOverlay();
    if (objPromo) objPromo.innerHTML = xmlhttp.responseText;
    document.getElementById("promoOverlay").style.display = 'block';
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
}

// Tickets Overlay --------------------------------------------------------------

function ShowTicketsOverlay()
{
	ShowOverlay();
	document.getElementById("overlayContent").style.display = 'block';
}