var CurrentForm = 0;

function PopupDocument(DocumentLocation, Title, x, y)
{
//  alert("PopupDocument : " + DocumentLocation);
  if ((document.all) || (DocumentLocation.lastIndexOf(".htm") != -1))
  {
    if ((x == 0) && (y == 0))
      WinString = 'resize="yes", title="' + Title + '"';
    else
      WinString = 'width=' + x + ',height=' + y + ',title="' + Title + '",resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no';
    NewWindow = window.open(DocumentLocation, 'NewWin', WinString);
  }
  else
  {
    NewWindow = window.open("docs/launch.htm", "NewWin", "width=10,height=10,resizeable=no,scrollbars=no,status=no,toolbar=no,menubar=no");
  }
}

function IsNumeric(Value)
{
  var loop;

  if (Value == "")
    return(false);
  for (loop=0; loop<Value.length; loop++)
  {
    if ((Value.charAt(loop) < "0") || (Value.charAt(loop) > "9"))
      return(false);
  }
  return(true);
}

function IsTelephoneNumber(Value)
{
  var loop;

  if (Value == "")
    return(false);
  for (loop=0; loop<Value.length; loop++)
  {
    if (((Value.charAt(loop) < "0") || (Value.charAt(loop) > "9")) && (Value.charAt(loop) != " ") && (Value.charAt(loop) != "-"))
      return(false);
  }
  return(true);
}

function IsEmail(email)
{
  invalidchars = " /:,;";
  if (email == "")
    return(false);
  for (i=0; i<invalidchars.length; i++)
  {
    badchar = invalidchars.charAt(i);
    if (email.indexOf(badchar, 0) > -1)
      return(false);
  }
  atPos = email.indexOf("@", 1);
  if (atPos == -1)
    return(false);
  periodpos = email.indexOf(".", atPos);
  if (periodpos == -1)
    return(false);
  if (periodpos+3 > email.length)
    return(false);
  return(true);
}


function Highlight(string, text)
{
    var strLength = string.length;
    txtLength = text.length;

    if ((strLength == 0) || (txtLength == 0))
      return string;
    
    LowerString = string.toLowerCase();
    var i = LowerString.indexOf(text);
    
    if ((! i) && (text != LowerString.substring(0,txtLength)))
      return string;

    if (i == -1)
      return string;

    var newstr = string.substring(0, i) + "<u>" + string.substring(i, i + txtLength) + "</u>";

    if ((i + txtLength) < strLength)
        newstr += Highlight(string.substring(i + txtLength, strLength), text);

    return newstr;
}

function UpdateDiv(DivID, innerHTML)
{
  if (document.all)
	  document.all[DivID].innerHTML = innerHTML;
  else if (document.getElementById)
	  document.getElementById(DivID).innerHTML = innerHTML;
  else if (document.layers)
  {
		with(document.layers[DivID].document)
    {
			open();
			write(txt);
			close();
		}
	}
}


function GetObject(ObjectName)
{
  if (document.all)
  {
    if (document.all[ObjectName])
      return(document.all[ObjectName]);
    else
      return(Null);
  }
  else if (document.getElementById)
  {
  	if (document.getElementById(ObjectName))
  	  return(document.getElementById(ObjectName));
    else
      return(Null);
  }
}

function SetFocus(ObjectName)
{
  if (document.all)
  {
    if (document.all[ObjectName])
      document.all[ObjectName].focus();
  }
  else if (document.getElementById)
  {
  	if (document.getElementById(ObjectName))
  	  document.getElementById(ObjectName).focus();
  }
  return(true);
}
