// -----------------------------------------------------------------------------------
function BrowserCheck()
{

  var b = navigator.appName;
  if (b == "Netscape") this.b = "NS";
  else if (b == "Microsoft Internet Explorer") this.b = "IE";
  else this.b = b;

  this.v = parseInt(navigator.appVersion);
  this.NS = (this.b == "NS" && this.v>=4);
  this.NS4 = (this.b == "NS" && this.v == 4);
  this.NS5 = (this.b == "NS" && this.v == 5);
  this.NS6 = (this.b == "NS" && this.v == 6);
  this.IE = (this.b == "IE" && this.v>=4);
  this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0);
  this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0);
  if (this.IE5 || this.NS5) this.VER5 = true;
  if (this.IE4 || this.NS4) this.VER4 = true;
  this.OLD = (! this.VER5 && ! this.VER4) ? true : false;
  this.min = (this.NS||this.IE);

}
// -----------------------------------------------------------------------------------
function OpenWin(url,name,width,height,screenx,screeny,p1,p2,p3,p4,p5,p6,p7,urladd)
{

  var wf = "";
  if (urladd == undefined)
  {
    urladd = '';
  }

 	wf = wf + "width=" + width;
 	wf = wf + ",height=" + height;
 	wf = wf + ",screenx=" + screenx;
 	wf = wf + ",screeny=" + screeny;
 	wf = wf + ",resizable=" + (p1 ? "yes" : "no");
 	wf = wf + ",scrollbars=" + (p2 ? "yes" : "no");
 	wf = wf + ",menubar=" + (p3 ? "yes" : "no");
 	wf = wf + ",toolbar=" + (p4 ? "yes" : "no");
 	wf = wf + ",directories=" + (p5 ? "yes" : "no");
 	wf = wf + ",location=" + (p6 ? "yes" : "no");
 	wf = wf + ",status=" + (p7 ? "yes" : "no");		

  return window.open(url + urladd,name,wf);

}
// -----------------------------------------------------------------------------------
function OpenCenterWin(url,name,width,height,p1,p2,p3,p4,p5,p6,p7,urladd)
{

  var mwin;

  var centerx = (screen.width/2)-(width/2);
  var centery = (screen.height/2)-(height/2);

  if (width > screen.width-10) { width = screen.width-10; p2 = 1; centerx = 0; }
  if (height > screen.height-50) { height = screen.height-50; p2 = 1; centery = 0; }

  mwin = OpenWin(url,name,width,height,centerx,centery,p1,p2,p3,p4,p5,p6,p7,urladd);
  mwin.moveTo(centerx,centery);

}
// -----------------------------------------------------------------------------------
function OpenMaxWin(url,name,p1,p2,p3,p4,p5,p6,p7,urladd)
{

  var mwin;

  var width = screen.width-10;
  var height = screen.height-50;

  mwin = OpenWin(url,name,width,height,0,0,p1,p2,p3,p4,p5,p6,p7,urladd);
  mwin.moveTo(0,0);

}
// -----------------------------------------------------------------------------------
function OpenCenterWinResize(url,name,width,height,urladd)
{

  OpenCenterWin(url,name,width,height,1,0,0,0,0,0,0,urladd);

}
// -----------------------------------------------------------------------------------
function OpenCenterWinNoResize(url,name,width,height,urladd)
{

  OpenCenterWin(url,name,width,height,0,0,0,0,0,0,0,urladd);

}
// -----------------------------------------------------------------------------------
function SubmitForm(cmd)
{

  window.document.form1.action = cmd;
  window.document.form1.submit();

}
// -----------------------------------------------------------------------------------
function SubmitFormName(cmd,frm)
{

  var obj = eval('window.document.' + frm);
  obj.action = cmd;
  obj.submit();

}
// -----------------------------------------------------------------------------------
function SubmitOpenerForm(cmd)
{

  window.opener.document.form1.action = cmd;
  window.opener.document.form1.submit();

}
// -----------------------------------------------------------------------------------
function SubmitOpenerFormName(cmd,frm)
{

  var obj = eval('window.opener.document.' + frm);
  if (cmd != '')
  {
    obj.action = cmd;
  }
  obj.submit();

}
// ----------------------------------------------------------------------------
function Var2EnhFind()
{

  var interm;
  
  if (document.form1.HLEDEJ_TEXT_ENH.value == '') { interm = ''} else { interm = ' A ' }
  document.form1.HLEDEJ_TEXT_ENH.value = document.form1.HLEDEJ_TEXT_ENH.value + interm + '"' + document.form1.VARIABLE.options[document.form1.VARIABLE.selectedIndex].value + document.form1.CONDITION.options[document.form1.CONDITION.selectedIndex].value + document.form1.HLEDEJ_TEXT.value + '"';

}
// -----------------------------------------------------------------------------------
function AddZero(s)
{

  s = String(s);
  if (s.length == 1) { s = '0'+s; }

  return s;

}
// -----------------------------------------------------------------------------------
function AssignDate(field)
{

  today = new Date();
  obj = eval('document.form1.'+field);
  obj.value = today.getFullYear()+'-'+AddZero(today.getMonth()+1)+'-'+AddZero(today.getDate())+' '+AddZero(today.getHours())+':'+AddZero(today.getMinutes())+':'+AddZero(today.getSeconds());

}
// ----------------------------------------------------------------------------
function WriteOpenerLayer(objtxt,text)
{

  // objtxt: <span id="objtxt" style="position:absolute"></span>

  if (!document.layers && !document.all) return;

  if (document.layers)
  {
    obj = eval('window.opener.document.layers.'+objtxt);
    obj.document.write(text);
    obj.document.close();
  } else if (document.all)
  { 
    obj = eval('window.opener.'+objtxt);
    obj.innerHTML = text;
  }

}
// -----------------------------------------------------------------------------------
function WriteLayer(objtxt,text)
{

  // objtxt: <span id="objtxt" style="position:absolute"></span>
  if (!document.layers && !document.all) return;

  if (document.layers)
  {
    obj = eval('document.layers.'+objtxt);
    obj.document.write(text);
    obj.document.close();
  } else if (document.all)
  {
    obj = eval(objtxt);
    obj.innerHTML = text;
  }

}
// -----------------------------------------------------------------------------------
function getStyleClass(className)
{

  var re = new RegExp("\\." + className + "$", "gi");
  var useRules = false;
  var useCSSRules = false;
  
  if (document.styleSheets.length > 0)
  {
    if (document.styleSheets[0].rules) { useRules = true; }
    if (document.styleSheets[0].cssRules) { useCSSRules = true; }
  }

  for (var s = 0; s < document.styleSheets.length; s++)
  {
    if (useRules)
    {
      for (var r = 0; r < document.styleSheets[s].rules.length; r++)
        if (document.styleSheets[s].rules[r].selectorText.search(re) != -1)
        {
          return document.styleSheets[s].rules[r].style;
        }
    } else if (useCSSRules)
    {
      for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
        if (document.styleSheets[s].cssRules[r].selectorText.search(re) != -1)
        {
          document.styleSheets[s].cssRules[r].sheetIndex = s;
          document.styleSheets[s].cssRules[r].ruleIndex = s;
          return document.styleSheets[s].cssRules[r].style;
        }
    }
  }

  return null;

}
// -----------------------------------------------------------------------------------
function getStyleClassProperty (className, propertyName)
{

  var styleClass = getStyleClass(className);

  if (styleClass)
    return styleClass[propertyName];
  else 
    return null;

}
// -----------------------------------------------------------------------------------
function CheckAll(form,check_prefix,check_main)
{

  var frm = eval('document.' + form);
  var chkmain = eval('document.' + form + '.' + check_main);

  for (var ii = 0; ii < frm.elements.length; ii++)
  {
    if (frm.elements[ii].name.substr(0, check_prefix.length) == check_prefix)
    {
      frm.elements[ii].checked = chkmain.checked;
    }
  }

}
// -----------------------------------------------------------------------------------
function CheckRangeVal(field, min, max, mintext, maxtext)
{

  var obj_field = eval(field);
  if (obj_field.value < min)
  {
    alert(mintext);
    obj_field.value = min;
  }

  if (obj_field.value > max)
  {
    alert(maxtext);
    obj_field.value = max;
  }

}
// -----------------------------------------------------------------------------------
