var GAL = {

    nav_bar_qual: 'thu',
    /* nav_bar_todos: {'thu': 0, 'com': 148, 'env': 300, 'adq': 450}, */
	nav_bar_todos: {'thu': 0, 'com': 148},

    ant_prox: function (){

        this.ant = this.qual - 1;
        this.prox = this.qual + 1;

        if (this.ant == 0){
        this.ant = '/' + this.total;
        }else if (this.ant == 1){
        this.ant = '';
        }else{
        this.ant = '/' + this.ant;
        }

        if (this.prox > this.total){
        this.prox = '';
        }else{
        this.prox = '/' + this.prox;
        }

    },

    nav_bar_go: function (qual){

        if (qual != this.nav_bar_qual){

            for (x in this.nav_bar_todos){

                if (x != qual){

                    $('hold_' +x).style.display = 'none';

                }else{

                    $('hold_' +x).style.display = 'inline';
                    this.nav_bar_qual = qual;
                    $('gal_nav_img').tween ('left', this.nav_bar_todos[qual]);

                }

            }

        }

    },

    nav_bar_links: function (){

        for (x in this.nav_bar_todos){

            $('gal_sec_' +x).addEvents({

                'click': function (){

                    var split = this.id.split('_');
                    GAL.nav_bar_go (split[2]);

                }

            });

        }

    },

    pg: function (pg){

        if (pg == 1){
        window.location = this.url;
        }else{

           var foto = (((pg - 1) * this.limite) + 1);
           window.location = this.url + '/' + foto;

        }

    },

    set: function (){

        this.ant_prox ();
        this.nav_bar_links ();
        this.thumb_links ();

        $(document.body).getElements('.gal_off').addEvents({

            'mouseenter': function(){
            this.className = 'ops img gal_on';
            },

            'mouseleave': function(){
            this.className = 'ops img gal_off';
            }

        });

        $('gal_seta_left').addEvents({

            'click': function(){
            window.location = GAL.url + GAL.ant;
            },

            'mouseenter': function(){
            this.className = 'on';
            },

            'mouseleave': function(){
            this.className = 'off';
            }

        });

        $('gal_seta_dir').addEvents({

            'click': function(){
            window.location = GAL.url + GAL.prox;
            },

            'mouseenter': function(){
            this.className = 'on';
            },

            'mouseleave': function(){
            this.className = 'off';
            }

        });

    },

    thumb_links: function (){

        $('gal_thumb_ul').getElements('li').each (function(el){

            var dados = el.id.split ('_');

            if (dados[1] != 'banner' && dados[1] != GAL.qual){

                el.addEvents({

                    'click': function(){
                    window.location = GAL.url + '/' + dados[1];
                    }

                });

            }

        });

    }

};
