var _waiting = false;

function wait_show ( ff )
{
    document.getElementById ( "_img_wait" ).src = "http://biblioteca.saori.com.br/saoribib/css/images/wait.gif";

  if ( ff && !_waiting )
  {
    _waiting = true;
    window.setTimeout( '__wait();' ,1000 );
  }
  else
  {
    if ( document.getElementById ( "_img_wait" ).src != "http://biblioteca.saori.com.br/saoribib/css/images/null.gif" )
      document.getElementById ( "_img_wait" ).src = "http://biblioteca.saori.com.br/saoribib/css/images/null.gif";
    _waiting = false;
  }

}

function __wait()
{
  if ( _waiting && document.getElementById ( "_img_wait" ).src == "http://biblioteca.saori.com.br/saoribib/css/images/null.gif" )
    document.getElementById ( "_img_wait" ).src = "http://biblioteca.saori.com.br/saoribib/css/images/wait.gif";    
}


//--------------------------------------------------------------------------------






var req = new Array();

function url_retrieve_get ( p_url, p_exec, p_num, p_wait ) 
{
  var bn = navigator.appName;
  var bv = navigator.appVersion;

  var p_num  = typeof ( p_num  ) != 'undefined' ? p_num  : 0;
  var p_wait = typeof ( p_wait ) != 'undefined' ? p_wait : true;    

  if ( bn == "Netscape" ) 
  { 
    req[p_num] = new XMLHttpRequest();
    req[p_num].overrideMimeType ( 'text/xml' );
    req[p_num].onreadystatechange = p_exec; 
    try 
    {
      req[p_num].open ( "GET", p_url, true );
      if ( p_wait ) wait_show ( true );
    } 
    catch (e) 
    {
      alert(e);
    }
    req[p_num].send(null);
  } 
  else 
  {
    if ( bn == "Microsoft Internet Explorer" ) 
    { 
      req[p_num] = new ActiveXObject ( "Microsoft.XMLHTTP" );
      if ( req[p_num] ) 
      {
        req[p_num].onreadystatechange = p_exec; //processStateChange;
        req[p_num].open ( "GET", p_url, true );
        req[p_num].send();
        if ( p_wait ) wait_show ( true );
      }
    }
  }
}


function url_retrieve_post ( p_url, p_parameters, p_exec, p_num, p_wait ) 
{
  var bn = navigator.appName;
  var bv = navigator.appVersion;

  var p_num  = typeof ( p_num  ) != 'undefined' ? p_num  : 0;    
  var p_wait = typeof ( p_wait ) != 'undefined' ? p_wait : true;    

  if ( bn == "Netscape" ) 
  { 
    req[p_num] = new XMLHttpRequest();
    if ( req[p_num] ) 
    {
      req[p_num].onreadystatechange = p_exec; //processStateChange;
      req[p_num].open ( "POST", p_url, true );
      req[p_num].setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" );
      req[p_num].setRequestHeader ( "Content-length", p_parameters.length );
      req[p_num].setRequestHeader ( "Connection", "close" );
      req[p_num].send ( p_parameters );
      if ( p_wait ) wait_show ( true );
    }
  } 
  else 
  {
    if ( bn == "Microsoft Internet Explorer" ) 
    { 
      req[p_num] = new ActiveXObject ( "Microsoft.XMLHTTP" );
      if ( req[p_num] ) 
      {
        req[p_num].onreadystatechange = p_exec; //processStateChange;
        req[p_num].open ( "POST", p_url, true );
        req[p_num].setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" );
        req[p_num].setRequestHeader ( "Content-length", p_parameters.length );
        req[p_num].setRequestHeader ( "Connection", "close" );
        req[p_num].send ( p_parameters );
        if ( p_wait ) wait_show ( true );
      }
    }
  }
}


