$(document).ready(function(){
	tabs();
	menuSlide();
	subMenu();
});
function tabs() {
	var tabsClass = $(".tabsWrap");
	if (tabsClass.length) {
		$(".tabsWrap .tabs li a").click(function(){
			var tabsIdName = $(this).parents(".tabsWrap").get(0).id;
			var tab = $(this).parents("ul").children("li");
			var tabNum = tab.length;
			tab.removeClass("over");
			this.parentNode.className = "over";
			for (var i = 1; i <= tabNum; i++) {
				$("#" + tabsIdName + "_" + i).css("display", "none");
			}
			$("#" + tabsIdName + "_" + this.rel).css("display", "").hide().fadeIn("slow");
		});
	}
}
function menuSlide() {
	var clickObj = $(".boxA dt em");
	if (clickObj.length) {
		$(clickObj).click(function(){
			if (this.className == "close") {
				this.className = "";
				$(this).parents("dl").children("dd").slideDown("1500");
			}else {
				this.className = "close";
				$(this).parents("dl").children("dd").slideUp("1500");
			}
		});
	}
}
function subMenu() {
	var popObj = $(".popMenu");
	if (popObj.length) {
		$(".popMenu a").mouseover(function(){
			closeOverlay();
			var html = '<div id="subMenu" class="boxE"><div class="boxTop"><span><span>&nbsp;</span></span></div><div class="outer"><div class="inner"><ul class="popUl" >';
			var num = $(this).attr("rel");
			
			for (var i = 0; i < menuText[num].length; i++) {
				if (i == menuText[num].length - 1)
					{
						html = html + '<li class="noBorder"><a href="' + menuText[num][i][1] + '">' + menuText[num][i][0] + '</a></li>';
						continue;
					}
				html = html + '<li><a href="' + menuText[num][i][1] + '" class="popA">' + menuText[num][i][0] + '</a></li>';
				
			}
			html = html + '</ul></div></div><div class="boxBottom"><span><span>&nbsp;</span></span></div></div>';
			var oldA = $(this).html();
			$(this).addClass("over");
			$(this).before(html);
			showOverlay(oldA);
			
		});
	}
}
function showOverlay(temp) {
	$("#subMenu").before('<div id="Pop_overlay" class="Pop_hide" style="background:#ffffff;filter:alpha(opacity=0);"></div>');
	//$(".boxE").mouseout(function(){$("#subMenu").remove();});
	$('#Pop_overlay').addClass("Pop_overlayBG")
		.css('opacity', 0)
		//.css('background','#ffffff')
		.mouseover(function(){
			closeOverlay();
		})
	  	.show()
	//$('#Pop_overlay').onmouseover=closeOverlay();

	return false
}
function closeOverlay() {
	$(".popMenu .over").removeClass("over");
	$("#subMenu").remove();
	//$("#Pop_overlay").remove();
	$("#Pop_overlay").hide();
}
function allCategory() {
	document.getElementById('allCategory').style.display='';
	showOverlay2();
}
function showOverlay2() {
	$("#allCategory").before('<div id="allC_overlay" class="allC_hide"></div>');
	$('#allC_overlay').hide().addClass("allC_overlayBG")
		.css('opacity', 0)
		.mouseover(function(){
			document.getElementById('allCategory').style.display='none';
			$('.allC_overlayBG').remove();
		})
	  	.show()
	return false
}