/*!
 * Subtle Effect helper JS
 * Copyright (c) 2014 Intense Visions, Inc.
 */
/* global jQuery */

(function($) {
    'use stict';

    function responsiveSubtle() {
        $('.intense.subtle-effect').each(function() {
            var $el = $(this);
            var width = $el.width();
            var $img = $('.subtle-effect-img', $el);
            var $figcaption = $('.subtle-effect-caption', $el);
            var imgheight = $img.attr( 'height' );
            var imgwidth = $img.attr( 'width' );
            var aspectRatio = imgheight / imgwidth;
            var outerHeight = width * aspectRatio;
            var newimgWidth = width * 1.15;
            var newimgHeight = newimgWidth * aspectRatio;

            $el.css( { height : outerHeight + 'px' } );
            $figcaption.css( { height : outerHeight + 'px' } );
            $img.css( { width: newimgWidth + 'px' } );
            $img.css( { maxWidth: newimgWidth + 'px' } );
            $img.css( { height: newimgHeight + 'px' } );
        });
    }

    $(document).ready(function() {
        setTimeout( function() {
                responsiveSubtle();
                $('.intense.subtle-effect').show();
        }, 250);        

        $(window).resize(function() {
            responsiveSubtle();
        });
    });
})(jQuery);
