// Form Hide functions

function Show(elem) { 
  document.getElementById(elem).style.display = ''; 
} 
function Hide(elem) { 
  document.getElementById(elem).style.display = 'none'; 
} 
function Toggle(elem) { 
status =  document.getElementById(elem).style.display;
if (status.match('none')) { 
  document.getElementById(elem).style.display = ''; } 
else {
  document.getElementById(elem).style.display = 'none'; 
} 
}
function Checkit(elem) {
	var box = document.getElementById(elem);
    box.checked = !(box.checked);
	}
	
  function toggle_it(itemID){ 
      // Toggle visibility between none and inline 
      if ((document.getElementById(itemID).style.display == 'none')) 
      { 
        document.getElementById(itemID).style.display = 'inline'; 
      } else { 
        document.getElementById(itemID).style.display = 'none'; 
      } 
  } 
  
function Select(obj,elem,selecta) { 
txt = obj.options[obj.selectedIndex].value;
if (txt.match(selecta)) {
  document.getElementById(elem).style.display = ''; 
} else {
  document.getElementById(elem).style.display = 'none'; 
}
}

	 
	 // this set of functions powers the class="button" css rollovers
var W3CDOM = (document.createElement && document.getElementsByTagName);

function addButtonRollovers() {
	if (!W3CDOM) return;
	var divs = document.getElementsByTagName("a");
	for (var i=0; i<divs.length; i++) {
		if (divs[i].className.indexOf('button') >= 0) {
			divs[i].rollPosition = "-"+(divs[i].offsetWidth+0)+"px";
			divs[i].onmouseover = buttonRollOver;
			divs[i].onmouseout = buttonRollOut;
		}
	}
}
function buttonRollOver() {
	this.style.backgroundPosition = this.rollPosition;
}
function buttonRollOut() {
	this.style.backgroundPosition = "0 0";
}

/** 
 * function to allow us to add multiple onload events which works on all browsers
 * (including IE / Mac!)
 * From: http://liorean.web-graphics.com/scripts/themeswitch.html 
 **/

var loadEventHandler={  // The Event Handler main object
  Add:function(f){  // Function for adding onload handlers
    loadEventHandler.col[loadEventHandler.col.length]=f;  // Add event handler to collection
    if(typeof window.addEventListener!='undefined')  // If W3C compliant
      window.addEventListener('load',f,false);  // Apply event handler
    else if(!loadEventHandler.ieSet)  // Otherwise, unless already set
      if(typeof document.onreadystatechange!='undefined')  // If supported
        document.onreadystatechange=loadEventHandler.onload;  // Add In event handler handler
    loadEventHandler.ieSet=true;  // Specify that event handler already is set
    return(typeof window.addEventListener!='undefined')  // Return whether W3C compliant
  },
  onload:function(){  // Function for handling multiple onload handlers in IE
    var m=/mac/i.test(navigator.platform);  // Detect whether mac
    if(typeof document.readyState!='undefined')  // If supported
      if(m?document.readyState!='interactive':document.readyState!='complete')  // And not already finished
        return;  // Exit
    for(var i=0,f;(f=(i<loadEventHandler.col.length)?loadEventHandler.col[i]:null);i++)  // For all event handlers
      f();  // Run event handler
    return  // Exit
  },
  ieSet:false,  // Variable to say whether event handler is set or not
  col:[]  // Collection for event handlers
};

loadEventHandler.Add(addButtonRollovers);

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

