﻿function setSeacheType(num,obj)
{
    document.getElementById("TopSeacheHi").value=num;
    ChangeCss(obj,"seachtype");
}

function ChangeCss(obj,name)
{
var list=document.getElementsByName(name);
for(var i=0;i<list.length;i++)
{
    list[i].className="";
}
obj.className="search_top2";
}
function searchKeydown(e)
{
    e = e || window.event;
    if(e.keyCode == 13)
    {
        return searchNewClick();
    }
}
function switchTag(tag,content,k,n,stylea,styleb)
{	 
	for(var i=1; i <=n; i++)
	{
		if (i==k)
		{
			document.getElementById(tag+i).className=stylea;
			document.getElementById(content+i).style.display="block";
		}else{
			document.getElementById(tag+i).className=styleb;
			document.getElementById(content+i).style.display="none";
		}
	}
}

function searchNewClick()
{
       var objSel = document.getElementById("TopSeacheHi");
	    var selValue = objSel.value;
		var keyword = document.getElementById("txtKeyWord").value;
		if(keyword.replace( /^\s*/, "").replace( /\s*$/, "").length < 1)
		{
		    alert("搜索关键词不能为空！");
		    return false;
		}
		//keyword = escape(keyword);
		
		var input = document.createElement("input");
        input.type="text";
		//1,资料，2试卷，3视频，4师傅，5图书
		
		var fm = document.createElement("form");
        fm.target="_blank";
        fm.method="get";
        
        
        
		var urlStr = "";
		if(selValue==1)
		{
		    input.name = "keyword";
		    urlStr = "http://www.shangxueba.com/share/searchresult.aspx";
		}
		if(selValue==2)
		{
		    input.name = "keyword";
			urlStr = "http://www.shangxueba.com/exam/searchresult.aspx";
		}
		if(selValue==3)
		{
		    input.name = "keyword";
		    urlStr = "http://v.shangxueba.com/video_search.aspx";
		}
		if(selValue==4)
		{
		    input.name = "txtKeyWord";
		    urlStr = "http://g.shangxueba.com/search.aspx";
		}
		if(selValue==5)
		{
		    var input_type = document.createElement("input");
		    input_type.name = "type";
		    input_type.value = "name";
		    fm.appendChild(input_type);
		    
		    input.name = "keyWord";
		    urlStr = "http://www.shangxueba.com/book/BookSearch.aspx";
		}

		
        
      
        input.value=keyword;
        fm.action = urlStr;
        fm.appendChild(input);
        

        document.body.appendChild(fm);
        fm.submit();
        document.body.removeChild(fm);
		return false;
}
