GridHandler = function()
{
    var nextId = 0;
	var url = "http://www.climatesmartbusiness.com/fp/cms/grid.ashx";
	
    var proxy = {
        
        "autoCompleteField" : function(tableSid, columnSid, prefix, callback, scope) {
            Call("autoCompleteField", [ tableSid, columnSid, prefix ], callback, scope, Array.prototype.slice.call(arguments, 5));
        },
        
        "cloneTableData" : function(tabSid, keys, callback, scope) {
            Call("cloneTableData", [ tabSid, keys ], callback, scope, Array.prototype.slice.call(arguments, 4));
        },
        
        "deleteTableData" : function(o, callback, scope) {
            Call("deleteTableData", [ o ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "exportTableData" : function(tabSid, keys, order, callback, scope) {
            Call("exportTableData", [ tabSid, keys, order ], callback, scope, Array.prototype.slice.call(arguments, 5));
        },
        
        "exportViewData" : function(viewXml, order, callback, scope) {
            Call("exportViewData", [ viewXml, order ], callback, scope, Array.prototype.slice.call(arguments, 4));
        },
        
        "getChangeLog" : function(tableName, keys, firstRow, numRows, orderBy, callback, scope) {
            Call("getChangeLog", [ tableName, keys, firstRow, numRows, orderBy ], callback, scope, Array.prototype.slice.call(arguments, 7));
        },
        
        "getColValFromPendingVal" : function(tableSid, columnSid, pendingValId, callback, scope) {
            Call("getColValFromPendingVal", [ tableSid, columnSid, pendingValId ], callback, scope, Array.prototype.slice.call(arguments, 5));
        },
        
        "getCSRInfo" : function(callback, scope) {
            Call("getCSRInfo", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "getForms" : function(callback, scope) {
            Call("getForms", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "getRegionOwnerList" : function(callback, scope) {
            Call("getRegionOwnerList", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "getSchema" : function(callback, scope) {
            Call("getSchema", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "getSchemaAndCSRInfo" : function(callback, scope) {
            Call("getSchemaAndCSRInfo", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "getTableData" : function(tabSid, keys, firstRow, numRows, order, callback, scope) {
            Call("getTableData", [ tabSid, keys, firstRow, numRows, order ], callback, scope, Array.prototype.slice.call(arguments, 7));
        },
        
        "getTableDataFilteredByView" : function(viewXml, tabSid, keys, firstRow, numRows, order, callback, scope) {
            Call("getTableDataFilteredByView", [ viewXml, tabSid, keys, firstRow, numRows, order ], callback, scope, Array.prototype.slice.call(arguments, 8));
        },
        
        "getTableDefinition" : function(tabSid, callback, scope) {
            Call("getTableDefinition", [ tabSid ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "getTableFilters" : function(tabSid, callback, scope) {
            Call("getTableFilters", [ tabSid ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "getUserList" : function(prefix, callback, scope) {
            Call("getUserList", [ prefix ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "getViewData" : function(viewXml, firstRow, numRows, order, callback, scope) {
            Call("getViewData", [ viewXml, firstRow, numRows, order ], callback, scope, Array.prototype.slice.call(arguments, 6));
        },
        
        "loadTableFilter" : function(filterSid, callback, scope) {
            Call("loadTableFilter", [ filterSid ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "renderFormToWord" : function(wordTemplate, keys, callback, scope) {
            Call("renderFormToWord", [ wordTemplate, keys ], callback, scope, Array.prototype.slice.call(arguments, 4));
        },
        
        "saveForm" : function(formSid, description, formXml, callback, scope) {
            Call("saveForm", [ formSid, description, formXml ], callback, scope, Array.prototype.slice.call(arguments, 5));
        },
        
        "saveTableData" : function(o, callback, scope) {
            Call("saveTableData", [ o ], callback, scope, Array.prototype.slice.call(arguments, 3));
        },
        
        "saveTableFilter" : function(tabSid, name, isPublic, filterXml, callback, scope) {
            Call("saveTableFilter", [ tabSid, name, isPublic, filterXml ], callback, scope, Array.prototype.slice.call(arguments, 6));
        },
        
        "searchEnum" : function(tabSid, colSid, searchVal, callback, scope) {
            Call("searchEnum", [ tabSid, colSid, searchVal ], callback, scope, Array.prototype.slice.call(arguments, 5));
        },
        
        "searchTableFilters" : function(tabSid, prefix, callback, scope) {
            Call("searchTableFilters", [ tabSid, prefix ], callback, scope, Array.prototype.slice.call(arguments, 4));
        },
        
        "system.about" : function(callback, scope) {
            Call("system.about", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "system.listMethods" : function(callback, scope) {
            Call("system.listMethods", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        },
        
        "system.version" : function(callback, scope) {
            Call("system.version", [ ], callback, scope, Array.prototype.slice.call(arguments, 2));
        }
    };
    
    function Call(method, params, callback, scope, callbackParams)
    {
        var request = { 
            id     : ++nextId, 
            method : method, 
            params : params 
        };
        Jayrock.Rpc.asyncRequest(url, request, callback, scope, callbackParams);
    }
        
    return proxy;
}();
