var textStore = new Array();
var abbrevIndex = new Array();


function setLoginFocus()
{
	var login = getElement('login');
  if (login.value == '')
  {
    login.focus();
  }
  else
  {
  	getElement('password').focus();
  }
}

function popup(page, name, width, height)
{
  popupWindow=window.open(page,name,"menubar=no,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height);
  popupWindow.focus();
	popupWindow.opener = window;
}

function showHelp(bookmark)
{
  var winName = window.open('/help.html#' + bookmark, 'ISDNhelp', 'width=275,height=360,scrollbars=yes,resizable=yes');
  winName.focus();
}

function checkAll(category)
{
  var i = 1;
  while (true)
  {
    var checkbox = eval('document.theForm.check_' + category + '_' + i);
    if (checkbox == undefined)
    {
    	if (i == 255) break;
      i = 255;
      continue;
    }
    checkbox.checked = true;
    if (i == 255) break;
    i++;
  }
}

function showHide(theIndex, collapseTo)
{
  var theImage, theDiv;
  if (document.all)
  {
    eval('theImage = document.all["Icon' + theIndex + '"]');
    eval('theDiv = document.all["Div' + theIndex + '"]');
  }
  else if (document.getElementById)
  {
    theImage = document.getElementById('Icon' + theIndex);
    theDiv = document.getElementById('Div' + theIndex);
  }
  else
  {
    eval('theImage = document["Icon' + theIndex + '"]');
    eval('theDiv = document["Div' + theIndex + '"]');
  }
    
  var imageURL = theImage.src;
  if (imageURL.substr(imageURL.length - 5, 1) == 'd')
  {
    theImage.src = imageURL.substr(0, imageURL.length - 5) + "r.gif";
    if (typeof(textStore[theIndex]) == "undefined")
    {
      textStore[theIndex] = theDiv.innerHTML;
      abbrevIndex[theIndex] = collapseTo;
      if (collapseTo > 0)
      {
        var eol = textStore[theIndex].toLowerCase().indexOf("<br />");
        if (eol > 0 && eol < collapseTo)
        {
          abbrevIndex[theIndex] = eol;
        }
      }
    }
    theDiv.innerHTML = abbrevIndex[theIndex] > 0
      ? (textStore[theIndex].substr(0, abbrevIndex[theIndex]) + " ...") : "<img height='1' />";
  }
  else
  {
    theImage.src = imageURL.substr(0, imageURL.length - 5) + "d.gif";
    theDiv.innerHTML = textStore[theIndex];
  }
}
