/* Start of http://www.mentorsphere.com/coordinator/mentoring.ashx?proxy */
// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.11214.0, Culture=neutral, PublicKeyToken=null
// on Monday, September 06, 2010 at 11:35:42 AM (Eastern Daylight Time)

function Mentoring(url)
{
    var self = this;
    var m = ["DeletePool","DeletePopulation","RemovePopulationFromPool","DeleteMatchSession","DeleteSurveyQuestion","DeleteSurveyQuestionValue","SelectPool","UnselectPool","SelectOrganizationCoordinator","UnselectOrganizationCoordinator","setUseAllAddressBooks","SelectBook","UnSelectBook","SelectEntireAddressBook","RemoveMembersFromPopulations","SelectPopulation","UnSelectPopulation","GetSelectedProtegeCount","GetSelectedMentorCount","SelectProtege","SelectMentor","CheckForDuplicateProtege","CheckForDuplicateMentor","SetOrganizationActivitiesGridPageIndex","SetOrganizationActivitiesGridPageSize","SetOrganizationActivitiesGridSortBy","DeleteOrganizationSurvey","SelectOrganizationSurvey","SelectSurveyQuestion","SetMatchCriteriaValue","SetMatchCriteriaValues","DeleteMatchCriteria","SelectAutoMatchProtege","SelectAutoMatchMentor","SetSurveyQuestionResponses","DeleteInspiration","ShowSurveyQuestionValues","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,false,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 /* DeletePool */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(0, { key: key }, callback));
        return rpc(new Call(0, [ key ], callback));
    }
    
    this[m[1]] = function /* DeletePopulation */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(1, { key: key }, callback));
        return rpc(new Call(1, [ key ], callback));
    }
    
    this[m[2]] = function /* RemovePopulationFromPool */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(2, { key: key }, callback));
        return rpc(new Call(2, [ key ], callback));
    }
    
    this[m[3]] = function /* DeleteMatchSession */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(3, { key: key }, callback));
        return rpc(new Call(3, [ key ], callback));
    }
    
    this[m[4]] = function /* DeleteSurveyQuestion */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(4, { key: key }, callback));
        return rpc(new Call(4, [ key ], callback));
    }
    
    this[m[5]] = function /* DeleteSurveyQuestionValue */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(5, { key: key }, callback));
        return rpc(new Call(5, [ key ], callback));
    }
    
    this[m[6]] = function /* SelectPool */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(6, { key: key }, callback));
        return rpc(new Call(6, [ key ], callback));
    }
    
    this[m[7]] = function /* UnselectPool */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(7, { key: key }, callback));
        return rpc(new Call(7, [ key ], callback));
    }
    
    this[m[8]] = function /* SelectOrganizationCoordinator */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(8, { key: key }, callback));
        return rpc(new Call(8, [ key ], callback));
    }
    
    this[m[9]] = function /* UnselectOrganizationCoordinator */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(9, { key: key }, callback));
        return rpc(new Call(9, [ key ], callback));
    }
    
    this[m[10]] = function /* setUseAllAddressBooks */ (value, callback)
    {
        if (self.kwargs) return rpc(new Call(10, { value: value }, callback));
        return rpc(new Call(10, [ value ], callback));
    }
    
    this[m[11]] = function /* SelectBook */ (bookKey, callback)
    {
        if (self.kwargs) return rpc(new Call(11, { bookKey: bookKey }, callback));
        return rpc(new Call(11, [ bookKey ], callback));
    }
    
    this[m[12]] = function /* UnSelectBook */ (bookKey, callback)
    {
        if (self.kwargs) return rpc(new Call(12, { bookKey: bookKey }, callback));
        return rpc(new Call(12, [ bookKey ], callback));
    }
    
    this[m[13]] = function /* SelectEntireAddressBook */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(13, { key: key }, callback));
        return rpc(new Call(13, [ key ], callback));
    }
    
    this[m[14]] = function /* RemoveMembersFromPopulations */ (populationKey, callback)
    {
        if (self.kwargs) return rpc(new Call(14, { populationKey: populationKey }, callback));
        return rpc(new Call(14, [ populationKey ], callback));
    }
    
    this[m[15]] = function /* SelectPopulation */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(15, { key: key }, callback));
        return rpc(new Call(15, [ key ], callback));
    }
    
    this[m[16]] = function /* UnSelectPopulation */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(16, { key: key }, callback));
        return rpc(new Call(16, [ key ], callback));
    }
    
    this[m[17]] = function /* GetSelectedProtegeCount */ (callback)
    {
        if (self.kwargs) return rpc(new Call(17, { }, callback));
        return rpc(new Call(17, [ ], callback));
    }
    
    this[m[18]] = function /* GetSelectedMentorCount */ (callback)
    {
        if (self.kwargs) return rpc(new Call(18, { }, callback));
        return rpc(new Call(18, [ ], callback));
    }
    
    this[m[19]] = function /* SelectProtege */ (key, value, callback)
    {
        if (self.kwargs) return rpc(new Call(19, { key: key, value: value }, callback));
        return rpc(new Call(19, [ key, value ], callback));
    }
    
    this[m[20]] = function /* SelectMentor */ (key, value, callback)
    {
        if (self.kwargs) return rpc(new Call(20, { key: key, value: value }, callback));
        return rpc(new Call(20, [ key, value ], callback));
    }
    
    this[m[21]] = function /* CheckForDuplicateProtege */ (callback)
    {
        if (self.kwargs) return rpc(new Call(21, { }, callback));
        return rpc(new Call(21, [ ], callback));
    }
    
    this[m[22]] = function /* CheckForDuplicateMentor */ (callback)
    {
        if (self.kwargs) return rpc(new Call(22, { }, callback));
        return rpc(new Call(22, [ ], callback));
    }
    
    this[m[23]] = function /* SetOrganizationActivitiesGridPageIndex */ (value, callback)
    {
        if (self.kwargs) return rpc(new Call(23, { value: value }, callback));
        return rpc(new Call(23, [ value ], callback));
    }
    
    this[m[24]] = function /* SetOrganizationActivitiesGridPageSize */ (value, callback)
    {
        if (self.kwargs) return rpc(new Call(24, { value: value }, callback));
        return rpc(new Call(24, [ value ], callback));
    }
    
    this[m[25]] = function /* SetOrganizationActivitiesGridSortBy */ (value, callback)
    {
        if (self.kwargs) return rpc(new Call(25, { value: value }, callback));
        return rpc(new Call(25, [ value ], callback));
    }
    
    this[m[26]] = function /* DeleteOrganizationSurvey */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(26, { key: key }, callback));
        return rpc(new Call(26, [ key ], callback));
    }
    
    this[m[27]] = function /* SelectOrganizationSurvey */ (key, value, callback)
    {
        if (self.kwargs) return rpc(new Call(27, { key: key, value: value }, callback));
        return rpc(new Call(27, [ key, value ], callback));
    }
    
    this[m[28]] = function /* SelectSurveyQuestion */ (key, value, type, callback)
    {
        if (self.kwargs) return rpc(new Call(28, { key: key, value: value, type: type }, callback));
        return rpc(new Call(28, [ key, value, type ], callback));
    }
    
    this[m[29]] = function /* SetMatchCriteriaValue */ (matchCriteriaKey, matchCriteriaValueKey, surveyQuestionType, surveyQuestionValueKey, operand, target, evaluationOrder, callback)
    {
        if (self.kwargs) return rpc(new Call(29, { matchCriteriaKey: matchCriteriaKey, matchCriteriaValueKey: matchCriteriaValueKey, surveyQuestionType: surveyQuestionType, surveyQuestionValueKey: surveyQuestionValueKey, operand: operand, target: target, evaluationOrder: evaluationOrder }, callback));
        return rpc(new Call(29, [ matchCriteriaKey, matchCriteriaValueKey, surveyQuestionType, surveyQuestionValueKey, operand, target, evaluationOrder ], callback));
    }
    
    this[m[30]] = function /* SetMatchCriteriaValues */ (items, callback)
    {
        if (self.kwargs) return rpc(new Call(30, { items: items }, callback));
        return rpc(new Call(30, [ items ], callback));
    }
    
    this[m[31]] = function /* DeleteMatchCriteria */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(31, { key: key }, callback));
        return rpc(new Call(31, [ key ], callback));
    }
    
    this[m[32]] = function /* SelectAutoMatchProtege */ (key, value, callback)
    {
        if (self.kwargs) return rpc(new Call(32, { key: key, value: value }, callback));
        return rpc(new Call(32, [ key, value ], callback));
    }
    
    this[m[33]] = function /* SelectAutoMatchMentor */ (key, value, callback)
    {
        if (self.kwargs) return rpc(new Call(33, { key: key, value: value }, callback));
        return rpc(new Call(33, [ key, value ], callback));
    }
    
    this[m[34]] = function /* SetSurveyQuestionResponses */ (items, callback)
    {
        if (self.kwargs) return rpc(new Call(34, { items: items }, callback));
        return rpc(new Call(34, [ items ], callback));
    }
    
    this[m[35]] = function /* DeleteInspiration */ (inspirationKey, callback)
    {
        if (self.kwargs) return rpc(new Call(35, { inspirationKey: inspirationKey }, callback));
        return rpc(new Call(35, [ inspirationKey ], callback));
    }
    
    this[m[36]] = function /* ShowSurveyQuestionValues */ (key, callback)
    {
        if (self.kwargs) return rpc(new Call(36, { key: key }, callback));
        return rpc(new Call(36, [ key ], callback));
    }
    
    // Returns an array of method names implemented by this service.
    
    this[m[37]] = function /* system.listMethods */ (callback)
    {
        if (self.kwargs) return rpc(new Call(37, { }, callback));
        return rpc(new Call(37, [ ], callback));
    }
    
    // Returns the version server implementation using the major, minor, build and revision format.
    
    this[m[38]] = function /* system.version */ (callback)
    {
        if (self.kwargs) return rpc(new Call(38, { }, callback));
        return rpc(new Call(38, [ ], callback));
    }
    
    // Returns a summary about the server implementation for display purposes.
    
    this[m[39]] = function /* system.about */ (callback)
    {
        if (self.kwargs) return rpc(new Call(39, { }, callback));
        return rpc(new Call(39, [ ], callback));
    }
    
    var url = typeof(url) === 'string' ? url : 'http://www.mentorsphere.com/coordinator/mentoring.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.parse(xhr.responseText);
            if (response.error != null) throw response.error;
            return response.result;
        }

        function xhr_onreadystatechange(sender, callback)
        {
            if (sender.readyState == /* complete */ 4)
            {
                try { 
                    sender.onreadystatechange = null; // Avoid IE7 leak (bug #12964)
                } 
                catch (e) { 
                    /* IE 6/Mobile throws for onreadystatechange = null */ 
                }

                var response = sender.status == 200 ? 
                    JSON.parse(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 */
        }
    }
}

Mentoring.rpcMethods = ["DeletePool","DeletePopulation","RemovePopulationFromPool","DeleteMatchSession","DeleteSurveyQuestion","DeleteSurveyQuestionValue","SelectPool","UnselectPool","SelectOrganizationCoordinator","UnselectOrganizationCoordinator","setUseAllAddressBooks","SelectBook","UnSelectBook","SelectEntireAddressBook","RemoveMembersFromPopulations","SelectPopulation","UnSelectPopulation","GetSelectedProtegeCount","GetSelectedMentorCount","SelectProtege","SelectMentor","CheckForDuplicateProtege","CheckForDuplicateMentor","SetOrganizationActivitiesGridPageIndex","SetOrganizationActivitiesGridPageSize","SetOrganizationActivitiesGridSortBy","DeleteOrganizationSurvey","SelectOrganizationSurvey","SelectSurveyQuestion","SetMatchCriteriaValue","SetMatchCriteriaValues","DeleteMatchCriteria","SelectAutoMatchProtege","SelectAutoMatchMentor","SetSurveyQuestionResponses","DeleteInspiration","ShowSurveyQuestionValues","system.listMethods","system.version","system.about"];
/* End of http://www.mentorsphere.com/coordinator/mentoring.ashx?proxy */
