function boxAnimation(p_max_items, p_instance_name, p_thumb_switching) {    
    this.current_index = 0,
    this.current_thumb_index = 1;
    this.timer_id = null,
    this.max_items = p_max_items,
    this._instance_name = p_instance_name,
    this._thumb_switching = p_thumb_switching;
    this.paused = false;

    this.show_content = function(p_index, p_reset_timer) {
        var _index = p_index;        
        var _thumb_index = p_index + 1;
        if (p_index + 1 >= this.max_items) {
            _thumb_index = 0;
        }




        // hide current & show next
        /*
        //od kad su ubacene instance prestao je raditi fade?!?
        $('.' + this._instance_name + '_content_main_' + this.current_index).fadeOut(120, function() {
        $('.' + this._instance_name + '_content_main_' + _index).fadeIn('fast')
        }
        );
        */

        $('.' + this._instance_name + '_content_main_' + this.current_index).hide();
        $('.' + this._instance_name + '_content_main_' + _index).show();

        var _old_index = this.current_index;
        var _old_thumb_index = this.current_thumb_index;



        if (this._thumb_switching) {
            $('.' + this._instance_name + '_content_side_' + _old_thumb_index).hide();
            $('.' + this._instance_name + '_content_side_' + _thumb_index).show();

            $('.' + this._instance_name + '_content_position_' + _index).addClass('active');
            $('.' + this._instance_name + '_content_position_' + _old_index).removeClass('active');





        } else {
            $('.' + this._instance_name + '_content_side_' + _index).addClass('active');
            $('.' + this._instance_name + '_content_side_' + _old_index).removeClass('active');
        }

        this.current_index = p_index;
        this.current_thumb_index = _thumb_index;

        if (typeof (p_reset_timer != 'undefined') && p_reset_timer) {
            if (!this.paused) {
                this.start_timer();
            }
        }
        //this.start_timer();
    },

    this.show_next_content = function() {
        var next_index = this.current_index + 1;
        if ((next_index + 1) > this.max_items) {
            next_index = 0;
        }

        this.show_content(next_index);
    },

    this.start_timer = function() {
        if (this.timer_id != null) {
            clearTimeout(this.timer_id);
        }
        if (this._instance_name != null) {
            this.timer_id = setInterval(this._instance_name + '.show_next_content()', 6000);
        }

    },

    this.stop_timer = function() {
        if (this.timer_id != null) {
            clearTimeout(this.timer_id);
        }
    }

    this.start_slideshow = function() {
        this.start_timer();
        $('#gs_play').css({ 'display': 'none' });
        $('#gs_pause').css({ 'display': 'block' });
        this.paused = false;
    }

    this.stop_slideshow = function() {
        this.stop_timer();
        $('#gs_play').css({ 'display': 'block' });
        $('#gs_pause').css({ 'display': 'none' });
        this.paused = true;
    }

    if (this.max_items == null) {
        this.max_items = 4;
    }

    if (this._thumb_switching == null) {
        this._thumb_switching = true;
    }
}