function updateTopButton() {
  if(getElt("top_button")) {
    var topButton = getElt("top_button");
    
    if(getWindowScrollTop() > 0) {
      setEltVisibility(topButton,'visible');
      setEltDisplay(topButton,'block');
      setEltPosition(topButton,'absolute');

      var difR = (getWindowWidth() - offsetRight -4);
      setEltLeft(topButton,difR);

      var difT = (getWindowHeight() - offsetBottom) + getWindowScrollTop();
      setEltTop(topButton,difT);
    } else {
      setEltVisibility(topButton,'hidden');
      setEltDisplay(topButton,'none');
    }
  }
}

function updatePrintButton() {
  if(getElt("print_button")) {
    var printButton = getElt("print_button");
    
    setEltVisibility(printButton,'visible');
    setEltDisplay(printButton,'block');
    setEltPosition(printButton,'absolute');

    var difR = (getWindowWidth() - offsetRight - 7);
    setEltLeft(printButton,difR);

    var difT = (getWindowHeight() - offsetBottom - 30) + getWindowScrollTop();
    setEltTop(printButton,difT);
  }
}

var spotTimer = new Object();

function swapSpotImg(spotId,mapType,mapName,overlayImg) {
  theElement = document.images["p_"+mapName];
  theElement.src = overlayImg;
  return true;
}

function showSpot(elType,spotId,mapType,mapName,overlayImg) {
  if (spotTimer[spotId]) clearTimeout(spotTimer[spotId]);
  var theBlock = getElt("block_"+spotId);
  if (elType == "area") {
    setEltPosition(theBlock,"absolute");
    setEltLeft(theBlock,curMouseX);
    setEltTop(theBlock,curMouseY+getWindowScrollTop());
  }
  setEltDisplay(theBlock,"block");

  if (overlayImg) {
    theElement = document.images["p_"+mapName];
    theElement.src = overlayImg;
  }
  return true;
}

function hideSpot(elType,spotId,mapType,mapName,hideImg) {
  if (mapType == "onmouseover") {
    spotTimer[spotId] = window.setTimeout('realHideSpot("'+spotId+'","'+mapType+'","'+mapName+'","'+hideImg+'")',500);
  }
  if (hideImg) {
    theElement = document.images["p_"+mapName];
    theElement.src = hideImg;
  }
  return true;
}

function realHideSpot(spotId,mapType,mapName,hideImg) {
  if (spotTimer[spotId]) clearTimeout(spotTimer[spotId]);
  var theBlock = getElt("block_"+spotId);
  setEltDisplay(theBlock,"none");
  return true;
}

function myTrimLeft(str) {
  var begin=0;
  while (begin<str.length &&
    (str.charAt(begin)==' ' ||
     str.charAt(begin)=='\t' ||
     str.charAt(begin)=='\r' ||
     str.charAt(begin)=='\n')) {
       begin++;
     }
  return str.substring(begin, str.length);
}

function myTrimRight(str) {
  var end=str.length;
  while (end>0 &&
    (str.charAt(end-1)==' ' ||
     str.charAt(end-1)=='\t' ||
     str.charAt(end-1)=='\r' ||
     str.charAt(end-1)=='\n')) {
       end--;
     }
  return str.substring(0, end);
}

function myTrim(str) {
  var result=""+str;
  result=myTrimRight(result);
  result=myTrimLeft(result);
  return result;
}

var skipcheckfields = "";

function checkForm(name) {   
  if (skipcheckfields=="true")
  { 
    return true;
  }
  obj = getForm(name);
  invalidFields = new Array();
  invalidNames = new Array();
  
  for (var i=0; i<requiredFields[name].length; i++) {
    if (obj.elements[requiredFields[name][i]].length) {
      optionChecked = false;
      for (var j=0; j<obj.elements[requiredFields[name][i]].length; j++) {
        if (obj.elements[requiredFields[name][i]][j].checked) {
          optionChecked = true;
        }
      }
      if (!optionChecked) {
        invalidFields[invalidFields.length] = obj.elements[requiredFields[name][i]][0];
        invalidNames[invalidNames.length] = requiredLabels[name][i];
      }
    }
   else if (obj.elements[requiredFields[name][i]].type != "hidden" &&
        (obj.elements[requiredFields[name][i]].value == "" ||
        (obj.elements[i].name.indexOf("Tab.Src") != -1) && (
        (""+obj.elements[i].value).indexOf("@")<0 ||
        (""+obj.elements[i].value).indexOf(".")<0))) {    
      invalidFields[invalidFields.length] = obj.elements[requiredFields[name][i]];
      invalidNames[invalidNames.length] = requiredLabels[name][i];
    }
  }
 
  if (invalidFields.length > 0) {
    msg = formMessage;
    for (var i=0; i<invalidFields.length; i++) {
      if (document.all && invalidFields[i].type == "input") {
        invalidFields[i].style.borderColor = "#ff6600";
        invalidFields[i].style.backgroundColor = "#ffeecc";
      }
      msg += (i==0?'':'\n') + '- ' + invalidNames[i];
    }
    alert(msg);
    return false;
  }
 return (invalidFields.length == 0);
}

var obj
var h = 0;
function showForm() {
  obj = document.getElementById('fh');
  if (h < 200) {
    h = h + 5;
    obj.style.height = h;
    f = window.setTimeout('showForm()',50); 
  }
  else window.clearTimeout(f);
}

height = 0;

function getArchive(url) {
  v = document.forms['cat'].elements['catitems'][document.forms['cat'].elements['catitems'].selectedIndex].value;
  if (v == '') return false;
  else document.location.href = url+'&cat='+v
}
