var handleNewsSlider = {

    pageId: 0,
    totalPages: 0,
    width: 0,
    btnBack: "",
    btnNext: "",
    element: "",
    clickActivate: false,
    Clone: function ()
    {
        var newObject = JQ.extend(true, {}, handleNewsSlider);
        return newObject;
    },
    init: function (container)
    {
        var se = container + " div.hlist ul";
        this.element = JQ(se);

        se = se + " > li";

        this.totalPages = JQ(se).length;

        if (JQ(container).parents("#left-pane").length > 0)
            this.width = 544;
        else
            this.width = 290;

        var btn = container + " .scroll-nav";
        this.btnBack = JQ(btn + " .left");
        this.btnNext = JQ(btn + " .right");

        this.element.css({ "width": (this.width * this.totalPages) + "px" });
        this.handlebtnNext();
        this.handlebtnBack();
        this.buttonManager();
    },

    buttonManager: function ()
    {
        this.btnBack.removeClass("deactivated");
        this.btnNext.removeClass("deactivated");

        var last = this.totalPages - 1;

        if (this.pageId == 0)
            this.btnBack.addClass("deactivated");

        if (this.pageId == last)
            this.btnNext.addClass("deactivated");
    },

    handlebtnNext: function ()
    {

        var that = this;

        that.btnNext.click(function ()
        {
            if (!that.btnNext.hasClass("deactivated") && that.clickActivate == false)
            {
                that.clickActivate = true;
                that.element.animate({ marginLeft: -((that.pageId + 1) * that.width) + "px" }, 1200, "easeOutCubic", function () { that.clickActivate = false; });
                that.pageId += 1;
                that.buttonManager();
            }

            return false;

        });

    },

    handlebtnBack: function ()
    {

        var that = this;
        that.btnBack.click(function ()
        {

            if (!that.btnBack.hasClass("deactivated") && that.clickActivate == false)
            {
                that.clickActivate = true;
                that.element.animate({ marginLeft: -((that.pageId - 1) * that.width) + "px" }, 1200, "easeOutCubic", function () { that.clickActivate = false; });
                that.pageId -= 1;
                that.buttonManager();
            }

            return false;

        });
    }
}
