// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.8316.0, Culture=neutral, PublicKeyToken=null
// on miércoles, 11 de noviembre de 2009 at 11:08:29 (Hora estándar romance)

// Proxy version 1.0

function JsonPortal(url)
{
    this["Login"] = function(user, password, callback)
    {
        return call("Login", [ user, password ], callback);
    }
    
    this["LoginForNewConsole"] = function(user, password, callback)
    {
        return call("LoginForNewConsole", [ user, password ], callback);
    }
    
    this["LoginById"] = function(user, callback)
    {
        return call("LoginById", [ user ], callback);
    }
    
    this["GenerateDeferedSetup"] = function(partnerId, applicationName, setupFile, shortcutFolder, shortcutName, langCode, langFile, setupTemplateFile, setupExecutableFile, hasAgreement, hasBackup, callback)
    {
        return call("GenerateDeferedSetup", [ partnerId, applicationName, setupFile, shortcutFolder, shortcutName, langCode, langFile, setupTemplateFile, setupExecutableFile, hasAgreement, hasBackup], callback);
    }

    this["GenerateSetup"] = function(partnerId, callback)
    {
        return call("GenerateSetup", [ partnerId ], callback);
    }
    
    this["GetGeneratedSetup"] = function(partnerId, callback)
    {
        return call("GetGeneratedSetup", [ partnerId], callback);
    }
    
    this["GetConnectedOperators"] = function(user, conversation, callback)
    {
        return call("GetConnectedOperators", [ user, conversation ], callback);
    }
    
    this["GetConnectedOperators2"] = function(callback)
    {
        return call("GetConnectedOperators2", [ ], callback);
    }
    
    this["GetConnectedAdministrators"] = function(user, conversation, callback)
    {
        return call("GetConnectedAdministrators", [ user, conversation ], callback);
    }
    
    this["GetMasterPageInfo"] = function(callback)
    {
        return call("GetMasterPageInfo", [ ], callback);
    }
    
    this["GetCurrentConversations"] = function(callback)
    {
        return call("GetCurrentConversations", [ ], callback);
    }
    
    this["GetCurrentConversationsbyRows"] = function(numrows, callback)
    {
        return call("GetCurrentConversationsbyRows", [ numrows ], callback);
    } 
    
    this["GetQueueConversations"] = function(callback)
    {
        return call("GetQueueConversations", [ ], callback);
    }  
    
    this["GetQueueConversationsbyRows"] = function(numrows, callback)
    {
        return call("GetQueueConversationsbyRows", [ numrows ], callback);
    }
    
    this["GetLatestConversations"] = function(callback)
    {
        return call("GetLatestConversations", [ ], callback);
    } 
    
    this["GetLatestConversationsbyRows"] = function(numrows, callback)
    {
        return call("GetLatestConversationsbyRows", [ numrows ], callback);
    }  
    
    this["GetLatestSurveys"] = function(callback)
    {
        return call("GetLatestSurveys", [ ], callback);
    } 
    
    this["GetLatestSurveysReplybyRows"] = function(numrows, callback)
    {
        return call("GetLatestSurveysReplybyRows", [ numrows ], callback);
    }
    
    this["GetLatestMovements"] = function(callback)
    {
        return call("GetLatestMovements", [ ], callback);
    }
    
    this["GetLatestOpersConv"] = function(callback)
    {
        return call("GetLatestOpersConv", [ ], callback);
    } 
    
    this["GetAdminConv"] = function(callback)
    {
        return call("GetAdminConv", [ ], callback);
    }    
    
    this["SendInvitationEmail"] = function(email, partnerId, callback)
    {
        return call("SendInvitationEmail", [ email, partnerId ], callback);
    }
    
    this["GetLatestNotify"] = function(callback)
    {
        return call("GetLatestNotify", [  ], 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 : '../../App_Handler/JsonPortal.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;
                
            delete sender['onreadystatechange'];
            sender = null;
                
            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 */
    }
}

JsonPortal.rpcMethods = ["Login", "LoginForNewConsole", "LoginById", "GenerateDeferedSetup", "GenerateSetup", "GetConnectedOperators", "GetConnectedOperators2", "GetConnectedAdministrators", "GetMasterPageInfo", "GetCurrentConversations", "GetCurrentConversationsbyRows", "GetQueueConversations", "GetQueueConversationsbyRows", "GetLatestConversations", "GetLatestConversationsbyRows", "GetLatestSurveys", "GetLatestSurveysReplybyRows", "GetLatestMovements", "GetLatestOpersConv", "GetAdminConv", "SendInvitationEmail", "GetLatestNotify", "system.listMethods", "system.version", "system.about"];

