/* ************************************************************************** */
/*     parameters to configure the menu system for eLog3 look and feel        */
/* ************************************************************************** */

var colSUBMShadowOuter = '#666666';    // inner shadow of submenu box
var colSUBMShadowInner = '#333333';    // outer shadow of submenu box
var colMenDispTime     = 20;

/* ************************************************************************** */
// the following section are the special functions from twinhelix
/* ************************************************************************** */

var hMM  = new ItemStyle(24, 10, '', 0, 2, '', '', 'highText',
                         'highText', 'itemHBar', 'itemHBarOver',
                          null, null, 'hand', 'default');

var subM = new ItemStyle(24, 0, '&gt;', -15, 2, '', '', 'lowText',
                         'highText', 'itemBorder', 'itemBorderOver',
                          null, null, 'hand', 'default');

var subM2 = new ItemStyle(24, 0, '&gt;', -15, 2, '', '', 'lowText',
                          'highText', 'itemBorder', 'itemBorderOver',
                           null, null, 'hand', 'default');

/* ************************************************************************** */
// HTS Error Window parameters
/* ************************************************************************** */

var win = null;
var timer = null;


/* ************************************************************************** */
/*     eLog 3 JS functions and procedures                                     */
/* ************************************************************************** */

function callSubmit()
{
  if (top.DataArea.document.forms)
  {
    top.DataArea.document.forms[0].submit();
  }
}


function callLinesSubmit()
{
  if (top.DataArea.Lines.document.forms)
  {
    top.DataArea.Lines.document.forms[0].submit();
  }
}


function callReset()
{
  if (top.DataArea.document.forms)
  {
    top.DataArea.document.forms[0].reset();
  }
}


function deactivateAreaLinks()
{
  deactivateLinks(top.ControlArea.document);
  deactivateLinks(top.DataArea.document);
  deactivateLinks(top.InfoArea.document);
}


function deactivateLinks(docObj)
{
  var iLength = docObj.links.length;
  for (i=0; i < iLength; i++)
  {
    docObj.links[i].href = '#';
/*    document.images[i].style.visibility = 'hidden';  */
/*    document.images[i].style.disabled = true;        */
  }
}


function MM_swapImage()
{
  var i, j=0, x, a = MM_swapImage.arguments;
  document.MM_sr=new Array;
  for (i=0; i<(a.length-2) ;i+=3)
  {
    if ((x=MM_findObj(a[i])) != null)
    {
      document.MM_sr[j++]=x;
      if (!x.oSrc)
        x.oSrc=x.src;
      x.src=a[i+2];
    }
  }
}

function MM_findObj(n, d)
{
  var p,i,x;
  if (!d)
    d=document;
  if ((p=n.indexOf("?"))>0 && parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document;
/*    n=n.substring(0,p);  // in eLog3 the frame is part of the image name */
  }
  if (!(x=d[n])&&d.all)
    x=d.all[n];
  for (i=0; !x&&i<d.forms.length; i++)
    x=d.forms[i][n];
  for (i=0; !x&&d.layers&&i<d.layers.length; i++)
    x=MM_findObj(n,d.layers[i].document);
  return x;
}


function MM_swapImgRestore()
{
  var i, x, a=document.MM_sr;
  for ( i=0; a&&i<a.length&&(x=a[i])&&x.oSrc; i++)
    x.src=x.oSrc;
}


function openWindow(sURL, sName, sParams)
{
  var wnd = open( sURL, sName, sParams);
  if (wnd)
  {
    if (wnd.opener == null)
      wnd.opener = self;
  }
  return wnd;
}

function CloseWin()
{
  if ((win!=null) && (win.open))
  {
    win.close();
    win = null;
/*    if ((sFocus!=null) && (!sFocus.equals(""))) */
/*    sbuf.append("      " + sFocus + ";                                   \r\n");  */
  }
}

function displayMessage(sBase, sTitle, sText, iWidth, iHeight)
{
  if (win != null)
    win.close();

  var posLeft=(screen.width-iWidth)/2 - 12;
  var posTop=(screen.height-iHeight)/2;

  winparams = "height="+iHeight+",width="+iWidth+",screenX="+posLeft;
  winparams+= ",screenY="+posTop+",top="+posTop+",left="+posLeft+",dependant,resizable";

  win = openWindow("", "mess_wnd", winparams);

  var doc = win.document;
  doc.open("text/html");
  doc.writeln('<html>');
  doc.writeln('<head>');
  doc.writeln('<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">');
  doc.writeln('<link rel="stylesheet" href="' + sBase + '/templates/elog3_green_std.css"></link>');
/*  doc.writeln('<bgsound src="http://localhost/htselog3/sounds/elog3_error.wav"></bgsound>'); */
  doc.writeln('<title>' + sTitle + '</title>');
  doc.writeln('</head>');
  doc.writeln('<body class="b_errwnd">');
  doc.writeln('<br>');
  doc.writeln('<center>' + sText + '</center>');
  doc.writeln('</body>');
  doc.writeln('</html>');
  doc.close();
  if (win.focus != null)
    win.focus();

  timer=setTimeout("CloseWin()", 3000);
}


function refresh()
{
  lastHRef=top.DataArea.location.href;
  iPos = lastHRef.indexOf("#top");
  if (iPos!=(-1))
    lastHRef= lastHRef.substring(0, iPos);
  iPos = lastHRef.indexOf("#Data_End");
  if (iPos!=(-1))
    lastHRef= lastHRef.substring(0, iPos);
  iPos = lastHRef.indexOf("&E=");
  if (iPos!=(-1))
  {
    length = lastHRef.length();
    endHRef = lastHRef.substring(iPos + 7, length);
    lastHRef = lastHRef.substring(0, iPos);
    lastHRef = lastHRef + endHRef;
  };
  iPos = lastHRef.indexOf("&M=");
  if (iPos!=(-1))
  {
    length = lastHRef.length();
    endHRef = lastHRef.substring(iPos + 7, length);
    lastHRef = lastHRef.substring(0, iPos);
    lastHRef = lastHRef + endHRef;
  };
  top.DataArea.location.replace(lastHRef);
}


function callURL(sURL)
{
  deactivateAreaLinks();
  top.DataArea.location.href=sURL;
}

function replaceInfoURL(sURL)
{
  top.InfoArea.location.replace(sURL);
}
