//2008-12-11 Mina: modifying this not needlessly blasticate the winodow.onload.
(function() {
	var oldOnLoad = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = initPage;
	} else {
		window.onload = function(){
			oldOnLoad();
			initPage();
		}
	}
}());

function initPage() {
  initPopupLinks();
  dohides();
  // place here any other code you wish to run when the page loads.
}




/* POPUP WINDOW FUNCTION
	Unobtrusive JS: uses class of anchor tag to apply pop-up window script
	classes should be added to arrays in popupLiinkConfig to set the various 
	settings within the popUp function
------------------------------------------------------------------------------------ */

var popupLinkConfig = new Array;

// Example: popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=no,location=no,menubar=no");
popupLinkConfig["popup"] = new Array ( "popup", "width=860,height=560,left="+ ((screen.availWidth - 860) /2) + ",top=" + (((screen.availHeight - 560) /2) - 16) + ",scrollbars=no,menubar=no,resizable=yes,location=no");
popupLinkConfig["popupscroll"] = new Array ( "popupscroll", "width=877,height=577,left="+ ((screen.availWidth - 877) /2) + ",top=" + (((screen.availHeight - 577) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=yes,location=no");
popupLinkConfig["slideshowpopup"] = new Array ( "slideshowpopup", "width=750,height=675,left="+ ((screen.availWidth - 750) /2) + ",top=" + (((screen.availHeight - 675) /2) - 16) + ",scrollbars=no,menubar=no,resizable=yes,location=no");
popupLinkConfig["footerpopup"] = new Array ( "footerpopup", "width=620,height=500,left="+ ((screen.availWidth - 620) /2) + ",top=" + (((screen.availHeight - 500) /2) - 16) + ",scrollbars=yes,menubar=no,resizable=yes,location=no");


// ==========================================================================

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




/* SHOW/HIDE ADJACENT SIBLING ELEMENT
	Uses a class to show and hide an adjacent sibling element. Without JS, the sibling
	is simply displayed. Could be a great way to simplify forms by collapsing
	fieldsets that aren't required.
-------------------------------------------------------------------------------------- */

function dohides()
	{

		var hs,tohide,newlink,newtext;
// get all P elements, loop over them
		hs=document.getElementsByTagName('h4');
		for (i=0;i<hs.length;i++)
			{
// check if the class contains trigger
				if(/trigger/.test(hs[i].className))
				{
// get the next sibling until it really is an element, if so, hide it
					tohide = hs[i].nextSibling;
					while(tohide.nodeType!=1) { tohide=tohide.nextSibling; }
					tohide.style.display='none';
/// assemble a link and take the content of the p as its text
					newlink=document.createElement('a');
					newtext=document.createTextNode(hs[i].firstChild.nodeValue);
					newlink.appendChild(newtext);
					newlink.href='#'
// create a new object attribute, this saves us looping in the showhide function
// add the event handlers
					newlink.colobj=tohide;
					newlink.onclick=function(){showhide(this.colobj);return false}
					//newlink.onkeypress=function(){showhide(this.colobj);return false}
// replace the paragraph with the link
					hs[i].replaceChild(newlink,hs[i].firstChild)
				}
			}
	}

	
function showhide(o)
	{
		if(o) { o.style.display=o.style.display=='none'?'block':'none'; }
	}