// $Revision: 4071 $

// test
function TTaskCaption(num)
{
  if(num == undefined)
  {
    alert("Exception: TTask(num) - num is undefined");
  }
  this.ID = 'TaskCaption';

  this.Number = num;
  
  this.Generate = Generate;
  this.IsTaskCaption = true;
  
  function Generate()
  {
    var res = "";
    
    res += /*BeginCenter() + */BeginSpan('id', this.ID) + "Задание " + BeginFont("style", "color: green; font-weight: bold") + 
               String(this.Number) + EndFont() + EndSpan()/* + EndCenter()*/;
    
    return res;
  }
  
  this.SetTaskCaption = function(text)
  {
    this.Number = text;
//    document.getElementById(this.ID).innerHTML = "Задание " + BeginFont("style", "color: green; font-weight: bold") + 
//               String(this.Number) + EndFont();
  }
  
  this.SetSpeedTestCaption = function()
  {
//    document.getElementById(this.ID).innerHTML = "Тест скорости";
  }
  
  this.Show = function(bShow)
  {           
    if(bShow == false)
      document.getElementById(this.ID).style.display = "none";
    else
      document.getElementById(this.ID).style.display = "";
  }
  
}

function TUserCaption(userName)
{
  this.UserName = userName;
  
  this.ID = 'UserCaption';
  
  this.Generate = Generate;
  this.Set = SetUserCaption;
  
  function Generate()
  {
    var res = "";
    
    res += "<b>" + BeginSpan('id', this.ID) + this.TrimUserCaption(this.UserName) + EndSpan() + "</b>";
    
    return res;
  }
  
  function SetUserCaption(val)
  {
    this.UserName = val;
    
//    document.getElementById(this.ID).innerHTML = this.TrimUserCaption(this.UserName);
  }
  
  this.GetUserName = function()
  {
    return this.UserName;
  }
  
  this.IsEmpty = function()
  {
    return  (this.UserName == "");
  }
  
  this.TrimUserCaption = function(name)
  {
    if(name.length > 17)
      return name.slice(0, 16) + "&hellip;";
    return name;
  }
}


function TLastError()
{
  this.CiteArr = new Array("Довольно ошибаться!",
                        "Все ошибки сделаны, ошибок больше нет.",
                        "Ещё одно неверное движение — и...",
                        "Не упустите шанс!",
                        "Осталась одна попытка.",
                        "Ещё не всё потеряно!",
                        "Предельная концентрация!");

  this.Get = function()
  {
    var j = Math.floor(Math.random() * this.CiteArr.length + 0.5);
    
    return this.CiteArr[j];    
  }
}

var LastErrorObj = new TLastError();