function sch_select(id,len)
{
	for(var i=0;i<=len-1;i++)
	{
		$("#bsch_radiofield_"+i).removeClass("select");
	}
	$("#bsch_radiofield_"+id).addClass("select");
	bsch_setField(id);
}

//改变搜索条件：0 全部 1 歌名 2 歌手 3 价格
function bsch_setField(id)
{
	newsch_hideSuggest();
    $i("bsch_form").field.value = id;
	checkflag = id;
	if(id==3)
	{
		 $i("bsch_cont1_div").style.display = "none";
		 $i("bsch_cont2_div").style.display = "block"; 
		 $i('bsch_cont2').value = $i("search_price").value;
	}
	else
	{
		$i("bsch_cont1_div").style.display = "block";
		$i("bsch_cont2_div").style.display = "none";
	}
}
//普通搜索 可以没有参数
function bsch_search(content,field)
{

	if(typeof(field)=="undefined") 
	{
		$i("bsch_form").field.value = checkflag;
	} 
	else
	{
		bsch_setField(field);
	}

    sch_select($i("bsch_form").field.value,4);

	if(typeof(content)=="undefined")
	{
		if($i("bsch_form").field.value=="3") //按价格
		{
            $i("bsch_form").content.value = $i("bsch_cont2").value.trim();
		}
		else
		{
			$i("bsch_form").content.value = $i("bsch_cont1").value.trim();
		}
	}
	else
	{
		$i("bsch_form").content.value = content;
		if($i("bsch_form").field.value=="3") //按价格
		{
            $i("bsch_cont2").value = content;
			$i("search_price").value = content;
		}
		else
		{
			$i("bsch_cont1").value = content;
		}
	}

    if($i("bsch_form").field.value!="3" && nsch_initword == $i("bsch_cont1").value.trim()) return; //防止nsch_initword
 
	//判断条件，是否合格
	if($i("bsch_form").content.value.trim() == "")
	{
		alert("请输入要搜索的关键字");
		try{ $i("bsch_cont1").focus(); }catch(e){}
		return;
	}
	else if(bsch_con_reg.test($i("bsch_form").content.value.trim()))
	{ 
		alert("您输入关键字含有非法字符，请重新输入");
		try{ $i("bsch_cont1").select(); }catch(e){}
		return;
	}

   //显示关键字
	try{ bsch_showkw($i("bsch_form").content.value); }catch(e){}
    
	newschSuggestPause = true;
	newschSuggestCloseFlag = true;


     //判断是否搜索页面
	if(window.location.href.indexOf("bsch_result") > 0)
	{
        bsch_searchAll();
	}
	else
	{
		if(sub_mod2!="")
           $i("bsch_form").action = "bsch_result.screen?auto=1&subm2="+sub_mod2;
		else  $i("bsch_form").action = "bsch_result.screen?auto=1";
		$i("bsch_form").submit();
	}
}

//全查
function bsch_searchAll(two_obj)
{	
	bsch_allinit_sch();
	bsch_content = $i("bsch_form").content.value;
	bsch_field = $i("bsch_form").field.value;
	var tem_two = "0";
	var tem_tname = "";
	var tem_tsinger = "";
	var tem_tprice = "";
	if(two_obj != null)
	{
		tem_two = Sys.undf(two_obj.two) ? "0":"1";
		tem_tname =  Sys.undf(two_obj.tname)? "":two_obj.tname;
		tem_tsinger = Sys.undf(two_obj.tsinger)? "":two_obj.tsinger;
		tem_tprice = Sys.undf(two_obj.tprice)? "":two_obj.tprice;
	}

	bsch_doSearch({
			content:bsch_content,
			field:bsch_field,
			type:1,
			page:1,
			sqflag:0,
			two: tem_two,
			tname: tem_tname,
			tsinger: tem_tsinger,
			tprice: tem_tprice
	});
	bsch_doSearch({
			content:bsch_content,
			field:bsch_field,
			type:2,
			page:1,
			sqflag:0,
			two: tem_two,
			tname: tem_tname,
			tsinger: tem_tsinger,
			tprice: tem_tprice
	});
	bsch_doSearch({
			content:bsch_content,
			field:bsch_field,
			type:3,
			page:1,
			sqflag:0,
			two: tem_two,
			tname: tem_tname,
			tsinger: tem_tsinger,
			tprice: tem_tprice
	});
}
function handle_bsearch(e)
{
	Sys.hKey(e,13,function(e){bsch_search();});
}
function bsch_focuscontentstyle()
{
	if($i("bsch_cont1").value.trim() != nsch_initword  &&  $i("bsch_cont1").style.color=="#999999")
	    $i("bsch_cont1").style.color="#000000";
}
//**************************
//建议（联想）
function newsch_contentPropertyCh(v)
{
	var c1 = $i("bsch_form").content.value.trim();
	var c2 = $i("bsch_form").field.value.trim();

	if(c1 != c2 && c1 != nsch_initword && v=="")
	{
		newsch_hideSuggest();
		newschSuggestCloseFlag = true;
	}

	$i("bsch_form").content.value =v;
		newsch_getSuggest(c2,v);
}
function bsch_focuscontent()
{
	if($i("bsch_cont1").value.trim() == nsch_initword)
	{
		$i("bsch_cont1").value = "";
		$i("bsch_cont1").style.color="#000000";
	}
}
//全查初始化
function bsch_allinit_sch()
{
    $i("bsch_noresultdiv").style.display = "none";
	$i("bsch_maindiv_1").style.display="block";
	$i("bsch_maindiv_2").style.display="block";
	$i("bsch_maindiv_3").style.display="block";

	bsch_arr_noresult_flag = [0,0,0];
	bsch_arr_tishiflag = [0,0,0];
	bsch_arr_totalpage = [0,0,0];
	bsch_count = 0;
}

//热门关键词搜索日志
function bsch_searchKW(c,f){
    sub_mod2='2.7';
    bsch_search(c,f);
}