/*
CSS for image
{
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}
*/
(function ($) {
    $.fn.fullBackground = function () {
        var image = $(this);

        function resizeBackground() {
            var imgwidth = image.width();
            var imgheight = image.height();

            var winwidth = $(window).width();
            var winheight = $(window).height();

            var widthratio = winwidth / imgwidth;
            var heightratio = winheight / imgheight;

            var widthdiff = heightratio * imgwidth;
            var heightdiff = widthratio * imgheight;

            if (heightdiff > winheight) {
                image.css({
                    width: winwidth + 'px',
                    height: heightdiff + 'px'
                });
            } else {
                image.css({
                    width: widthdiff + 'px',
                    height: winheight + 'px'
                });
            }
        }
        resizeBackground();
        $(window).resize(function () {
            resizeBackground();
        });
    };
})(jQuery)
