$(function(){
	$('#menu .submenu > a').click(function(e){
		e.preventDefault();
		$(this).addClass('hoveri');
		$(this).parent().find('.sub').fadeIn(200);
	});
	$('#menu .submenu').mouseleave(function(){
		$(this).find('.sub').hide();
		$(this).find('a:first').removeClass('hoveri');
	});
	$('#search .text').focusin(function(){
		if ($(this).val() == $(this).attr('title'))
			$(this).val('');
	}).focusout(function(){
		if ($(this).val() == '')
			$(this).val($(this).attr('title'));
	});
	
	var toppad = 0;
	var iefix = false;
	if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
		iefix = true;
	}
	$(window).resize(function(){pageAlign();});
	$(window).load(function(){pageAlign();});
	pageAlign();
	function pageAlign() {
		if ($('#wrapper').height() < ($(window).height() + toppad)) {
			var height = ($(window).height() - $('#wrapper').height() + toppad)/2;
			$('#wrapper').css({'margin-top':height});
			if (iefix) {
				$('body').css('background-position', 'center '+(143+height));
			}
		} else {
			$('#wrapper').css({'margin-top':0});
			if (iefix) {
				$('body').css('background-position', 'center 143');
			}
		}
	}
});
