$(function(){
$("#header").load("/module/header.tpl");
$("#sidebar").load("/module/sidebar.php");
$("#login").load("/module/login.php");
$("#footer").load("/module/footer.tpl");

$("#topSubMenu1").load("/module/mainSubMenu1.php");
$("#topSubMenu2").load("/module/mainSubMenu2.php");
$("#topSubMenu3").load("/module/mainSubMenu3.php");
$("#topSubMenu4").load("/module/mainSubMenu4.php");
$("#topSubMenu5").load("/module/mainSubMenu5.php");
$("#topSubMenu6").load("/module/mainSubMenu6.php");
});
$(function(){
	$("body,th,td").css("font-size",$.cookie('fsize'));
});
function font(size){
	$("body,th,td").css("font-size",size);
	$.cookie("fsize",size,{expires:30,path:'/'});
	switch($.cookie('fsize')) {		
		case '12px':
			$("#fnormal").css("background","url('/image/fch_n.gif') no-repeat bottom");
			$("#flarge").css("background","url('/image/fch_b.gif') no-repeat top");
		break;
		
		case '16px':
			$("#fnormal").css("background","url('/image/fch_n.gif') no-repeat top");
			$("#flarge").css("background","url('/image/fch_b.gif') no-repeat bottom");
		break;				
	}	
	
}

if($.cookie('fsize') == '16px') {
	$("#fnormal").css("background","url('/image/fch_n.gif') no-repeat top");
	$("#flarge").css("background","url('/image/fch_b.gif') no-repeat bottom");
} else {
	$("#fnormal").css("background","url('/image/fch_n.gif') no-repeat bottom");
	$("#flarge").css("background","url('/image/fch_b.gif') no-repeat top");
}
var timer = 0;
var mOver = false;	
var menuId = "";
function overMenuBtn(id) {	
	noDisplayMenu();
	menuOver(id);
}
function outMenuBtn(id) {	
	mOver = false;	
	if(!timer){
		timer = setInterval("checkMenuBlock()",100);
	}
}
function menuOver(id){
	mOver = true;	
	menuId = id;	
	id = "menuBlock"+id;	
	var menuObject = document.getElementById(id);	
	menuObject.style.display = "block";		
	switch(id) {
		case 'menuBlockAbout':
			document.getElementById('About').style.background = "url('/image/menu/gMenu1.gif') no-repeat bottom";
		break;

		case 'menuBlockSearch':
			document.getElementById('Search').style.background = "url('/image/menu/gMenu2.gif') no-repeat bottom";
		break;

		case 'menuBlockKnow':
			document.getElementById('Know').style.background = "url('/image/menu/gMenu3.gif') no-repeat bottom";
		break;
	}
}
function menuOut(id){
	outMenuBtn(id);
}
function checkMenuBlock(){
	if(!mOver){	
		noDisplayMenu();
	}
}
function noDisplayMenu() {
	if(menuId) {
		id = "menuBlock" + menuId;	
		menuObject = document.getElementById(id);	
		menuObject.style.display = "none";		
		menuId = "";	
		switch(id) {
			case 'menuBlockAbout':
				document.getElementById('About').style.background = "url('/image/menu/gMenu1.gif') no-repeat top";
			break;
			case 'menuBlockSearch':
				document.getElementById('Search').style.background = "url('/image/menu/gMenu2.gif') no-repeat top";
			break;
			case 'menuBlockKnow':
				document.getElementById('Know').style.background = "url('/image/menu/gMenu3.gif') no-repeat top";
			break;
		}
	}
	if(timer) {
		clearInterval(timer);	
		timer = 0;	
	}
}
$(function(){
	var Tabs = $("ul#tabMenu li a");
	var TabActive = "active";
	var TabContents = $("div#contentsSection");
	$("div" , TabContents).hide();

	$(Tabs).click(function(e){
		e.preventDefault();
		$("div" , TabContents).hide();
		$($(this).attr("href")).fadeIn(0);
		$(Tabs).removeClass(TabActive);
		$(this).addClass(TabActive);
		$.cookie("groupContents", $(this).attr("href") , {expires: 7});		
	});
	var CookieName = $.cookie("groupContents");
	if (CookieName != null) {
		$(Tabs).removeClass(TabActive);
		$("a[href="+CookieName+"]").addClass(TabActive);
		$(CookieName).fadeIn(0);
	} else {
		$("#tabMenu li a:first").addClass(TabActive);
		$("div:first" , TabContents).fadeIn(0);
	}
});
window.onload = function(){
	var aObj = document.getElementsByTagName("a");
	for(i = 0;i < aObj.length; i++){
		aObj[i].onfocus = function(){ this.blur(); }
	}
}

