// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.8316.0, Culture=neutral, PublicKeyToken=null
// on Thursday, September 09, 2010 at 7:39:50 PM (SE Asia Standard Time)

// Proxy version 1.0

function AjaxLoader(url)
{
    this["UO"] = function(callback)
    {
        return call("UO", [ ], callback);
    }
    
    this["saleOnline"] = function(callback)
    {
        return call("saleOnline", [ ], callback);
    }
    
    this["AE"] = function(answerID, callback)
    {
        return call("AE", [ answerID ], callback);
    }
    
    this["CR"] = function(region, callback)
    {
        return call("CR", [ region ], callback);
    }
    
    this["loadProduct"] = function(proID, callback)
    {
        return call("loadProduct", [ proID ], callback);
    }
    
    this["loadNews"] = function(id, callback)
    {
        return call("loadNews", [ id ], callback);
    }
    
    this["loadPromo"] = function(id, callback)
    {
        return call("loadPromo", [ id ], callback);
    }
    
    this["loadFAQsContent"] = function(id, callback)
    {
        return call("loadFAQsContent", [ id ], callback);
    }
    
    this["loadCCContent"] = function(id, callback)
    {
        return call("loadCCContent", [ id ], callback);
    }
    
    this["loadNewsContent"] = function(id, callback)
    {
        return call("loadNewsContent", [ id ], callback);
    }
    
    this["loadPromoContent"] = function(id, callback)
    {
        return call("loadPromoContent", [ id ], callback);
    }
    
    this["updateRP"] = function(rdMark, rsMark, reMark, proID, callback)
    {
        return call("updateRP", [ rdMark, rsMark, reMark, proID ], callback);
    }
    
    this["postComment"] = function(content, email, proID, callback)
    {
        return call("postComment", [ content, email, proID ], callback);
    }
    
    this["addRegister"] = function(regInfo, textWordVerification, callback)
    {
        return call("addRegister", [ regInfo, textWordVerification ], callback);
    }
    
    this["getListProduct"] = function(strCatID, callback)
    {
        return call("getListProduct", [ strCatID ], callback);
    }
    
    this["loadProTech"] = function(proID, regID, callback)
    {
        return call("loadProTech", [ proID, regID ], callback);
    }
    
    this["getParaChartAnswer"] = function(callback)
    {
        return call("getParaChartAnswer", [ ], callback);
    }
    
    /* Returns an array of method names implemented by this service. */
    
    this["system.listMethods"] = function(callback)
    {
        return call("system.listMethods", [ ], callback);
    }
    
    /* Returns the version server implementation using the major, minor, build and revision format. */
    
    this["system.version"] = function(callback)
    {
        return call("system.version", [ ], callback);
    }
    
    /* Returns a summary about the server implementation for display purposes. */
    
    this["system.about"] = function(callback)
    {
        return call("system.about", [ ], callback);
    }
    
    var url = typeof(url) === 'string' ? url : 'http://www.tragoplaptop.com/Js/HandlerAjax.ashx';
    var self = this;
    var nextId = 0;

    function call(method, params, callback)
    {
        var request = { id : nextId++, method : method, params : params };
        return callback == null ? 
            callSync(method, request) : callAsync(method, request, callback);
    }

    function callSync(method, request)
    {
        var http = newHTTP();
        http.open('POST', url, false, self.httpUserName, self.httpPassword);
        setupHeaders(http, method);
        http.send(JSON.stringify(request));
        if (http.status != 200)
            throw { message : http.status + ' ' + http.statusText, toString : function() { return message; } };
        var response = JSON.eval(http.responseText);
        if (response.error != null) throw response.error;
        return response.result;
    }

    function callAsync(method, request, callback)
    {
        var http = newHTTP();
        http.open('POST', url, true, self.httpUserName, self.httpPassword);
        setupHeaders(http, method);
        http.onreadystatechange = function() { http_onreadystatechange(http, callback); }
        http.send(JSON.stringify(request));
        return request.id;
    }

    function setupHeaders(http, method)
    {
        http.setRequestHeader('Content-Type', 'text/plain; charset=utf-8');
        http.setRequestHeader('X-JSON-RPC', method);
    }

    function http_onreadystatechange(sender, callback)
    {
        if (sender.readyState == /* complete */ 4)
        {
            var response = sender.status == 200 ? 
                JSON.eval(sender.responseText) : {};
            
            response.xmlHTTP = sender;
                
            callback(response);
        }
    }

    function newHTTP()
    {
        if (typeof(window) != 'undefined' && window.XMLHttpRequest)
            return new XMLHttpRequest(); /* IE7, Safari 1.2, Mozilla 1.0/Firefox, and Netscape 7 */
        else
            return new ActiveXObject('Microsoft.XMLHTTP'); /* WSH and IE 5 to IE 6 */
    }
}

AjaxLoader.rpcMethods = ["UO","saleOnline","AE","CR","loadProduct","loadNews","loadPromo","loadFAQsContent","loadCCContent","loadNewsContent","loadPromoContent","updateRP","postComment","addRegister","getListProduct","loadProTech","getParaChartAnswer","system.listMethods","system.version","system.about"];
