
;(function($) {
    defaults  = {
        width:320,      // width in px
        height:240,     // height in px
        index:0        // start from frame number N
    };

    /**
     * Create a new instance of agentisForm.
     *
     * @classDescription	This class creates a new agentisForm and manipulate it
     *
     * @return {Object}	Returns a new agentisForm object.
     * @constructor
     */
    $.fn.agentisForm = function(settings) {

        var _agentisForm = this;

        /*
         * Construct
         */
        this.each(function(){

            var ext = $(this);

            this.playId   = null;
            this.playFlag = false;
            this.playFrame = false;
            this.goToFlag = false;
            this.inited   = new Array();
            this.titles   = new Array();

            /**
             * Build Html
             * @method
             */
            this.build    = function () {
                var _self = this;
                return true;
            };

            /**
             * Init N-slide
             * @method
             * @param {Integer} index
             * @param {Boolean} next
             */
            this.init = function (index) {
                // initialize only ones

                return false;
            };

            /**
             * Play agentisForm
             * @method
             */
            this.checkAll = function (id) {
                var _self = this;

                $('input[name="' + id + '[]"]').attr('checked', true);
            };


            // Now initialize the agentisForm
            this.options = $.extend({}, defaults, settings);

            if (typeof(settings) != 'undefined') {
                if (typeof(settings.controls) != 'undefined')
                   this.options.controls = $.extend({}, defaults.controls,  settings.controls);
            }

            this.build();

            /**
             * Show agentisForm
             */
            //ext.show();

            return ext;
        });


        /**
         * external functions - append to $
         */
        _agentisForm.checkAll = function(id){ _agentisForm.each(function () { this.checkAll(id);  }) };
        /*
        _agentisForm.stopSlide = function(){ _agentisForm.each(function () { this.stop();  }) };
        _agentisForm.nextSlide = function(){ _agentisForm.each(function () { this.next();  }) };
        _agentisForm.prevSlide = function(){ _agentisForm.each(function () { this.prev();  }) };
        _agentisForm.getTitle  = function(){ _agentisForm.each(function () { this.getTitle(); }) };
        _agentisForm.goToSlide = function(n){ _agentisForm.each(function () { this.goToSlide(n); }) };

        */
        return this;
    }
})(jQuery);
$(document).ready(function() {

    $(window).scroll(function () {
        var pos = $("#content-buttons").position();
        var top = $(window).scrollTop();
        if(pos.top + 88 < top) {
            $('#button-overlay').show();
        } else {
            $('#button-overlay').hide();
        }
    });


    $('#report-control-close').click(function() {
        hideParameterForm();
    });

    $('#report-control-open').click(function() {
        showParameterForm();
    });

    $('#header .header-menu li li ul').each(function(i, obj) {
        $(obj, this).parent().addClass('more');
    });
});


function loadUrlFromSelect(object)
 {
    newPage = object.options[object.selectedIndex].value

   if (newPage != "") {
      document.location.href = newPage
   }
 }


function submit(formId)
{
    $('#' + formId).submit();

}


function setLocation(url)
{
    window.location.href = url;
}

function confirmSetLocation(message, url)
{
    if(confirm(message)) {
        setLocation(url);
    }
}

function confirmDelete(message)
{
    return confirm(message);
}

function hideParameterForm()
{
    $('#leftnav').hide();
    $('#content').removeClass('span-18').addClass('span-24');
    $('#report-control-open').show()
}

function showParameterForm()
{
    $('#leftnav').show();
    $('#content').removeClass('span-24').addClass('span-18');
    $('#report-control-open').hide()
}

$(document).ready(function() {
    $("#loading").ajaxStart(function(){
        $(this).show();
    });
    $("#loading").ajaxStop(function(){
        $(this).hide();
    });

});
