//初始加载
function Init()
{
     //PreLoad();
}

//创建XML读取对象
function ActiveXObjectGet()
{
	var arrSignatures = ["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"] ;

	for( var i=0 ; i<arrSignatures.length ; i++ )
	{
		 try
	     {
			var dom = new ActiveXObject(arrSignatures[i]) ;
			if (dom) return dom;			
	     }
		catch(e)
     	{	    
    	}
	}
}

//填充搜索关键词
function GetKeyWord()
{
	
    var xmlDoc = new ActiveXObjectGet() ;
    xmlDoc.async = false;
    xmlDoc.load("http://mall.sina.com.cn/SinaECMallAdFile/PagePublic/KeywordValue.xml");

	var sReturn = "";
	
	//根据Xpath获取相关值
	nodes = xmlDoc.selectNodes("//Keywords/Keyword");
	
	for(var i = 0;i<nodes.length;i++)
	{   		
		sReturn = sReturn + "<a href=" + nodes(i).attributes[1].text + " target=_blank class=\"touzi\">"  + nodes(i).attributes[0].text + "</a>&nbsp;"		
	}
		
	return sReturn;
}

//填充搜索分类
function FillSearch()
{ 	
	try
	{		
		var searchObj = document.all.type ;
	       
		if(searchObj.type=="select-one")
		{
		      var xmlDoc = ActiveXObjectGet() ;
		      xmlDoc.async = false;
		      xmlDoc.load("http://mall.sina.com.cn/SinaECMallAdFile/PagePublic/SearchValue.xml");

		      //根据Xpath获取相关值
		      nodes = xmlDoc.selectNodes("//Searchs/Search");

		      //填充列表框
		      for(var i = 0;i<nodes.length;i++)
		      {
					var item=document.createElement("OPTION"); 
					item.text = nodes(i).attributes[1].text;
					item.value  = nodes(i).attributes[0].text;
					parent.document.getElementById("type").options.add(item);
		      }
		}
	}
	catch(e)
	{
	
	}
}


//页面装载时则行页面初始化
function PreLoad()
{
	divKeywords.innerHTML=GetKeyWord();
	FillSearch();
}

//头的搜索
function SearchWord(webRootPath)
{
        var type = document.all.type.value ;
	    var word = document.all.txtSearchWord.value ;	    	    	    
		window.location = webRootPath + "/SRH/NewSearchlist.aspx?type=" + type + "&Word=" + escape(word) ;     
}


function MM_reloadPage(init) 
{
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);