/* 
  Javascript for Evocatio
  http://evo.cat.io/
*/


/**
 * Firestarter : Ignite stuff
 **************************************************************************************** */
$(document).ready(function(){

    /**
     * carouselh-bootstrap In case we have a carousel
     * 
     * "h" stands for Horizontal.
     **/
    if($('.carouselh-bootstrap').size() >= 1){
        $('body').append('<script defer src="/js/libs/jquery.jcarousel.min.js"></script>');
        $(".carouselh-bootstrap").jcarousel({
            auto: 5,
            vertical: false,
            wrap: "last",
            initCallback: jcarousel_loop
        });
    }
    /* /carouselh-bootstrap */
    
    /** See req-displaynonehero */
    if($(".hero-unit").css('display') == 'none'){
        $(".hero-unit").fadeIn(1000);
    }
    
    /* =nth-child-FIX  Clean way to mess with nth-child *v/
    $('section blockquote:nth-child(odd)').addClass('odd');
    $('section blockquote:nth-child(even)').addClass('even');
    $('section img.illustration:nth-child(odd)').addClass('odd');
    $('section img.illustration:nth-child(even)').addClass('even');
    */
   
    $(".scroll").click(function(event){
            //prevent the default action for the click event
            event.preventDefault();

            //get the full url - like mysitecom/index.htm#home
            var full_url = this.href;

            //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
            var parts = full_url.split("#");
            var trgt = parts[1];

            //get the top offset of the target anchor
            var target_offset = $("#"+trgt).offset();
            var target_top = target_offset.top;

            //goto that anchor by setting the body scroll top to anchor top
            $('html, body').animate({scrollTop:target_top}, 750);
    });
    
});
/* *************************************************************************************** *
 * /Firestarter : Ignite stuff
 **/




/**
 * Behaviors : All that is callable
 **************************************************************************************** */

/* ==|==== Behavior: Loop automatique jCarousel ========================================= */
function jcarousel_loop(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    
    
};
/* ==|==== /Behavior: Loop automatique jCarousel ======================================== */

/* *************************************************************************************** *
 * /Behaviors : All that is callable
 **/
