$(function(){
	var $height = Math.round(screen.height * 0.7);
	/* $("#contents").css("max-height", $height + "px"); */ 
	$("#banner").fadeIn("fast");
	$("div.submenu:visible").hide();
	$("div.menu").corner("fray");
	/* $("div.top_parts").corner("round 5px"); */
	$("#loading").hide();
	$("#contents_loading").hide();
	
	/* $("#leftpane").one('load', function(){
		$paneHeight = $("#leftpane").css('height');
    	$("#rightpane").css('height', $paneHeight);
	}); */

	$("div.menu").not("#name_search").not("#id_search").hover(function(){
		$(this).fadeTo("normal", 0.5);
	}, function(){
		$(this).fadeTo("normal", 1.0);
	});

	$("div.menu,div.submenu").filter("#menu_top,#menu_handi,#menu_news,#menu_shop").click(function(){
		$("#top:visible").hide();
		$("#contents").empty();
		$("#handi:visible").hide();
		$("div.close:visible").hide();
	});

	$("div.submenu").hover(function(){
		$(this).fadeTo("normal", 0.5);
	}, function(){
		$(this).fadeTo("normal", 1.0);
	});

	$("#menu_top").click(function(){
		$("#top:hidden").show();
		return false;
		/* location.reload(); */
	});

	$("#menu_handi").click(function(){
		$("#contents_loading:visible").hide();
		$("div.close:hidden").show();
		$("#handi").show();
		return false;
	});
		
	$("#menu_result").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkresult.php';
	});

	$("#menu_ranking").click(function(){
		location.href = location.protocol + '//' + location.host + '/ranking.html';
	});

	$("#menu_all_player").click(function(){
		location.href = location.protocol + '//' + location.host + '/all_player.html';
	});

	$("#menu_nineR").click(function(){
		location.href = location.protocol + '//' + location.host + '/9rresult.html';
	});

	$("#menu_best10m").click(function(){
    	$("#menu_best10m_3k").slideToggle("normal");
    	$("#menu_best10m_10k").slideToggle("normal");
    	$("#menu_best10m_15k").slideToggle("normal");
    	$("#menu_best10m_30k").slideToggle("normal");
		return false;
	});

	$("#menu_best10m_3k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10mona.html';
	});

	$("#menu_best10m_10k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10monb.html';
	});

	$("#menu_best10m_15k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10monc.html';
	});

	$("#menu_best10m_30k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10mond.html';
	});

	$("#menu_best10").click(function(){
    	$("#menu_best10_3k").slideToggle("normal");
    	$("#menu_best10_10k").slideToggle("normal");
    	$("#menu_best10_15k").slideToggle("normal");
    	$("#menu_best10_30k").slideToggle("normal");
		return false;
	});

	$("#menu_best10_3k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10a.html';
	});

	$("#menu_best10_10k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10b.html';
	});

	$("#menu_best10_15k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10c.html';
	});

	$("#menu_best10_30k").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkbest10d.html';
	});

	$("#menu_rule").click(function(){
		location.href = location.protocol + '//' + location.host + '/rule.html';
	});

	$("#menu_reg_edit").click(function(){
    	$("#menu_register").slideToggle("normal");
    	$("#menu_rename").slideToggle("normal");
    	$("#menu_sendpass").slideToggle("normal");
		return false;
	});
	
	$("#menu_register").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkregister.php';
	});

	$("#menu_rename").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkrename.php';
	});

	$("#menu_sendpass").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkmail_passwd.php';
	});

	$("#menu_rename_history").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkrename.html';
	});

	$("#menu_bbs").click(function(){
		location.href = location.protocol + '//' + location.host + '/bbs/wforum.cgi';
	});

	$("#menu_statistics").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkstatistics.html';
	});

	$("#menu_statistics2").click(function(){
		location.href = location.protocol + '//' + location.host + '/tkstatistics2.html';
	});

	$("#menu_news").click(function(){
		$("div.close:hidden").show();
		$("#contents_loading:hidden").show();
		$("#contents").empty()
		/* .css("min-height", "2000px") */
		.load("news.php", "", function () {
			$("#contents_loading:visible").hide("slow");
		})
		.show("fast");
	});

	$("#menu_shop").click(function(){
		$("div.close:hidden").show();
		$("#contents").empty().load("shop.utf8.html").show();
	});

	$("#show_recent_games_detail").click(function(){
		$("#top:visible").hide();
		$("#handi:visible").hide();
		$("#contents").empty().load("result.html").show();
		$("div.close:hidden").show();
		return false;
	});
	
	$("div.close").click(function(){
		$("#contents").hide();
		$("#handi:visible").hide();
		$("#top:hidden").show();
		$("div.close:visible").hide();
		return false;
	});
	
});