/* 
 * JAVASCRIPT
 * @AUTHOR Tiago Marciano | www.tiagomarciano.com
 * @MAIL thiagomarciano@gmail.com
 */

/**
 * CASCATA
 */
var scrollSpeed  = 20;
var step         = 1;
var current      = 0;
var imageHeight  = 4300;
var headerHeight = 300;

var restartPosition = -(imageHeight - headerHeight);

function scrollBgHeader(){
    current += step;
    if (current == restartPosition){
        current = 0;
    }
    $('#header').css("background-position","0 "+current+"px");
}

var init = setInterval("scrollBgHeader()", scrollSpeed);


/**
 * DOM EVENTS
 */
$(function() {
    
    /**
     * MENU
     */
    $('#sdt_menu > li').bind('mouseenter',function(){
        var $elem = $(this);
        $elem.find('img')
        .stop(true)
        .animate({
            'width':'195px',
            'height':'170px',
            'left':'0px'
        },400,'easeOutBack')
        .andSelf()
        .find('.sdt_wrap')
        .stop(true)
        .animate({
            'top':'140px'
        },500,'easeOutBack')
        .andSelf()
        .find('.sdt_active')
        .stop(true)
        .animate({
            'height':'170px'
        },300,function(){
            var $sub_menu = $elem.find('.sdt_box');
            if($sub_menu.length){
                var left = '195px';
                if($elem.parent().children().length == $elem.index()+1)
                    left = '-195px';
                $sub_menu.show().animate({
                    'left':left
                },200);
            }
        });
    }).bind('mouseleave',function(){
        var $elem = $(this);
        var $sub_menu = $elem.find('.sdt_box');
        if($sub_menu.length)
            $sub_menu.hide().css('left','0px');

        $elem.find('.sdt_active')
        .stop(true)
        .animate({
            'height':'0px'
        },300)
        .andSelf().find('img')
        .stop(true)
        .animate({
            'width':'0px',
            'height':'0px',
            'left':'85px'
        },400)
        .andSelf()
        .find('.sdt_wrap')
        .stop(true)
        .animate({
            'top':'25px'
        },500);
    });
            
 
    /**
     * SLIDE BOX
     */                        
    $('.boxgrid.slideright').hover(function(){
        $(".cover", this).stop().animate({
            top:'325px'
        },{
            queue:false,
            duration:300
        });
    }, function() {
        $(".cover", this).stop().animate({
            top:'0px'
        },{
            queue:false,
            duration:300
        });
    });
    
    
    /**
     * VERIFICAÇÃO DE BROWSER
     */
    var browser = navigator.appName;
                    
    if (browser == 'Microsoft Internet Explorer')
    {
        //alert('Você está usando um navegador desatualizado.\n\nPara ter uma melhor experiência neste site, atualize seu navegador.\nUse um navegador novo e mais rápido como: \n\nChrome | Firefox | Safari | IE9');
    }
    
    /**
     * HOVER EFFECTS
     */
    $('#patrocinios img, .designed a, #social_box li a img').fadeTo("slow", 1.0);
    
    $('#patrocinios img, .designed a, #social_box li a img').hover(function(){
        $(this).fadeTo("slow", 0.6);
    }, function(){
        $(this).fadeTo("slow", 1.0);
    });
    
        
})
