$(document).ready(function(){
    $('ul.main_menu li').hover(
        function() {
            if($(this).parent().parent().attr('id')=='rodape_content'){
                var topVal = $('ul.submenu', this).height()+20;
                $('ul.submenu', this).css('top',-topVal);
                $('ul.submenu', this).show('slide',{ direction: 'down' });
            } else
                $('ul.submenu', this).show('slide',{ direction: 'up' });
        },function() {
            if($(this).parent().parent().attr('id')=='rodape_content'){
                $('ul.submenu', this).hide('slide', { direction: 'down' });
            } 
            else
                $('ul.submenu', this).hide('slide', { direction: 'up' });
        }
    );

    $('.list_prod li a').hover(
        function(){
            $(this).parent().css('background-position','0 -250px');
        },function(){
            $(this).parent().css('background-position','0 0');
        }
    );
    
    var complement_w = $(document).width() - 930;
    if(complement_w > 0) $('.header_complement, .footer_complement').width(complement_w);


    //para tirar esse evento do formulário, coloque a classe "edit" na tag form
    $('form.change_default').each(function(){
        var $form= $(this);

        $form.find('input[type=text], textarea')
        .focus(function(){
           var $entTxt = $(this);
           if($.trim($entTxt.val()) == this.defaultValue)
                $entTxt.val('');
        })
        .blur(function(){
            var $entTxt = $(this);
            if($.trim($entTxt.val())=='')
                $entTxt.val(this.defaultValue);
        });
    });

    if($('#ban_slides').size() && $('#ban_slides').children().size()>1){
        $('#ban_slides').after('<div id="ban_pager_buttom"></div>').cycle({
            fx: 'fade',
            pager: '#ban_pager_buttom'
        });
    }
    if($("#info_prod .info .pane").size())
        $('#info_prod .info .pane').jScrollPane({showArrows: true, topCapHeight: 115, bottomCapHeight: 30, scrollbarWidth: 10, arrowSize: 10,scrollbarMargin: 0, dragMinHeight: 14, dragMaxHeight: 30});

    if($("#loadLojas").size())
        $("#loadLojas").click(function(){
            get_uf = $("#uf").val();
            var type = "onde-encontrar";
            if($(this).text()=='listar representantes'){
                type='representantes';
            }
            if(get_uf != '')
                this.href = type+'/uf+'+get_uf+'/';
    });
    $('.ItemPhoto:last').removeClass('ItemPhoto').addClass('ItemPhoto_last');
    var list_prod_cont = 3;
    $('.list_prod li').each(function(){

        $this = $(this);

        if(list_prod_cont==0){
            list_prod_cont = 3;
            $this.addClass('last');
        }
        else{
            if($this.hasClass('duplo')){
                list_prod_cont = list_prod_cont -2;
            }
            else{
                list_prod_cont = list_prod_cont -1;
            }
        }


    });

});
