var imgId, upImg, downImg, overImg, hrPage;

function LoadImages() {
   var noBtns = 6,  i;
   var homepage = "http://" + window.location.host;
   if (document.images) {
      imgId = new Array(noBtns);
      upImg = new Array(noBtns);
      overImg = new Array(noBtns);
      downImg = new Array(noBtns);
      hrPage = new Array(noBtns);
      imgId[0] = "home";
      imgId[1] = "about";
      imgId[2] = "contact";
      imgId[3] = "downloads";
      imgId[4] = "calculators";
      imgId[5] = "etc";
      hrPage[0] = homepage;
      hrPage[1] = "/about.html";
      hrPage[2] = "mailto:admin@thesoftwarebuilder.com";
      hrPage[3] = "/download.html";
      hrPage[4] = "/calcs.html";
      hrPage[5] = "/articles.html";
      for (i = 0; i < noBtns; i++) {
         upImg[i] = new Image(100, 30);
         downImg[i] = new Image(100, 30);
         overImg[i] = new Image(100, 30);
         upImg[i].src = "images/buttons/btn_" + imgId[i] + "_up.gif";
         downImg[i].src = "images/buttons/btn_" + imgId[i] + "_down.gif";
         overImg[i].src = "images/buttons/btn_" + imgId[i] + "_over.gif";
      }
   }
}

function OverButton(btnIndex) {
   btnImg = document.getElementById(imgId[btnIndex]);
   btnImg.src = overImg[btnIndex].src;
}

function DownButton(btnIndex) {
   btnImg = document.getElementById(imgId[btnIndex]);
   btnImg.src = downImg[btnIndex].src;
}

function OutButton(btnIndex) {
   btnImg = document.getElementById(imgId[btnIndex]);
   btnImg.src = upImg[btnIndex].src;
}

function UpButton(btnIndex) {
   btnImg = document.getElementById(imgId[btnIndex]);
   btnImg.src = overImg[btnIndex].src;
   window.location.href = hrPage[btnIndex];
}

function DoSubmit(theFile) {
   var str;
   if (document.getElementById('idAgree').checked == 1) {
      document.fetchform.fileName.value = theFile;
      document.fetchform.submit();
   }
   else {
      str = "You must agree to read and abide by the terms of the included ";
      str += "license agreement before downloading one of these modules."
      alert(str);
   }
}

function DoMapSubmit(theFile) {
   var str;
   if (document.getElementById('idAgree').checked == 1) {
      document.fetchform.fileName.value = theFile;
      document.fetchform.submit();
   }
   else {
      str = "You must read and certify that you understand and agree with this ";
      str += "statement before downloading any of these maps."
      alert(str);
   }
}

function DoBHSubmit(theFile) {
   var str;
   if (document.getElementById('idAgree').checked == 1) {
      document.fetchform.fileName.value = theFile;
      document.fetchform.submit();
   }
   else {
      str = "You must agree to read and abide by the terms of the included ";
      str += "license agreement before downloading Billable Hours."
      alert(str);
   }
}

function ClientSubmit(theFile) {
   document.fetchform.fileName.value = theFile;
   document.fetchform.submit();
}

function CheckLogin() {
   if (document.loginForm.userID.value.length > 0) {
      if (document.loginForm.passwd.value.length > 0) {
         document.loginForm.submit();
      }
      else {
         alert("You must enter a password.");
      }
   }
   else {
      alert("You must enter a user ID.");
   }
}

function PrintMsg(msg, x, y, w, h) {
   var window2=window.open(
      "",
      "",
      "left=" + x.toString() + "," +
      "top=" + y.toString() + "," +
      "width=" + w.toString() + "," +
      "height=" + h.toString());
   var styleLine = "<body style=\"background-color:lightyellow;" +
      "font-family:helvetica,arial,sans-serif;font-size:10pt\">";
   window2.document.open("text/html", "replace");
   window2.document.write(styleLine);
   window2.document.write(msg);
   window2.document.write("</body>");
   window2.document.close();
}

function findHelp(h) {
   oldWin = parent.frames["inframe"];
   if (oldWin.location.replace == null)
      oldWin.location.replace = oldWin.location.assign;
   oldWin.location.replace(oldWin.location.pathname + "#" + h);
}

function printResults(s, w, h) {
   descr ="toolbar=no,location=no,directories=no,status=no,menubar=yes," +
      "scrollbars=yes,resizable=yes,width=" + w + ",height=" + h;
   resultWindow = window.open ("","Results",descr);
   resultWindow.document.open();
   resultWindow.document.write(s);
   resultWindow.document.close();
}
