/* IE PNG Fix */
function loadPng(obj, image) {
  if (navigator.platform != "Win32" || navigator.appName != "Microsoft Internet Explorer") return;
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7);
	
	if (itsAllGood && obj.currentStyle.backgroundImage.match(/\.png/i) != null) {
		var bg	= obj.currentStyle.backgroundImage;
		if (!image) {
		  image = bg.substring(5,bg.length-2);
		}
  	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + image + "', sizingMethod='scale')";
  	obj.style.backgroundImage = "url(/images/bg_1x1.gif)";
	}
}

/* Assist IE with whatever:hover's */
ieHover = function() {
	var element = document.getElementById("gtd-stages");
	if (element) {
	  element = element.getElementsByTagName("UL")[0];
  	element.onmouseover = function() {
  		this.className += " ie-hover";
  	}
  	element.onmouseout = function() {
  		this.className = this.className.replace(new RegExp(" ie-hover\\b"), "");
  	}
  }
}

/* External links */
function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
	}
}

/* Popup links */
function popupWindow(theURL, winName, winWidth, winHeight) {
	var posLeft = (Math.floor(screen.width/2)) - (Math.floor(winWidth/2));
	var posTop = (Math.floor(screen.height/2)) - (Math.floor(winHeight/2));

	newWindow = window.open(theURL,winName, "width=" + winWidth + ",height=" + winHeight + ",left=" + posLeft + ",top=" + posTop + ", location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0");
	newWindow.focus();

	return false;
}

/* Allows chained onload's */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}