﻿function init_topMenu(xmlpath){
		$.ajax({
		  type: "GET",
		  url: xmlpath ,
		  dataType: "xml" ,
		  success : function(data){
				  $(data).find("menus > menu").each(function(){
						var temp_str;
						temp_str="<li><a href="+$(this).attr("link")+">"+$(this).attr("name")+"</a>"
						if($(this).find("submenu").size()>0){
							temp_str+="<dl class=top910_submenu>"
							$(this).find("submenu").each(function(){
								temp_str+="<dd><a href="+$(this).attr("link")+">"+$(this).attr("name")+"</a></dd>"
							});
							temp_str+="</dl>"
						}
						temp_str+="</li>";
						temp_str = temp_str.replace(/(aabbcc)/g,"&");
						$(temp_str).appendTo("#top910_menu");
					});
			
					$("#top910_menu li").each(function(){
						$(this).hover(
						function(){ 
							$(this).children("dl.top910_submenu").show();
						},
						function(){
							$(this).children("dl.top910_submenu").hide();
						});
					});
		  },
		  error  : function(){
                alert("加载XML失败！")
		  }
		}); 
}

//====================热门关键字搜索词语
function init_SearchHotMenu(xmlpath){
		$.ajax({
		  type: "GET",
		  url: xmlpath ,
		  dataType: "xml" ,
		  success : function(data){
				  var temp_str="";
				  $(data).find("menus > menu").each(function(){
						temp_str+="<a href="+$(this).attr("link")+">"+$(this).attr("name")+"</a> "
						//if($(this).find("submenu").size()>0){
							//temp_str+="<dl class=top910_submenu>"
							//$(this).find("submenu").each(function(){
								//temp_str+="<a href="+$(this).attr("link")+">"+$(this).attr("name")+"</a>"
							//});
							//temp_str+="</dl>"
						//}
						//temp_str+="</li>";
						
						 
					});
				 temp_str = temp_str.replace(/(aabbcc)/g,"&");
				  $(temp_str).appendTo("#Main_menu_bg02_font");
		  },
		  error  : function(){
                alert("加载XML失败+++++++++！")
		  }
		}); 
}


//====================初始化页面
$(function(){
	init_topMenu("/xml/webtop_menu.xml");
	init_SearchHotMenu("/xml/webSearch_menu.xml");
});
