/* ============================================================================== */
/* Unobtrusive JS Window Popups */
var popupLinkConfig = new Array;

popupLinkConfig["url-map"] = new Array ( "", "width=636,height=548,toolbar=no,location=no,menubar=yes,resizable=yes,status=yes");

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;
}

/* ============================================================================== */
/* Generic onload Function - allows more than one function to be called */
function generic() {
	// Set the main window/tab name
	windowTitle="sd-main";
	window.name = windowTitle;
	// alert("Window Name is: " + windowTitle);
	// Fires first, then body onload
	initPopupLinks();
	// Load the non-invasive JS popup window functionality
}

// Setup onload function
if(typeof window.addEventListener !='undefined') {
	// ...Gecko, Safari, Konqueror, and Standard
	window.addEventListener('load',generic,false);
} else if(typeof document.addEventListener !='undefined') {
	// ...Opera 7
	document.addEventListener('load',generic,false);
} else if(typeof window.attachEvent != 'undefined') {
	// ...Win/IE
	window.attachEvent('onload',generic);
} else {
	// ...Mac IE5 and anything else
	// Ifthere's an existing onload function
	if(typeof window.onload == 'function') {
		// Call existing onload function
		existing();
		
		// Call generic onload function
		generic();
	} else {
		// Setup onload function
		window.onload = generic;
	}
}
