﻿
var popupLinkConfig = new Array;
popupLinkConfig["external"] = new Array ( "winExternal", "");

//window.onload = initPage;  

function initPage() {
  initPopupLinks();
}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
} 

function getObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById) 
    {
		return document.getElementById(objectId);
		// W3C DOM	
    } 
    else if (document.all && document.all(objectId)) 
    {
		// MSIE 4 DOM
		return document.all(objectId);
    } 
    else if (document.layers && document.layers[objectId]) 
    {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } 
    else 
    {
		return false;
    }
}

function getObjectStyle(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById) 
    {
		return document.getElementById(objectId).style;
		// W3C DOM	
    } 
    else if (document.all && document.all(objectId)) 
    {
		// MSIE 4 DOM
		return document.all(objectId).style;
    } 
    else if (document.layers && document.layers[objectId]) 
    {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } 
    else 
    {
		return false;
    }
}

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = objectId;
    
    if(styleObject)
    {
		styleObject.visibility = newVisibility;
		return true;
    } 
    else 
    {
		//alert("we couldn't find the object, so we can't very well move it");
		return false;
    }
}

function changeObjectDisplay(objectId, newDisplay) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getObjectStyle(objectId);
    
    if(styleObject)
    {
		styleObject.display = newDisplay;
		return true;
    } 
    else 
    {
		//alert("we couldn't find the object, so we can't very well move it");
		return false;
    }
}

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getObjectStyle(objectId);
    
    if(styleObject) 
    {
		if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform == "MacPPC"))
		{
			styleObject.pixelLeft = newXCoordinate;
			styleObject.pixelTop = newYCoordinate;
			return true;
		}
		else
		{
			styleObject.left = newXCoordinate;
			styleObject.top = newYCoordinate;
			return true;		
		}		
    } 
    else 
    {
		//alert("we couldn't find the object, so we can't very well move it");
		return false;
    }
} 

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
