// Initialization
$.valign = {
	init: function() {
		for (module in $.valign) {
			if ($.valign[module].init)
				$.valign[module].init();
		}
	}
};

$(document).ready($.valign.init);


$.valign.fn = {
	init: function() {
		$(window)
			.bind('resize', this.resize)
			.each(this.preload);
	},
	preload: function() {adjust()},
	resize: function() {adjust()}
};

function adjust(){
	var ah = $('#wrapper').height()+80;
	var ph = $(window).height();
	var mh = (ph - ah) / 2;
	var of=0;
	mh=(0<mh)?mh:0;
	of=(ph<620)?'scroll':'hidden';
	if($('#text').size() && $('#container').size()){
		var ch=$('#container').height();
		var th=$('#text').height()+96;
		of=(ch<th)?'scroll':'hidden';
//		console.log(of);
	}
//	of=(ah-80<ph)?'hidden':'scroll';
//	alert($('#container').outerHeight({margin:true}));
	$('#wrapper').css({'padding-top':mh});
//	$('#wrapper').css({'top':mh,'height':wh,'overflow-y':of});
//	$('#wrapper').css({'top':mh});
	if(!$.browser.safari){
		$('#page').css({'overflow-y':of});
	}else{
		$('body').css({'overflow-y':of});
	}
}


