function cls_loader(s_name)
{
  if(s_name)
  {
    this.holder = $(s_name);
    this.exist = true;
  }
  else
  {
    this.exist = false;
  }
}

cls_loader.prototype.clean = function()
{
  if(!this.exist){return;}
  if(this.holder.hasChildNodes())
  {
    for(i=0;i<this.holder.childNodes.length;i++)
    {
      this.holder.removeChild(this.holder.childNodes[i]);
    }
  }
}

cls_loader.prototype.createNew = function(s_type, s_message)
{
  if(!this.exist){return;}
  this.clean();

  if(!s_message){s_message = '';}
  
  this.holder.style.display = 'block';

  newContent = document.createElement('div');
    switch(s_type)
    {
      case 'loading':
        newContent.className = 'fntSml fntClrGray';
        newContent.innerHTML = '<img src="/global/images/common/ico/ajax_loader.gif" alt="loading" style="height: 16px; width: 16px; vertical-align: -3px; margin-right: 10px;" />'+ s_message;
      break;

      case 'failure':
        newContent.className = 'fntSml fntClrRed';
        newContent.innerHTML = '<img src="/global/images/common/ico/error_16x16.png" alt="error" style="height: 16px; width: 16px; vertical-align: -3px; margin-right: 10px;" />'+ s_message;
      break;

      case 'success':
        newContent.className = 'fntSml fntClrGreen';
        newContent.innerHTML = '<img src="/global/images/common/ico/valid_16x16.png" alt="vaild" style="height: 16px; width: 16px; vertical-align: -3px; margin-right: 10px;" />'+ s_message;
      break;
    }
  this.holder.appendChild(newContent);
}

cls_loader.prototype.loading = function(s_message)
{
  if(!this.exist){return;}
  this.createNew('loading', s_message);
  this.status = 'loading';
}

cls_loader.prototype.failed = function(s_message)
{
  if(!this.exist){return;}
  this.createNew('failure', s_message);
  this.status = 'failed';
}

cls_loader.prototype.success = function(s_message)
{
  if(!this.exist){return;}
  this.createNew('success', s_message)
  this.status = 'success';
}

