function setsrch(c){
	for(i=0;i<=3;i++){
		document.getElementById("stab"+i).className = "";
	}
	c.className = "cur";
    if(c.id=="stab0"){
        document.srchfrm.action="fund";
        stabid=0;
        document.srchfrm.q.value="请输入代码或简称或拼音首字母。如hxdp或000011或华夏大盘";
        if(document.srchfrm.q.value=='请输入代码或简称或拼音首字母。如hxdp或000011或华夏大盘'){
		    document.srchfrm.q.style.color='#989797';
        }
    }
    if(c.id=="stab1"){
        document.srchfrm.action="level";
        stabid=1;
        document.srchfrm.q.value="请输入代码或简称或拼音首字母。如hxdp或000011或华夏大盘";
        if(document.srchfrm.q.value=='请输入代码或简称或拼音首字母。如hxdp或000011或华夏大盘'){
		    document.srchfrm.q.style.color='#989797';
        }
    }

    if(c.id=="stab2"){
        document.srchfrm.action="ask";stabid=2;document.srchfrm.q.value="请输入关键字";
        if(document.srchfrm.q.value=='请输入关键字'){
		  document.srchfrm.q.style.color='#989797';
        }
    }
    if(c.id=="stab3"){
	    document.srchfrm.action="news";stabid=3;document.srchfrm.q.value="请输入关键字";
        if(document.srchfrm.q.value=='请输入关键字'){
		    document.srchfrm.q.style.color='#989797';
        }
    }
}
function  trim(str)
{  
    // 用正则表达式将前后空格  
    // 用空字符串替代。  
    return str.replace(/(^\s*)|(\s*$)/g, "");  
}
function existFundCode(fundCode)
{
	var newstockFunds = newstockFund[1].split(";");
	for(var i = 0; i < newstockFunds.length; i++)
	{
		if (newstockFunds[i] == fundCode)
		{
			 return true;
		}
	}
	}
	function existnewFundCode(fundCode)
{
	var newFunds = newFund[1].split(";");
	for(var i = 0; i < newFunds.length; i++)
	{
		if (newFunds[i] == fundCode)
		{
			 return true;
		}
	}
	}
function submitForm(){
var temp=trim(document.srchfrm.q.value);
var AstockFund="a;b;c;,;.;;\';\";1;2;3;4;5;6;7;8;9;0;!;@;#;$;%;^;&;*;(;); ;请输入代码或简称或拼音首字母;请输入关键字;";
var AstockFunds = AstockFund.split(";");
	if(document.srchfrm.newaction.value=='fund'){
		if(existFundCode(temp)){
		  window.open("http://supermarket.jjmmw.com/main/view/fundcode/"+temp+".shtml") ;
		}else if(existnewFundCode(temp)){
		  window.open("http://supermarket.jjmmw.com/main/fund/new/"+temp+".shtml") ;
		}else{
			alert("您的输入有误,请重新输入基金代码");
		  return;
		 }
		
	}else if(document.srchfrm.newaction.value=='level'){
				if(!existFundCode(temp)||temp==""){
		  alert("您的输入有误,请重新输入基金代码!");
		  return;
		    }
	    		window.open("http://surpass.jjmmw.com/cgi-bin/sailipper/SaiLevel?function=queryCommonResult&time=one_year&fundcode="+temp) ;
	}else if(document.srchfrm.newaction.value=='surpass'){
				if(!existFundCode(temp)||temp==""){
		  alert("您的输入有误,请重新输入基金代码!");
		  return;
		    }
		window.open("http://supermarket.jjmmw.com/cgi-bin/tool/Function?function=allSelect&fundcode="+temp) ;
		
	}else if(document.srchfrm.newaction.value=='ask'){	
		if ("请输入代码或简称或拼音首字母" == temp){
				alert("您的输入有误,请重新输入!");
					 return;
				}
			for(var i = 0; i < AstockFunds.length; i++)
			{
				if (AstockFunds[i] == temp)
				{
				 	alert("您的输入有误,请重新输入关键字!");
					 return;
				}
			}
		window.open("http://ask.jjmmw.com/cgi-bin/asknew/AskNew?function=search&select=0&type=0&word="+temp);
	}else if(document.srchfrm.newaction.value=='news'){
			if ("请输入代码或简称或拼音首字母" == temp){
					alert("您的输入有误,请重新输入关键字!");
					 return;
				}
			for(var i = 0; i < AstockFunds.length; i++)
			{
				if (AstockFunds[i] == temp)
				{
				alert("您的输入有误,请重新输入关键字!");
					 return;
				}
			}
		window.open("http://news.jjmmw.com/cgi-bin/news/NewsCenter?function=search&search_key="+temp);
	}else if(document.srchfrm.newaction.value=='customer'){
			if ("请输入代码或简称或拼音首字母" == temp){
					alert("您的输入有误,请重新输入关键字!");
					 return;
				}
			for(var i = 0; i < AstockFunds.length; i++)
			{
				if (AstockFunds[i] == temp)
				{
				alert("您的输入有误,请重新输入关键字!");
					 return;
				}
			}
		window.open("http://www.jjmmw.com/cgi-bin/customer/CustomerCenter?function=search&search_key="+temp);
	}
}
