function $(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (typeof element == 'string')
element = document.getElementById(element);
return element;
}
function trim(inputString) {
return inputString.replace(/^ +/,"").replace(/ +$/,"");
}
function sr_ra_1(o){
if(k=$("sr_keyw")){
if(""==k.value || "请输入"==k.value.substring(0,3)){
k.value = o.title
k.style.color = "#AAB7C7"
}
$("sel_ra").value = o.title
var a = o.value.split("||")
$("sr_fm").action = a[0]
//$("sr_fm").tracelog.value = a[1]
}
}
function sr_ra_2(o){
if(k=$("sr_keyw")){
if(""==k.value || "请输入"==k.value.substring(0,3)){
k.value = o.title
k.style.color = "#AAB7C7"
}
$("sel_ra").value = o.title
var a = o.value.split("||")
if(document.all){
$("sr_fm").attributes[83].value = a[0]
}else{
$("sr_fm").attributes[0].value = a[0]
}
//$("sr_fm").tracelog.value = a[1]
$("sr_fm").action.value = a[2]
$("sr_fm").searchType.value = a[3]
$("sr_fm").searchPlace.value = a[4]
}
}
function sr_forblog(){
if($("sr_fm").searchType.value=="person"){
$("sr_fm").username.value = $("sr_keyw").value
}else{
$("sr_fm").username.value = ""
}
if($("sr_fm").tracelog.value == "blogsearch_wintag" ){
$("sr_fm").ebookname.value = $("sr_keyw").value
$("sr_fm").keywords.value = "赢在中国"
}
else{
$("sr_fm").ebookname.value = ""
$("sr_fm").keywords.value = $("sr_keyw").value
}
}
var sr_gl = ["","",""]
function sr_sel(o,n){
if(k=$("sr_fm")){
if(o.value!=""){
var t = 1==n ? k.biztype : 2==n ? k.province : k.categoryId
t.value=o.value
sr_gl[n-1] = n
}else
sr_gl[n-1] = ""
k.tracelog.value = "chinaindex_searchcompany_" + sr_gl[0] + sr_gl[1] + sr_gl[2]
}
}
function sr_clickfrd(o){
var k = $("sr_keyw")
if(""==k.value || "请输入"==k.value.substring(0,3)){
k.value = o.title
k.style.color = "#AAB7C7"
}
$("sel_ra").value = o.title
$("sr_fm").searchType.value = o.value;
}
function sr_chgcateid(n){
$("sr_fm").categoryId.value = n
}
function sr_chgbiztyp(n){
$("sr_fm").biztype.value = n
}
function sr_chgtrdtp(n){
$("sr_fm").trade_type.value = n
}
function sr_onfocus(o){
var v = o.value;
if(v.substring(0,3) =="请输入")o.value = ""
o.style.color="#000";
}
function sr_onblur_1(o){
/*if($("sel_ra")){
var s = $("sel_ra").value;
if(""==o.value || s==o.value){ o.style.color="#AAB7C7";o.value= s }
}*/
}
function sr_addswd(){
var tr = $("sr_fm").tracelog.value
var a = ""
if("chinaindex_searchsale_cy1"==tr){
a = " 创业"
}else if("chinaindex_searchsale_cy2"==tr){
a = " 招商"
}else if("chinaindex_searchsale_cy"==tr){
a = " 加盟"
}else if("chinaindex_searchcompany_wm"==tr){
a = " 出口"
}
$("sr_fm").keywords.value =$("sr_keyw").value+a;
}
function tp_search(o){
var v = o.keywords.value;
if(v.length > 100){
alert("您输入的关键字过长！");
return false;
}
if(v == ""  || v.substring(0,3) =="请输入") {
alert("请输入关键字！");
return false;
}
}
function sr_bwzd(o){
var s=$('sr_keyw').value;
if( s == '' || s == $('sel_ra').value ){
alert('请输入关键字！');
return false;
}
var h = o.href
o.href = h.substring(0,h.indexOf('keywords=')+9) + $('sr_keyw').value
return true;
}
//suggestion
function getCookie(sName) {
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}
function initHistory(){
var keys_str = getCookie('h_keys');
if(keys_str != null  )
{
var keys_array = keys_str.split("#");
if(keys_array.length >= 5){
var strlen =0;
var str="最近搜索记录：";
for(var i=0;i<keys_array.length && i<9;i++){
var type = keys_array[i].substring(keys_array[i].length-3,keys_array[i].length);
var key = keys_array[i].substring(0,keys_array[i].length-3);
strlen = strlen + key.length;
if(strlen < 30){
if(type =='[供]')
str+=" <a target=_blank href=http://search.china.alibaba.com/selloffer/"+encodeURI(key)+".html?tracelog=jy_homepage_historyky class=textwhite onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuy');\">"+ key +"</a> ";
else
str+=" <a target=_blank href=http://search.china.alibaba.com/buyoffer/"+encodeURI(key)+".html?tracelog=jy_homepage_historyky class=textwhite onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\">"+ key +"</a> ";
}
}
document.getElementById("sform_1").innerHTML=str;
}
}
}
var searchActivedItem=1;
//结构化搜索
function SB_OnBlur_x(ctrlObj,ctrlMenuID, event){
if(searchActivedItem == 1){
return SB_OnBlur(ctrlObj,ctrlMenuID, event)
}else{
return true;
}
}
function SB_OnKeyDown_x(ctrlObj,ctrlMenuID, event){
if(searchActivedItem == 1){
return SB_OnKeyDown(ctrlObj,ctrlMenuID, event)
}else{
return true;
}
}
function SB_OnKeyUp_x(ctrlObj,ctrlMenuID, event){
if(searchActivedItem == 1){
return SB_OnKeyUp(ctrlObj,ctrlMenuID, event)
}else{
return true;
}
}
//new
function sr_topul_ini(){
var n = $("sr_n").value
var c = $("tl_"+n).className
$("tl_"+n).className = c.replace("_","_v_")
$("tl_"+n).onclick = $("tl_"+n).onmouseover = function(){return false}
}
//add by 070827
//初始化输入框默认值
function initDefaultValue(){
var keyW = getQuery("keywords");
if(keyW&&keyW!="")document.getElementById("sr_keyw").value = decodeURI(keyW);
}
/*获取url中的keywords值*/
function getQuery(name)
{
　　var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
　　var r = location.href.substr(location.href.indexOf("\?")+1).match(reg);
　　if (r!=null) return r[2]; return null;
}
function getkeyword(obj){
var skey = document.getElementById("sr_keyw").value;
if(trim(skey)==""||"请输入"==skey.substring(0,3)){
return true;
}else{
window.location.href=obj.href+"?keywords="+encodeURI(skey);
return false;
}
}
