var WindowSizeX, WindowSizeY, ScreenX, ScreenY;
var w3c, ns4, ie4, ie5, ns6, got;
var gotDom = -1;
got = false;

function GetInfo()
{
  if (got) return;

  got = true;

  w3c=(document.getElementById)?true:false;
  ns4=(document.layers)?true:false;
  ie4=(document.all && !this.w3c)?true:false;
  ie5=(document.all && this.w3c)?true:false;
  ns6=(this.w3c && navigator.appName.indexOf("Netscape")>=0 )?true:false;

  WindowSizeX = (ie5 || ie4) ? document.body.clientHeight : window.innerHeight;
  WindowSizeY = (ie5 || ie4) ? document.body.clientWidth : window.innerWidth;
  ScreenX = screen.Width;
  ScreenY = screen.Height;
}

function GetSelectValue(id)
{
  var SelectObj = GetElement(id);
  return SelectObj.options[SelectObj.selectedIndex].value;
}

function SetElementText(id, text)
{
  GetInfo();
  var Obj = GetElement(id);
  if (ns4)
  {
    Obj.document.open();
    Obj.document.write(text);
    Obj.document.close();
  }
  else
  {
    Obj.innerHTML = text;
  }
}

function GetElement(id)
{
  GetInfo();
  if (w3c) return document.getElementById(id);
  if (ns4) return document.layers[id];
  if (ie4) return document.all(id);
}

function ShowItem(Item)
{
  var ItemObject = GetElement(Item);
  if (ns4) ItemObject.visibility="show";
  else
  {
    ItemObject.style.visibility="visible";
    ItemObject.style.display="block";
  }
}

function HideItem(Item)
{
  ItemObject = GetElement(Item);
  if (ns4) ItemObject.visibility="hide";
  else
  {
    ItemObject.style.display="none";
    ItemObject.style.visibility="hidden";
  }
}

function ToggleItem(Item)
{
  ItemObject = GetElement(Item);
  var hidden;
  if (ns4) hidden = (ItemObject.visibility == 'hide');
  else
  {
//    hidden = (ItemObject.style.display == 'none' || ItemObject.style.visibility == "hidden");
    hidden = (ItemObject.style.visibility == "hidden");
  }
  if (hidden) ShowItem(Item); else HideItem(Item);
}

function PopUp(URL, w, h, l, t, id)
{
  if (w == 0) w = 400;
  if (h == 0) h = 300;
  if (t == 0) t = 20;
  if (l == 0) l = 50;
  day = new Date();
  if (id == '') id = day.getTime();
  x = "page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=no," +
      "location=no,statusbar=no,menubar=no,resizable=no,width=" + w + ",height=" + h + "," +
      "left = " + l + ",top = " + t + "');";
  eval(x);
}

function PopUpScroll(URL, w, h, l, t, id)
{
  if (w == 0) w = 400;
  if (h == 0) h = 300;
  if (t == 0) t = 20;
  if (l == 0) l = 50;
  day = new Date();
  if (id == '') id = day.getTime();
  x = "page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes," +
      "location=no,statusbar=no,menubar=no,resizable=no,width=" + w + ",height=" + h + "," +
      "left = " + l + ",top = " + t + "');";
  eval(x);
}

function ChangeOpenerURL(URL)
{
  window.opener.document.location=URL;
}

function HintWindow(Caption, Text)
{
  myWin = open("", "HintWindow", "toolbar=no,scrollbars=yes,resizable=no,location=no,statusbar=no,menubar=no,height=200,width=400,left=50,top=100");

  // open document for further output
  myWin.document.open();

  // create document
  myWin.document.writeln("<html><head><title>" + Caption + "</title>");
  myWin.document.writeln('</head><body topmargin="5px" text="Black" bgcolor="Cornsilk">');
  myWin.document.writeln(Text);
  myWin.document.writeln("</body></html>");

  // close the document - (not the window!)
  myWin.document.close();
}

function PadString(str, len, padding)
{
  if (padding == null) padding = ' ';
  while (str.length < len)
  {
    str = padding + str;
  }
  return str;
}