var NATURA = {
    _init: function() {
        try {
            NATURA._cufon();
            NATURA._isValidBrowser();
            NATURA._subMenu();
            NATURA._siteMap();
            NATURA._selectBox();
            NATURA._startTwitter();
            NATURA._maskFormLogin();
            NATURA._maskFormTwoInput();
            NATURA._tabs();
            NATURA._drop_list();
            NATURA.uiTabs();
            NATURA._loader();
            NATURA._externalLink();
            NATURA._ativaCheckbox();
            NATURA.carrossel();

        } catch (e) {
            if (e) {
                alert(e.description);
            }
        };
    },
    _cufon: function() {

        Cufon.replace('.gillSansTitMenu', { fontWeight: 300, fontSize: '27px', forceHitArea: true });
        Cufon.replace('.gillSans16', { fontWeight: 300, fontSize: '16px', forceHitArea: true });
        Cufon.replace('.gillSans15Light', { fontWeight: 'light', fontSize: '15px', letterSpacing: '1px', forceHitArea: true });
        Cufon.replace('.gillSans16LightHover', { fontWeight: 'light', fontSize: '16px', letterSpacing: '2px', forceHitArea: true, hover: { color: '#C10808'} });
        Cufon.replace('.gillSans16Light', { fontWeight: 'light', fontSize: '16px', letterSpacing: '2px', forceHitArea: true });
        Cufon.replace('.gillSans16LightRed', { fontWeight: 'light', fontSize: '16px', letterSpacing: '2px', color: '#ce1126', forceHitArea: true });
        Cufon.replace('.gillSans24Light', { fontWeight: 'light', fontSize: '24px', forceHitArea: true });
        Cufon.replace('.gillSans19Light', { fontWeight: 'light', fontSize: '19px', forceHitArea: true });
        Cufon.replace('.gillSans20Light', { fontWeight: 'light', fontSize: '20px', forceHitArea: true });
        Cufon.replace('.gillSans24Light', { fontWeight: 'light', fontSize: '24px', forceHitArea: true });
        Cufon.replace('.gillSans26Light', { fontWeight: 'light', fontSize: '26px', forceHitArea: true });
        Cufon.replace('.gillSans16Bold', { fontWeight: 'bold', fontSize: '16px', forceHitArea: true });
        Cufon.replace('.gillSans13', { fontWeight: 'normal', fontSize: '13px', forceHitArea: true });
        Cufon.replace('.gillSans14', { fontWeight: 'normal', fontSize: '14px', forceHitArea: true });
        Cufon.replace('.gillSans14Bold', { fontWeight: 600, fontSize: '14px', forceHitArea: true });
        Cufon.replace('.gillSans18Light', { fontWeight: 'light', fontSize: '18px', forceHitArea: true });
        Cufon.replace('.gillSans11Light', { fontWeight: 'light', fontSize: '11px', forceHitArea: true });
        Cufon.replace('.gillSans11LightRed', { fontWeight: 'light', fontSize: '11px', color: '#C10808', forceHitArea: true });
        Cufon.replace('.gillSans16LightHover', {
            fontWeight: '300',
            fontWeight: 'light',
            fontSize: '16px', hover: { color: '#C10808' }
        });
        Cufon.replace('.gillSansModal', { fontWeight: 'light', fontSize: '18px' });

    },
    _isValidBrowser: function() {
        if (jQuery.browser.msie && (Math.round(parseFloat(jQuery.browser.version)) == 6)) {
            $('.browser_suport').css('display', 'block').animate({ top: -80 }, 500);
            $($('body')[0]).css('position', 'relative').animate({ marginTop: 80 }, 500);
        }
    },

    _startCarosel: function() {
        var $j = jQuery.noConflict();
        $j(document).ready(function() {
            $j('#mycarousel').jcarousel();
        });
    },

    _subMenu: function() {
        $(document).ready(function() {
            $("ul.submenu").superfish({
                pathClass: 'overideThisToUse',
                hoverClass: 'sfHover',
                delay: 1000,                            // one second delay on mouseout 
                animation: { opacity: 'show', height: 'show' },  // fade-in and slide-down animation 
                speed: 'fast'                          // faster animation speed                 

            });
        })
    },

    _selectBox: function() {
        $('#menuSelection').menu({
            content: $('#menuSelection').next().html(),
            showSpeed: 400
        });
    },

    _siteMap: function() {
        $("a.bt_sitemap").toggle(function() {
            $("div.content_sitemap").hide()
				    .parent()
				    .find('a.bt_sitemap')
				    .addClass('mais');

        }, function() {
            $("div.content_sitemap").show()
			    .parent()
			    .find('a.bt_sitemap')
			    .removeClass('mais');



            var b = $('body')[0];


            $(b).scrollTo('100%', 200, { queue: true })



        });
    },

    _startTwitter: function() {
        $("#twitter").getTwitter({
            userName: "sitedamarca",
            numTweets: 4,
            loaderText: "Loading tweets...",
            slideIn: true,
            slideDuration: 750,
            showHeading: true,
            headingText: "TWITTER",
            showProfileLink: true,
            showTimestamp: false
        });
    },

    _maskFormLogin: function() {
        $(document).ready(function() {
            $('.password-limpar').show();
            $('.password-senha').hide();

            $('.password-limpar').focus(function() {
                $('.password-limpar').hide();
                $('.password-senha').show();
                $('.password-senha').focus();
            });

            $('.password-senha').blur(function() {
                if ($('.password-senha').val() == '') {
                    $('.password-limpar').show();
                    $('.password-senha').hide();
                }
            });
        });
    },

    _maskFormTwoInput: function() {
        $(document).ready(function() {
            $('.password-limpar1').show();
            $('.password-senha1').hide();

            $('.password-limpar1').focus(function() {
                $('.password-limpar1').hide();
                $('.password-senha1').show();
                $('.password-senha1').focus();
            });

            $('.password-senha1').blur(function() {
                if ($('.password-senha1').val() == '') {
                    $('.password-limpar1').show();
                    $('.password-senha1').hide();
                }
            });
        });
    },

    _loader: function() {
        var div = $('#loading_progress').css({ position: 'absolute' });
        //alert('#loading_progress');
        $(document).mousemove(function(e) {
            div.css({ top: (e.pageY + 18), left: (e.pageX + 18) });
            //alert('#loading_progress');
        });
    },

    _tabs: function() {
        $('.tabs').each(function() {
            var tab = $(this),
				nav = $(this).find('.tabs_nav'),
				nav_li = nav.find('li'),
				content = $(this).find('.tabs_content');

            nav_li.each(function(x) {
                $(this).find('a.linktab').live('click', function() {
                    if ($(this).attr('rel') == 'open-others') {
                        tab.find('.drop_list').show();
                        NATURA._drop_list();
                    } else {
                        tab.find('.drop_list').hide();
                    };
                    nav.find('a.linktab').removeClass('selected');
                    nav.find('a.linktab').parent().removeClass('border_bottom_none').removeClass('nodash');
                    $(this).addClass('selected');
                    $(this).parent().addClass('border_bottom_none');

                    if (!$(this).parent().is(".tabs .tabs_nav li:first-child"))
                        $(this).parent().prev().addClass("nodash");

                    content.removeClass('show').eq(x).addClass('show');
                    // return false;
                });
            });
        });
    },
    _drop_list: function() {

        $(".drop_list ol>li").live('mouseover', function() {
            $(".drop_sub", this).show()
        });

        $(".drop_list ol>li").live('mouseout', function() {
            $(".drop_sub", this).hide()
        });
    },

    /* aplicado destaque de produtos */
    uiTabs: function() {
        $('#tabvanilla  ul.tabnav').tabs({ fx: { width: 'toggle', opacity: 'toggle'} });
        $('#featuredvid > ul').tabs();
        /* inserir funcao no callback quando for implemantar  a alteração da lista de produtos*/
    },

    _ativaCheckbox: function() {
        $('.radioTipoArquivo input').each(function(index) {

            $(this).click(function() {
                if ($(this).attr('checked')) {
                    $('.radioTipoArquivo label').eq(index).addClass('inputAtivo');
                }
                else {
                    $('.radioTipoArquivo label').eq(index).removeClass();
                }
            })
        })
    },

    /* aplicado na lista de produtos  */
    carrossel: function() {

        $('.SlideShow_area').carrossel({
            time: 0.8,
            delay: 2,
            easing: 'easeInOutQuint',
            controls: {
                pause: $('.SlideShow_area').parent().parent().find('.content_control a.bt_pause'),
                next: $('.SlideShow_area').parent().parent().find('.content_control a.bt_next'),
                prev: $('.SlideShow_area').parent().parent().find('.content_control a.bt_prev')
            },
            direction: 'left',
            loop: true,
            autoStart: true
        });

        $('#post_SlideShowArea .bt_pause').HAS



        $('#post_SlideShowArea .sliderArea').carrossel({
            autoStart: true,
            time: 0.8,
            delay: 2,
            easing: 'easeInOutSine',
            loop: true,
            direction: 'left',
            onStarted: function() {
                $('#post_SlideShowArea .count_indice').html('');
                $('#post_SlideShowArea .post_desc .total').html(this.childLength);

                for (c = 0; c < this.childLength; c++) {
                    $('#post_SlideShowArea .count_indice').append('<a href="#" rel="' + c + '">' + (c + 1) + '</a>' + "\n");
                    $($('#post_SlideShowArea .post_desc .count')[c]).html(c + 1);
                }
                var s = this;

                if ($('#post_SlideShowArea .bt_pause').hasClass('bt_playAtivo')) {                    
                    s.pause();
                }


                $('#post_SlideShowArea .count_indice a').click(function(e) {
                    e.preventDefault();
                    s.goToSlide(Number($(this).attr('rel')));
                });



                $('#post_SlideShowArea .bt_pause').click(function(e) {
                    e.preventDefault();
                    s.pause();

                    if ($(this).hasClass('bt_playAtivo')) {
                        $(this).removeClass('bt_playAtivo');

                    }
                    else {
                        $(this).addClass('bt_playAtivo');

                    }

                });

                $('#post_SlideShowArea .bt_next').click(function(e) {
                    e.preventDefault();
                    s.nextSlide();
                });

                $('#post_SlideShowArea .bt_prev').click(function(e) {
                    e.preventDefault();
                    s.prevSlide();
                });
            },
            onChanged: function(slide) {
                $('#post_SlideShowArea .count_indice a').each(function(i) {
                    $(this).removeClass('desactived').removeClass('actived');

                    if (i == slide)
                        $(this).addClass('actived');
                    else if (i > slide)
                        $(this).addClass('desactived');
                });
            }
        });


    },

    _externalLink: function() {
        var a = $("a[rel='external-link']");
        if (a.length > 0) {
            for (var x = 0; x < a.length; x++) { a.eq(x).attr('target', '_blank') };
        };
    }
}

$(document).ready(function() {
    NATURA._init();
    //alert('pat');
});


function comentarioOpenClose(thisItem) {
    $(document).ready(function() {
        $(thisItem).each(function() {
            $(this).parent().parent().next().slideToggle('slow');
        })
    })
}

function openPopup(url, n, w, h, s) {
    window.open(url, n, "width=" + w + ",height=" + h + ",scrollbars=" + s + ", top=" + (screen.height - h) / 2 + ",left=" + (screen.width - w) / 2);
}



