function globalOnLoad() {
    // Assign link events
    for (var i = 0; i < document.links.length; i++) {
        if (document.links[i].className.match('External')) {
            document.links[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (document.links[i].className.match('Enlargement')) {
            document.links[i].onclick = function() { enlargementPopup(this.href, this.title); return false; }
        }
    }

    // Run page onLoad function, if it exists
    if (typeof onLoad != 'undefined') {
        onLoad();
    }

}

function messageFlasher() {
	var startcolor;
	var endcolor;

	arrEle = document.getElementsByClassName("Message","MainContent");

	for(i = 0; i < arrEle.length; i++) {

	    if ( Element.hasClassName(arrEle[i], "Error") ) { startcolor = '#FFC0CB'; endcolor = '#ffffff';  }
	    if ( Element.hasClassName(arrEle[i], "Notice") ) { startcolor = '#FFFF99'; endcolor = '#ffffff';  }

	    new Effect.Highlight(arrEle[i], {startcolor: startcolor,endcolor: endcolor, duration: 2});
	}

}

function offsitePopup(url) {
    var popUp = window.open(url, 'offsiteWindow', 'width=1024,height=768,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

function enlargementPopup(url, title) {
    var popUp = window.open(url, 'enlargementWindow', 'width=800,height=600,scrollbars=yes,resizable=yes,menubar=no,toolbar=no,location=no');
    if (typeof popUp == 'object') {
        popUp.focus();
    }
}

/*
function topNavAnimator() {
	arrEle = document.getElementsByClassName("Selected","TopBits");

	for(i = 0; i < arrEle.length; i++) {
	   alert(arrEle[i].id);
        new Effect.Morph(arrEle[i].id, { style:'margin-top: 0px, height:100px', duration: 3.0});

//       new Effect.Morph(arrEle[i], { style: 'margin-top:0px,height:75px' });
	}

}
*/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(globalOnLoad);
addLoadEvent(messageFlasher);
//addLoadEvent(topNavAnimator);

