AjaxFavorites_class = function() {
    this.connection = new Ext.data.Connection({
        url: "/Library/ajaxpro/AjaxFavorites,App_Code.nb3thwog.ashx",
        listeners: {
            requestcomplete: function(connection, response, options) {
                var onsuccess = options.onsuccess;
                if (typeof onsuccess == "function") {
                    onsuccess(Ext.decode(response.responseText));
                }
            },
            requestexception: function(connection, response, options, e) {
                var onerror = options.onerror;
                var r = response.responseText;
                if (r.indexOf('{"Message":') == 0 && typeof onerror == "function") {
                    onerror(Ext.decode(r));
                } else {
                    onerror({"Message":"Failed."});
                }
            }
        }
    });
};

AjaxFavorites_class.prototype = {
    GetMyFavoriteTitles: function(favoriteID, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "GetMyFavoriteTitles",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"favoriteID": favoriteID},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AddFavoriteTitle: function(strNewFavTitle, strFavTitleID, itemIDList, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AddFavoriteTitle",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"strNewFavTitle": strNewFavTitle, "strFavTitleID": strFavTitleID, "itemIDList": itemIDList},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    Remove: function(idstring, FavorID, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "Remove",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"idstring": idstring, "FavorID": FavorID},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    DeleteFav: function(titleID, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "DeleteFav",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"titleID": titleID},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxFavorite: function(strList, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxFavorite",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"strList": strList},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxGetfavoriteCaption: function(onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxGetfavoriteCaption",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxSetValueToPrint: function(tmpSort, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxSetValueToPrint",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"tmpSort": tmpSort},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxSend: function(Title, Notes, Address, FavID, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxSend",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"Title": Title, "Notes": Notes, "Address": Address, "FavID": FavID},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxShowEmail: function(onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxShowEmail",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxShareFav: function(FirstName, LastName, txtEmail, idstr, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxShareFav",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"FirstName": FirstName, "LastName": LastName, "txtEmail": txtEmail, "idstr": idstr},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxSetFavoritePanelStatus: function(isnail, isopen, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxSetFavoritePanelStatus",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"isnail": isnail, "isopen": isopen},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxgetFavoritePanelstatus: function(onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxgetFavoritePanelstatus",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {},
            onsuccess: onsuccess,
            onerror: onerror
        });
    },
    AjaxGetPrintFavoriteDetail: function(favoriteID, tabIndex, onsuccess, onerror) {
        return this.connection.request({
            ajaxProMethod: "AjaxGetPrintFavoriteDetail",
            ajaxProToken: (typeof AjaxPro !== "undefined" && AjaxPro.token !== null) ? AjaxPro.token : "",
            params: {"favoriteID": favoriteID, "tabIndex": tabIndex},
            onsuccess: onsuccess,
            onerror: onerror
        });
    }
};

var AjaxFavorites = new AjaxFavorites_class();


