﻿var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

// SPECIAL CHECK FOR FIREFOX (FOR PNG SUPPORT)
var ff = "";
if(navigator.userAgent.indexOf("Firefox")!=-1)
{
	var versionindex=navigator.userAgent.indexOf("Firefox")+8;
	if (parseInt(navigator.userAgent.charAt(versionindex))>=1)
	{
		ff = (!document.all && document.getElementById);
	}
}

// SPECIAL CHECK FOR IE 7 (FOR PNG SUPPORT)
var ie7 = "";
var version=0;
if (navigator.appVersion.indexOf("MSIE")!=-1)
{
	temp=navigator.appVersion.split("MSIE");
	version=parseFloat(temp[1]);
}
//NON IE browser will return 0
if (version >= 7.0)
{
	ie7 = (document.all && document.getElementById);
}

// SPECIAL CHECK FOR SAFARI (FOR PNG SUPPORT)
var safari = (navigator.userAgent.indexOf('Safari')!=-1);

// CLOSES THE POPUP
function showPopup(popupName)
{
	// SET DOM VALUES	
	if(browser == "ns4")
	{
		document.layers[popupName].visibility = "show";
	}
	else if(browser == "ie4")
	{
		document.all[popupName].style.visibility = "visible";
	}	
	else if(browser == "w3c-png" || browser == "w3c-nopng")
	{
		document.getElementById(popupName).style.visibility = "visible";
	}	
}

// CLOSES THE POPUP
function hidePopup(popupName)
{
	// SET DOM VALUES	
	if(browser == "ns4")
	{
		document.layers[popupName].visibility = "hidden";
	}
	else if(browser == "ie4")
	{
		document.all[popupName].style.visibility = "hidden";
	}	
	else if(browser == "w3c-png" || browser == "w3c-nopng")
	{
		document.getElementById(popupName).style.visibility = "hidden";
	}	
}

// DETERMINES WHAT BROWSER VERSION WE HAVE/STANDARDS COMPLIANCE
function getBrowser()
{
	if(ns4)
	{
		browser = "ns4";
	}
	// Explorer 4
	else if(ie4)
	{
		browser = "ie4";
	}
	// W3C - WITH PNG SUPPORT
	else if(ie7 || ff || safari)
	{
		browser = "w3c-png";
	}
	// W3C - IE5, IE6 and Netscape 6 WITHOUT PNG SUPPORT
	else if(ie5 || ns6)
	{
		browser = "w3c-nopng";
	}
}

// VERIFIES THAT WE ARE READY TO POPULATE ONCE LOADED
function processReqChange()
{
    // only if req shows "loaded"
    if (xmlReq.readyState == 4) 
	{
		// only if "OK"
		if (xmlReq.status == 200)
		{
            popupatePopup();
        }	
		else
		{
            alert("There was a problem retrieving the XML data:\n" + xmlReq.statusText);
		}
	}
}

// CALLED TO VERIFY THAT OUR XML FILE HAS LOADED
function verify()
{
  // 0 Object is not initialized
  // 1 Loading object is loading data
  // 2 Loaded object has loaded data
  // 3 Data from object can be worked with
  // 4 Object completely initialized
  if (xmlDoc.readyState != 4)
  {
      return false;
  }
}
