/// Common JavaScript functions


// Ensure there is a getElementById() function
if(!document.getElementById){
  if(document.all)
  document.getElementById=function(){
    if(typeof document.all[arguments[0]]!="undefined")
    return document.all[arguments[0]]
    else
    return null
  }
  else if(document.layers)
  document.getElementById=function(){
    if(typeof document[arguments[0]]!="undefined")
    return document[arguments[0]]
    else
    return null
  }
}

// Ensure there is a addLoadEvent function
if(!window.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 checkEnter(event, which)
{     
    var code = 0;
    var NS4 = (document.layers) ? true : false;

    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
        document.forms[which].submit();
}

/**************************************************/

function browserwidth()
{
   return document.all ? document.body.clientWidth : window.innerWidth;
}

/* From ALA: http://www.alistapart.com/stories/alternate/ */

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

