$("document").ready(function(){
	var oDouble=$(".option_double");
	oDouble.each(function(){
		$(this).find(".up:last").css("margin","0").end().find(".down:last").css("margin","0");
		$(this).find("a").each(function(i,o){
			this.setAttribute("box",i);
		}).end().parent().find(".cont").each(function(i,o){
			this.setAttribute("box",i);
		});
	});
	oDouble.each(function(){
		$(this).find("a").click(function(e){
			e.preventDefault();
			var oParent=$(this.parentNode);
			if(oParent.is(".here")){return;}
			var oParents=$(this.parentNode.parentNode);
			oParents.find(".here").removeClass("here");
			oParent.addClass("here");
			if(oParent.is(".up")){
				var oUp=oParents.find(".up");
				var oDown=oParents.find(".down");
				oUp.removeClass("up").addClass("down");
				oDown.removeClass("down").addClass("up");
				oParents.append(oUp);
			}
			oParents.parent().find(".option_cont .here").removeClass("here").end().parent().find("div[@box="+this.getAttribute("box")+"]").addClass("here");
		});
	});
	var oSingle=$(".option_single");
	$(".option_single").each(function(){
		$(this).find("a").each(function(i,o){
			this.setAttribute("box",i);
		}).end().parent().find(".cont").each(function(i,o){
			this.setAttribute("box",i);
		});
	});
	oSingle.each(function(){
		$(this.getElementsByTagName("a")).click(function(e){
			e.preventDefault();
			var oParent=$(this.parentNode);
			if(oParent.is(".here")){return;}
			var oParents=$(this.parentNode.parentNode);
			oParents.find(".here").removeClass("here");
			oParent.addClass("here");
			oParents.parent().find(".option_cont .here").removeClass("here").end().parent().find("div[@box="+this.getAttribute("box")+"]").addClass("here");
		});
	});
	$(".general").filter(":odd").css("backgroundColor","#fafafa").end().filter(":last").css("border","0");
	$("#mix .cont:odd").css({"backgroundColor":"#e8e8e8"});
	var oMENU=$(".menu");
	$("#hot").hover(function(){oMENU.attr("show","0").fadeOut("fast");},function(){});
	$("#main").hover(function(){oMENU.attr("show","0").fadeOut("fast");},function(){});
	function HideMenu(){oMENU.filter("[@show=0]").fadeOut("fast");oMENU.find("li.here").each(function(){if(oMENU.filter("[@name="+$(this).attr("menu")+"]").attr("show")!=1){$(this).removeClass("here").find("a").removeClass("here");}});}
	oMENU.attr("show","0");
	oMENU.hover(function(){
		oMENU.find("li[@menu="+$(this).attr("name")+"]").parent().attr("show","1");
		$(this).attr("show","1");
	},function(){$(this).attr("show","0");window.setTimeout(HideMenu,100);});
	$("#sub_menu .m").find("a").click(function(e){e.preventDefault();}).hover(function(){
		oMENU.fadeOut("fast").attr("show","0");
		var sMenu=this.parentNode.getAttribute("menu");
		if(sMenu==null){return;}
		var oMenu=$("ul[@name="+sMenu+"]");
		var oOffset=$(this).offset();
		oMenu.css({"top":oOffset.top+25,"left":oOffset.left});
		oMenu.show("fast");
		oMenu.attr("show","1");
	},function(){});
	//在有子菜单的项右侧添加箭头图标
	oMENU.find("li").filter("[@menu]").find("a").css("background","url(http://cimg.178.com/aion/i03_16/arrow2.gif) no-repeat right 5px").click(function(e){e.preventDefault();});
	oMENU.find("a").hover(function(){
		var sMenu=this.parentNode.getAttribute("menu");
		$(this).parents("ul").find("li").each(function(){oMENU.filter("."+this.getAttribute("menu")).fadeOut("fast").attr("show","0");});
		if(sMenu==null){return;}
		$(this).addClass("here").parent().addClass("here");
		var oOffset=$(this).offset();
		oMENU.filter("[@name="+sMenu+"]").css({"top":oOffset.top,"left":oOffset.left+$(this).width()+5}).show("fast").attr("show","1");
	},function(){
		var sMenu=this.parentNode.getAttribute("menu");
		if(sMenu==null){return;}
		var oMenu=$("ul[@name="+sMenu+"]");
		oMenu.attr("show","0");
		window.setTimeout(HideMenu,100);
	});
});
