var globalImgServer = 'http://style.alibaba.com';

var Cookies={set:function(name,value){var argv=arguments;var argc=arguments.length;var expires=(argc>2)?argv[2]:null;var domain=(argc>3)?argv[3]:null;var path=(argc>4)?argv[4]:'/';var secure=(argc>5)?argv[5]:false;document.cookie=name+"="+escape(value)+
((expires==null)?"":("; expires="+expires.toGMTString()))+
((path==null)?"":("; path="+path))+
((domain==null)?"":("; domain="+domain))+
((secure==true)?"; secure":"");},get:function(name){var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;var j=0;while(i<clen){j=i+alen;if(document.cookie.substring(i,j)==arg)
return this.__get(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;}
return null;},__get:function(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1){endstr=document.cookie.length;}
return unescape(document.cookie.substring(offset,endstr));},clear:function(name){var argv=arguments;var argc=arguments.length;var domain=(argc>1)?argv[1]:null;var path=(argc>2)?argv[2]:'/';var secure=(argc>3)?argv[3]:false;if(this.get(name)){document.cookie=name+"="+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}},cookieCache:{},getCookieTable:function(name,domain){var table=Cookies.cookieCache[name];if(null==table||table.changed){table=new CookieTable(name);var str=Cookies.get(name);if(null!=str&&str!=""){table.parseFromString(str);}
if(domain){table.domain=domain;}
Cookies.cookieCache[name]=table;}
return table;}};var noExpires=new Date();noExpires.setTime(noExpires.getTime()+60*60*1000*24*60);var SEP_GROUP="\n\n";var SEP_GROUP_NAME="^\n";var SEP_GROUP_ITEM="$\n";var SEP_ATTR="\t";var NO_SET_STR="NOSET";function isArray(object){return object!=null&&typeof object=="object"&&'join'in object;}
function CookieTable(name,arrOrString,expires,domain,path,secure){this.expires=expires?expires:noExpires;this.domain=domain?domain:null;this.path=path?path:'/';this.secure=secure?secure:false;this.name=name?name:null;this.groups=arrOrString&&isArray(arrOrString)?arrOrString:[];this.__tree={};this.changed=false;this.buildString=function(arr){if(null!=arr&&arr.length>0){return arr.join(SEP_GROUP);}
return null;}
this.parseFromString=function(str){if(null==str||""==str)return this;var arr=str.split(SEP_GROUP);this.removeAll();for(var i=0;i<arr.length;i++){if(null!=arr[i]&&""!=arr[i]){var group=new CookieGroup();group.parseFromString(arr[i]);this.add(group);}}
return this;}
this.toString=function(){return this.buildString(this.groups);}
this.size=function(){return this.groups.length;}
this.arrange=function(){var arr=[],obj={};for(var i=0;i<this.size();i++){if(null!=this.groups[i]){arr[arr.length]=this.groups[i];obj[this.groups[i].name]=this.groups[i];}}
this.removeAll();this.groups=arr;this.__tree=obj;}
this.__clearTree=function(){this.__tree={};}
this.__addToTree=function(obj){if(null!=obj){this.__tree[obj.name]=obj;}}
this.__removeFromTree=function(obj){if(null!=obj){delete this.__tree[obj.name];}}
this.removeAll=function(){this.groups=[];this.__clearTree();}
this.get=function(name){if(this.__tree[name]){return this.__tree[name];}
return null;}
this.add=function(obj){if(null==obj)return;for(var i=0;i<this.size();i++){if(obj.name.toLowerCase()==this.groups[i].name.toLowerCase()){this.remove(obj.name);}}
obj.parent=this;this.groups[this.size()]=obj;this.__addToTree(obj);return this;}
this.remove=function(str){if(null==str||""==str)return;for(var i=0;i<this.size();i++){if(str.toLowerCase()==this.groups[i].name.toLowerCase()){this.__removeFromTree(this.groups[i]);this.groups[i]=null;}}
this.arrange();return this;}
this.save=function(){this.changed=true;Cookies.set(this.name,this.toString(),this.expires,this.domain,this.path,this.secure);}
this.clear=function(){Cookies.clear(this.name);}
if(this.name!=null&&typeof(arrOrString)=="string"){this.parseFromString(arrOrString);}else if(this.name!=null&&isArray(arrOrString)){for(var i=0;i<this.size();i++){if(null!=this.groups[i]){this.__addToTree(this.groups[i]);this.groups[i].parent=this;}}}}
function CookieGroup(name,arrOrString){this.name=name?name:null;this.items=arrOrString&&isArray(arrOrString)?arrOrString:[];this.__tree={};this.max=20;this.parent=null;this.buildString=function(arr){var str=this.name?this.name:NO_SET_STR;if(null!=arr&&arr.length>0){return str+SEP_GROUP_NAME+arr.join(SEP_GROUP_ITEM);}
return str;}
this.parseFromString=function(str){if(null==str||""==str)return this;var name_end=str.indexOf(SEP_GROUP_NAME);if(name_end>-1){this.name=str.substring(0,name_end);var itemsStr=str.substring(name_end+SEP_GROUP_NAME.length);if(null!=itemsStr&&itemsStr!=""){this.removeAll();var arr=itemsStr.split(SEP_GROUP_ITEM);for(var i=0;i<arr.length;i++){if(null!=arr[i]&&""!=arr[i]){var item=new CookieItem();item.parseFromString(arr[i]);this.add(item);}}}}else{this.name=str;}
return this;}
this.toString=function(){return this.buildString(this.items);}
this.getReverse=function(){var arr=[];if(this.size()>0){return this.items.slice(0,this.items.length).reverse();}
return arr;}
this.setMax=function(max){this.max=max;this.arrange();}
this.size=function(){return this.items.length;}
this.arrange=function(){var arr=[],obj={};for(var i=0;i<this.size();i++){if(null!=this.items[i]){arr[arr.length]=this.items[i];}}
if(arr.length>this.max){arr=arr.slice(arr.length-this.max,arr.length);}
for(var i=0;i<arr.length;i++){obj[arr.key]=arr[i];}
this.removeAll();this.items=arr;this.__tree=obj;}
this.__clearTree=function(){this.__tree={};}
this.__addToTree=function(obj){if(null!=obj){this.__tree[obj.key]=obj;}}
this.__removeFromTree=function(obj){if(null!=obj){delete this.__tree[obj.key];}}
this.removeAll=function(){this.items=[];this.__clearTree();}
this.get=function(key){if(this.__tree[key]){return this.__tree[key];}
return null;}
this.add=function(obj){if(null==obj)return;for(var i=0;i<this.size();i++){if(obj.key.toLowerCase()==this.items[i].key.toLowerCase()){this.remove(obj.key);}}
obj.parent=this;this.items[this.size()]=obj;this.__addToTree(obj);return this;}
this.remove=function(str){if(null==str||""==str)return;for(var i=0;i<this.size();i++){if(str.toLowerCase()==this.items[i].key.toLowerCase()){this.__removeFromTree(this.items[i]);this.items[i]=null;}}
this.arrange();return this;}
this.save=function(){if(null!=this.parent){this.arrange();this.parent.save();}}
if(this.name!=null&&typeof(arrOrString)=="string"){this.parseFromString(this.name+SEP_GROUP_NAME+arrOrString);}else if(this.name!=null&&isArray(arrOrString)){for(var i=0;i<this.size();i++){if(null!=this.items[i]){this.__addToTree(this.items[i]);this.items[i].parent=this;}}}}
function CookieItem(key,arrOrString){this.key=key?key:null;this.attributes=arrOrString&&isArray(arrOrString)?arrOrString:[];this.max=20;this.parent=null;this.buildString=function(arr){var str=this.key?this.key:NO_SET_STR;if(null!=arr&&arr.length>0){return str+SEP_ATTR+arr.join(SEP_ATTR);}
return str;}
this.parseFromString=function(str){if(null==str||""==str)return this;var arr=str.split(SEP_ATTR);if(arr.length>0){this.key=arr[0];this.attributes=arr.slice(1,arr.length);}
return this;}
this.setMax=function(max){this.max=max;this.arrange();}
this.size=function(){return this.attributes.length;}
this.toString=function(){return this.buildString(this.attributes);}
this.getReverse=function(){var arr=[];if(this.size()>0){return this.attributes.slice(0,this.attributes.length).reverse();}
return arr;}
this.reverseString=function(){return this.buildString(this.getReverse());}
this.arrange=function(){var arr=[];for(var i=0;i<this.size();i++){if(null!=this.attributes[i]){arr[arr.length]=this.attributes[i];}}
if(arr.length>this.max){this.attributes=arr.slice(arr.length-this.max,arr.length);}else{this.attributes=arr;}}
this.removeAll=function(){this.attributes=[];}
this.get=function(index){return index<this.size()?this.attributes[index]:null;}
this.add=function(str){if(null==str||""==str)return;this.remove(str);this.attributes[this.size()]=str;this.arrange();return this;}
this.remove=function(str){if(null==str||""==str)return;for(var i=0;i<this.size();i++){if(str.toLowerCase()==this.attributes[i].toLowerCase()){this.attributes[i]=null;}}
this.arrange();return this;}
this.contains=function(str){for(var i=0;i<this.size();i++){if(str.toLowerCase()==this.attributes[i].toLowerCase()){return true;}}}
this.save=function(){if(null!=this.parent){this.arrange();this.parent.save();}}
if(this.key!=null&&typeof(arrOrString)=="string"){this.parseFromString(this.key+SEP_ATTR+arrOrString);}}
var TOP_DOMAIN="alibaba.com";var HISTORY_COOKIE_NAME="history";var GROUP_KEYWORDS="keywords";var GROUP_PRODUCT="product";var GROUP_SELLOFFER="selloffer";var GROUP_BUYOFFER="buyoffer";var GROUP_COMPANY="company";var GROUP_CATEGORY="category";var GROUP_PRODUCT_SELLOFFER=GROUP_PRODUCT+"_"+GROUP_SELLOFFER;var MAX_KEYWORDS=8;var MAX_PRODUCT=8;var MAX_SELLOFFER=8;var MAX_BUYOFFER=6;var MAX_COMPANY=4;var MAX_CATEGORY=6;var MAX_PRODUCT_SELLOFFER=8;function getHistoryCookieTable(){return Cookies.getCookieTable(HISTORY_COOKIE_NAME,TOP_DOMAIN);}
function getHistoryCookieGroup(groupName){var table=getHistoryCookieTable();var group=table.get(groupName);if(null==group){group=new CookieGroup(groupName);table.add(group);group.parent=table;}
return group;}
function addOrUpdateHistoryCookieItem(groupName,itemKey,value,max){if(null==value||""==value)return;var group=getHistoryCookieGroup(groupName);var item=group.get(itemKey);var changed=false;if(isArray(value)){item=new CookieItem(itemKey,value);changed=true;}else{item=(null==item)?new CookieItem(itemKey):item;item.add(value);changed=true;}
group.add(item);if(groupName==GROUP_KEYWORDS){item.setMax(max);}else{group.setMax(max);}
if(changed){group.save();}}
function logKeywordsHistory(value){addOrUpdateHistoryCookieItem(GROUP_KEYWORDS,GROUP_KEYWORDS,value,MAX_KEYWORDS);}
function logProductHistory(itemKey,value){addOrUpdateHistoryCookieItem(GROUP_PRODUCT_SELLOFFER,itemKey,value,MAX_PRODUCT_SELLOFFER);}
function logSellOfferHistory(itemKey,value){addOrUpdateHistoryCookieItem(GROUP_PRODUCT_SELLOFFER,itemKey,value,MAX_PRODUCT_SELLOFFER);}
function logCompanyHistory(itemKey,value){addOrUpdateHistoryCookieItem(GROUP_COMPANY,itemKey,value,MAX_COMPANY);}
function logBuyOfferHistory(itemKey,value){addOrUpdateHistoryCookieItem(GROUP_BUYOFFER,itemKey,value,MAX_BUYOFFER);}
function logCategoryHistory(itemKey,value){addOrUpdateHistoryCookieItem(GROUP_CATEGORY,itemKey,value,MAX_CATEGORY);}

AE.namespace('AE.widget.intelligentSearch');AE.widget.intelligentSearch=function(){this.inputEl=null;this.jsonData=[];this.selectedOption=[-1,'',''];this.config={};this._defConfig={url:'',inputElId:'',listCssClass:'intelligentList',listCssStyle:'left:0px;top:0px;width:200px;height:auto;z-index:100',keyWordClass:'',listItemNum:10,requestDelay:0.15,enableResultCount:1,enableCatShow:1,returnVarName:'intelSearchData',isNeedSubmit:true};this.init=function(userConfig){this.config=YL.merge(this._defConfig,userConfig);this.inputEl=get(this.config.inputElId);this.UIController=YL.merge(this.UIController,{});this.requestHander=YL.merge(this.requestHander,{});this.dataParser=YL.merge(this.dataParser,{});this.UIController.init(this);this.onInit.fire();if(window.location.href.indexOf('chinasuppliers')!=-1){this.config.enableCatShow=0;}};this.initOnActive=function(){if(this.requestHander.requestCount==0&&!this.dataParser.isInit){this.requestHander.init(this);this.dataParser.init(this);this.UIController.initEvts();this.onActive.fire();return true;}
return false;};this.onInit=new YAHOO.util.CustomEvent('onInit',this);this.onActive=new YAHOO.util.CustomEvent('onActive',this);this.onRequestSent=new YAHOO.util.CustomEvent('onRequestSent',this);this.onRequestFailure=new YAHOO.util.CustomEvent('onRequestFailure',this);this.onRequestSuccess=new YAHOO.util.CustomEvent('onRequestSuccess',this);this.onListDisplay=new YAHOO.util.CustomEvent('onListDisplay',this);this.onListDisplayed=new YAHOO.util.CustomEvent('onListDisplayed',this);this.onListHide=new YAHOO.util.CustomEvent('onListHide',this);this.onListHidden=new YAHOO.util.CustomEvent('onListHidden',this);this.onOptionClick=new YAHOO.util.CustomEvent('onOptionClick',this);this.onOptionMouseDown=new YAHOO.util.CustomEvent('onOptionMouseDown',this);this.onInputKeyDown=new YAHOO.util.CustomEvent('onInputKeyDown',this);};AE.widget.intelligentSearch.prototype={requestHander:{_parent:null,_timer:null,_processor:null,_isLoading:false,disabled:false,requestCount:0,previousQuery:'',returnDataLength:0,init:function(scope){this._parent=scope;},send:function(){var _self=this,P=this._parent,config=P.config;var inputEl=P.dataParser.HTMLElements.inputEl;if(this.disabled||this._isLoading){return;};this._isLoading=true;this._timer=setTimeout(function(){var inputVal=inputEl.value.toLowerCase().replace(/^\s+/,'').replace(/\s{2,}/g,' ');if(trim(inputVal)==''){P.UIController.hideList();_self._isLoading=false;return;}
P.onRequestSent.fire();_self.requestCount++;_self._processor=YAHOO.util.Get.script(_self._buildURL(inputVal,inputEl.form),{onSuccess:_self._onSuccess,scope:_self,charset:'iso-8859-1',data:inputVal,insertBefore:P.inputEl});_self._isLoading=false;},config.requestDelay*1000);},_onSuccess:function(o){var P=this._parent;P.jsonData=eval('window.'+P.config.returnVarName);if(!YL.isArray(P.jsonData)||P.jsonData.length==0||trim(P.inputEl.value)==''){this.returnDataLength=0;P.UIController.hideList();}else{P.dataParser.update(P);P.UIController.displayList();P.onRequestSuccess.fire();}
P.selectedOption[2]=o.data;P.jsonData=null;o.purge();},_buildURL:function(searchStr,f){var P=this._parent,config=P.config,param='',baseUrl=config.url;if(baseUrl.indexOf('?')!=-1){var urlArray=baseUrl.split('?');baseUrl=urlArray[0];param='&'+urlArray[1];}
return(baseUrl+'?keyword='+encodeURIComponent(searchStr)+'&'+'searchType='+(config.enableCatShow==1?(!!f.IndexArea?f.IndexArea.value:''):'')+'&'+'varname='+config.returnVarName+'&'+'__number='+config.enableResultCount+'&'+'time='+(new Date()).getTime()+param);}},dataParser:{_parent:null,isInit:false,HTMLElements:{docEl:document,inputEl:null,listBox:null,iframeMask:null,showBtn:null,hideBtn:null,optionList:[]},init:function(scope){var P=scope,config=P.config,inputEl=P.inputEl,els=this.HTMLElements;this._parent=P;els.inputEl=inputEl;els.iframeMask=this._insertHTMLAfter(els.inputEl,this._buildHTML(config.listCssClass,config.listItemNum));els.listBox=YUD.getNextSibling(els.iframeMask);this._initHTMLElements(els.listBox);this._formatHTML();this.isInit=true;},update:function(parentScope){var P=this._parent,config=P.config,els=this.HTMLElements,optionList=els.optionList,jsonData=P.jsonData,tempData=[];if(!this.isInit){this.init(parentScope)};for(var i=0,l=jsonData.length;i<l;i++){if(!!jsonData[i].cat){for(j=0,k=jsonData[i].cat.length;j<k;j++){tempData.push({keywords:jsonData[i].keywords,cat:jsonData[i].cat[j]});}
tempData.push({keywords:jsonData[i].keywords});}else{tempData.push(jsonData[i]);}}
P.requestHander.returnDataLength=tempData.length;for(i=0,l=optionList.length;i<l;i++){var option=optionList[i],numHtml='',txtHtml='';var inputVal=els.inputEl.value.toLowerCase().replace(/^\s+/,'').replace(/\s{2,}/g,' ');if(i<tempData.length){if(config.keyWordClass!=''){txtHtml='<span class="js_key">'+this._boldKeyWords(tempData[i].keywords,inputVal,config.keyWordClass)+'</span>';}else{txtHtml='<span class="js_key">'+tempData[i].keywords+'</span>';}
if(config.enableCatShow==1){option.removeAttribute('catid');if(!!tempData[i].cat){for(var item in tempData[i].cat){if(tempData[i].cat.hasOwnProperty(item)){txtHtml+='<span class="cat" style="font-weight:bold;"> in '+tempData[i].cat[item]+'</span>';option.setAttribute('catid',item);}}}}
if(config.enableResultCount==1&&tempData[i].count){numHtml='<span class="s">'+tempData[i].count+'</span>';}
option.innerHTML=numHtml+txtHtml;YUD.setStyle(option,'display','');}else{YUD.setStyle(option,'display','none');}
option=null;}
tempData=null;},_buildHTML:function(skinClass,itemNum){var html='<iframe frameborder="0" src="about:blank" scrolling="no" class="intelligentIframeMask" style="visibility:hidden;"></iframe>'+'<div class="'+skinClass+'" style="visibility:hidden;">'+'<div class="showSearchSuggestion" style="display:none;">Search Suggestions</div>'+'<div><div class="intelligentListTitle"><span>Hide</span>Search Suggestions</div>';for(var i=0;i<itemNum;i++){html+='<p id="listItem'+i+'">&nbsp;</p>';};html+='</div></div>';return html;},_insertHTMLAfter:function(el,html){if(el.insertAdjacentHTML){el.insertAdjacentHTML('AfterEnd',html);}else{var range=el.ownerDocument.createRange(),frag;range.setStartAfter(el);frag=range.createContextualFragment(html);el.parentNode.insertBefore(frag,el.nextSibling)}
return el.nextSibling;},_initHTMLElements:function(container){var els=this.HTMLElements,optionList=[];els.showBtn=container.firstChild;els.hideBtn=YUD.getFirstChild(YUD.getNextSibling(els.showBtn));optionList=container.getElementsByTagName('p');for(var i=0,j=optionList.length;i<j;i++){var option=optionList[i];}
els.optionList=optionList;},_formatHTML:function(){var P=this._parent,config=P.config,els=this.HTMLElements;var listBox=els.listBox,ifmMask=els.iframeMask,hideBtn=els.hideBtn;if(!config.listCssStyle||config.listCssStyle==''){return;}
config.listCssStyle=config.listCssStyle.replace(/\s/ig,'');var styles=config.listCssStyle.split('\;');for(var i=0;i<styles.length;i++){var styleItem=styles[i].split('\:'),styleName=styleItem[0],styleValue=styleItem[1];if(!styleName)continue;switch(styleName.toLowerCase()){case'z-index':YUD.setStyle(listBox,styleName,styleValue);YUD.setStyle(ifmMask,'z-index',YUD.getStyle(listBox,'z-index')-1);break;case'top':case'left':case'width':case'height':YUD.setStyle([listBox,ifmMask],styleName,styleValue);break;default:YUD.setStyle(listBox,styleName,styleValue);}}
listBox.orgWidth=listBox.clientWidth+'px';},_boldKeyWords:function(str,keyWord,css){if(!keyWord)return str;return str.replace(keyWord,'<span class="'+css+'">'+keyWord+'</span>');}},UIController:{_els:{},_parent:null,_currentListItemIndex:-1,isOptionBoxOpen:false,isOptionListOpen:true,init:function(scope){this._parent=scope;var inputEl=get(scope.config.inputElId);YUE.on(inputEl,'click',this._inputElOnClick,this);YUE.on(inputEl,'keydown',this._inputElOnKeydown,this);},initEvts:function(){if(!this._parent||!this._parent.dataParser.isInit){return;}
this._els=this._parent.dataParser.HTMLElements;this.bindListeners(this._evtsMap);},_evtsMap:[['docEl','click','_documentOnClick'],['inputEl','keyup','_inputElOnKeyup'],['inputEl','paste','_inputElOnKeyup'],['showBtn','click','_showBtnOnClick'],['hideBtn','click','_hideBtnOnClick'],['optionList','click','_optionOnClick'],['optionList','mouseover','_optionOnMouseover'],['optionList','mousedown','_optionOnMousedown']],bindListeners:function(evtsMap){for(var i=0;i<evtsMap.length;i++){var evtDef=evtsMap[i];var el=evtDef[0],evt=evtDef[1],fname=evtDef[2];YUE.on(this._els[el],evt,this[fname],this);}},_inputElOnKeyup:function(e,scope){scope._parent.requestHander.send();},_inputElOnKeydown:function(e,scope){var P=scope._parent,f=this.form,opts=scope._els.optionList,opt=null,catid='';P.initOnActive();scope._parent.onInputKeyDown.fire(e.keyCode);if(scope.isOptionListOpen){scope.moveListItem(e.keyCode);if(e.keyCode==13&&scope._currentListItemIndex!=-1){opt=opts[scope._currentListItemIndex];catid=opt.getAttribute('catid');if(!!catid){YUE.stopEvent(e);window.location=f.action+'?'+scope.param(f,{CatId:catid});}}}},_inputElOnClick:function(e,scope){YUE.stopEvent(e);var P=scope._parent,initStatus=P.initOnActive();P.requestHander.send();},_documentOnClick:function(e,scope){if(scope.isOptionBoxOpen){scope.hideList();}},_showBtnOnClick:function(e,scope){YUE.stopEvent(e);YUD.setStyle(scope._els.hideBtn,'display','');YUD.setStyle(YUD.getNextSibling(this),'display','');YUD.setStyle(this,'display','none');scope.displayList(scope._els.listBox.orgWidth);scope.isOptionListOpen=true;},_hideBtnOnClick:function(e,scope){YUE.stopEvent(e);YUD.setStyle(scope._els.showBtn,'display','');YUD.setStyle(this.parentNode,'display','none');YUD.setStyle(this,'display','none');scope.isOptionListOpen=false;scope.hideList('auto');},_optionOnClick:function(e,scope){var config=scope._parent.config,f=scope._els.inputEl.form,catid=this.getAttribute('catid');scope._parent.onOptionClick.fire(this);YUE.stopEvent(e);if(config.isNeedSubmit==true){if(!!catid){window.location=f.action+'?'+scope.param(f,{CatId:catid});}else{scope.submitSelect(f);}}
scope.hideList();},_optionOnMouseover:function(e,scope){var inx=this.id.replace('listItem','');YUE.stopEvent(e);scope.transListItem(inx);scope.setListItemIndex(inx);},_optionOnMousedown:function(e,scope){var inx=this.id.replace('listItem','');scope._parent.selectedOption[0]=inx;scope.setInputElValue(scope._els.optionList[inx]);scope._parent.onOptionMouseDown.fire(this);},displayList:function(w){var els=this._els;if(!!w){YUD.setStyle(els.listBox,'width',w);}
this.syncMaskWH();if(this.isOptionBoxOpen){return;}
this._parent.onListDisplay.fire();YUD.setStyle([els.listBox,els.iframeMask],'visibility','visible');this.isOptionBoxOpen=true;this._parent.onListDisplayed.fire();},hideList:function(w){var els=this._els;if(!!w){YUD.setStyle(els.listBox,'width',w);}
if(!this.isOptionBoxOpen){return;}
this._parent.onListHide.fire();YUD.setStyle([els.listBox,els.iframeMask],'visibility','hidden');YUD.removeClass(els.optionList,'current');this.isOptionBoxOpen=false;this._currentListItemIndex=-1;this._parent.onListHidden.fire();},moveListItem:function(kCode){var optionList=this._els.optionList;var inx=this._currentListItemIndex;var dLen=this._parent.requestHander.returnDataLength;if(dLen<=0||(kCode!=38&&kCode!=40)){return;}
if(kCode==38){inx--;if(inx<0)inx=dLen-1;}else if(kCode==40){inx++;if(inx>=dLen)inx=0;}
this.transListItem(inx);this.setListItemIndex(inx);this._parent.selectedOption[0]=inx;this.setInputElValue(optionList[inx]);},transListItem:function(nextInx){var prevInx=this._currentListItemIndex;if(prevInx>=0){YUD.removeClass(this._els.optionList[prevInx],'current');}
YUD.addClass(this._els.optionList[nextInx],'current');},param:function(f,ext){var ps={},qar=[],fels=f.elements,qr='';for(var i=0,l=fels.length;i<l;i++){if(!fels[i].name)continue;ps[fels[i].name]=encodeURIComponent(fels[i].value).replace(/%20/g,'+');}
ps=YL.merge(ps,ext);for(var p in ps){if(ps.hasOwnProperty(p)){qar.push(p+'='+ps[p]);}}
qr=qar.join('&');ps=null;qar=null;return qr;},submitSelect:function(f){if(this._els.inputEl.value.replace(/\s/g,'')!=''){f.submit();}},setListItemIndex:function(inx){this._currentListItemIndex=parseInt(inx);},setInputElValue:function(option){var _self=this,val='',key=YUD.getElementsByClassName('js_key','span',option);if(key.length==1){val=key[0].innerText||key[0].textContent;}
this._parent.requestHander.disabled=true;this._parent.selectedOption[1]=val+(!!option.getAttribute('catid')?('^'+option.getAttribute('catid')):'');this._els.inputEl.value=val;},syncMaskWH:function(){var listBox=this._els.listBox;var ifmMask=this._els.iframeMask;YUD.setStyle(ifmMask,'width',listBox.offsetWidth+'px');YUD.setStyle(ifmMask,'height',listBox.offsetHeight+'px');}}};

AE.namespace('AE.widget.xSelector');AE.widget.xSelector=function(){var _self=this,isActive=false;_self.orgSelect=null;_self.options=null;_self.selectedIndex=-1;_self.browseIndex=0;_self.addNodeStatus=0;_self.DATA={selectBox:null,inputEl:null,arrowEl:null,optionBox:null,optionOl:null,optionLis:[],mask:null};_self.onChange=new YAHOO.util.CustomEvent('onChange',_self);var defConfig={selectId:'',fakeSelectId:'',selectBoxWH:[200,18],selectBoxZIndex:0,visibleOptions:20,optionBoxTop:'',arrowBoxLeft:'',isStick:0};_self.init=function(userConfig){defConfig=YL.merge(defConfig,userConfig);var cfg=defConfig,D=_self.DATA;_self.orgSelect=get(cfg.selectId);D.selectBox=get(cfg.fakeSelectId);D.inputEl=YUD.getElementsByClassName('inputEl','input',D.selectBox)[0];D.arrowEl=YUD.getElementsByClassName('arrowNormal','div',D.selectBox)[0];if(!_self.orgSelect){return;}
_self.options=_self.orgSelect.options;_self.selectedIndex=_self.orgSelect.selectedIndex;D.inputEl.value=(_self.orgSelect[_self.selectedIndex]).text;bindListeners();formatSelector();_self.orgSelect.fakeSelect=_self;};_self.dropdown=function(){var D=_self.DATA;if(YUD.getStyle(D.optionBox,'visibility')=='hidden'){YUD.setStyle([D.optionBox,D.mask],'visibility','visible');}};_self.rollup=function(){var D=_self.DATA;if(YUD.getStyle(D.optionBox,'visibility')=='visible'){YUD.setStyle([D.optionBox,D.mask],'visibility','hidden');}
if(defConfig.isStick&&YUD.get('allCate')){YUD.setStyle(YUD.get('allCate'),'visibility','hidden');}};_self.select=function(inx){var D=_self.DATA,option=D.optionLis[inx];if(option.innerHTML!=''&&inx!=_self.selectedIndex){D.inputEl.value=option.childNodes[0].nodeValue;_self.orgSelect.options[inx].selected=true;_self.selectedIndex=inx;_self.onChange.fire(_self.orgSelect);}};var buildOptionList=function(){var cfg=defConfig,D=_self.DATA;D.optionBox=createEl('div',{'class':'optionBox'});var listItems='<ol class="optionOl">';for(var i=0;i<_self.options.length;i++){var option=_self.options[i];if(option.text.match(/^-{3,}$/ig)!=null){listItems+='<li id="simulateOption'+i+'" class="optionLi subLine"></li>';}else{listItems+='<li id="simulateOption'+i+'" class="optionLi '+option.className+'">'+option.text+'</li>';}}
listItems+='</ol>';D.optionBox.innerHTML=listItems;D.selectBox.appendChild(D.optionBox);D.optionOl=D.optionBox.firstChild;D.optionLis=D.optionOl.getElementsByTagName('li');};var formatSelector=function(){var cfg=defConfig,D=_self.DATA;var selectBoxW=cfg.selectBoxWH[0]+'px';var selectBoxH=cfg.selectBoxWH[1]+'px';YUD.setStyle(D.selectBox,'z-index',cfg.selectBoxZIndex);if(parseInt(YAHOO.env.ua.ie)==8){YUD.setStyle(D.selectBox,'display','inline-block');}
YUD.setStyle(D.inputEl,'width',selectBoxW);YUD.setStyle(D.inputEl,'height',selectBoxH);YUD.setStyle(D.inputEl,'line-height',selectBoxH);YUD.setStyle(D.arrowEl,'left',cfg.arrowBoxLeft);YUD.setStyle(D.arrowEl,'z-index',cfg.selectBoxZIndex+2);};var formatOptionList=function(){var cfg=defConfig,D=_self.DATA;if(cfg.optionBoxTop&&cfg.optionBoxTop!=''){YUD.setStyle(D.optionBox,'top',cfg.optionBoxTop);}
YUD.setStyle(D.optionBox,'z-index',cfg.selectBoxZIndex+1);YUD.setStyle(D.optionBox,'visibility','hidden');if(AE.bom.isIE6){YUD.setStyle(D.optionBox,'width','10px');}
if(D.optionOl.offsetWidth<D.inputEl.offsetWidth){YUD.setStyle(D.optionBox,'width',D.inputEl.offsetWidth+'px');}else{YUD.setStyle(D.optionBox,'width',D.optionOl.offsetWidth+'px');}
if(D.optionLis.length>cfg.visibleOptions){YUD.setStyle(D.optionBox,'height',(D.optionLis[0].offsetHeight*cfg.visibleOptions)+'px');}
YUD.setStyle(D.optionOl,'overflow','hidden');};var bindListeners=function(){var D=_self.DATA,cfg=defConfig;YUE.on(D.selectBox,'click',function(e){YUE.stopEvent(e);D.inputEl.focus();if(!isActive){buildOptionList();formatOptionList();bindListenersOnActive();iframeMask();isActive=true;}
if(YUD.getStyle(D.optionBox,'visibility')=='hidden'){D.optionBox.scrollTop=_self.selectedIndex*D.optionLis[0].offsetHeight;transOptionStyle(_self.selectedIndex);_self.dropdown();if(defConfig.isStick){stickAllCate();}}else{_self.rollup();}});YUE.on(D.selectBox,'mouseover',function(e){YUD.addClass(D.arrowEl,'arrowMouseover');});YUE.on(D.selectBox,'mouseout',function(e){YUD.removeClass(D.arrowEl,'arrowMouseover');});};var bindListenersOnActive=function(){var D=_self.DATA,cfg=defConfig;YUE.on(document,'click',_self.rollup);YUE.on(D.inputEl,'keydown',function(e){YUE.stopEvent(e);if(e.altKey&&(e.keyCode==38||e.keyCode==40)){if(YUD.getStyle(D.optionBox,'visibility')=='hidden'){transOptionStyle(_self.selectedIndex);_self.dropdown();}else{_self.rollup();}}
if(!e.altKey){var inx=0,optionHeight=D.optionLis[0].offsetHeight,scrollNum=Math.floor(D.optionBox.scrollTop/optionHeight);if(e.keyCode==38){inx=(_self.browseIndex<1)?0:_self.browseIndex-1;if(_self.browseIndex==scrollNum){D.optionBox.scrollTop=(scrollNum-1)*optionHeight;}
transOptionStyle(inx);_self.select(inx);}else if(e.keyCode==40){inx=(_self.browseIndex+1>=D.optionLis.length)?(D.optionLis.length-1):(_self.browseIndex+1);if(_self.browseIndex==scrollNum+cfg.visibleOptions-1){D.optionBox.scrollTop=(scrollNum+1)*optionHeight;}
transOptionStyle(inx);_self.select(inx);}else if(e.keyCode==13){_self.rollup();_self.select(_self.browseIndex);}}});for(var i=0;i<D.optionLis.length;i++){var optionLi=D.optionLis[i];YUE.on(optionLi,'click',function(e){YUE.stopEvent(e);_self.select(getIndex(this));_self.rollup();});YUE.on(optionLi,'mouseover',function(e){YUE.stopEvent(e);transOptionStyle(getIndex(this));});}};var iframeMask=function(){var cfg=defConfig,D=_self.DATA;D.mask=createEl('iframe',{'frameBorder':'0','width':D.optionBox.offsetWidth,'height':D.optionBox.offsetHeight});YUD.setStyle(D.mask,'position','absolute');YUD.setStyle(D.mask,'left',YUD.getStyle(D.optionBox,'left'));YUD.setStyle(D.mask,'top',YUD.getStyle(D.optionBox,'top'));YUD.setStyle(D.mask,'visibility','hidden');YUD.setStyle(D.mask,'z-index',cfg.selectBoxZIndex);D.selectBox.appendChild(D.mask);};var getIndex=function(option){return parseInt(option.id.replace('simulateOption',''));};var transOptionStyle=function(inx){var D=_self.DATA;if(D.optionLis[inx].innerHTML!=''){YUD.removeClass(YUD.getElementsByClassName('currentLi','li',D.optionOl),'currentLi');YUD.addClass(D.optionLis[inx],'currentLi');if(defConfig.isStick&&YUD.get('allCate')){YUD.removeClass(YUD.get('allCate'),'currentLi');}}
_self.browseIndex=inx;};var createEl=function(tag,properties){var el=document.createElement(tag);for(var p in properties){if(p=='class'){YUD.addClass(el,properties[p]);}else{el.setAttribute(p,properties[p]);}}
return el;};var stickAllCate=function(){var D=_self.DATA,oLiLast=D.optionBox.getElementsByTagName('li')[D.optionBox.getElementsByTagName('li').length-1];if(!_self.addNodeStatus){var eAllCate=document.createElement('div'),eAllCateBg=document.createElement('div');tAllCate=document.createTextNode('\u00A0 In All Categories'),liHeight=34,startTop=D.optionBox.offsetTop+D.optionBox.offsetHeight-liHeight,cateWidth=D.optionBox.clientWidth;eAllCateBg.className='stickSubLine';eAllCate.setAttribute('id','allCate');eAllCate.className='stickAllCate';eAllCate.style.cssText='top:'+startTop+'px;width:'+cateWidth+'px;';eAllCate.appendChild(eAllCateBg);eAllCate.appendChild(tAllCate);D.selectBox.appendChild(eAllCate);_self.addNodeStatus=1;}else{eAllCate=YUD.get('allCate');YUD.setStyle(eAllCate,'visibility','visible');}
YUE.on(eAllCate,'click',function(e){YUE.stopEvent(e);_self.select(getIndex(oLiLast));_self.rollup();});YUE.on(eAllCate,'mouseover',function(e){YUE.stopEvent(e);var inx=getIndex(oLiLast);var D=_self.DATA;YUD.removeClass(YUD.getElementsByClassName('currentLi','li',D.optionOl),'currentLi');YUD.addClass(eAllCate,'currentLi');_self.browseIndex=inx;});};};

AE.namespace('AE.searchBar');AE.searchBar=function(){this.config={bar:get("searchBar"),form:get("SearchForm"),tabsBox:get("searchTabsBox"),searchInput:get("SearchTextIdx"),intelligent:get("searchIntelligent"),hintClass:"hint",countrySelect:get("searchCountry"),submitBtn:get("searchSubmit"),hiddenIndexArea:get("searchIndexArea"),advanceSearchLink:"http://www.alibaba.com/trade/advancesearch",onlyOneShow:false,isNeedSubmit:true,selectlinkDatas:{country_home:{AU:'Australia',BR:'Brazil',CA:'Canada',CN:'China (Mainland)',EG:'Egypt',HK:'Hong Kong',IN:'India',ID:'Indonesia',JP:'Japan',MY:'Malaysia',PH:'Philippines',SG:'Singapore',KR:'South Korea',TW:'Taiwan',TH:'Thailand',TR:'Turkey',UK:'United Kingdom',US:'United States',VN:'Vietnam',advanceSearch:'More ...'},country_listing:{AU:'Australia',BR:'Brazil',CA:'Canada',CN:'China (Mainland)',EG:'Egypt',HK:'Hong Kong',IN:'India',ID:'Indonesia',JP:'Japan',MY:'Malaysia',PH:'Philippines',SG:'Singapore',KR:'South Korea',TW:'Taiwan',TH:'Thailand',TR:'Turkey',UK:'United Kingdom',US:'United States',VN:'Vietnam','':'----------------------',afr:'[Africa]','nam,csa':'[Americas]','asi,gcn':'[Asia]',asi:'[Asia (except China)]',aoc:'[Oceania]',csa:'[Central and South America]',eec:'[Eastern Europe and CIS]','weu,eec':'[Europe and CIS]',gcn:'[Great China]',mea:'[Middle East]',nam:'[North America]',weu:'[Western Europe]',advanceSearch:'More ...'}},locations:{AF:'Afghanistan',AL:'Albania',DZ:'Algeria',AS:'American Samoa',AD:'Andorra',AO:'Angola',AI:'Anguilla',AQ:'Antarctica',AG:'Antigua and Barbuda',AR:'Argentina',AM:'Armenia',AW:'Aruba',AU:'Australia',AT:'Austria',AZ:'Azerbaijan',BS:'Bahamas',BH:'Bahrain',BD:'Bangladesh',BB:'Barbados',BY:'Belarus',BE:'Belgium',BZ:'Belize',BJ:'Benin',BM:'Bermuda',BT:'Bhutan',BO:'Bolivia',BA:'Bosnia and Herzegowina',BW:'Botswana',BV:'Bouvet Island',BR:'Brazil',IO:'British Indian Ocean Territory',BN:'Brunei Darussalam',BG:'Bulgaria',BF:'Burkina Faso',BI:'Burundi',KH:'Cambodia',CM:'Cameroon',CA:'Canada',CV:'Cape Verde',KY:'Cayman Islands',CF:'Central African Republic',TD:'Chad',CD:'Channel Island',CL:'Chile',CN:'China (Mainland)',CX:'Christmas Island',CC:'Cocos (Keeling) Islands',CO:'Colombia',KM:'Comoros',CG:'Congo',ZR:'Congo, The Democratic Republic Of The',CK:'Cook Islands',CR:'Costa Rica',CI:'Cote D\'Ivoire',HR:'Croatia (local name: Hrvatska)',CU:'Cuba',CY:'Cyprus',CZ:'Czech Republic',DK:'Denmark',DJ:'Djibouti',DM:'Dominica',DO:'Dominican Republic',TP:'East Timor',EC:'Ecuador',EG:'Egypt',SV:'El Salvador',GQ:'Equatorial Guinea',ER:'Eritrea',EE:'Estonia',ET:'Ethiopia',FK:'Falkland Islands (Malvinas)',FO:'Faroe Islands',FJ:'Fiji',FI:'Finland',FR:'France',FX:'France Metropolitan',GF:'French Guiana',PF:'French Polynesia',TF:'French Southern Territories',GA:'Gabon',GM:'Gambia',GE:'Georgia',DE:'Germany',GH:'Ghana',GI:'Gibraltar',GR:'Greece',GL:'Greenland',GD:'Grenada',GP:'Guadeloupe',GU:'Guam',GT:'Guatemala',GN:'Guinea',GW:'Guinea-Bissau',GY:'Guyana',HT:'Haiti',HM:'Heard and Mc Donald Islands',HN:'Honduras',HK:'Hong Kong',HU:'Hungary',IS:'Iceland',IN:'India',ID:'Indonesia',IR:'Iran (Islamic Republic of)',IQ:'Iraq',IE:'Ireland',IL:'Israel',IT:'Italy',JM:'Jamaica',JP:'Japan',JO:'Jordan',KZ:'Kazakhstan',KE:'Kenya',KI:'Kiribati',KS:'Kosovo',KW:'Kuwait',KG:'Kyrgyzstan',LA:'Lao People\'s Democratic Republic',LV:'Latvia',LB:'Lebanon',LS:'Lesotho',LR:'Liberia',LY:'Libyan Arab Jamahiriya',LI:'Liechtenstein',LT:'Lithuania',LU:'Luxembourg',MO:'Macau',MK:'Macedonia',MG:'Madagascar',MW:'Malawi',MY:'Malaysia',MV:'Maldives',ML:'Mali',MT:'Malta',MH:'Marshall Islands',MQ:'Martinique',MR:'Mauritania',MU:'Mauritius',YT:'Mayotte',MX:'Mexico',FM:'Micronesia',MD:'Moldova',MC:'Monaco',MN:'Mongolia',MS:'Montserrat',MA:'Morocco',MZ:'Mozambique',MM:'Myanmar',NA:'Namibia',NR:'Nauru',NP:'Nepal',NL:'Netherlands',AN:'Netherlands Antilles',NC:'New Caledonia',NZ:'New Zealand',NI:'Nicaragua',NE:'Niger',NG:'Nigeria',NU:'Niue',NF:'Norfolk Island',KP:'North Korea',MP:'Northern Mariana Islands',NO:'Norway',OM:'Oman',Other:'Other Country',PK:'Pakistan',PW:'Palau',PS:'Palestine',PA:'Panama',PG:'Papua New Guinea',PY:'Paraguay',PE:'Peru',PH:'Philippines',PN:'Pitcairn',PL:'Poland',PT:'Portugal',PR:'Puerto Rico',QA:'Qatar',RE:'Reunion',RO:'Romania',RU:'Russian Federation',RW:'Rwanda',KN:'Saint Kitts and Nevis',LC:'Saint Lucia',VC:'Saint Vincent and the Grenadines',WS:'Samoa',SM:'San Marino',ST:'Sao Tome and Principe',SA:'Saudi Arabia',SN:'Senegal',SC:'Seychelles',SL:'Sierra Leone',SG:'Singapore',SK:'Slovakia (Slovak Republic)',SI:'Slovenia',SB:'Solomon Islands',SO:'Somalia',ZA:'South Africa',KR:'South Korea',ES:'Spain',LK:'Sri Lanka',SH:'St. Helena',PM:'St. Pierre and Miquelon',SD:'Sudan',SR:'Suriname',SJ:'Svalbard and Jan Mayen Islands',SZ:'Swaziland',SE:'Sweden',CH:'Switzerland',SY:'Syrian Arab Republic',TW:'Taiwan',TJ:'Tajikistan',TZ:'Tanzania',TH:'Thailand',TG:'Togo',TK:'Tokelau',TO:'Tonga',TT:'Trinidad and Tobago',TN:'Tunisia',TR:'Turkey',TM:'Turkmenistan',TC:'Turks and Caicos Islands',TV:'Tuvalu',UG:'Uganda',UA:'Ukraine',AE:'United Arab Emirates',UK:'United Kingdom',US:'United States',UM:'United States Minor Outlying Islands',UY:'Uruguay',UZ:'Uzbekistan',VU:'Vanuatu',VA:'Vatican City State (Holy See)',VE:'Venezuela',VN:'Vietnam',VG:'Virgin Islands (British)',VI:'Virgin Islands (U.S.)',WF:'Wallis And Futuna Islands',EH:'Western Sahara',YE:'Yemen',YU:'Yugoslavia',ZM:'Zambia',ZW:'Zimbabwe'},submitErrors:{isEmpty:"Please input a search term.",tooLong:"please input a search term less than 50 characters.",onlyEng:"Sorry, the information you filled in is not in English. Please input the information in English instead."},setups:{product:{type:'product',actionUrl:'http://www.alibaba.com/trade/search',indexArea:'product_en',submitFormWhenClicked:false},sell:{type:'sell',actionUrl:'http://www.alibaba.com/trade/search',indexArea:'offer_en',submitFormWhenClicked:false},company:{type:'company',actionUrl:'http://www.alibaba.com/trade/search',indexArea:'company_en',submitFormWhenClicked:false},buy:{type:'buy',actionUrl:'http://importer.alibaba.com/buyeroffers',indexArea:'offer_en',submitFormWhenClicked:false},tradeShows:{type:'tradeShows',actionUrl:'http://tradeshow.alibaba.com/search',indexArea:'ts_en',submitFormWhenClicked:false}},fackSelectorConfig:{selectId:"searchCategory",fakeSelectId:"fakeSelectorBox",selectBoxWH:[244,20],selectBoxZIndex:1000,optionBoxTop:"23px",arrowBoxLeft:"235px"},historyInput:{tab:get("historyTab"),searchInput:get("historySearchInput"),searchCountry:get("historySearchCountry")}}
this.manualSubmit=new YAHOO.util.CustomEvent('manualSubmit',this);}
AE.searchBar.prototype={init:function(config){this.config=YL.merge(this.config,config||{});this.defineEvent();this.defaultRun();return this;},defineEvent:function(){var _self=this;var config=_self.config;var tabs=config.tabsBox.getElementsByTagName("a");var searchSelects=config.bar.getElementsByTagName("select");_self.config.tabs=tabs;_self.config.searchSelects=searchSelects;var searchInput=config.searchInput;var searchForm=config.form;YUE.on(tabs,"click",function(){if(YUD.hasClass(this.parentNode,'current'))return true;return _self.searchTabClick(this);})
YUE.on(searchInput,"click",function(ev){_self.searchHint(this,"disable");})
YUE.on(searchSelects,"mouseover",function(ev){YUE.removeListener(this,ev.type,arguments.callee);_self.fillSelect(this);})
YUE.on(searchSelects,"focus",function(ev){YUE.removeListener(this,ev.type,arguments.callee);_self.fillSelect(this);})
YUE.on(searchForm,"submit",function(ev){return _self.searchFormSubmit();})
YUE.onDOMReady(function(){_self.historyRestore();if(window.location.hash.replace("#","").length==0){_self.collapseInput(searchInput);}})
if(config.countrySelect){YUE.on(config.countrySelect,"change",function(ev){_self.countrySelectsChange(this);})}},defaultRun:function(){var _self=this;var config=this.config;this.tabSelected=YUD.getElementsByClassName("current","*",config.tabsBox)[0];this.selectedType=this.tabSelected.getElementsByTagName("a")[0].id;var searchInput=config.searchInput;if(searchInput.value!=""||searchInput.getAttribute("hasKeyword")=="true"){searchInput.hasFocus=true;searchInput.value=XMLDecode(searchInput.value);if(typeof(logKeywordsHistory)=='function'){logKeywordsHistory(searchInput.value)};}else{this.searchHint(searchInput,"hint",this.tabSelected.getElementsByTagName("a")[0].getAttribute("hint"));}
config.form.attributes["action"].value=config.setups[this.selectedType].actionUrl;this.defaultSelect();_self.intelligentObj=this.intSearchIntelligent();if(get(config.fackSelectorConfig.selectId)){var selectorTop=new AE.widget.xSelector();selectorTop.init(config.fackSelectorConfig);_self.selectorTop=selectorTop;}
if(config.onlyOneShow){YUE.on(config.searchInput,"click",function(){_self.selectorTop.rollup();})
if(get(config.fackSelectorConfig.selectId)){YUE.on(config.fackSelectorConfig.fakeSelectId,"click",function(){_self.intelligentObj.UIController.hideList();})}}},searchTabClick:function(tab){var config=this.config;if(YUD.hasClass(tab.parentNode,"current")){return false};if((/https?:\/\/[^/]+/i).test(tab.href))return true;this.selectedType=tab.id;var searchType=tab.id;var searchInput=config.searchInput;if(!searchInput.hasFocus||searchInput.value==""){this.searchHint(searchInput,"hint",tab.getAttribute("hint"));}else{searchInput.focus();}
YUD.removeClass(this.tabSelected,"current")
this.tabSelected=tab.parentNode;YUD.addClass(this.tabSelected,"current");var oSearchConfig=config.setups[searchType];config.form.attributes["action"].value=oSearchConfig.actionUrl;config.hiddenIndexArea.value=oSearchConfig.indexArea;if(searchType==oSearchConfig.indexArea&&oSearchConfig.submitFormWhenClicked){this.searchFormSubmit()}
return false;},intSearchIntelligent:function(){if(this.config.intelSearchConfig){var controler=new AE.widget.intelligentSearch();controler.init(this.config.intelSearchConfig);return controler;}},searchHint:function(input,type,hintText){var _self=this;if(type=="hint"&&hintText){input.value=hintText;YUD.addClass(input,_self.config.hintClass);input.hasFocus=false;this.collapseInput(input);}else if(type=="disable"){YUD.removeClass(input,_self.config.hintClass);if(input.hasFocus==false){input.value="";}
input.hasFocus=true;}
YUE.on(input,"keydown",function(ev){if(input.hasFocus){return;}
_self.searchHint(input,"disable");input.hasFocus=true;})
YUE.on(input,"paste",function(ev){if(input.hasFocus){return;}
_self.searchHint(input,"disable");input.hasFocus=true;})},collapseInput:function(input){if(input.createTextRange){var rng=input.createTextRange();if(input.hasFocus)rng.moveStart('character',input.value.length);rng.collapse(true);rng.select();}else if(input.setSelectionRange){var rng=input.setSelectionRange(0,0);}
input.focus();},fillSelect:function(select){if(!select.linkData||select.filled)return;var dataObj=select.linkData;for(var key in dataObj){select.options.add(new Option(dataObj[key],key));}
select.filled=true;var key=select.getAttribute("selected");if(!key||key=="")return;if(dataObj[key]){select.remove(select.selectedIndex);select.value=key;}},defaultSelect:function(){var config=this.config;for(i=0;i<config.searchSelects.length;i++){var select=config.searchSelects[i];var dataName=select.getAttribute("dataName");if(!dataName||dataName=="")continue;select.linkData=config.selectlinkDatas[dataName];if(!select.linkData)continue;var key=select.getAttribute("selected");if(!key||key=="")continue;if(select.linkData[key]){select.selectedOp=select.options.add(new Option(select.linkData[key],key));select.value=key;}else{if(config.locations[key]){select.selectedOp=select.options.add(new Option(config.locations[key],key));select.value=key;eval("select.linkData."+key+" = '"+config.locations[key]+"';")}}}},searchFormSubmit:function(){var config=this.config;var historyInput=config.historyInput;var searchInput=config.searchInput;var submitErrors=config.submitErrors;if(trim(searchInput.value)==''||!searchInput.hasFocus){alert(submitErrors.isEmpty);return false;}
if(searchInput.value.length>50){alert(submitErrors.tooLong);return false;}
if(!/^[\x00-\x7F]*$/.test(trim(searchInput.value))){alert(submitErrors.onlyEng);return false;}
historyInput.tab.value=this.selectedType;if(searchInput.hasFocus){historyInput.searchInput.value=searchInput.value;}
if(config.countrySelect){historyInput.searchCountry.value=config.countrySelect.value;}
YUE.removeListener(config.form,"submit");if(config.isNeedSubmit){config.form.submit();}else{this.manualSubmit.fire(config.form);}},countrySelectsChange:function(countrySelect){if(countrySelect.value=="advanceSearch"){location=this.config.advanceSearchLink;}},historyRestore:function(){var searchInput=this.config.searchInput;var historyInput=this.config.historyInput;if(historyInput.tab.value!=""){this.searchTabClick(get(historyInput.tab.value));}
if(historyInput.searchInput.value!=""){searchInput.hasFocus=true;this.searchHint(searchInput,"disable");searchInput.value=historyInput.searchInput.value;}
if(historyInput&&historyInput.searchCountry.value!=""){this.config.countrySelect.setAttribute("selected",historyInput.searchCountry.value)
this.defaultSelect();}}}


function logger(theUrl){if(theUrl==null)
return;window.setTimeout("loadHtml('"+theUrl+"')",10);}
function doIfExploreIsNotSupport(){alert("Only Available to Microsoft Internet Explorer and FireFox 1.5 or above.");}
function clientNotReadyAction(fn){if(!ATMAPI.isPluginReady()){ATMAPI.installPlugin(fn);}else if(ATMAPI.isNeedUpdatePlugin()){ATMAPI.updatePlugin(fn);}else{typeof fn==='function'?fn():ATMAPI.downloadClient(fn);}}
function getWebAtmUrl(from,receiverId,id){var webAtmUrl="",referUrl=document.URL;webAtmUrl="http://us.my.alibaba.com/user/webatm/start_web_atm.htm?enemberId="+encode(receiverId)+"&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$");return webAtmUrl;}
function doOpenWebIM(from,memberId,id){var win=open(getWebAtmUrl(from,memberId,id),Math.round(Math.random()*24*100),'width=785,height=616,location=no,toolbar=no,status=no,resizable=yes,scrollbars=no');win.focus();}
function OnlyCheckAlitalkInstalled(){return ATMAPI.getClientFlag();}
function newCheckAlitalkInstalled(){return ATMAPI.getClientFlag();}
function clickAlitalk(uid){if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){sendMessageNotEn(uid);}else{clientNotReadyAction();}}else{doIfExploreIsNotSupport();}}
function alitalkEncrypt(memberId,from,id){var para="",selfpara="",win;if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){var referUrl=document.URL;var timestamp=new Date();para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time"+timestamp.getTime();logger(selfpara);sendMessage(memberId,para);}else{if(OnLine==1){doOpenWebIM(from,memberId,id);}else{clientNotReadyAction();}}}else{doOpenWebIM(from,memberId,id);}}
function alitalkInstallOrLogin(dlConfirm){if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){ATMAPI.startATM("","","");}else{clientNotReadyAction();}}else{doIfExploreIsNotSupport();}}
function alitalkEncryptFormyalibaba(memberid,from,id,displayName,messageType){var para="",selfpara="";if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){var referUrl=document.URL;var timestamp=new Date();para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time="+timestamp.getTime();logger(selfpara);sendMessage(memberid,para);}else{var url="http://us.my.alibaba.com/mcweb/sendMessage.htm?";url+="selectedIds="+id+"&selectedNames="+escape(displayName)+"&messageType="+messageType;window.open(url);}}else{doOpenWebIM(from,memberid,id);}}
function sendMessage(memberId,paras){ATMAPI.sendClientMsg("","","enaliint",memberId,1,"&encrypt=1"+paras);}
function sendMessageNotEn(uid,paras){ATMAPI.sendClientMsg("","","enaliint",uid,1,"&encrypt=1"+paras);}
function alitalkFeedback(memberId,from,id){var para="";if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){var referUrl=document.URL;var timestamp=new Date();para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK#from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();sendMessageNotEn(memberId,para);}else{clientNotReadyAction();}}else{doOpenWebIM(from,memberId,id);}}
function SetCookie(sName,sValue){var life=new Date();life.setTime(life.getTime()+365*24*60*60*1000);document.cookie=sName+"="+escape(sValue)+"; expires="+life.toGMTString();;}
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]);}}
function DelCookie(sName){var sValue="false";document.cookie=sName+"="+escape(sValue)+"; expires=Fri, 31 Dec 1999 23:59:59 GMT;";}
function clickSave(box){if(box.checked){SetCookie("notShowMsg","true");}else{DelCookie("notShowMsg");}}
var fromSellLeads="0";var fromProduct="1";var fromCompany="2";var fromBuyLead="10";var fromFreeFeedBack="20";var fromGScontact="30";var fromGSFeedBack="40";var wwwServer="http://www.alibaba.com";var imageServer=globalImgServer;function alitalkEncryptNew(enemberId,from,id,type){var para="",selfpara="",nextUrl="",win;if(ATMAPI.isBrowserSupport){if(fromBuyLead==from){buyingLeadsCheckRight(enemberId,from,id)
return;}
if(ATMAPI.isClientReady()){var referUrl=document.URL;var timestamp=new Date();if(OnLine==2){para="url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time="+timestamp.getTime();logger(selfpara);win=open(getFeedBackUrl(from,id),'feedBack','fullscreen=yes,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');win.focus();}else{para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time="+timestamp.getTime();logger(selfpara);sendMessage(enemberId,para);}}else{clientNotReadyAction(function(){if(OnLine==1||OnLine==8){doOpenWebIM(from,enemberId,id);}else{win=open(getFeedBackUrl(from,id,type),'feedBack','fullscreen=yes,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');win.focus();}});}}else{doOpenWebIM(from,enemberId,id);}}
function alitalkEncryptForEscrow(enemberId,from,id){alitalkEncryptNew(enemberId,from,id,null);}
function targetToWebMessage(enemberId,from,id){var iframe=document.getElementById("webmessagehelpframe")
if(iframe==null){iframe=document.createElement("iframe");iframe.id="webmessagehelpframe"
iframe.width=0;iframe.height=0;document.body.appendChild(iframe);}
iframe.src="http://www.alibaba.com/alitalk/innerie/webMessageCheckPage.htm?needEncypt=true&targetid="+encode(enemberId)+"&from="+from+"&id="+id;}
function alitalkEncryptLiveInput(url){var para="",selfpara="",nextUrl="",win;if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){ATMAPI.startATM("","","");}else{nextUrl=wwwServer+url;win=open(nextUrl,'liveinput','width=600,height=500,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');win.focus();}}else{doIfExploreIsNotSupport();}}
function alitalkEncryptGetLive(){alitalkEncryptLiveInput('/others/popup/errorMsg_Browser_Installnow_For_LiveHelp.vhtml');}
function getFeedBackUrl(from,id,type){var feedBackUrl="";if(fromSellLeads==from){feedBackUrl="http://us.my.alibaba.com/mcweb/contact.htm?action=mcweb:contact_action&req_page=feedback.init&domain=0&id="+id;}else{if(type===1){feedBackUrl="http://us.my.alibaba.com/mcweb/contact.htm?action=mcweb:contact_action&req_page=feedback.init&domain="+from+"&id="+id+'&isWholesale=1';}else{feedBackUrl="http://us.my.alibaba.com/mcweb/contact.htm?action=mcweb:contact_action&req_page=feedback.init&domain="+from+"&id="+id;}}
return feedBackUrl;}
function urlAddQueryString(baseUrl,queryString){if(baseUrl!=null){if(baseUrl.indexOf("?")==-1){return baseUrl+"?"+queryString;}
return baseUrl+"&"+queryString;}
return baseUrl;}
function makeFeedBackElement(elementId,from,id,openStyle){var fbElement=document.getElementById(elementId);if(fbElement==null)
return;feedbackUrl=getFeedBackUrl(from,id);if(openStyle=="0"){fbElement.href=feedbackUrl;}else{var winUrl=feedbackUrl;fbElement.href="javascript:openMaxWin('"+winUrl+"'"+",'');";}}
function makeFeedBackButton(elementId,from){var fbElement=document.getElementById(elementId);if(fbElement==null)
return;if(fromSellLeads==from||fromProduct==from||fromCompany==from){fbElement.src=imageServer+"/images/eng/style/button/inquire_now.gif";fbElement.alt="Inquire Now";}else{fbElement.src=imageServer+"/images/eng/style/button/send_quotation.gif";fbElement.alt="Quotation Now";}}
function openMaxWin(winUrl,name){if(winUrl==null)
return;var win=open(winUrl,name,'fullscreen=yes,menubar=no,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes');win.focus();}
function startTM(from,id){ATMAPI.startATM("","","");}
function validateTM(enemberId,from,id){var referUrl=document.URL;var timestamp=new Date();para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();sendMessage(enemberId,para);}
function buyingLeadsCheckRight(enemberId,from,id){checkUrl=wwwServer+"/others/popup/TmBuyingLeadsStepAfterSignIn.html"+"?offerid="+id+"&fm="+from+"&md="+encode(enemberId);var win=open(checkUrl,'checkRight'+Math.round(Math.random()*24*100),'width=800,height=550,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');win.focus();}
function alitalkEncryptNewBuyingLeads(enemberId,from,id){var para="",selfpara="",nextUrl="",win;if(ATMAPI.isBrowserSupport){if(ATMAPI.isClientReady()){var referUrl=document.URL;var timestamp=new Date();if(OnLine==2){para="url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time="+timestamp.getTime();logger(selfpara);win=open(getFeedBackUrl(from,id),'feedBack','fullscreen=yes,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');win.focus();}else{para="&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from="+from+"#id="+id+"#refer="+referUrl.replace(/&/ig,"$")+"#time="+timestamp.getTime();selfpara="http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from="+from+"&id="+id+"&refer="+referUrl.replace(/&/ig,"$")+"&time="+timestamp.getTime();logger(selfpara);sendMessage(enemberId,para);window.setTimeout("window.close()",1000);}}else{clientNotReadyAction(function(){if(OnLine==1){doOpenWebIM(from,enemberId,id);}else{window.location=getFeedBackUrl(from,id)
window.moveTo(0,0);window.resizeTo(screen.availWidth,screen.availHeight);}});}}else{doOpenWebIM(from,enemberId,id);}}
function startorInstallTM(){alitalkInstallOrLogin(true);}
function startAlitalk(){alitalkInstallOrLogin(false);}
function multiImg(maxLen){atmMultiImg(maxLen,'atm32',true);}
function multiImgById(maxLen,css,needInner){if(css==undefined||css==null)
return;css=(needInner==1)?"atm32":"atm16";atmMultiImg(maxLen,css,needInner);}
function singleUserImgById(css,needInner){showVirtualATMIcon('talkId32',css,OnLine,needInner);}
function singleUserImgSmall(alitalkId){showVirtualATMIcon(alitalkId,'atm32',OnLine,true);}
function multiImgSmall(maxLen){atmMultiImg(maxLen,'atm32',true);}
function singleUserImg16(){showVirtualATMIcon('talkId16','atm32',OnLine,true);}
function userDefineATM(objId,css,needInner){showVirtualATMIcon(objId,css,OnLine,needInner);}
function singleUserImg24(talkId){var id=talkId||'talkId24',css='atm24',txt=['I\'m online<br />Chat now!','Offline'];switch(id){case'talkId16':css='atm16';txt=['Chat now!','Offline'];break;case'talkId24':css='atm24';break;case'talkId32':css='atm32';break;case'talkId48':css='atm48';}
showVirtualATMIcon(id,css,OnLine,true,txt);}
function singleUserImg32(alitalkId){var alitId=alitalkId||"talkId32";showVirtualATMIcon(alitalkId,'atm32',OnLine,true);}
function singleUserImg48(talkId){var id=talkId||'talkId48';YUE.on(window,"load",function(){showVirtualATMIcon(id,'atm48',OnLine,true);});}
function showVirtualATMIcon(id,css,online,isShowTxt,usrTxt){var alit,noalit;var onlineHref='1';var offlineHref='0';id=id||'talkId32';css=css||'atm32';usrTxt=usrTxt||['I\'m Online<br />Chat Now!','Offline','I\'m Away','I\'m Busy'];var noPng=AE.browse.isIE6||AE.browse.isIE7||/\d/.test(css);alit=get(id);if(alit!=null){alit.className=css+'grey'+(noPng?'':' '+css+'PngGrey');alit.innerHTML=!!isShowTxt?usrTxt[1]:'';alit.href=alit.href.replace('isOnline',offlineHref);alit.title='Please Leave a Message';}
noalit=get('noAli'+id);if(online==1&&alit!=null){alit.className=css+'online'+(noPng?'':' '+css+'PngOnline');alit.innerHTML=!!isShowTxt?usrTxt[0]:'';alit.href=alit.href.replace('isOnline',onlineHref);alit.title='Chat with me';}else if((online==6||online==0)&&alit!=null){alit.className=css+'grey'+(noPng?'':' '+css+'PngGrey');alit.innerHTML=!!isShowTxt?usrTxt[1]:'';alit.href=alit.href.replace('isOnline',offlineHref);alit.title='Please Leave a Message';}else if(online==8&&alit!=null){alit.className=css+'away'+(noPng?'':' '+css+'PngAway');alit.innerHTML=!!isShowTxt?usrTxt[2]:'';alit.href=alit.href.replace('isOnline',offlineHref);alit.title='Please Leave a Message';}else if(online==7&&alit!=null){alit.className=css+'busy'+(noPng?'':' '+css+'PngBusy');alit.innerHTML=!!isShowTxt?usrTxt[3]:'';alit.href=alit.href.replace('isOnline',offlineHref);alit.title='Please Leave a Message';}}
function atmMultiImg(maxLen,atmClass,needInner,textAry){for(var i=0;i<maxLen;i++){var j=i+1;showVirtualATMIcon("talkId"+j,atmClass,online[i],needInner,textAry);}}
function atmSingleImg(atmId,atmClass,needInner,userText){showVirtualATMIcon(atmId,atmClass,online[0],needInner,userText);}


AE.namespace('AE.widget.scriptLoader');AE.widget.scriptLoader=function(){var _self=this;var requestQuee=[];var defConfig={onSuccess:function(){},isLoadImmediately:false,isParallelLoad:false};var config={};var loadedCounter=0,requestCounter=0;var canRunSuccessFun=false;_self.init=function(oConfig){config=YL.merge(defConfig,oConfig||{});};_self.pushRequest=function(sRequestUrl){requestQuee.push(sRequestUrl);++requestCounter;if(config.isLoadImmediately){if(config.isParallelLoad){parallelLoad();}else{serialLoad();}}};_self.load=function(onSuccessFun){if(onSuccessFun){config.onSuccess=onSuccessFun;}
canRunSuccessFun=true;if(config.isParallelLoad){parallelLoad();}else{serialLoad();}};var serialLoad=function(){if(requestQuee.length>0){var sUrl=requestQuee[0];requestQuee=requestQuee.slice(1);YAHOO.util.Get.script(sUrl,{onSuccess:loadSuccess});}};var parallelLoad=function(){while(requestQuee.length){YAHOO.util.Get.script(requestQuee[0],{onSuccess:loadSuccess});requestQuee=requestQuee.slice(1);}};var loadSuccess=function(){++loadedCounter;if(loadedCounter>=requestCounter&&canRunSuccessFun){config.onSuccess();}else if(loadedCounter<requestCounter&&!config.isParallelLoad){serialLoad();}else{return;}};};
