﻿function GetUrl(NewId){		   
	for (var i=1;i<8;i++){
		var NewString = "TopMenu" + i;
		document.getElementById(NewString).className = "iMenuL";
	}
	document.getElementById("TopMenu"+NewId).className = "iMenuO";		
}
function ToSearch(){
	if(document.getElementById("iKeyWords").value.replace(" ","") == ""){
	    alert("请输入关键字！");
		return false;	
	}else{
	    var iAction = document.getElementById("tSearchType").options[document.getElementById("tSearchType").selectedIndex].value;
		var iUrl = "/Product.aspx";
		if (iAction==1) iUrl = "/Product_Text.aspx";
		if (iAction==2) iUrl = "/DownLoadList.aspx";	
		var form = document.forms[0];
		SearchForm.action = iUrl;
		SearchForm.submit();
		return true;	
	}
}
function SelectSearch(Sid){
    if(Sid==0){
        GetKongJian("SearchType").style.display = "none";
        GetKongJian("t").style.display = "inline";
    }else if(Sid==1){
        GetKongJian("SearchType").style.display = "inline";
        GetKongJian("t").style.display = "inline";
    }else if(Sid==2){
        GetKongJian("SearchType").style.display = "none";
        GetKongJian("t").style.display = "none";
    }
}
function GetKeyWords(){
	iAjax = new GdpxAjaxObject();
	iAjax.OnComplete = KeyWords_Complete;
	iAjax.OnError = KeyWords_OnError;	
	iAjax.DoCallBack("/GetHotKeyWords.aspx","",null);
}
function KeyWords_Complete(responseText,responseXML){
	GetKongJian("HotKeywords").innerHTML = responseText;			
}
function KeyWords_OnError(){
	return false;
}
function getCookie(name)
{
	var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
	if(arr=document.cookie.match(reg)) return unescape(arr[2]);
	else return null;
}
function getCookie(cookie_name)
{
	var allcookies = document.cookie;
	var cookie_pos = allcookies.indexOf(cookie_name);
	// 如果找到了索引，就代表cookie存在，
	// 反之，就说明不存在。
	if (cookie_pos != -1)
	{
		// 把cookie_pos放在值的开始，只要给值加1即可。
		cookie_pos += cookie_name.length + 1;
		var cookie_end = allcookies.indexOf(";", cookie_pos);
		if (cookie_end == -1)
		{
			cookie_end = allcookies.length;
		}
		var value = unescape(allcookies.substring(cookie_pos, cookie_end));
	}
	return value;
}
//解码程序

function DecodeCookie(str)

{

　var strArr;

　var strRtn="";

　strArr=str.split("a");

　for (var i=strArr.length-1;i>=0;i--)

　strRtn+=String.fromCharCode(eval(strArr[i]));

　return strRtn;

}
function dSetWork(){
	if(getCookie("SearchWord")) GetKongJian("iKeyWords").value = DecodeCookie(getCookie("SearchWord"));
	if(getCookie("tSearchType")) GetKongJian("tSearchType").selectedIndex = getCookie("tSearchType");
	if(getCookie("SearchType")) GetKongJian("SearchType").selectedIndex = getCookie("SearchType");
	if(getCookie("Search")) GetKongJian("t").selectedIndex = getCookie("Search");
	if(getCookie("tSearchType")) SelectSearch(getCookie("tSearchType"));
}
