// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.8316.0, Culture=neutral, PublicKeyToken=null
// on Sunday, September 05, 2010 at 2:52:41 PM (Eastern Daylight Time)

function AjaxServices(url)
{
    var self = this;
    var m = ["addShout","getDeltaShouts","getSpyHtml","checkStory","kickStory","kickRssStory","tagStory","unTagStory","getUserStoryTags","reportAsSpam","moderatorMarkAsSpam","moderatorUnMarkAsSpam","moderatorMarkRssAsDelete","viewCount","viewRssCount","checkUsernameExists","checkEmailExists","saveColorPreferences","system.listMethods","system.version","system.about"];
    var idems = [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true];
    
    this[m[0]] = function /* addShout */ (message, toUsername, chatID, lastReceivedShoutID, callback)
    {
        if (self.kwargs) return rpc(new Call(0, { message: message, toUsername: toUsername, chatID: chatID, lastReceivedShoutID: lastReceivedShoutID }, callback));
        return rpc(new Call(0, [ message, toUsername, chatID, lastReceivedShoutID ], callback));
    }
    
    this[m[1]] = function /* getDeltaShouts */ (toUsername, chatID, lastReceivedShoutID, callback)
    {
        if (self.kwargs) return rpc(new Call(1, { toUsername: toUsername, chatID: chatID, lastReceivedShoutID: lastReceivedShoutID }, callback));
        return rpc(new Call(1, [ toUsername, chatID, lastReceivedShoutID ], callback));
    }
    
    this[m[2]] = function /* getSpyHtml */ (callback)
    {
        if (self.kwargs) return rpc(new Call(2, { }, callback));
        return rpc(new Call(2, [ ], callback));
    }
    
    this[m[3]] = function /* checkStory */ (url, callback)
    {
        if (self.kwargs) return rpc(new Call(3, { url: url }, callback));
        return rpc(new Call(3, [ url ], callback));
    }
    
    this[m[4]] = function /* kickStory */ (storyID, isKick, callback)
    {
        if (self.kwargs) return rpc(new Call(4, { storyID: storyID, isKick: isKick }, callback));
        return rpc(new Call(4, [ storyID, isKick ], callback));
    }
    
    this[m[5]] = function /* kickRssStory */ (rssStoryID, isKick, callback)
    {
        if (self.kwargs) return rpc(new Call(5, { rssStoryID: rssStoryID, isKick: isKick }, callback));
        return rpc(new Call(5, [ rssStoryID, isKick ], callback));
    }
    
    this[m[6]] = function /* tagStory */ (storyID, tagString, callback)
    {
        if (self.kwargs) return rpc(new Call(6, { storyID: storyID, tagString: tagString }, callback));
        return rpc(new Call(6, [ storyID, tagString ], callback));
    }
    
    this[m[7]] = function /* unTagStory */ (storyID, tagID, callback)
    {
        if (self.kwargs) return rpc(new Call(7, { storyID: storyID, tagID: tagID }, callback));
        return rpc(new Call(7, [ storyID, tagID ], callback));
    }
    
    this[m[8]] = function /* getUserStoryTags */ (storyID, callback)
    {
        if (self.kwargs) return rpc(new Call(8, { storyID: storyID }, callback));
        return rpc(new Call(8, [ storyID ], callback));
    }
    
    this[m[9]] = function /* reportAsSpam */ (storyID, callback)
    {
        if (self.kwargs) return rpc(new Call(9, { storyID: storyID }, callback));
        return rpc(new Call(9, [ storyID ], callback));
    }
    
    this[m[10]] = function /* moderatorMarkAsSpam */ (storyID, callback)
    {
        if (self.kwargs) return rpc(new Call(10, { storyID: storyID }, callback));
        return rpc(new Call(10, [ storyID ], callback));
    }
    
    this[m[11]] = function /* moderatorUnMarkAsSpam */ (storyID, callback)
    {
        if (self.kwargs) return rpc(new Call(11, { storyID: storyID }, callback));
        return rpc(new Call(11, [ storyID ], callback));
    }
    
    this[m[12]] = function /* moderatorMarkRssAsDelete */ (rssStoryID, tryDelete, callback)
    {
        if (self.kwargs) return rpc(new Call(12, { rssStoryID: rssStoryID, tryDelete: tryDelete }, callback));
        return rpc(new Call(12, [ rssStoryID, tryDelete ], callback));
    }
    
    this[m[13]] = function /* viewCount */ (storyID, callback)
    {
        if (self.kwargs) return rpc(new Call(13, { storyID: storyID }, callback));
        return rpc(new Call(13, [ storyID ], callback));
    }
    
    this[m[14]] = function /* viewRssCount */ (rssStoryID, callback)
    {
        if (self.kwargs) return rpc(new Call(14, { rssStoryID: rssStoryID }, callback));
        return rpc(new Call(14, [ rssStoryID ], callback));
    }
    
    this[m[15]] = function /* checkUsernameExists */ (username, callback)
    {
        if (self.kwargs) return rpc(new Call(15, { username: username }, callback));
        return rpc(new Call(15, [ username ], callback));
    }
    
    this[m[16]] = function /* checkEmailExists */ (email, callback)
    {
        if (self.kwargs) return rpc(new Call(16, { email: email }, callback));
        return rpc(new Call(16, [ email ], callback));
    }
    
    this[m[17]] = function /* saveColorPreferences */ (kickItTextColor, kickItBackgroundColor, kickCountTextColor, kickCountBackgroundColor, borderColor, callback)
    {
        if (self.kwargs) return rpc(new Call(17, { kickItTextColor: kickItTextColor, kickItBackgroundColor: kickItBackgroundColor, kickCountTextColor: kickCountTextColor, kickCountBackgroundColor: kickCountBackgroundColor, borderColor: borderColor }, callback));
        return rpc(new Call(17, [ kickItTextColor, kickItBackgroundColor, kickCountTextColor, kickCountBackgroundColor, borderColor ], callback));
    }
    
    // Returns an array of method names implemented by this service.
    
    this[m[18]] = function /* system.listMethods */ (callback)
    {
        if (self.kwargs) return rpc(new Call(18, { }, callback));
        return rpc(new Call(18, [ ], callback));
    }
    
    // Returns the version server implementation using the major, minor, build and revision format.
    
    this[m[19]] = function /* system.version */ (callback)
    {
        if (self.kwargs) return rpc(new Call(19, { }, callback));
        return rpc(new Call(19, [ ], callback));
    }
    
    // Returns a summary about the server implementation for display purposes.
    
    this[m[20]] = function /* system.about */ (callback)
    {
        if (self.kwargs) return rpc(new Call(20, { }, callback));
        return rpc(new Call(20, [ ], callback));
    }
    
    var url = typeof(url) === 'string' ? url : 'http://thaikicks.com/services/ajax/ajaxservices.ashx';
    var nextId = 0;

    function Call(method, params, callback)
    {
        this.url = url;
        this.callback = callback;
        this.proxy = self;
        this.idempotent = idems[method];
        this.request = 
        { 
            id     : ++nextId, 
            method : m[method], 
            params : params 
        };
    }

    function rpc(call)
    {
        return self.channel != null && typeof(self.channel.rpc) === 'function' ?
            self.channel.rpc(call) : call;
    }

    this.kwargs = false;
    this.channel = new JayrockChannel();

    function JayrockChannel()
    {
        this.rpc = function(call)
        {
            var async = typeof(call.callback) === 'function';
            var xhr = newXHR();
            xhr.open('POST', call.url, async, this.httpUserName, this.httpPassword);
            xhr.setRequestHeader('Content-Type', this.contentType || 'application/json; charset=utf-8');
            xhr.setRequestHeader('X-JSON-RPC', call.request.method);
            if (async) xhr.onreadystatechange = function() { xhr_onreadystatechange(xhr, call.callback); }
            xhr.send(JSON.stringify(call.request));
            call.handler = xhr;
            if (async) return call;
            if (xhr.status != 200) throw new Error(xhr.status + ' ' + xhr.statusText);
            var response = JSON.eval(xhr.responseText);
            if (response.error != null) throw response.error;
            return response.result;
        }

        function xhr_onreadystatechange(sender, callback)
        {
            if (sender.readyState == /* complete */ 4)
            {
                var response = sender.status == 200 ? 
                    JSON.eval(sender.responseText) : {};
                
                callback(response, sender);
            }
        }

        function newXHR()
        {
            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 */
        }
    }
}

AjaxServices.rpcMethods = ["addShout","getDeltaShouts","getSpyHtml","checkStory","kickStory","kickRssStory","tagStory","unTagStory","getUserStoryTags","reportAsSpam","moderatorMarkAsSpam","moderatorUnMarkAsSpam","moderatorMarkRssAsDelete","viewCount","viewRssCount","checkUsernameExists","checkEmailExists","saveColorPreferences","system.listMethods","system.version","system.about"];
