/*@cc_on @*/

ajaxRequest = function(url,callbackf,method,body,headers,sync)
{
    this.url      = url;
    this.wState   = callbackf || function() { };
    this.method   = method || "GET";
    this.body     = body || null;
    this.headers  = headers || false;
    this.sync     = sync || true;
    this.abortReq = false;
    
    this.req = (window.XMLHttpRequest) 
           ?
           new XMLHttpRequest()
           :
           ((window.ActiveXObject)
           ?
           new ActiveXObject("Microsoft.XMLHTTP")
           :
           false
           );
    
    this.doRequest = function()
    {
        this.req.open(this.method,this.url,this.sync);
        if (this.headers)
        {
            for (var i=0; i<this.headers.length; i+=2)
            {
                this.req.setRequestHeader(
                    this.headers[i],this.headers[i+1]
                );
            }
        }
        this.req.onreadystatechange = this.wState;
        (!this.abortReq) ? this.req.send(this.body) : this.req.abort();
    };
};



comRequest = function()
{
	
	

	this.sendAndLoad = function(url,dataStr,callBackFncOK,callBackFncError)
	{
		this.url=url;
		this.callBackOK=callBackFncOK || function() { };
		this.callBackError=callBackFncError || function() { };
		
		
		this.ajaReq=new ajaxRequest(this.url,this.onLoad,"POST","");
		this.ajaReq.doRequest();
		
	};
	
	this.onLoad=function()
	{
		
		// Get the scope from the comRequest
		var creq=parent.cReq;
		var r= creq.ajaReq.req;
		if (r.readyState==4)
		{
			if (r.status==200)
			{
				creq.callBackOK(r.responseText);
			}
			else
			{
				creq.callBackError(r);
			}
			
			
		}
		else
		{
			//alert("readystate: " + r.readyState);
		}
	};


};



function test()
{
	
	alert("test");
};


