 
  var cur_wide;
  var old_wide;
  var min_bs = 100;
  var max_bs = 110;
  
  function show_alert(text, button_caption, button_onclick) 
  {
    var bc = button_caption || 'Close';
    var bo = button_onclick || 'hide_alert();';

    $('#reg_form').hide(); 
    $('#login_form').hide(); 
    $('#alert').html('<div onclick=\"hide_alert();\" class=\"close_button\">X</div><center><br>'+text+'<br>'+'<div style=\'position: absolute; left: 10px; text-align: center; width: 300px; bottom: 10px;\'><input type=button value=\''+bc+'\' onclick=\''+bo+'\'></div>'); 
    var w = document.getElementById('all_waiting');
    var r = document.getElementById('alert');
    set_fullscreen(w);               
    set_element_top_middle(r);    
  } 
  
  function hide_alert()
  {
                                                         
   var w = document.getElementById('all_waiting');
   var r = document.getElementById('alert');
   w.style.display = 'none';
   r.style.display = 'none';
 
  }
  
  function start_waiting()
  {
  if (document.getElementById('waiting')) 
   return;
   var e = document.createElement('div');
   var b = document.body;
   b.appendChild(e);
   e.id = 'waiting';
   

   set_fullscreen(e);
   set_element_top_middle(document.getElementById('ds'));
  }
  
  function stop_waiting()
  {
   if (document.getElementById('waiting'))
    document.body.removeChild(document.getElementById('waiting'));
  }
  
  function set_fullscreen(elem)
  {
   var b = document.body;   
      elem.style.position = 'absolute';  
                var left = b.offsetLeft, 
                    top = b.offsetTop,
                    width = b.offsetWidth,
                    height = b.offsetHeight,
                    l = b._loading;
                elem.style.left = left+'px';
                elem.style.top = top+'px';
                elem.style.width = width+'px';
                elem.style.height = height+'px';
                elem.style.display = 'block';     
                
                $('#all_waiting').fadeTo(1,0);                   
  }
  
  function set_element_top_middle(elem)
  {
    height = document.body.offsetHeight;  
    sY = 0;
    if( typeof( scrollY ) == 'number' ) sY = scrollY;
    if( typeof( document.documentElement.scrollTop ) == 'number' ) sY = document.documentElement.scrollTop;     
 
    sX = 0;
    if( typeof( scrollX ) == 'number' ) sX = scrollX;
    if( typeof( document.documentElement.scrollLeft ) == 'number' ) sX = document.documentElement.scrollLeft;  
    
    
      var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    }  
    //alert(sX);
    elem.style.position = 'absolute';
    elem.style.display = 'inline';     
    elem.style.top = (sY+Math.round(myHeight/2)-Math.round(elem.offsetHeight/2))+'px';
    elem.style.left = (sX+Math.round(myWidth/2)-Math.round(elem.offsetWidth/2))+'px';
    
  }
  

  
