// -----------------------------------------------------------------------------

var aHTTP = new Array();

function HTTP( url, htmlElement, fnHTTPUpdate )
{
 var http = null;
 if( window.XMLHttpRequest )
		http = new XMLHttpRequest();
/*
 else if( window.ActiveXObject )
		if( !( http = new ActiveXObject( "Msxml2.XMLHTTP" ) ) )
			http = new ActiveXObject( "Microsoft.XMLHTTP" );
*/
 if( !http )
 	return false;
 aHTTP[ http.httpID = aHTTP.length ] = http;
 http.htmlElement = null;
 if( HTTP.arguments.length > 1 && $(htmlElement) )
  {
   http.htmlElement = $(htmlElement);
   http.htmlElement.fnHTTPUpdate = fnHTTPUpdate;
  }
 http.onreadystatechange = function(){ if( this.readyState == 4 )
                                          {
                                           if( this.status==200 )
                                              {
                                               // html
                                               if( (/text\/html/).test( this.getResponseHeader('Content-Type') ) && this.htmlElement )
                                                  {
                                                   this.htmlElement.innerHTML = this.responseText;
                                                   if( this.htmlElement.fnHTTPUpdate )
                                                      this.htmlElement.fnHTTPUpdate();
                                                  }
                                               // javascript
                                               else if( (/(text|application)\/javascript/).test( this.getResponseHeader('Content-Type') ) )
                                                  {
                                                   js=document.createElement("script");
		                                               js.setAttribute( 'type', 'text/javascript' );
		                                               js.text = this.responseText;
		                                               document.body.appendChild(js);                                                  
                                                  }
                                              }
                                           aHTTP[this.httpID]=null;
                                          }
                                     }
 http.open("GET",url,true);
 http.setRequestHeader( 'Accept', HTTP.arguments.length == 1 ? 'application/javascript' : 'text/html' );
 http.send(null);
 http = null;
 return true;
}

// -----------------------------------------------------------------------------

