function SD_needGoogleTradeMark(d){for(var g=["google.com","google.cn","googlechinablog.com","gmodules.com","googlepages.com","googlecode.com"],a=0;a<g.length;a++){var j=d.indexOf(g[a]);if(j==0||j>0&&j==d.length-g[a].length&&d.charAt(j-1)==".")return false}return true}window.daohangSuggest={};
(function(){var d=window.encodeURIComponent?encodeURIComponent:escape,g=window.decodeURIComponent?decodeURIComponent:unescape,a={};function j(e){return document.getElementById(e)}a.keyStrokeTimeoutId=-1;a.GetQueryFromInputField=function(){return a.inputFieldEl.value.toLowerCase().replace(/\s+/g,"")};a.SetGoogleTradeMarkToInputBox=function(e){if(e&&a.hostName&&SD_needGoogleTradeMark(window.location.hostname)){a.inputFieldEl.style.backgroundImage="url('"+a.hostName+"/images/watermark.gif')";a.inputFieldEl.style.backgroundRepeat=
"no-repeat";a.inputFieldEl.style.backgroundPositionY="50%"}else a.inputFieldEl.style.backgroundImage=""};a.Install=function(e,m,n,q,k,p,t,s){a.searchActive=false;a.typedQuery="";a.grayDescriptionText="";a.showGrayDescription=true;a.ajaxObject=null;a.waitingForSearchResults=false;a.searchCache={};a.results=null;a.inputFieldEl=j(e);a.suggestResultEl=j(m);a.renderFunction=n;a.maxResultCount=!q?60:q;a.clientType=!s?"daohang":s;a.hostName=k?k:"";a.SetGoogleTradeMarkToInputBox(true);a.initialized=true;
a.backupInitialResult=a.suggestResultEl.innerHTML;a.grayDescriptionText=a.GetQueryFromInputField();a.inputFieldEl.onkeyup=a.HandleInputKeyUp;a.inputFieldEl.onblur=a.HandleInputBlur;a.inputFieldEl.onfocus=a.HandleInputFocus;if(p){a.googleSearchFieldEl=j(p);a.googleSearchFieldEl.focus()}a.addGoogleSuggest=!t?false:t};a.UpdateInitialResult=function(e){if(e)a.backupInitialResult=e};a.ClearTypedQuery=function(){a.typedQuery=""};a.HandleInputKeyUp=function(e){if(a.initialized)if(a.searchActive){a.inputFieldEl.style.color=
"#000";e=a.GetQueryFromInputField();if(e!=a.typedQuery){if(a.keyStrokeTimeoutId!=-1){window.clearTimeout(a.keyStrokeTimeoutId);a.keyStrokeTimeoutId=-1}a.typedQuery=e;a.keyStrokeTimeoutId=window.setTimeout(a.QuerySearch,100)}return true}};a.HandleInputFocus=function(e){if(a.showGrayDescription==true){a.inputFieldEl.value="";a.inputFieldEl.style.color="#000";a.SetGoogleTradeMarkToInputBox(false)}a.searchActive=true};a.HandleInputBlur=function(e){e=a.GetQueryFromInputField();if(e==""){a.inputFieldEl.value=
a.grayDescriptionText;a.inputFieldEl.style.color="#999";a.showGrayDescription=true;a.SetGoogleTradeMarkToInputBox(true)}else a.showGrayDescription=false;a.typedQuery=e;a.searchActive=false};a.ChangeWaitingForSearchResults=function(e){if(a.waitingForSearchResults!=e){e||a.CancelCurrentAjaxRequest();a.waitingForSearchResults=e}};a.CancelCurrentAjaxRequest=function(){if(a.ajaxObject)try{var e=document.getElementsByTagName("head").item(0);e.removeChild(a.ajaxObject)}catch(m){}};a.QuerySearch=function(){if(a.searchActive)if(a.typedQuery==
"")a.suggestResultEl.innerHTML=a.backupInitialResult;else{var e=d(a.typedQuery),m=a.hostName+"/suggest?num="+a.maxResultCount+"&q="+e+"&client="+a.clientType,n="http://www.google.cn/complete/search?hl=zh-CN&client=suggest&js=true&q="+e;if(a.searchCache[e]){a.waitingForSearchResults&&a.ChangeWaitingForSearchResults(false);a.ProccessResults(a.searchCache[e],true)}else{a.ChangeWaitingForSearchResults(true);a.ajaxObject=document.createElement("script");a.ajaxObject.src=m;a.ajaxObject.charset="utf-8";
a.ajaxObject.type="text/javascript";a.ajaxObject.defer=true;e=document.getElementsByTagName("head").item(0);e.appendChild(a.ajaxObject);if(a.addGoogleSuggest){a.ajaxObject=document.createElement("script");a.ajaxObject.src=n;a.ajaxObject.charset="utf-8";a.ajaxObject.type="text/javascript";a.ajaxObject.defer=true;e=document.getElementsByTagName("head").item(0);e.appendChild(a.ajaxObject)}}}};a.HandleAjaxResponse=function(e){a.ProccessResults(e,false)};a.ProccessResults=function(e,m){a.results=e.split("|");
var n=a.results[0];m||(a.searchCache[n]=e);g(n)==a.typedQuery&&a.renderFunction(a.results,a.suggestResultEl,1)};a.ClickLog=function(e){var m=e*2+1;(new Image).src="http://www.google.cn/url?sa=T&url="+d(a.results[m])+"&ct=sit&cd="+e+"&cad=sgt&source=shallowdir"};window.daohangSuggest={_installSugg:a.Install,_handleAjax:a.HandleAjaxResponse,_shdSuggLog:a.ClickLog,_updateInnerHtml:a.UpdateInitialResult,_clearTypedQuery:a.ClearTypedQuery,_handleKeyUp:a.HandleInputKeyUp}})();
var _installSugg=window.daohangSuggest._installSugg,_handleAjax=window.daohangSuggest._handleAjax,_shdSuggLog=window.daohangSuggest._shdSuggLog,_updateInnerHtml=window.daohangSuggest._updateInnerHtml,_clearTypedQuery=window.daohangSuggest._clearTypedQuery,_handleKeyUp=window.daohangSuggest._handleKeyUp;
function onResizeElement(d,g){if(d){var a=Math.floor(d.offsetWidth/66);if(a>12)a=12;if(a<2)a=2;var j=d.className.replace(/gg-span-\d+/g,"");j+=" gg-span-"+a;if(g){j=j.replace(new RegExp(g+"-span-\\d+","g"),"");j+=" "+g+"-span-"+a}d.className=j}}function clickTrack(d){this.a=d}
clickTrack.prototype.click=function(d){var g="http://www.google.cn/ig/ui?",a=["action=chinagadgets"];a.push("m="+this.a);if(d)for(var j=new Array("id","nodeName","href"),e=0,m=j.length;e<m;e++)d[j[e]]&&a.push(j[e]+"="+_esc(d[j[e]]));if(document.images)(new Image).src=g+a.join("&")};var ct=new clickTrack("shallowdir_v2");window.shallowdir={};
function _shallowdir_init(d){var g=new _IG_Prefs,a=new _IG_Tabs,j=g.getInt("count");j=j?j:36;var e=parseInt(g.getMsg("default_number_of_visited_items"),10),m=g.getMsg("default_tab_count"),n=[],q=[],k=[],p=[],t=g.getInt("selected_tab_index"),s={},r=39;function z(b,c,f){var h=[];if(b.length==f)h.push('<div id="dhs_loading">'+g.getMsg("nofound")+"</div>");else{h.push('<ol class="gg-section gg-grid-1dot3 gg-grid">');f=f;for(var i=0;i<r;i++){if(f<b.length){h.push('<li><h4><a href="');h.push(b[f]);h.push('" onclick="window.shallowdir._addVisitedWebsites'+
d+'(this.href, this.innerHTML)" onmousedown="ct.click(this)"');h.push(' target="_blank">');h.push(b[f+1]);h.push("</a></h4></li>")}else h.push('<li style="background:none">&nbsp;</li>');f+=2}h.push("</ol>");_gel("history"+d).innerHTML=u(a.getSelectedTab().getIndex())}c.innerHTML=h.join("")}window._shdInstallSuggest=function(){window.daohangSuggest?window.daohangSuggest._installSugg("dhs_q","content_div",z,r,"http://www.265.com"):window.setTimeout("_shdInstallSuggest()",500)};function A(b){if(!b||
typeof b!="object"||!b.firstChild||!b.getElementsByTagName("site").length)_gel("content_div").innerHTML='<div id="dhs_loading">'+g.getMsg("loading")+"</div>";else{var c=b.getElementsByTagName("category")[0];if(c=c.getAttribute("name"))c=" - "+c;b=b.getElementsByTagName("site");c=['<ol class="gg-section gg-grid-1dot3 gg-grid">'];for(var f=_min(b.length,r),h=0;h<f;h++){var i=b[h],o=i.getAttribute("url");i=i.getAttribute("title");c.push('<li><h4><a href="'+o+'" title="'+i+'" onclick="window.shallowdir._addVisitedWebsites'+
d+'(this.href, this.innerHTML)" onmousedown="ct.click(this)" target="_blank">'+i+"</a></h4></li>")}c.push("</ol>");_gel("history"+d).innerHTML=u(a.getSelectedTab().getIndex());_gel("content_div").innerHTML=c.join("")}window._shdInstallSuggest()}function B(b,c){_gel("content_div").innerHTML="<i>"+g.getMsg("loading")+"</i>";if(c){b="http://www.google.cn/ig/modules/chinagadgets/exp/shallowdir/topwebsites/topwebsites/"+c+".xml";_IG_FetchXmlContent(b,A,{refreshInterval:1800});window._shdInstallSuggest()}}
function w(){r=39;if(r<=0||r>60)r=60;B(r,q[a.getSelectedTab().getIndex()]);_gel("dhs_q").value=g.getMsg("example");_gel("dhs_q").style.color="#999999";_gel("dhs_q").onkeydown=function(b){b=b||window.event;var c=b.keyCode||b.which||b.charCode;setTimeout(function(){if(_gel("dhs_q").value==""){_gel("content_div").style.display="none";_gel("content_div").innerHTML="<i>"+g.getMsg("loading")+"</i>";_gel("content"+d).style.display="block";v();q[a.getSelectedTab().getIndex()]||x(false)()}else{if(!q[a.getSelectedTab().getIndex()]&&
c!=37&&c!=38&&c!=39&&c!=40)_gel("content_div").innerHTML="<i>"+g.getMsg("loading")+"</i>";_gel("content_div").style.display="";_gel("content"+d).style.display="none"}},0)}}function C(){s={};k=[];p=[];q=[];n=[];var b=g.getString("selected_sections"),c=b.split(",").length;if(!b){b=g.getMsg("section");c=m}b=b.split(",");for(var f=0;f<c;++f){var h=b[f].split("|");n[f]=h[0];q[f]=h[1];s[n[f]]=q[f]}b=g.getString("visited_websites");b=b.split("||");if(b.length>=2)for(f=0;f<b.length-1&&f<e*2;f+=2){k.push(b[f]);
p.push(b[f+1])}}function D(b,c){c=c.replace("<span>","");c=c.replace("</span>","");c=c.replace("<SPAN>","");c=c.replace("</SPAN>","");for(var f=false,h=0;h<k.length;++h)if(b==k[h]){k.splice(h,1);p.splice(h,1);f=true;break}if(!f&&k.length==e){k.shift();p.shift()}k.push(_hesc(b));p.push(_hesc(c));b=[];c=[];for(h=0;h<k.length;++h){b.push(k[h]);b.push(p[h]);c.push('<a href="'+k[h]+'">'+p[h]+"</a>")}g.set("visited_websites",b.join("||").replace(/<a /g,'<a onmousedown="ct.click(this)" target=_blank '));
if(!_gel(a.getSelectedTab().visitedWebsiteID))_gel("history"+d).innerHTML=u(a.getSelectedTab().tabId);_gel(a.getSelectedTab().visitedWebsiteID).innerHTML=c.join(g.getMsg("split_visit"));v()}function E(){if(a.getTabs().length)for(var b=a.getTabs().length-1;b>=0;--b)a.removeTab(0);C();for(b=0;b<n.length;++b){var c=n[b];c==g.getMsg("coolSite")?a.addTab("<span> "+g.getMsg("coolSite")+" </span>",{callback:_IG_Callback(x(true)),tooltip:g.getMsg("coolSite")}):a.addTab("<span>"+_hesc(c)+"</span>",{callback:_IG_Callback(F,
b,c,q[b]),tooltip:c})}a.addTab("<span> + </span>",{callback:_IG_Callback(G),tooltip:g.getMsg("config_tab_tooltip")});a.setSelectedTab(0)}function x(b){return function(){b&&w();_gel("history"+d).style.display="";_gel("dhs_q").style.display="";_gel("content_div").style.display="none";_gel("content"+d).style.display="block";for(var c=g.getMsg("coolSiteList").split("@"),f=['<ol class="L-list">'],h=0;h<c.length;h++){f.push("<li><ul>");for(var i=c[h].split(","),o=0;o<i.length;o++){var l=i[o].split("|");
if(o==0&&_hesc(l[0])=="Flash")f.push('<li class="L-title"><h4><a href="'+_hesc(l[1])+'" onclick="window.shallowdir._addVisitedWebsites'+d+'(this.href, this.innerHTML)" class="L-title" >['+_hesc(l[0])+"]</a></h4></li>");else o==0?f.push('<li class="L-title"><h4><a href="'+_hesc(l[1])+'" onclick="window.shallowdir._addVisitedWebsites'+d+'(this.href, this.innerHTML)" class="L-title" >[ '+_hesc(l[0])+" ]</a></h4></li>"):f.push('<li><h4><a href="'+_hesc(l[1])+'" onclick="window.shallowdir._addVisitedWebsites'+
d+'(this.href, this.innerHTML)">'+_hesc(l[0])+"</a></h4></li>")}f.push("</ul></li>")}f.push("</ol>");f.push('<div style="text-align:right;clear:both"><a href="http://www.265.com/" target="_blank">'+g.getMsg("more")+"</a></div>");_gel("history"+d).innerHTML=u("");_gel("content"+d).innerHTML=f.join("").replace(/<a /g,'<a onmousedown="ct.click(this)" target=_blank ');v()}}function G(b){_gel("history"+d).style.display="none";_gel("dhs_q").style.display="none";_gel("content_div").style.display="none";
_gel("content"+d).style.display="block";b=g.getMsg("section").split(",");for(var c=[g.getMsg("set_favorite_topic_msg"),'<ol class="gg-section gg-grid-1dot3 gg-grid">'],f=0;f<b.length;++f){var h=b[f].split("|");c.push('<li><label><input id="topic_checkbox'+d+h[1]+'" type="checkbox" '+(s[h[0]]?"checked":"")+"/>"+h[0]+"</label></li>")}c.push("</ol>");c.push('<div class="gg-section">');c.push('<input type="button" class="gg-button gg-button-primary" ');c.push('value="'+g.getMsg("save_msg")+'" ');c.push('onclick="window.shallowdir._saveConfig'+
d+'()"/>');c.push('<input type="button" class="gg-button" ');c.push('value="'+g.getMsg("cancel_msg")+'" ');c.push('onclick="window.shallowdir._cancelConfig'+d+'()"/>');c.push("</div>");_gel("content"+d).innerHTML=c.join("")}function H(){var b=g.getMsg("section");b=b.split(",");for(var c=[],f=0;f<b.length;++f){var h=b[f].split("|"),i=_gel("topic_checkbox"+d+h[1]);i.checked&&c.push(h[0]+"|"+h[1])}g.set("selected_sections",c.join(","));y()}function I(){a.setSelectedTab(t)}function J(b,c){_gel(b).innerHTML=
"<div>"+c+"</div>"}function F(b,c,f,h){_gel("history"+d).style.display="";_gel("dhs_q").style.display="";_gel("content_div").style.display="none";_gel("content"+d).style.display="block";w();_gel("content"+d).innerHTML='<div class="gg-loading" title="'+d+'"></div>';_IG_FetchXmlContent("http://www.google.cn/ig/modules/chinagadgets/exp/shallowdir/topwebsites/"+h+".xml",function(i){var o=i?i.getElementsByTagName("site"):null;if(!i||!o.length)J(b,i?g.getMsg("no_data"):g.getMsg("error"));else{i="visited_website"+
d+b;a.getSelectedTab().visitedWebsiteID=i;a.getSelectedTab().tabId=b;g.set("selected_tab_index",c);g.set("selected_category",h);t=c;i=['<ol class="gg-section gg-grid-1dot3 gg-grid">'];for(var l=0;l<o.length&&l<j;++l){var K=o[l].getAttribute("url"),L=o[l].getAttribute("title");i.push('<li><h4><a href="'+_hesc(K)+'" onclick="window.shallowdir._addVisitedWebsites'+d+'(this.href, this.innerHTML)">'+_hesc(L)+"</a></h4></li>")}i.push("</ol>");i.push('<div style="text-align:right;clear:both"><a href="http://www.265.com/" target="_blank">'+
g.getMsg("more")+"</a></div>");_gel("history"+d).innerHTML=u(b);_gel("content"+d).innerHTML=i.join("").replace(/<a /g,'<a onmousedown="ct.click(this)" target=_blank ');v()}},{refreshInterval:600})}function u(b){var c=[];b="visited_website"+d+b;c.push('<div style="clear:both"></div>');c.push('<div style="bottom:0;display:inline-block;z-index:99999;" class="gg-section">'+g.getMsg("recent_visit"));c.push('<span id="'+b+'">');b=[];for(var f=0;f<k.length;++f)b.push('<a href="'+k[f]+'" target=_blank>'+
p[f]+"</a>");c.push(b.join(g.getMsg("split_visit")));c.push("</span></div>");return c.join("")}function y(){E();w();_IG_AddDOMEventHandler(window,"resize",v)}function v(){var b=_gel("content"+d);if(b.style.display=="none"){onResizeElement(_gel("content_div"),"shallowdir");_gel("content"+d).className=_gel("content_div").className}else{onResizeElement(_gel("content"+d),"shallowdir");_gel("content_div").className=_gel("content"+d).className}_IG_AdjustIFrameHeight()}window.shallowdir["_cancelConfig"+
d]=I;window.shallowdir["_saveConfig"+d]=H;window.shallowdir["_addVisitedWebsites"+d]=D;y()}