var gl_ob = 44;
var sm_le = Array('Неизвестная ошибка!', 'Неверный логин или пароль!', 'Превышено максимальное число попыток входа! Попробуйте зайти позже.');

SM_LIR = function(json)
{
 var jx = jsonParse(json);
 if (jx.done)
 {
  document.getElementById('usp_spl').href = './users/'+jx.login;
  document.getElementById('usp_login').innerHTML = jx.login;
  document.getElementById('usp_nmc').innerHTML = jx.nmc;
  document.getElementById('usp_cpl').innerHTML = jx.cpl;
  document.getElementById('usp_ldr').style.display = 'none';
  document.getElementById('usp_ifb').style.display = '';
  if (typeof(SM_LIRX) == 'function') SM_LIRX();
 }
 else
 {
  document.getElementById('usp_ldr').style.display = 'none';
  document.getElementById('usp_frm').style.display = '';
  alert(sm_le[jx.err]);
 }
}

function SM_Login()
{
 if (document.getElementById('usp_frm').username.value == '' || document.getElementById('usp_frm').password.value == '')
  alert('Заполните поля!');
 else
 {
  document.getElementById('usp_frm').style.display = 'none';
  document.getElementById('usp_ldr').style.display = '';
  sendRequest('./json/system', SM_LIR, 'POST', encodeForm('usp_frm'));
 }
 return false;
}

SM_LOR = function(json)
{
 var jx = jsonParse(json);
 if (jx.done)
 {
  document.getElementById('usp_ldr').style.display = 'none';
  document.getElementById('usp_frm').style.display = '';
  if (typeof(SM_LORX) == 'function') SM_LORX();
 }
 else alert(sm_le[0]);
}

function SM_Logout()
{
 document.getElementById('usp_ifb').style.display = 'none';
 document.getElementById('usp_ldr').style.display = '';
 sendRequest('./json/system?logout', SM_LOR);
 return false;
}
