$(function() {   

        var theWindow        = $(window),
            $bg              = $("#large_bg, #background-screen"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('large_bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('large_bgwidth');
                }

				/*var width = ( theWindow.width() / 2 ) - ( $bg.innerWidth() / 2 );
				
				alert( width );
				
				$bg.css( { "left": "-" + width + "px" } );*/

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

		$( document ).ready( function(){
			$( ".entry-header-image" ).load( function(){
				var height = $( this ).height();
				var width = $( this ).width();
				
				var parentWidth = $( this ).parent().width();
				
				var resizeRatio = 1;	
				
				resizeRatio = parentWidth / width;
	      		
				var midPoint = ( height * resizeRatio ) / 2;
				
				$(this).css( { "top": "-" + midPoint + "px", "height":height*resizeRatio, "width":width*resizeRatio } );
			});
			
			$( ".entry-header-image" ).each( function(){
			var height = $( this ).height();
				var width = $( this ).width();
				
				var parentWidth = $( this ).parent().width();
				
				var resizeRatio = 1;	
				
				resizeRatio = parentWidth / width;
	      		
				var midPoint = ( height * resizeRatio ) / 2;
				
				$(this).css( { "top": "-" + midPoint + "px", "height":height*resizeRatio, "width":width*resizeRatio } );;
			});
			
			//$( "#contact_button" ).colorbox( {href:"http://www.gaboosh.com/contact.html"} );
			
		});

});
