$(document).ready(function(){
    
    String.prototype.capitalize = function(){
        return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
    };
    function mycarousel_initCallback(carousel)
    {
     
        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };
    
    /* Slider Tab for community news */
    $('#slider_tab').show();
    $('#slider_tab').jshowoff({ 
        speed:15000,
        controls: true,
        hoverPause: false
        
    }); 
    
    /* Michif Word of the Day */
    $.ajax({
        url: "../resources/michifWordDay.txt",
        data: "text",
        success: function(data){
            var type = data.substring(0, data.indexOf("#", 0));
            data = data.substring(data.indexOf("#", 0)+1);
            var mySplitResult = data.split(":");
            var word = mySplitResult[0];
            var meaning = mySplitResult[1];
            $("#michifWord_Title").html("Michif: " + type.capitalize());
            $("#michifWordWord").html(word);
            $("#michifWordMeaning").html(meaning);
            $("#michifWord").slideToggle("slow");
         }
    });
    
    /* Carousel Element */
    jQuery('#mycarousel').jcarousel({
        vertical: true,
        scroll: 1,
        initCallback: mycarousel_initCallback
    });
});
