function adjustRatio(){
	var image = $('#gallery');
    
    var ratio = Math.max($(window).width()/image.width(),$(window).height()/image.height());
	
	if ($(window).width() > $(window).height()) {
		image.css({width:image.width()*ratio,height:'auto'});
	} else {
		image.css({width:'auto',height:image.height()*ratio});
	}
	
}

$(document).ready(function() {
	
	$("#accordion").tabs();
	
	$('#gallery').load( function(){ adjustRatio(); } );
	
	$(window).resize(function(){
  		adjustRatio();
	});
	
	$("#accordion").tabs();
	
});
