$(function(){

	// vertically align function
	$.fn.vAlign = function() {
		return this.each(function(i){
		var ah = $(this).height();
		var ph = $(this).parent().height();
			if(ph >= ah){
				var mh = (ph - ah) / 2;
				$("body").css('overflow', 'hidden');	
				$(this).css('margin-top', mh);	
				//$("body").css('margin-top', mh);	
			} else {
				$(this).css('margin-top', 10);
			}
		var aw = $(this).width();
		var pw = $(this).parent().width();
			if(pw >= aw){
				var mw = (pw - aw) / 2;
				$("body").css('overflow', 'hidden');	
				$(this).css('margin-left', mw);	
			} else {
				$(this).css('margin-top', 10);
			}
		});
	};

});

/* call jquery on ready */
$(document).ready(function(){
	$("#container").vAlign();
});

/* call jquery on resize */
$(window).bind('resize', function(){	
	$("#container").vAlign(); 
});

