function describe(aMsg){ window.status = aMsg; return true; };

function doCalendarSetup(aInputName, aButtonName){
  Calendar.setup({
     inputField     :    aInputName,    // id of the input field
     ifFormat       :    "%Y-%m-%d",       // format of the input field
     showsTime      :    false,            // will display a time selector
     button         :    aButtonName, // trigger for the calendar (button ID)
     singleClick    :    true,
     step           :    1                 // show all years in drop-down boxes (instead of every other year as default)
  });
}

function validateform(){
  for(var i=0;i<reguiredFlds.length;i++){
    if (document.registerform.elements[reguiredFlds[i]].type=="select-one") {
      if (document.registerform.elements[reguiredFlds[i]].value=="-"){
        alert("You must select a " + reguiredFlds[i]);
        return false;
      };
    }else{
      if (document.registerform.elements[reguiredFlds[i]].value.length==0){
        alert("You must fill in the " + reguiredFlds[i]);
        return false;
      };
    };
  }
  return true;
}

function getWindowWidth(){
  minW = 1004;
  if (parseInt(navigator.appVersion, 10)>3) {
   if (navigator.appName=="Netscape") {
    minW = window.innerWidth-16;
   }
   if (navigator.appName.indexOf("Microsoft")!=-1) {
    minW = document.body.offsetWidth-20;
   }
  }
  return minW;
}

function getWindowHeight(){
  minH = 600;
  if (parseInt(navigator.appVersion, 10)>3) {
   if (navigator.appName=="Netscape") {
    minH = window.innerHeight-16;
   }
   if (navigator.appName.indexOf("Microsoft")!=-1) {
    minH = document.body.offsetHeight-20;
   }
  }
  return minH;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function doClear(aControlId){ findControl(aControlId).value = ""; };
function setValue(aControlId, aValue){ findControl(aControlId).value = aValue; };
function checkEmail(aEmail){ return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(aEmail)); }
function trim(s) {return s.replace(/^\s*(.*?)\s*$/,"$1")}

function validateNumericInput(e){
  var key = window.event ? e.keyCode : e.which;
  reg = /\d|\./;
  if (key<32) return true;
  var keychar = String.fromCharCode(key);
  return reg.test(keychar);
}

function clearFormElements(frm){
  for(var i=0;i<frm.elements.length;i++){
    el = frm.elements[i];
    switch (el.tagName.toLowerCase()) {
      case 'input'   :
      case 'textarea':  el.value=trim(el.value);
                        break;
    }
  }
}

