(function($) {
    // plugin definition
    var elements;
    $.fn.Resize = function() {
    elements = this;
        $(document).ready(function() {
            $("img", elements).each(function() { resizeImage(this); });
        });

        $(window).load(function() {
            $("img", elements).each(function() { resizeImage(this); });
        });

        $(window).bind("resize", function() {
            $("img", elements).each(function() { resizeImage(this); });
        });
    }

    function resizeImage(cnr) {
        var width = "auto";
        var height = "100%";
        if ($(cnr).width() > 1280 || $(cnr).height() < $(window).height()) {
            width = "auto";
            height = "100%";
        }
        else if ($(cnr).width() <= 1280) {
            $(cnr).width(1280);
            width = "1280px";
            height = "auto";
        }

        $(cnr).css({ 'display': 'block', 'left': '-10000px', 'position': 'fixed' })
        $(cnr).css({
            'left': (($(window).width() - $(cnr).width()) / 2) + 'px',
            'width': width,
            'height': height,
            'position': 'fixed'
        });
    }
})(jQuery);
