/**
 * @author adam
 */
//Load Multiple Scripts to Work on the Same Page
//-------------------------------------------------------------------------------
function addLoadListener(fn) {
  if (typeof window.addEventListener != 'undefined') { //W3C standard
    window.addEventListener('load', fn, false);
  }else if (typeof document.addEventListener != 'undefined') { //for Opera
   	document.addEventListener('load', fn, false);
  }else if (typeof window.attachEvent != 'undefined') { //IE method
    window.attachEvent('onload', fn);
  }else{ //Mac IE5 or other old browsers
    var oldfn = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = fn;
    }else{
      window.onload = function() {
      	oldfn();
       	fn();
      };
  	}
  }
}

//--------------------------------------------------------------------------------
//attach events to an element
//-------------------------------------------------------------------------------
function attachEventListener(target, eventType, functionRef, capture) {
  if (typeof target.addEventListener != "undefined") {
    target.addEventListener(eventType, functionRef, capture);
  }else if (typeof target.attachEvent != "undefined") { //IE
    target.attachEvent("on" + eventType, functionRef);
  }else{ //Mac IE 5.0 and other old browsers
    eventType = "on" + eventType;
    if (typeof target[eventType] == "function") {
      var oldListener = target[eventType];
      target[eventType] = function() {
        oldListener();
        return functionRef();
      };
    }else{
      target[eventType] = functionRef;
    }
  }
}

//cancellation of an element's default action
//-------------------------------------------------------------------------------
function stopDefaultAction(event) {
  event.returnValue = false;
  if (typeof event.preventDefault != "undefined") {
    event.preventDefault();
  }
}

//show and hide an element
//-------------------------------------------------------------------------------
var showhide = function(event,node){
    if (typeof event == "undefined"){
          event = window.event;
    }
    if(node.style.display=="none"){
        node.style.display = "block";
    }else if(node.style.display=="block" || node.style.display=="inline-block"){
        node.style.display = "none";
    }
    //stop default link actions
    stopDefaultAction(event);
     return false;
};
