var Report = Class.create(Arland.Control, {
    initialize: function($super, id) {
		$super(id);
        if(this.container)
        {
            this.form = this.container.getElementsByTagName("form")[0];
            this.isPaginable = false;
            if(this.form)
            {
                this.form.observe("submit", (function(e) {
                    this.submit();
                    return Event.stop(e);
                }).bindAsEventListener(this));

                if(this.form.elements["p"])
                {
                    this.currentPage = parseInt(this.form.elements["p"].value);
                    this.isPaginable = true;
                }
            }
        }
    },
    submit: function()
    {
        if(!this.container) return;
        if(this.isPaginable)
            this.setPage(0);
        this.form.submit();
    },
    gotoPage: function(p)
    {
        if(!this.container) return;
        this.setPage(p);
        this.form.submit();
    },
    nextPage: function()
    {
        if(!this.container) return;
        this.setPage(this.currentPage+1);
        this.form.submit();
    },
    prevPage: function()
    {
        if(!this.container) return;
        this.setPage(this.currentPage-1);
        this.form.submit();
    },

    /* private */
    setPage: function(p)
    {
        this.form.elements["p"].value = p;
    }
});
