/*
author : balibell
source need : http://style.china.alibaba.com/js/fdevlib/core/fdev-min.js
*/
/*
lnSearchForm 搜索表单的初始化，需要埋入相关html 代码
<form id="lnSearchForm"
<input id="lnSearchKeyWords"
<select id="lnSearchSelect"
*/
FYE.on('lnSearchForm','submit',function (){
var f = FYG('lnSearchForm');
f.setAttribute('method','get');
var k = FYG('lnSearchKeyWords');
var s = FYG('lnSearchSelect');
var kv = k.value;
if(kv=='' || kv=='输入关键字'){
alert("请输入关键字！");
k.focus();
}
var a = [];
a['help'] = 'wiki_answer_search.htm';
a['quan'] = 'quan_search.htm';
a['fship'] = 'profile_search.htm';
a['news'] = 'news_search.htm';
a['club'] = 'forum_search.htm';
a['blog'] = 'blog_search.htm';
a['buy'] = 'offer_search.htm';
a['sell'] = 'search.htm';
a['comp'] = 'company_search.htm';
a['video'] = 'http://video.china.alibaba.com/video/search/search_video.html';
f.action = s.value == 'video' ?  a[s.value] : 'http://search.china.alibaba.com/search/' + a[s.value];
})
function searchBox33(Config){
function idGet(a){return document.getElementById(a)}
function tagGet(a,b){return (b||document).getElementsByTagName(a)}
function loopRun(a,fn){var L=a.length;while(L){fn.call(a[--L],L);}}
function aliCLK(S){
//return alert(S);
aliclick(this,'?searchtrace='+S);
}
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 0;
}
var searchBox={
config:!function(){
if(Config.type==5){
Config.Url=[
'http://search.china.alibaba.com/search/offer_search.htm',
'http://search.china.alibaba.com/search/company_search.htm',
'http://search.china.alibaba.com/search/wiki_answer_search.htm',
'http://search.china.alibaba.com/search/business_search.htm',
'http://search.china.alibaba.com/search/search.htm',
'http://search.china.alibaba.com/search/news_search.htm',
'http://search.china.alibaba.com/search/forum_search.htm',
'http://search.china.alibaba.com/search/profile_search.htm',
'http://search.china.alibaba.com/search/blog_search.htm'
];
Config.seType=[
2,4,20,7,1,9,10,14,13
];
Config.option=[
'产品',
'公司',
'生意经',
'批发直达',
'求购信息',
'资讯',
'论坛',
'商友',
'博客'
];
Config.aliClkParameter=[
'searchbox_saleofferdetail_top_tab_sale',
'searchbox_saleofferdetail_top_tab_company',
'searchbox_saleofferdetail_top_tab_alihelp',
'searchbox_saleofferdetail_top_tab_pifa',
'searchbox_saleofferdetail_top_tab_buy',
'searchbox_saleofferdetail_top_tab_info',
'searchbox_saleofferdetail_top_tab_club',
'searchbox_saleofferdetail_top_tab_friend_blog',
'searchbox_saleofferdetail_top_tab_blog',
'searchbox_saleofferdetail_top_history',
'searchbox_saleofferdetail_top_dosearch'
];
}
}(),
all:!function (){
var S=idGet('select33'),
V=idGet('select33Val'),
K=idGet('keywords33'),
F=idGet('nav_act_form'),
O=idGet('select33Option'),
T=idGet('select33OseType'),
I=0,
Show=0;
V.innerHTML=Config.option[0];
O.innerHTML='<li>'+Config.option.join('</li><li>')+'</li>';
F.action=Config.Url[I];
loopRun(tagGet('li',O),function(i){
this.onclick=function(){
if(I==i)return;
V.innerHTML=this.innerHTML;
F.action=Config.Url[i];
T.value=Config.seType[i];
aliCLK(Config.aliClkParameter[i]);
if(Config.auto){
loopRun.removeListener(Config.auto.inputBox, 'keyup', Config.auto.adjustKeyCode);
if(Config.option[i]=='产品'){
loopRun.on(Config.auto.inputBox, 'keyup', Config.auto.adjustKeyCode,Config.auto, true);
}
}
I=i;
};
this.onmouseover=function(){
this.className='liHover';
};
this.onmouseout=function(){
this.className='';
};
});
V.onclick=O.onclick=function(){
if(Show){
Show=0;
O.style.display='none';
}else{
setTimeout(function(){Show=1;},0);
O.style.display='block';
}
};
var dk=document.onclick;
document.onclick=function(){
dk&&dk();
if(Show){
Show=0;
O.style.display='none';
}
};
idGet('nav_act_form').onsubmit = function(){
return false;
}
idGet('submit33').onclick = function(){
if (K.value.substr(0,3) == '请输入') {
alert('请输入关键字');
return!1;
}else if(K.value == ''){
aliCLK(Config.aliClkParameter[6]);
if(V.innerHTML=='生意经'){
location = 'http://baike.china.alibaba.com/';
}else if(V.innerHTML=='批发直达'){
location = 'www.1688.com';
}else if(V.innerHTML=='公司'){
location = 'http://page.china.alibaba.com/cp/cp1.html';
}else if(V.innerHTML=='资讯'){
location = 'http://info.china.alibaba.com/';
}else if(V.innerHTML=='论坛'){
location = 'http://club.china.alibaba.com/';
}else if(V.innerHTML=='博客'){
location = 'http://blog.china.alibaba.com/';
}else if(V.innerHTML=='商友'){
location = 'http://page.china.alibaba.com/cp/cp9.html';
}else{
location = 'http://page.china.alibaba.com/buy/index.html';
}
return!0;
}
aliCLK(Config.aliClkParameter[6]);
idGet('nav_act_form').submit();
};
/*
K.onfocus=function(){
if (K.value.substr(0,3) == '请输入') {
K.value = '';
}
};*/
}(),
cgKeyColor:!function(){
FYE.on(idGet('keywords33'),'focus',function(){
this.style.color='#000';
});
}(),
cutH1:!function(){
var h1=tagGet('h1',idGet('masthead'))[0];
if(h1){
h1.style.width='220px';
var fc = h1.childNodes[0];
if(fc && fc.nodeType == 3 && fc.nodeValue.lenB()>14){
fc.nodeValue = fc.nodeValue.cut(14) + '…';
}else if(fc && fc.nodeType == 1 && fc.innerHTML.lenB()>14){
fc.innerHTML = fc.innerHTML.cut(14) + '…';
}
}
}()
};
}
