$(window).load(function() {
    
    // Calculate if we need to start the slider
    var bodyWidth = $('body').width();
    $(this).data('slider', false);
    if (bodyWidth >= 768) {
        //initiate slider    
        $('.flexslider').flexslider({
            animation: "fade",
            slideDirection: "horizontal",
            slideshow: true,
            slideshowSpeed: 11000,
            animationDuration: 600,
            directionNav: true,
            controlNav: false,
            randomize: false,
            animationLoop: true,
            pauseOnAction: true,
            pauseOnHover: true
        });
    } else {
        $(window).resize(function() {
            var newBodyWidth = $('body').width();
            if (newBodyWidth >= 768) {
                var flag = $(this).data('slider');
                if (!flag) {
                    //initiate slider    
                    $('.flexslider').flexslider({
                        animation: "fade",
                        slideDirection: "horizontal",
                        slideshow: true,
                        slideshowSpeed: 11000,
                        animationDuration: 600,
                        directionNav: true,
                        controlNav: false,
                        randomize: false,
                        animationLoop: true,
                        pauseOnAction: true,
                        pauseOnHover: true
                    });
                    $(this).data('slider', true);
                }
            }
        });
    }

    //$('.flexslider').flexslider({
        //animation: "fade",
        //slideDirection: "horizontal",
        //slideshow: true,
        //slideshowSpeed: 11000,
        //animationDuration: 600,
        //directionNav: true,
        //controlNav: false,
        //randomize: false,
        //animationLoop: true,
        //pauseOnAction: true,
        //pauseOnHover: true
    //});
});

