function ajaxLoader(id, config)
{
  this.is_ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
  this.is_ie5 = ( this.is_ie && /msie 5\.0/i.test(navigator.userAgent) );
  this.is_ie6 = ( this.is_ie && /msie 6\.0/i.test(navigator.userAgent) );
  this.is_opera = ( /opera/i.test(navigator.userAgent) );
  this.is_chrome = ( /chrome/i.test(navigator.userAgent) );
  this.is_safari = ( /safari/i.test(navigator.userAgent) );
  this.obj = null;

  if (typeof(config)=='undefined') config={};
  if (typeof(config.alpha)=='undefined') this.alpha=0.8; else this.alpha=config.alpha;
  if (typeof(config.bg)=='undefined') this.bg='#ffffff'; else this.bg=config.bg;

  if (typeof(config.left)=='undefined') this.left=1; else this.left=config.left;
  if (typeof(config.top)=='undefined') this.top=1; else this.top=config.top;

  if (typeof(config.aVer)=='undefined') this.aVer='m'; else this.aVer=config.aVer;
  if (typeof(config.aHor)=='undefined') this.aHor='c'; else this.aHor=config.aHor;

  if (typeof(config.imgLoader)=='undefined') this.imgLoader='img/loader.gif'; else this.imgLoader=config.imgLoader;
  if (typeof(config.imgEmpty)=='undefined') this.imgEmpty='img/empty.gif'; else this.imgEmpty=config.imgEmpty;
  
  if (typeof(id) !='undefined')  this.obj = document.getElementById(id);

  this.exist=false;
  var self = this;

  this.createTopObj = function()
   {
     var win = window;

     if(typeof(win.pageXOffset) != 'undefined')
       var xobj = win.document.getElementsByTagName('body').item(0);
     else
       var xobj = (win.document.compatMode && win.document.compatMode == "CSS1Compat")?win.document.documentElement.getElementsByTagName('body').item(0):win.document.body || null;

     self.obj=document.createElement('div');
     self.obj.style.cssText='position: absolute; left: '+self.left+'px; top: '+self.top+'px; background-color: '+self.bg+'; opacity:'+parseFloat(self.alpha)+'; filter: alpha(opacity='+(parseFloat(self.alpha)*100)+'); -moz-opacity:'+parseFloat(self.alpha)+';';
     self.obj.style.zIndex=980;
     xobj.appendChild(self.obj);
   }

  this.show = function(w, h, t, l)
   {
    if (self.aVer=='b') a_top=h-parseInt(self.loader.height);
    else if (self.aVer=='m') a_top=(parseInt((h/2)-(parseInt(self.loader.height)/2)));
    else if (self.aVer=='t') a_top=0;

    if (self.aHor=='r') a_left=w-parseInt(self.loader.width);
    else if (self.aHor=='l') a_left=0;
    else if (self.aHor=='c') a_left=(parseInt((w/2)-(parseInt(self.loader.width)/2)));
    
    self.loader.style.left=a_left+'px';
    self.loader.style.top=a_top+'px';
    
    self.obj.style.width = w+'px';
    self.obj.style.height = h+'px';
    self.obj.style.top = t+'px';
    self.obj.style.left = l+'px';
    self.empty.style.width = w+'px';
    self.empty.style.height = h+'px';
    self.obj.style.display = 'block';

    self.exist=true;
   }

  this.showOnElement = function(el_id)
   {
     if (typeof(el_id)=='object') var s_div=el_id;
     else var s_div = document.getElementById(el_id);

     var a_top = 0;
     var a_left = 0;

     var ee=s_div;
     
     while (ee.offsetParent)
     {
       a_left += ee.offsetLeft ;
       a_top  += ee.offsetTop  ;

       if (!(self.is_opera))
       {
         var add_left=parseInt(ee.clientLeft);
         var add_top=parseInt(ee.clientTop);
         if (!(isNaN(add_left))&&add_left>1) a_left += add_left;
         if (!(isNaN(add_top))&&add_top>1)   a_top += add_top;
       }
       ee=ee.offsetParent;
     }

     self.show(parseInt(s_div.offsetWidth), parseInt(s_div.offsetHeight), a_top, a_left);
   }
  this.hide = function()
   {
     if (self.exist)
     {
       self.obj.innerHTML='';
//      purge(self.obj);
       self.obj.parentNode.removeChild(self.obj);
//      self.obj.style.display = 'none';
     }
     self.exist=false;
   }

  if (typeof(id) =='undefined')
  {
    self.createTopObj();
  }

  this.obj.style.display = 'none';
//   this.obj.style.border = '1px solid black';
  this.empty = document.createElement('img');
  this.empty.src = this.imgEmpty;
  this.obj.appendChild(this.empty);

  this.loader = document.createElement('img');
  this.loader.src = this.imgLoader;
  this.loader.style.position = 'absolute';
  this.obj.appendChild(this.loader);
  this.progresses = new Array();

}