var tanSearch={};
tanSearch.tmp={};
tanSearch.tmp.keyword={};
tanSearch.tmp.mode="note";
tanSearch.tmp.stat="http://so.tancee.com/";
tanSearch.user={};
tanSearch.user.saveHistory;
tanSearch.user.loadAll;
tanSearch.user.currentCategory;
tanSearch.user.currentTab={};
tanSearch.user.list=[];
tanSearch.user.history=[];
if(document.all){
var location="";
}
tanSearch.init=function(){
tanSearch.config.loadSettings();
tanSearch.config.loadHistory();
tanSearch.config.loadSearchState();
tanSearch.updateLanguage();
tanSearch.config.loadPreferredList();
tanSearch.config.loadQueryParameters();
tanSearch.search.buildUI();
tanSearch.attachEvents();
};
tanSearch.addToFavorites=function(){
var _1=$lang("title");
var _2="http://so.tancee.com/";
if(document.all){
window.external.AddFavorite(_2,_1);
}else{
if(window.sidebar){
window.sidebar.addPanel(_1,_2,"");
}else{
if(window.opera&&window.print){
var _3=document.createElement("a");
_3.setAttribute("rel","sidebar");
_3.setAttribute("href",_2);
_3.setAttribute("title",_1);
_3.click();
}
}
}
};
tanSearch.updateLanguage=function(){
if(tanSearch.localeLang[tanSearch.user.langCode]){
$langNamespace=tanSearch.localeLang[tanSearch.user.langCode];
}else{
$langNamespace=tanSearch.localeLang[tanSearch.defaults.langCode];
tanSearch.user.langCode=tanSearch.defaults.langCode;
}
if(tanSearch.localeList[tanSearch.user.langCode]){
tanSearch.list=tanSearch.localeList[tanSearch.user.langCode];
}else{
tanSearch.list=tanSearch.localeList[tanSearch.defaults.langCode];
}
tanSearch.updateTitle();
$id("btn_set_home").innerHTML=$lang("set_home");
$id("btn_privacy").innerHTML=$lang("tancee_daohang");
$id("btn_privacy").href=$lang("tancee_daohang_url");
$id("btn_tan_web").innerHTML=$lang("tan_web");
$id("btn_tan_web").href=$lang("tan_web_url");
$id("btn_history").innerHTML=$lang("history");
$id("btn_options").innerHTML=$lang("options");
$id("btn_custom_prefer").innerHTML=$lang("custom_prefer");
$id("txt_options_header").innerHTML=$lang("options");
$id("txt_opt_lang").innerHTML=$lang("opt_lang");
$id("txt_opt_save_history").innerHTML=$lang("opt_save_history");
$id("txt_opt_load_all").innerHTML=$lang("opt_load_all");
$id("txt_options_list").innerHTML=$lang("options_list");
$id("txt_list_current_preferred").innerHTML=$lang("list_current_preferred");
$id("txt_list_default").innerHTML=$lang("list_default");
$id("txt_list_add_text").innerHTML=$lang("list_add_text");
$id("txt_list_i_new").innerHTML=$lang("list_i_new");
$id("txt_list_i_name").innerHTML=$lang("list_i_name");
$id("txt_list_i_url").innerHTML=$lang("list_i_url");
$id("i_note_internal").innerHTML=$lang("list_i_note_internal");
$id("i_note_edit").innerHTML=$lang("list_i_note");
$id("note").innerHTML=$lang("no_search_notice");
$id("btn_opt_save").value="  "+$lang("save")+"  ";
$id("btn_opt_cancel").value="  "+$lang("cancel")+"  ";
};
tanSearch.updateTitle=function(_4){
if(!_4){
_4=="";
}
document.title=$lang("title")+(_4!=""?": "+_4:"");
};
tanSearch.attachEvents=function(){
$event("+","keyup",$id("keyword"),tanSearch.search.keyword.check);
$event("+","click",$id("btn_go"),function(){
tanSearch.search.checkUpdate(true);
});
$event("+","click",$id("btn_history"),tanSearch.history.show);
$event("+","click",$id("btn_options"),tanSearch.options.show);
$event("+","click",$id("btn_custom_prefer"),function(){
tanSearch.options.show("list");
});
$event("+","click",$id("btn_add_new"),tanSearch.options.list.addCustomItem);
$event("+","click",$id("btn_i_save"),tanSearch.options.list.saveItem);
$event("+","click",$id("btn_list_default"),tanSearch.options.list.restoreDefault);
$event("+","click",$id("btn_opt_save"),tanSearch.options.save);
$event("+","click",$id("btn_opt_cancel"),tanSearch.search.checkUpdate);
$event("+","blur",$id("history"),function(){
setTimeout("tanSearch.history.hide()",200);
});
$event("+","resize",window,tanSearch.search.frame.adjustSize);
};
tanSearch.switchMode=function(_5){
var _6=$id("content");
var _7=$id("noteWrapper");
var _8=$id("options");
switch(_5){
case "note":
var _9=$id("keyword");
if(_9){
_9.focus();
}
_6.style.display="none";
_7.style.display="block";
_8.style.display="none";
break;
case "search":
_6.style.display="block";
_7.style.display="none";
_8.style.display="none";
break;
case "options":
_6.style.display="none";
_7.style.display="none";
_8.style.display="block";
break;
}
tanSearch.tmp.mode=_5;
};
tanSearch.config={};
tanSearch.config.loadSettings=function(){
var _a=$cookies("ln");
if(_a==null){
if(navigator.language){
tanSearch.user.langCode=navigator.language;
}else{
tanSearch.user.langCode=navigator.userLanguage;
}
}else{
tanSearch.user.langCode=_a;
}
tanSearch.user.langCode=tanSearch.user.langCode.toLowerCase();
var _a=$cookies("sh");
if(_a=="false"){
tanSearch.user.saveHistory=false;
}else{
if(_a!=null){
tanSearch.user.saveHistory=true;
}else{
tanSearch.user.saveHistory=tanSearch.defaults.saveHistory;
}
}
var _a=$cookies("la");
if(_a=="false"){
tanSearch.user.loadAll=false;
}else{
if(_a!=null){
tanSearch.user.loadAll=true;
}else{
tanSearch.user.loadAll=tanSearch.defaults.loadAll;
}
}
};
tanSearch.config.saveSettings=function(){
$cookies("ln",tanSearch.user.langCode);
$cookies("sh",tanSearch.user.saveHistory);
$cookies("la",tanSearch.user.loadAll);
};
tanSearch.config.loadPreferredList=function(){
var _b=unescape($cookies("pl"));
tanSearch.user.list=$fromJSON(_b);
if(tanSearch.user.list==null){
if(tanSearch.defaults.preferredList[tanSearch.user.langCode]){
tanSearch.user.list=$clone(tanSearch.defaults.preferredList[tanSearch.user.langCode]);
}else{
tanSearch.user.list=tanSearch.defaults.preferredList["en-us"];
}
}
if(!tanSearch.list["preferred"]){
tanSearch.list["preferred"]={};
}
tanSearch.list["preferred"].title=$lang("preferred");
tanSearch.list["preferred"].items={};
tanSearch.list["preferred"].items=tanSearch.config.convertPreferredList(tanSearch.user.list);
};
tanSearch.config.savePreferredList=function(){
$cookies("pl",escape($toJSON(tanSearch.user.list)));
};
tanSearch.config.convertPreferredList=function(_c){
var _d={};
for(var i=0;i<_c.length;i++){
var _f=_c[i];
var _10;
if(!_f.c&&_f.n){
_d[_f.n]={"custom":true,"name":_f.n,"title":_f.t,"url":_f.u};
continue;
}
try{
_10=tanSearch.list[_f.c].items[_f.n];
}
catch(e){
_10=undefined;
}
if(_10==undefined){
_c.splice(i,1);
i--;
continue;
}
_d[_f.c+"_"+_f.n]={"category":_f.c,"name":_f.n,"title":_10.title+(_10.subtitle?_10.subtitle:""),"url":_10.url};
}
return _d;
};
tanSearch.config.saveSearchState=function(){
$cookies("ct",escape($toJSON(tanSearch.user.currentTab)));
};
tanSearch.config.loadSearchState=function(){
tanSearch.user.currentCategory=tanSearch.defaults.category;
var val=$cookies("ct");
val=$fromJSON(unescape(val));
if(val){
tanSearch.user.currentTab=val;
}
};
tanSearch.config.saveHistory=function(){
$cookies("kw",escape(tanSearch.user.history.join(",")));
};
tanSearch.config.loadHistory=function(){
var kw=unescape($cookies("kw"));
kw=kw.split(",");
var _13=[];
for(var i=0;i<kw.length;i++){
if(i==tanSearch.defaults.tanKeyword){
break;
}
kw[i]=kw[i].$trim();
if(kw[i]==""){
kw.splice(i,1);
i--;
continue;
}
_13.push(kw[i]);
}
tanSearch.user.history=_13;
};
tanSearch.config.loadQueryParameters=function(){
var _15=$parseQueryString();
if(_15["q"]){
_15["q"]=_15["q"].replace(/\+/g," ");
_15["q"]=unescape(_15["q"]);
_15["q"]=tanSearch.config.decodeUTF8String(_15["q"]);
$id("keyword").value=_15["q"];
}
if(_15["c"]){
if(tanSearch.list[_15["c"]]){
tanSearch.user.currentCategory=_15["c"];
}
}
};
tanSearch.config.decodeUTF8String=function(str){
var _17="";
for(var i=0;i<str.length;i++){
var b1=str.charCodeAt(i);
if(b1<128){
_17+=String.fromCharCode(b1);
}else{
if((b1>191)&&(b1<224)){
var b2=str.charCodeAt(i+1);
_17+=String.fromCharCode(((b1&31)<<6)|(b2&63));
i++;
}else{
var b2=str.charCodeAt(i+1);
var b3=str.charCodeAt(i+2);
_17+=String.fromCharCode(((b1&15)<<12)|((b2&63)<<6)|(b3&63));
i+=2;
}
}
}
return _17;
};
tanSearch.search={};
tanSearch.search.buildCategories=function(){
var _1c="";
for(var cat in tanSearch.list){
if(!tanSearch.tmp.keyword[cat]){
tanSearch.tmp.keyword[cat]={};
}
_1c+="<a id=\"cat_"+cat+"\" href=\"javascript:tanSearch.search.activateCategory('"+cat+"');\""+(cat=="preferred"?" class=\"preferred\"":"")+" onclick=\"this.blur()\">"+tanSearch.list[cat].title.$encodeHTML()+"</a>";
}
$write(_1c,"categories");
};
tanSearch.search.activateCategory=function(cat){
if(!cat){
cat=tanSearch.user.currentCategory;
}
try{
$id("cat_"+tanSearch.user.currentCategory).className=(tanSearch.user.currentCategory=="preferred"?"preferred ":"");
}
catch(e){
}
tanSearch.user.currentCategory=cat;
$id("cat_"+cat).className=(cat=="preferred"?"preferred-active":"active");
if(cat=="preferred"){
$id("btn_custom_prefer_wrapper").style.display="inline";
}else{
$id("btn_custom_prefer_wrapper").style.display="none";
}
tanSearch.search.buildTabs();
tanSearch.search.activateTab(tanSearch.user.currentTab[cat]);
};
tanSearch.search.buildTabs=function(){
var cat=tanSearch.user.currentCategory;
var _20=tanSearch.list[cat].items;
var _21="";
var _22="";
for(var _23 in _20){
if(!tanSearch.list[cat].defaultTab){
tanSearch.list[cat].defaultTab=_23;
}
if(!tanSearch.user.currentTab[cat]){
tanSearch.user.currentTab[cat]=_23;
}
tanSearch.tmp.keyword[cat][_23]="";
_21+="<a id=\"search_"+_23+"\" href=\"javascript:tanSearch.search.activateTab('"+_23+"');\" onclick=\"this.blur();\">"+_20[_23].title.$encodeHTML()+"</a>";
_22+="<div id=\"iframe_wrapper_"+_23+"\" style=\"display: none;\">"+"</div>\n";
}
$write(_21,"searches");
$write(_22,"content");
};
tanSearch.search.activateTab=function(_24){
var cat=tanSearch.user.currentCategory;
if(!tanSearch.list[cat].items[_24]){
_24=tanSearch.list[cat].defaultTab;
}
try{
$id("search_"+tanSearch.user.currentTab[cat]).className="";
$id("iframe_wrapper_"+tanSearch.user.currentTab[cat]).style.display="none";
}
catch(e){
}
tanSearch.user.currentTab[cat]=_24;
$id("iframe_wrapper_"+_24).style.display="block";
$id("search_"+_24).className="buttons-active";
tanSearch.search.frame.adjustSize();
tanSearch.search.checkUpdate();
};
tanSearch.search.buildUI=function(){
tanSearch.search.buildCategories();
tanSearch.search.activateCategory();
tanSearch.history.build();
};
tanSearch.search.checkUpdate=function(_26){
var _27=tanSearch.search.keyword.get();
if(_27==""){
tanSearch.switchMode("note");
}else{
tanSearch.history.hide();
tanSearch.search.execute(_26);
tanSearch.switchMode("search");
}
tanSearch.updateTitle(_27);
tanSearch.config.saveSearchState();
};
tanSearch.search.execute=function(_28){
var cat=tanSearch.user.currentCategory;
var _2a=tanSearch.list[cat].items;
tanSearch.search.frame.doSearch(tanSearch.user.currentTab[cat],_28);
if(tanSearch.user.loadAll){
var i=0;
for(var _2c in _2a){
if(_2c!=tanSearch.user.currentTab[cat]){
i++;
setTimeout("tanSearch.search.frame.doSearch(\""+_2c+"\","+_28+")",1000*i);
}
}
}
};
tanSearch.search.keyword={};
tanSearch.search.keyword.cleanFor=function(_2d){
return _2d;
};
tanSearch.search.keyword.check=function(_2e){
if(_2e.keyCode==13){
tanSearch.search.checkUpdate(true);
}
};
tanSearch.search.keyword.get=function(){
return $id("keyword").value.$trim();
};
tanSearch.search.keyword.set=function(_2f){
$id("keyword").value=tanSearch.user.history[_2f];
tanSearch.search.checkUpdate();
};
tanSearch.search.frame={};
tanSearch.search.frame.prepare=function(_30){
var _31=$id("iframe_wrapper_"+_30);
if(!_31){
return;
}
_31.innerHTML="";
var _32=window.document.createElement("iframe");
_32.id="iframe_"+_30;
_32.src="about:blank";
_32.allowTransparency=true;
_32.frameBorder="0";
_31.appendChild(_32);
var _33;
if(!window.opera){
_33=document.documentElement.clientHeight;
}else{
_33=document.body.clientHeight;
}
_32.width="100%";
_32.height="400px";
tanSearch.search.frame.showLoading(_30);
};
tanSearch.search.frame.showLoading=function(_34){
var _35=$id("iframe_"+_34);
if(!_35){
return;
}
var _36="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+"<html xmlns=\"http://www.w3.org/1999/xhtml\">"+"<head>"+"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"+"<title>Search Result</title>"+"<link rel=\"stylesheet\" type=\"text/css\" href=\"css/base.css\" />"+"<link rel=\"stylesheet\" type=\"text/css\" href=\"css/custom.css\" />"+"</head>";
_36+="<body>";
_36+="<div class=\"loading\">"+"<img src=\"images/loading.gif\" /> "+$lang("loading").$encodeHTML()+"</div>";
_36+="</body>"+"</html>";
try{
var obj=_35.contentWindow.document;
obj.open();
obj.write(_36);
obj.close();
}
catch(e){
}
};
tanSearch.search.frame.doSearch=function(_38,_39){
var _3a=tanSearch.search.keyword.get();
var cat=tanSearch.user.currentCategory;
if(tanSearch.tmp.keyword[cat][_38]==_3a&&!_39){
return;
}
tanSearch.history.save(_3a);
tanSearch.search.frame.prepare(_38);
var obj=$id("iframe_"+_38);
if(!obj){
return;
}
var url=tanSearch.list[cat].items[_38].url;
if(url.indexOf("{keyword:raw}")>-1){
url=url.replace("{keyword:raw}",_3a);
}else{
if(url.indexOf("{keyword:escape}")>-1){
url=url.replace("{keyword:escape}",escape(_3a));
}else{
if(url.indexOf("{keyword:gb2312}")>-1){
url=url.replace("{keyword:gb2312}",$GB2312.encodeURIComponent(_3a));
}else{
url=url.replace("{keyword}",encodeURIComponent(_3a));
}
}
}
obj.src=url;
setTimeout(tanSearch.search.frame.adjustSize,100);
tanSearch.tmp.keyword[cat][_38]=_3a;
};
tanSearch.search.frame.adjustSize=function(){
var _3e=tanSearch.user.currentTab[tanSearch.user.currentCategory];
var obj=$id("iframe_"+_3e);
if(!obj){
return;
}
var _40;
if(!window.opera){
_40=document.documentElement.clientHeight;
}else{
_40=document.body.clientHeight;
}
obj.height=_40-obj.offsetTop;
};
tanSearch.history={};
tanSearch.history.build=function(){
var _41="";
for(var i=0;i<tanSearch.user.history.length;i++){
_41+="<a href=\"javascript:;\" onclick=\"tanSearch.search.keyword.set("+i+")\">"+tanSearch.user.history[i].$encodeHTML().$cut(50)+"</a>";
}
_41+="<a href=\"javascript:;\" onclick=\"tanSearch.history.clean();\" class=\"special\">"+$lang("clean_history")+"</a>";
$write(_41,"history");
if(tanSearch.user.saveHistory){
$id("btn_history_wrapper").style.display="inline";
}else{
$id("btn_history_wrapper").style.display="none";
}
};
tanSearch.history.show=function(_43){
var obj=_43.srcElement?_43.srcElement:_43.target;
var _45=obj.offsetLeft;
var top=obj.offsetTop;
var _47=obj.offsetParent;
while(_47.tagName.toUpperCase()!="BODY"){
_45+=_47.offsetLeft;
top+=_47.offsetTop;
_47=_47.offsetParent;
}
var _48=$id("history");
_48.style.top=top+obj.offsetHeight+"px";
_48.style.left=_45+"px";
_48.style.visibility="visible";
_48.style.top=top+obj.offsetHeight+"px";
_48.focus();
};
tanSearch.history.hide=function(){
$id("history").style.visibility="hidden";
};
tanSearch.history.save=function(_49){
if(tanSearch.user.saveHistory&&_49){
for(var i=0;i<tanSearch.user.history.length;i++){
if(tanSearch.user.history[i]==_49){
tanSearch.user.history.splice(i,1);
i--;
}
}
if(tanSearch.user.history.length>=tanSearch.defaults.tanKeyword){
tanSearch.user.history.pop();
}
tanSearch.user.history.unshift(_49);
tanSearch.history.stat(_49);
}else{
tanSearch.user.history=[];
}
tanSearch.config.saveHistory();
tanSearch.history.build();
};
tanSearch.history.stat=function(_4b){
if(!tanSearch.tmp.stat){
return;
}
var p="?lang="+tanSearch.user.langCode+"&cat="+tanSearch.user.currentCategory+"&sid="+tanSearch.user.currentTab[tanSearch.user.currentCategory]+"&kw="+_4b;
var p=tanSearch.tmp.stat+p;
var req;
try{
req=new XMLHttpRequest();
}
catch(e){
try{
req=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
return;
}
}
try{
req.open("GET",p,true);
req.send("");
}
catch(e){
}
};
tanSearch.history.clean=function(){
tanSearch.history.save();
};
tanSearch.options={};
tanSearch.options.currentType="";
tanSearch.options.show=function(_4e){
var _4f=$id("opt_sec_setup");
var _50=$id("opt_sec_list");
_4f.style.display="none";
_50.style.display="none";
switch(_4e){
case "list":
tanSearch.options.list.build();
_50.style.display="block";
break;
default:
tanSearch.options.setup.build();
_4f.style.display="block";
}
tanSearch.options.currentType=_4e;
tanSearch.switchMode("options");
};
tanSearch.options.hide=function(){
$id("options").style.display="none";
};
tanSearch.options.save=function(){
switch(tanSearch.options.currentType){
case "list":
tanSearch.options.list.save();
break;
default:
tanSearch.options.setup.save();
break;
}
tanSearch.options.currentType="";
tanSearch.search.buildUI();
tanSearch.search.checkUpdate();
};
tanSearch.options.setup={};
tanSearch.options.setup.build=function(){
var _51=$id("opt_lang");
_51.innerHTML="";
for(label in tanSearch.localeLang){
_51.options.add(new Option(tanSearch.localeLang[label]._name.$encodeHTML(),label));
if(tanSearch.user.langCode==label){
_51.selectedIndex=_51.options.length-1;
}
}
$id("opt_save_history").checked=tanSearch.user.saveHistory;
$id("opt_load_all").checked=tanSearch.user.loadAll;
};
tanSearch.options.setup.save=function(){
var _52=$id("opt_lang");
var _53=_52.options[_52.selectedIndex].value;
if(tanSearch.user.langCode!=_53){
tanSearch.user.langCode=_53;
tanSearch.updateLanguage();
tanSearch.config.loadPreferredList();
tanSearch.search.buildUI();
}
tanSearch.user.langCode=_53;
tanSearch.user.saveHistory=$id("opt_save_history").checked;
tanSearch.user.loadAll=$id("opt_load_all").checked;
tanSearch.config.saveSettings();
};
tanSearch.options.list={};
tanSearch.options.list.build=function(){
$id("opt_edit_table").style.display="none";
tanSearch.options.preferredList=$clone(tanSearch.user.list);
tanSearch.options.processedList=tanSearch.config.convertPreferredList(tanSearch.options.preferredList);
tanSearch.options.list.buildPreferred();
tanSearch.options.list.buildAll();
};
tanSearch.options.list.save=function(){
tanSearch.options.list.saveItem();
tanSearch.user.list=tanSearch.options.preferredList;
tanSearch.list["preferred"].items=tanSearch.options.processedList;
tanSearch.list["preferred"].defaultTab=null;
tanSearch.config.savePreferredList();
};
tanSearch.options.list.labelToIndex=function(_54){
for(var i=0;i<tanSearch.options.preferredList.length;i++){
var _56=tanSearch.options.preferredList[i];
var id=_56.c?_56.c+"_"+_56.n:_56.n;
if(id==_54){
return i;
}
}
return -1;
};
tanSearch.options.list.buildPreferred=function(){
var _58="";
for(var _59 in tanSearch.options.processedList){
var _5a=tanSearch.options.processedList[_59];
_58+="<div class=\"list-item-hot\" style=\"cursor:pointer;\" id=\"p_"+_59+"\""+" onclick=\"tanSearch.options.list.selectItem('"+_59+"')\""+">"+"<div class=\"list-control\">"+"&nbsp; <img width=\"16\" height=\"16\" src=\"images/btn_remove.png\" onclick=\"tanSearch.options.list.removeItem('"+_59+"')\" alt=\""+$lang("list_remove")+"\"/>"+"</div>"+_5a.title.$encodeHTML()+(_5a.custom?" <img width=\"16\" height=\"16\" src=\"images/custom.png\" alt=\"Custom\"/>":"")+"</div>";
}
$write(_58,"list_preferred");
tanSearch.options.list.selectedItem="";
$id("opt_edit_table").style.display="none";
};
tanSearch.options.list.buildAll=function(){
var _5b="";
var _5c="";
for(var cat in tanSearch.list){
if(cat=="preferred"){
continue;
}
var _5e="";
for(var _5f in tanSearch.list[cat].items){
var _60=tanSearch.list[cat].items[_5f];
var sid=cat+"_"+_5f;
var _62=tanSearch.options.processedList[sid]!=undefined?true:false;
_5e+="<div id=\"a_"+sid+"\" class=\"list-item\" onclick=\"tanSearch.options.list.addItem('"+cat+"','"+_5f+"')\" alt=\""+$lang("list_add")+"\""+(_62?" style=\"display:none;\"":"")+">"+_60.title.$encodeHTML()+(_60.subtitle?_60.subtitle.$encodeHTML():"")+"</div>";
}
_5b+="<div id=\"c_"+cat+"\" class=\"list-cat\" onclick=\"tanSearch.options.list.toggleCategory('"+cat+"')\">"+"<code>-</code> "+tanSearch.list[cat].title.$encodeHTML()+"</div>";
_5b+="<div id=\"cw_"+cat+"\">"+_5e+"</div>";
}
$write(_5b,"list_all");
};
tanSearch.options.list.toggleCategory=function(cat){
var obj=$id("c_"+cat);
var _65=$id("cw_"+cat);
if(_65.style.display!="none"){
_65.style.display="none";
obj.innerHTML="<code>+</code> "+tanSearch.list[cat].title.$encodeHTML();
}else{
_65.style.display="block";
obj.innerHTML="<code>-</code> "+tanSearch.list[cat].title.$encodeHTML();
}
};
tanSearch.options.list.selectItem=function(_66){
try{
$id("p_"+tanSearch.options.list.selectedItem).className="list-item-hot";
tanSearch.options.list.toggleControl(tanSearch.options.list.selectedItem,false);
}
catch(e){
}
$id("p_"+_66).className="list-item-selected";
tanSearch.options.list.toggleControl(_66,true);
if(tanSearch.options.list.inEditCustom==true){
tanSearch.options.list.saveItem();
}
tanSearch.options.list.selectedItem=_66;
$id("opt_edit_table").style.display="block";
tanSearch.options.list.showItemData(_66);
};
tanSearch.options.list.toggleControl=function(_67,_68){
var obj=$id("c_p_"+_67);
if(!obj){
return;
}
if(_68){
obj.style.visibility="visible";
}else{
obj.style.visibility="hidden";
}
};
tanSearch.options.list.moveItem=function(_6a){
var _6b=tanSearch.options.list.labelToIndex(tanSearch.options.list.selectedItem);
if(_6b<0){
return;
}
var _6c=tanSearch.options.preferredList;
var _6d=_6c[_6b];
var _6e=_6c[_6b+_6a];
if(_6a<0){
if(_6b==0){
return;
}
_6c.splice(_6b,1);
_6c.splice(_6b+_6a,1,_6d,_6e);
}else{
if(_6b==(tanSearch.options.preferredList.length-1)){
return;
}
_6c.splice(_6b+_6a,1,_6e,_6d);
_6c.splice(_6b,1);
}
var _6f=_6d.c?_6d.c+"_"+_6d.n:_6d.n;
var _70=_6e.c?_6e.c+"_"+_6e.n:_6e.n;
var s=$id("p_"+_6f);
var t=$id("p_"+_70);
var p=s.parentNode;
if(_6a<0){
p.insertBefore(s,t);
}else{
p.insertBefore(t,s);
}
tanSearch.options.processedList=tanSearch.config.convertPreferredList(tanSearch.options.preferredList);
};
tanSearch.options.list.addItem=function(cat,_75){
if(tanSearch.options.processedList[cat+"_"+_75]){
alert("This search engine has already added!");
return;
}
try{
var _76=tanSearch.list[cat][_75];
}
catch(e){
return;
}
tanSearch.options.preferredList.push({c:cat,n:_75});
$id("a_"+cat+"_"+_75).style.display="none";
tanSearch.options.processedList=tanSearch.config.convertPreferredList(tanSearch.options.preferredList);
tanSearch.options.list.buildPreferred();
};
tanSearch.options.list.addCustomItem=function(){
var _77="";
for(var i=0;i<20;i++){
_77="c_"+i;
if(tanSearch.options.processedList[_77]==undefined){
break;
}
}
var _79={n:_77,t:$lang("default_title"),u:"http://search/?q={keyword}"};
tanSearch.options.preferredList.push(_79);
var _79={custom:true,name:_77,title:$lang("default_title"),url:"http://search/?q={keyword}"};
tanSearch.options.processedList[_77]=_79;
tanSearch.options.list.buildPreferred();
tanSearch.options.list.selectItem(_77);
};
tanSearch.options.list.showItemData=function(sid){
var _7b=tanSearch.options.processedList[sid];
var _7c=$id("i_name");
var _7d=$id("i_url");
var _7e=$id("i_note_internal");
var _7f=$id("i_note_edit");
_7c.value=_7b.title;
_7d.value=_7b.url;
_7e.style.display="none";
_7f.style.display="none";
if(_7b.custom){
tanSearch.options.list.inEditCustom=true;
_7f.style.display="inline";
_7c.disabled=false;
_7d.disabled=false;
}else{
tanSearch.options.list.inEditCustom=false;
_7e.style.display="inline";
_7c.disabled=true;
_7d.disabled=true;
}
};
tanSearch.options.list.saveItem=function(){
if(!tanSearch.options.list.inEditCustom){
return;
}
var _80=tanSearch.options.list.labelToIndex(tanSearch.options.list.selectedItem);
if(_80<0){
alert("invalid item");
return;
}
var _81={n:tanSearch.options.list.selectedItem,t:$id("i_name").value.$trim(),u:$id("i_url").value.$trim()};
if(_81.t.length<1||_81.t.length>20){
alert($lang("invalid_name"));
return;
}
if(_81.u.indexOf("http")!=0){
alert($lang("invalid_url"));
return;
}
if(_81.u.indexOf("{keyword")<0){
alert($lang("invalid_url_keyword"));
return;
}
tanSearch.options.preferredList[_80]=_81;
tanSearch.options.processedList[_81.n]={custom:true,name:_81.n,title:_81.t,url:_81.u};
tanSearch.options.list.buildPreferred();
};
tanSearch.options.list.removeItem=function(_82){
var _83=tanSearch.options.list.labelToIndex(_82);
var _84=tanSearch.options.preferredList[_83];
if(tanSearch.options.preferredList.length==1){
alert($lang("list_at_least_one"));
return;
}
if(!_84.c){
if(!confirm($lang("list_delete_confirm"))){
return;
}
}
if(_84.c){
$id("a_"+_84.c+"_"+_84.n).style.display="block";
}
tanSearch.options.preferredList.splice(_83,1);
tanSearch.options.processedList=tanSearch.config.convertPreferredList(tanSearch.options.preferredList);
tanSearch.options.list.buildPreferred();
};
tanSearch.options.list.restoreDefault=function(){
if(!confirm($lang("list_default_confirm"))){
return;
}
tanSearch.options.preferredList=$clone(tanSearch.defaults.preferredList[tanSearch.user.langCode]);
tanSearch.options.processedList=tanSearch.config.convertPreferredList(tanSearch.options.preferredList);
tanSearch.options.list.buildPreferred();
};

