(function($){
	var origDiv = '#origDiv';
	var origImg = '#origDiv img';
	
	//resize the image on brower load
	$(document).ready(function() {
		$(origDiv).resizeImg();
	});
	//resize the image on browser resize
	$(window).bind("resize", function() {
		$(origDiv).resizeImg();
	});
    
    //Adjust image size
    $.fn.resizeImg = function() {
        //define original width and height of the image
        var imgWidth = $(origImg).attr('width');  
        var imgHeight = $(origImg).attr('height');
        //define image ratio
        var ratio = imgHeight/imgWidth;
        //get browser dimensions
        var winWidth = $(window).width();
        var winHeight = $(window).height();
		var winRatio = winHeight/winWidth;
        //resize the image
        if (winRatio > ratio) {
            $(this).height(winHeight);
            $(this).width(winHeight / ratio);
            $(this).children().height(winHeight);
            $(this).children().width(winHeight / ratio);
        } else {
            $(this).width(winWidth);
            $(this).height(winWidth * ratio);
            $(this).children().width(winWidth);
            $(this).children().height(winWidth * ratio);
        }

    };
})(jQuery);


