/////////////////////////////////////////////////////////
// Logon Form functions

function OnLoad()
{
  if (ShowSignInPage())  // if this isn't the main window
    return;

  if (self.OnCustomLogonLoaded && OnCustomLogonLoaded(window))
    return;

  document.logonform.r.value = GetURLParam('r');
  if (document.logonform.r.value.length == 0)
    document.logonform.r.value = GetURLParam('R');

  if (document.logonform.r.value.length == 0)
    document.logonform.r.value = 'default';

  SetFocus();
  ClearLoading();
}

function OnUnload()
{
  EnableForm(document.logonform);
}

function ClearLoading()
{
  var loading = getelement('loadingpage');
  if (loading != null)
  {
    clearTimeout(progressTimeID);
    loading.innerHTML = "";
  }
}

function WriteTranslationList()
{
  var i, iCount;

  if ((typeof (aTranlationList) == "undefined") ||
      ((iCount = aTranlationList.length) == 0))
    return;

  document.write('<span class="LogonLanguage">' + LOGON_SELECT_LANGUAGE + '<span>');

  iCount = aTranlationList.length;
  for (i = 0; i < iCount; i++)
  {
    if (aTranlationList[i].length != 3)
      continue;

    document.write('<a href="rtisa.dll?r=' + aTranlationList[i][1] + '"><img align="absmiddle" border=0 title="' + aTranlationList[i][0] + '" src="' + HTMLPath + 'images\\' + aTranlationList[i][2] + '"></a>&nbsp;&nbsp;');
  }
}

function SetFocus()
{
  if (document.logonform.username.value.length == 0)
    document.logonform.username.focus();
  else
    document.logonform.framesize.focus();
}

function postProcess(form)
{
  if (self.OnCustomLogon && OnCustomLogon(window, form))
    return;

  DisableForm(form);
}

function DisableForm(theform)
{
  var i, iLength;
  var tempobj;

  if (document.all || document.getElementById)
  {
    iLength = theform.length;
    for (i = 0; i < iLength; i++)
    {
      tempobj = theform.elements[i];
      if (tempobj.type.toLowerCase() == "submit")
        tempobj.disabled = true;
    }

    return true;
  }
}

function EnableForm(theform)
{
  var i, iLength;
  var tempobj;

  if (document.all || document.getElementById)
  {
    iLength = theform.length;
    for (i = 0; i < iLength; i++)
    {
      tempobj = theform.elements[i];
      if (tempobj.type.toLowerCase() == "submit")
        tempobj.disabled = false;
    }

    return true;
  }
}
