$(document).ready(function(){

	$("*").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});

	if($(".jshide").length) $(".jshide").hide();

	/* Fragments */

	if($(".tabs").length) {

		$(".tabs li > a.on").showFragment();

		$(".tabs li a").click(function(){
			var parent = $(this).parents(".tabs");
			$("li > a.on", parent).hideFragment();
			$(this).showFragment();
			return false;
		});

	}

	$("input, select, textarea").each(function(){

		$(this).focus(function(){
			$(this).showBalloon();
		});

		$(this).blur(function(){
			$("#"+$(this).attr("id")+"-balloon").css("visibility", "hidden");
		});
	});

	//$("form .error").showBalloon();

});

$.fn.showFragment = function() {
	var fragment = $(this).attr("href");
	$(this).addClass("on");
	$(fragment).show();
}

$.fn.hideFragment = function() {
	var fragment = $(this).attr("href");
	$(this).removeClass("on");
	$(fragment).hide();
}

$.fn.showBalloon = function() {

	var topoffset = Math.round(($(this).innerHeight()/2)+$(this).offset().top);
	var leftoffset = Math.round($(this).innerWidth()+$(this).offset().left);

	$("#"+$(this).attr("id")+"-balloon").css("visibility", "visible").css("top", topoffset-($("#"+$(this).attr("id")+"-balloon").innerHeight()/2)).css("left", leftoffset+5);

}