var V2WEB_HTTP_REQUEST_METHOD_GET  = "GET";
var V2WEB_HTTP_REQUEST_METHOD_PUT  = "PUT";
var V2WEB_HTTP_REQUEST_METHOD_POST = "POST";

var V2Web_HttpRequest_List = null;

////////////////////////////////////////
function V2Web_HttpRequest_Node ( method, url, onload, param, userName, password )
{
  if (window.XMLHttpRequest) this.xmlHttp=new XMLHttpRequest(); // Mozilla, etc.
  else if (window.ActiveXObject) this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE
  if (this.xmlHttp!=null) {
    this.xmlHttp.onreadystatechange=V2Web_HttpRequest_StateChange;
    this.xmlHttp.open(method,url,true,userName,password);
  }
  else alert("Your browser does not support AJAX.");
  this.onloadFunc = onload;
  this.onloadParam = param;
}

V2Web_HttpRequest_Node.prototype.xmlHttp     = null;
V2Web_HttpRequest_Node.prototype.onloadParam = null;
V2Web_HttpRequest_Node.prototype.onloadFunc  = null;
V2Web_HttpRequest_Node.prototype.callOnload  = function() 
{
  if (this.onloadFunc != null) this.onloadFunc ( this.xmlHttp, this.onloadParam );
}
V2Web_HttpRequest_Node.prototype.send = function(content) 
{ 
  if (this.xmlHttp != null) this.xmlHttp.send(content); 
}

////////////////////////////////////////
function V2Web_HttpRequest_StateChange()
{
  if (V2Web_HttpRequest_List == null) return;
  for (var i = 0; i < V2Web_HttpRequest_List.length; ++i)
  {
    if (V2Web_HttpRequest_List[i].xmlHttp.readyState==4) { // is Loaded?
      V2Web_HttpRequest_List[i].callOnload();
	  V2Web_HttpRequest_List.splice(i,1);
	}
  }
}

////////////////////////////////////////
function V2Web_HttpRequest ( method, url, onload, param, userName, password, content )
{
  if (V2Web_HttpRequest_List == null) V2Web_HttpRequest_List = new Array();
  var node = new V2Web_HttpRequest_Node(method, url, onload, param, userName, password);
  V2Web_HttpRequest_List.push(node);
  node.send(content);
}

