(function ($) {
	$.fn.vAlign = function() {
		return this.each(function(i){
			var h = $(this).height();
			var oh = $(this).outerHeight();
			var mt = (h + (oh - h)) / 2;
			if ($("body").height()<h) {
				$(this).css("margin-top", 0);
				$(this).css("top", 0);
				$(this).css("position", "relative");
			}
			else {
				$(this).css("margin-top", "-" + mt + "px");
				$(this).css("top", "50%");
				$(this).css("position", "absolute");
			}
		});
	};
})(jQuery);

(function ($) {
	$.fn.hAlign = function() {
		return this.each(function(i){
			var w = $(this).width();
			var ow = $(this).outerWidth();
			var ml = (w + (ow - w)) / 2;
			if ($("body").width()<w) {
				$(this).css("margin-left", 0);
				$(this).css("left", 0);
				$(this).css("position", "relative");
			}
			else {
				$(this).css("margin-left", "-" + ml + "px");
				$(this).css("left", "50%");
				$(this).css("position", "absolute");
			}
		});
	};
})(jQuery);

function dontFocus() {
	$("a").focus(function() {
		$(this).blur();
	});	
	$("input.send").focus(function() {
		$(this).blur();
	});	
}

function fixPengs() {
	$("#logo a img").pngfix();
	$("#container").pngfix();	
	$("#menu ul li a").pngfix();	
	$("#submenu").pngfix();
}

function fitAll() {
	return;
	$("#wholepage").vAlign();
	$("#wholepage").hAlign();
}

function addOnResize() {
	window.onresize = function() {
		fitAll();							  
	}
}

$(document).ready(function() {
	if ($.browser.msie) {
		if(parseInt($.browser.version)<7) {	// < IE 7
			fixPengs();
		}
	}
	fitAll();
	addOnResize();
	addOnclicks();
	dontFocus();
});