  var curSub = false;
  var viewportWidth = 0;
  var viewportHeight = 0;
  
  function show(theName) {
    obj = document.getElementById(theName);
    cl = obj.className.replace('hide','show');
    obj.className = cl;
  }

  function hide(theName) {
    obj = document.getElementById(theName);
    cl = obj.className.replace('show','hide');
    obj.className = cl;
  }
  
  function showSub(theId) {
    hideSub();
    curSub = theId;
    obj = document.getElementById('sub_' + theId);
    obj.className = 'submenu a1';
    obj = document.getElementById('t_' + theId);
    obj.className = '';
  }
  
  function hideSub() {
    if (curSub) {
      obj = document.getElementById('sub_' + curSub);
      obj.className = 'submenu a0';
      obj = document.getElementById('t_' + curSub);
      obj.className = 'inact';
      curSub = false;
    }
  }
  
  function swapCheckbox(theName,theObj,hCheck) {
    checkObj = document.getElementById(theName);
    prevVal = checkObj.value;
    if (prevVal == 0) {
      theObj.style.backgroundPosition='0px ' + hCheck + 'px';
      newVal = 1;
    } else {
      theObj.style.backgroundPosition='0px 0px';
      newVal = 0;
    }
    checkObj.value = newVal;
  }
  
  function swap_category(theId) {
    oldCat = document.forms.catForm.category.value;
    obj = document.getElementById(oldCat);
    obj.className = 'hide';
    obj = document.getElementById('a_' + oldCat);
    obj.src = 'images/arrow_right.png';
    obj = document.getElementById(theId);
    obj.className = 'show';
    obj = document.getElementById('a_' + theId);
    obj.src = 'images/arrow_down.png';
    document.forms.catForm.category.value = theId;
  }
  
  function getScreenWidth() {
    if (navigator.appName == "Netscape") sw = window.innerWidth;
    else sw = document.body.clientWidth;
    return sw;
  }
    
  function getScreenHeight() {
    if (navigator.appName == "Netscape") sh = window.innerHeight;
    else sh = document.body.clientHeight;
    return sh;
  }
  
  function centerDiv(theId) {
    obj = document.getElementById(theId);
    w = obj.offsetWidth + 300;
    h = obj.offsetHeight + 300;
    sw = getScreenWidth();
    sh = getScreenHeight();
    scrolly = (document.all)?document.body.scrollTop:window.pageYOffset;
    obj.style.left = Math.ceil((sw - w) / 2)  + 'px';
    obj.style.top = Math.ceil((sh - h) / 2) + scrolly + 'px';
  }
  
  function centerBody() {
    obj = document.getElementById('body');
    bw = Math.round(obj.style.width.replace('px',''));
    w = getScreenWidth();
    l = Math.max(0,Math.round((w-bw) / 2) - 34);
    obj.style.left = l + 'px';  
  }
  
  function checkEnter(event,formObj) {
    var code = 0;
    NS4 = (document.layers) ? true : false;
    if (NS4) code = event.which;
    else code = event.keyCode;
    if (code==13) formObj.submit();
  }
  
  function resetBackgrounds() {
    inputList = document.getElementsByTagName("input");
    for(i=0;i<inputList.length;i++) inputList[i].style.backgroundColor = "transparent";
    selectList = document.getElementsByTagName("select");
    for(i=0;i<selectList.length;i++) selectList[i].style.backgroundColor = "transparent";  
  }
  
  function swapCheck(theId) {
    che = document.getElementById('check_' + theId);
    hid = document.getElementById('checkbox_' + theId);
    if (hid.value == '1') {
        cla = 'hide';
        val = '0';
    } else {
        cla = 'show';
        val = '1';
    }
    che.className = cla;
    hid.value = val;
    //alert(che.className);
    
  }
  
  function getScrollPos() {
    ScrollTop = document.body.scrollTop;
    if (ScrollTop == 0) {
      if (window.pageYOffset) ScrollTop = window.pageYOffset;
      else ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }
    return ScrollTop;
  }
  
  function setHeights(corr,hom) {
    viewportWidth = getScreenWidth() - 10;
    viewportHeight = getScreenHeight() - 120;
    con = document.getElementById('content');
    bod = document.getElementById('body');
    if (getScreenWidth() > 1000) document.body.style.overflowX = 'hidden';
    h = getScreenHeight() - bod.offsetTop - 50;
    if (bod.offsetHeight < h) bod.style.height = h + 'px';
    foo = document.getElementById('footer');
    if (foo) foo.style.top = bod.offsetHeight + 'px';
    centerBody();
    resetBackgrounds();
    bod.className = 'a1';
  }

