function buildTrigger() {
   /* This function is called by an <ajax:htmlContent> chain is triggered in
   * response to a family change. This function shall trigger the click
   * event for the BuildTriggerId element. That is a hidden element in the 
   * capbuild.jsp page whose click shall trigger a refresh of the 
   * <div id="blbuilder"> div, which contains the build parameters for the
   * selected family.
   */
  var trg = document.getElementById("blcapsel");
  if (trg) {
    if (document.createEvent) {
      // not IE
      var ev = document.createEvent("MouseEvents");
      ev.initMouseEvent("click",true,true,window,
        0,0,0,0,0,false,false,false,false,0,null);
      trg.dispatchEvent(ev);
    } else {
      // IE
      trg.fireEvent("onclick");
    }
  }
  return true;
}
function buildPreFunc() {
   /* This function is called by an <ajax:htmlContent> chain is triggered in
   * response to a family change. This function shall trigger the click
   * event for the BuildTriggerId element. That is a hidden element in the 
   * capbuild.jsp page whose click shall trigger a refresh of the 
   * <div id="blbuilder"> div, which contains the build parameters for the
   * selected family.
   */
  var elem = document.getElementById("build");
  elem.style.backgroundColor="#a0a000";
  return true;
}
function setHelpId(evt) {
  /* This setHelpId() function is typically attached to the onmouseover event
   * of an image for which help text is desired. When such an event occurs, 
   * this function shall identify the element that sourced the event, and 
   * write its id into a hidden input element whose id is "helpid". The helpid
   * hidden input shall be subsequently used by the ajax:htmlContent tag to
   * retrieve help text from the server.
   */
  var daEvent = evt || window.event;
  var elem = daEvent.target || daEvent.srcElement;
  var hider = document.getElementById("helpid");
  hider.value = elem.id;
  return false;
}
function setFamilyId(evt) {
  /* This setFamilyId() function is attached to the onmouseover event
   * of a family name in the capbuild family selection table.
   * When such an event occurs, this function shall identify the element that
   * sourced the event (td of the family chosen), and write its id into a
   * hidden input element whose id is "famprefix". The id of each td table
   * entry is the family prefix for that family. The hidden input shall be
   * subsequently used by the ajax:htmlContent tag to trigger the capfamily.jsp
   * from the server.
   */
  var daEvent = evt || window.event;
  var elem = daEvent.target || daEvent.srcElement;
  var hider = document.getElementById("famprefix");
  hider.value = elem.id;
  return false;
}
function showHelp() {
  showDiv("helpDiv");
}
function showBuildErr() {
  showDiv("blfeedback");
}
function showDiv(id) {
  var elem = document.getElementById(id);
  if (elem != null) {
    elem.style.border="2px solid black";
    elem.style.height="auto";
    elem.style.margin="10px 0 0 0";
    elem.style.visibility="visible";
  }
}
function eraseDivs() {
  eraseDiv("noteDiv");
  eraseDiv("helpDiv");
  eraseDiv("availDiv");
  eraseDiv("availAllDiv");
}
function eraseDiv(id) {
  var elem = document.getElementById(id);
  elem.style.border="0 none";
  elem.style.height="0";
  elem.style.margin="0 0";
  elem.style.visibility="hidden";
  return false;
}
function submitBuildForm(optionValue)
{
	if(optionValue != "")
	{
		document.buildForm.submit();
	}
}
function selectTab(seltab) {
  /* used by capedge.jsp onload. Triggers a "click" on
   * the TabPanel tab depending on the context.
   * param  seltab shall be null or "build". If it is 
   * "build" then click the "Specify a Part" tab (the 2nd tab).
   * If it is null, then click the "Lookup a Part tab (the 1st tab)
   */
  var cur = $('tabPanelId');  
  var children = cur.getElementsByTagName('a');  
  var indx = 0;
  if (seltab) {
    if (seltab == "build") indx = 1;
  }
  var tab = children[indx];  
  if (document.createEvent) {
    // not IE
    var ev = document.createEvent("MouseEvents");
    ev.initMouseEvent("click",true,true,window,
      0,0,0,0,0,false,false,false,false,0,null);
    tab.dispatchEvent(ev);
  } else {
    // IE
    tab.fireEvent("onclick");
  }
  return false;
}

// 30 min = 1000 ms * 60 *30 (-1 min)
TM_SESSION_INACTIVE = 1740000;

function sessionMon() {
  $("timeoutDiv").style.display = 'none';
  timeoutTimer = setTimeout(onSessionEnd,TM_SESSION_INACTIVE);
  document.getElementsByTagName("body")[0].onmouseover = function(event) {
    renewSession();
  }
}
function onSessionEnd() {
  $("timeoutDiv").style.visibility = 'visible';
  new Effect.BlindDown($("timeoutDiv"));
  document.getElementsByTagName("body")[0].onmouseover = null;
}
function renewSession() {
  $("timeoutDiv").style.display = 'none';
  clearInterval(timeoutTimer);
  timeoutTimer = setTimeout(onSessionEnd,TM_SESSION_INACTIVE);
}
function showWait(id) {
  var elem = document.getElementById(id);
  if (elem != null) {
    elem.className="imgOn";
  }
}

