// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.8316.0, Culture=neutral, PublicKeyToken=null
// on dinsdag 7 september 2010 at 4:48:07 (Romance Daylight Time)

// Proxy version 1.0

function MethodHandler(url)
{
    this["saveVote"] = function(id, callback)
    {
        return call("saveVote", [ id ], callback);
    }
    
    this["getPopularData"] = function(page, type, stationName, callback)
    {
        return call("getPopularData", [ page, type, stationName ], callback);
    }
    
    this["getStationData"] = function(callback)
    {
        return call("getStationData", [ ], callback);
    }
    
    this["getWinkelData"] = function(callback)
    {
        return call("getWinkelData", [ ], callback);
    }
    
    this["getShopByStationAndCat"] = function(stat, cat, callback)
    {
        return call("getShopByStationAndCat", [ stat, cat ], callback);
    }
    
    this["getCatByStation"] = function(naam, callback)
    {
        return call("getCatByStation", [ naam ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["addShopToUser"] = function(station, winkel, callback)
    {
        return call("addShopToUser", [ station, winkel ], callback);
    }
    
    this["greetings"] = function(callback)
    {
        return call("greetings", [ ], callback);
    }
    
    this["logOut"] = function(callback)
    {
        return call("logOut", [ ], callback);
    }
    
    this["setView"] = function(value, callback)
    {
        return call("setView", [ value ], callback);
    }
    
    this["getView"] = function(callback)
    {
        return call("getView", [ ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["getDataUser"] = function(callback)
    {
        return call("getDataUser", [ ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["checkIfLoggedIn"] = function(callback)
    {
        return call("checkIfLoggedIn", [ ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["deleteWinkel"] = function(id, callback)
    {
        return call("deleteWinkel", [ id ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["deleteStation"] = function(id, callback)
    {
        return call("deleteStation", [ id ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["addStationUser"] = function(naam, callback)
    {
        return call("addStationUser", [ naam ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["updateFavoritStationUser"] = function(id, callback)
    {
        return call("updateFavoritStationUser", [ id ], callback);
    }
    
    /* Returns the Northwind employees as a DataSet. */
    
    this["registerUser"] = function(uo, callback)
    {
        return call("registerUser", [ uo ], callback);
    }
    
    this["saveSuggestie"] = function(sug, naam, callback)
    {
        return call("saveSuggestie", [ sug, naam ], callback);
    }
    
    this["getStationID"] = function(naam, callback)
    {
        return call("getStationID", [ naam ], 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.lagare.be/assets/ashx/MethodHandler.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 */
    }
}

MethodHandler.rpcMethods = ["saveVote","getPopularData","getStationData","getWinkelData","getShopByStationAndCat","getCatByStation","addShopToUser","greetings","logOut","setView","getView","getDataUser","checkIfLoggedIn","deleteWinkel","deleteStation","addStationUser","updateFavoritStationUser","registerUser","saveSuggestie","getStationID","system.listMethods","system.version","system.about"];
