// JavaScript Document

(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign2 = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = (ph - ah) / 2;
	$(this).css('margin-top', mh);
	});
};
})(jQuery);


$(document).ready(function(){
	initSiteVerticalAlign();
	$(window).resize(function(){
		initSiteVerticalAlign();				  
	});
});


function initSiteVerticalAlign(){
	var windowHeigth = $(window).height();
	var siteHeigth = $('.site').height();
	if(windowHeigth > siteHeigth){
		$('.site').vAlign2();
		
		$('body').css({'background-position':'center center','overflow-y':'hidden'});
	}else{
		$('body').css({'background-position':'center top','overflow-y':'visible'});
	}
}


