/* http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			if (oldonload) {
			    oldonload();
			}
			func();
		}
	}
}

function popup(URL)
	{
		myWindow = window.open(URL, "pop_up_window", "width=500,height=300,scrollbars");
		myWindow.focus();
	}

/* http://www.dustindiaz.com/getelementsbyclass/ */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* by Jeremy Keith */
function insertAfter(newElement, targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	}
	else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

function buttonEndings() {
	if (!document.getElementsByTagName) {
		return false
	}
	
	var buttons = getElementsByClass("formInputButton");
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEnding";
		insertAfter(div, buttons[i]);
	}
	var buttons = getElementsByClass("BlueFormInputButton");
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEndingBlue";
		insertAfter(div, buttons[i]);
	}
	var buttons = getElementsByClass("BlueWhiteFormInputButton");
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEndingBlueWhite";
		insertAfter(div, buttons[i]);
	}
	var buttons = getElementsByClass("GreyBlueFormInputButton");
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEndingGreyBlue";
		insertAfter(div, buttons[i]);
	}
	var buttons = getElementsByClass("DarkGreyWhiteFormInputButton");
	/* loop through all buttons and attach a child div */
	for (i=0; i < buttons.length; i++) {
		var div = document.createElement("div");
		div.className = "buttonEndingDarkGreyWhite";
		insertAfter(div, buttons[i]);
	}
}

addLoadEvent(buttonEndings);

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}
var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}
function hideWait() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById(\'pleaseWaitWindow\')');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.all[\'pleaseWaitWindow\']');
  else
     document.poppedLayer =   
        eval('document.layers[\'`pleaseWaitWindow\']');
  document.poppedLayer.style.visibility = "hidden";
  document.poppedLayer.style.display = "none";
}

function showWait() {
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById(\'pleaseWaitWindow\')');
  else if (browserType == "ie")
     document.poppedLayer = 
         eval('document.all[\'pleaseWaitWindow\']');
  else
     document.poppedLayer = 
         eval('document.layers[\'`pleaseWaitWindow\']');
  document.poppedLayer.style.visibility = "visible";
  document.poppedLayer.style.display = "block";
  document.getElementById("body_content_container").style.opacity = "50";
  document.getElementById("body_content_container").style.filter = "alpha(opacity=25)";
	document.body.style.cursor = "wait";
}








