var BdComment=function(){var fe={};fe.getRandomKey=function(){return parseInt(new Date().getTime()*Math.random()*10000)};function C(tag){if(typeof tag=="string"){return document.createElement(tag)}else{if(typeof tag=="object"){return tag}}return null}function byteLength(str){return str.replace(/[^\u0000-\u007f]/g,"\u0061\u0061").length}function trim(s){s=s.replace(/(^\s+)|(\s+$)/g,"");s=s.replace(/\[_br_\]+/gm,"");s=s.replace(/(^　+)|(　+$)/g,"");return s}fe.isArray=function(o){return(o&&typeof o.length=="number"&&typeof o.splice!="undefined"&&!Fe.propertyIsEnumerable(o,"length"))};function G(id){if(typeof id=="string"){return document.getElementById(id)}else{if(typeof id=="object"){return id}}return null}fe.removeAt=function(me,index){return me.splice(index,1)};function Gn(name){return document.getElementsByName(name)}var Browser=(function(){var ua=navigator.userAgent;var safari=0,webkit=0,opera=0,ie=0,gecko=0,ff=0;if(ua.indexOf("Safari")>-1&&/Version\/(\d+(\.\d+)?)/.test(ua)){safari=RegExp.$1}if(window.opera&&/Opera(\s|\/)(\d+(\.\d+)?)/.test(ua)){opera=RegExp.$2}if(ua.indexOf("Gecko")>-1&&ua.indexOf("KHTML")==-1&&/rv\:(\d+(\.\d+)?)/.test(ua)){gecko=RegExp.$1}if(/MSIE (\d+(\.\d+)?)/.test(ua)){ie=RegExp.$1}if(/Firefox(\s|\/)(\d+(\.\d+)?)/.test(ua)){ff=RegExp.$2}if(ua.indexOf("KHTML")>-1&&/AppleWebKit\/([^\s]*)/.test(ua)){webkit=RegExp.$1}return({isStrict:document.compatMode=="CSS1Compat",isSafari:safari,isWebkit:webkit,isOpera:opera,isGecko:gecko,isIE:ie,isFF:ff})})();fe.on=function(el,type,handler){var a=[],type=type.replace(/^on/,"").toLowerCase();for(var i=3,l=arguments.length;i<l;i++){a.push(arguments[i])}if(el.attachEvent){el[type+handler]=function(){a=[event].concat(a);handler.apply(el,a)};el.attachEvent("on"+type,el[type+handler])}else{el[type+handler]=function(e){a=[e].concat(a);handler.apply(el,a)};el.addEventListener(type,el[type+handler],false)}};var format=function(str,json){if(arguments.length>1){var m=format,k=/([.*+?^=!:${}()|[\]\/\\])/g,l=(m.left_delimiter||"{").replace(k,"\\$1"),r=(m.right_delimiter||"}").replace(k,"\\$1");var r1=m._r1||(m._r1=new RegExp("#"+l+"([^"+l+r+"]+)"+r,"g")),r2=m._r2||(m._r2=new RegExp("#"+l+"(\\d+)"+r,"g"));if(typeof (json)=="object"){return str.replace(r1,function(a,key){var v=json[key];if(typeof v=="function"){v=v(key)}return typeof (v)=="undefined"?"":v})}else{if(typeof (json)!="undefined"){var vs=Array.prototype.slice.call(arguments,1);var vl=vs.length;return str.replace(r2,function(a,index){index=parseInt(index,10);return(index>=vl)?a:vs[index]})}}}return str};format.delimiter=function(left,right){var me=Fe.format;me.left_delimiter=left||"{";me.right_delimiter=right||left||"}";me._r1=me._r2=null};var setStyle=function(a,b){var c=document.styleSheets[0];if(c.addRule){c.addRule(a,b)}else{if(c.insertRule){c.insertRule(a+" { "+b+" }",c.cssRules.length)}}};var StringBuffer=function(){this.bf=new Array()};StringBuffer.prototype.append=function(str){this.bf.push(str)};StringBuffer.prototype.toString=function(){return this.bf.join("")};if(Browser.isFF){HTMLElement.prototype.__defineGetter__("children",function(){var nodes=this.childNodes;var nNodes=nodes.length;for(var a=[],i=0;i<nNodes;i++){if(nodes[i].nodeType==1){a.push(nodes[i])}}return a})}var body=function(){var W=0,H=0,SL=0,ST=0,SW=0,SH=0,STH=0,STW=0;var w=window,d=document,dd=d.documentElement;W=dd.clientWidth||d.body.clientWidth;H=w.innerHeight||dd.clientHeight||d.body.clientHeight;ST=parseInt(d.body.scrollTop)||parseInt(dd.scrollTop);SL=parseInt(d.body.scrollLeft)||parseInt(dd.scrollLeft);SW=Math.max(d.body.scrollWidth,dd.scrollWidth||0);SH=Math.max(d.body.scrollHeight,dd.scrollHeight||0,H);STH=SH+ST;STW=SW+SL;return{scrollTop:parseInt(ST),scrollLeft:parseInt(SL),documentWidth:parseInt(SW),documentHeight:parseInt(SH),viewWidth:parseInt(W),viewHeight:parseInt(H),scrollHeight:STH,scrollWidth:STW}};Object.extend=function(des,src){for(var property in src){des[property]=src[property]}return des};fe.encodeText=function(str){str=str.replace(/</g,"&lt;");str=str.replace(/>/g,"&gt;");str=str.replace(/\'/g,"&#39;");str=str.replace(/\"/g,"&#34;");str=str.replace(/\\/g,"&#92;");str=str.replace(/\[/g,"&#91;");str=str.replace(/\]/g,"&#93;");str=str.replace(/(\u000A|\u000D)+/gm,"[_br_]");str=str.replace(/\s/g,"　");return str};fe.decodeHtml=function(str){str=str.replace(/&lt;/g,"<");str=str.replace(/&gt;/g,">");str=str.replace(/&#39;/g,"'");str=str.replace(/&#34;/g,'"');str=str.replace(/&#92;/g,"\\");str=str.replace(/&#91;/g,"[");str=str.replace(/\&#93;/g,"]");return str};fe.decodeText=function(str){str=str.replace(/\[_i_\]/g,"<i>");str=str.replace(/\[_\/i_\]/g,"</i>");str=str.replace(/\[_b_\]/g,"<b>");str=str.replace(/\[_\/b_\]/g,"</b>");str=str.replace(/\[_em_\]/g,"<em>");str=str.replace(/\[_\/em_\]/g,"</em>");str=str.replace(/\[_u_\]/g,"<u>");str=str.replace(/\[_\/u_\]/g,"</u>");str=str.replace(/\[_br_\]/g,"<br>");str=str.replace(/&#91;_br_&#93;/g,"<br>");str=str.replace(/\[_q_\]/g,"<q>");str=str.replace(/\[_\/q_\]/g,"</q>");return str};window.getUrlArgs=function(key,s){var reg=new RegExp(key+"=([0-9]+)"),s=s||location.href;if(reg.test(s)){return RegExp.$1}return null};window.setReplyFocus=function(){var textarea=G(CommentConfig.CommentReply.id.textarea_id),panel=G(CommentConfig.CommentReply.id.panel_id);if(textarea){panel.scrollIntoView();setTimeout(function(){textarea.focus()},100)}};function deHtmlEntity(s){if(typeof (deHtmlEntity.div)!="object"){deHtmlEntity.div=C("div")}if(!CommentConfig.CommentList.isWarp){s=s.replace(/\[_br_\]/g,"　")}if(/&#[0-9]+?;/.test(s)){deHtmlEntity.div.innerHTML=s;return deHtmlEntity.div.innerHTML}return s}function serCommentData(o){var config=CommentConfig.CommentList;newObject={};newObject.data={};newObject.arrData=[];var data=o.body.data;for(var i=0,l=data.length;i<l;i++){if(data[i]["un"]==""||data[i]["un"]=="anonymous"){data[i]["un"]=config.anonymous}data[i]["ip"]=replaceIp(data[i]["ip"]);if(data[i]["cdatetime"]!=""){data[i]["cdatetime"]=formatDate(new Date(data[i]["cdatetime"]*1000),config.date_format)}newObject.data[data[i]["reply_id"]]=data[i];newObject.data[data[i]["reply_id"]].number=i+1;newObject.data[data[i]["reply_id"]].content=deHtmlEntity(data[i]["content"]);var cloneData=Object.clone(data[i]);newObject.arrData.push(cloneData)}delete data;for(var j in o){newObject[j]=o[j]}newObject.body.length=l;return newObject}function replaceIp(str){str=str.replace(/[^.]+$/g,"*");return str}function formatDate(me,format){var x=me;var p=function(s){return s<10?"0"+s:s};return format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?/g,function(format){switch(format){case"hh":return p(x.getHours()<13?(x.getHours()===0?12:x.getHours()):(x.getHours()-12));case"h":return x.getHours()<13?(x.getHours()===0?12:x.getHours()):(x.getHours()-12);case"HH":return p(x.getHours());case"H":return x.getHours();case"mm":return p(x.getMinutes());case"m":return x.getMinutes();case"ss":return p(x.getSeconds());case"s":return x.getSeconds();case"yyyy":var y="000"+x.getFullYear();return y.substring(y.length-4);case"yy":var y="000"+x.getFullYear();return y.substring(y.length-2);case"dddd":return Fe.Date.lang.dayNames[x.getDay()];case"ddd":return Fe.Date.lang.abbreviatedDayNames[x.getDay()];case"dd":return p(x.getDate());case"d":return x.getDate().toString();case"MM":return p((x.getMonth()+1));case"M":return x.getMonth()+1}})}fe.isObject=function(o){return(o&&(typeof (o)=="object"||typeof (o)=="function"))||false};Object.clone=function(object){var unlinked=null;if(fe.isArray(object)){unlinked=[];for(var i=0,l=object.length;i<l;i++){unlinked[i]=Object.clone(object[i])}}else{if(fe.isObject(object)){unlinked={};for(var p in object){unlinked[p]=Object.clone(object[p])}}else{return object}}return unlinked};function deleteCookie(name,path,domain){if(getCookie(name)){document.cookie=name+"="+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}}function getCookieVal(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1){endstr=document.cookie.length}return unescape(document.cookie.substring(offset,endstr))}function getCookie(name){var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;while(i<clen){var j=i+alen;if(document.cookie.substring(i,j)==arg){return getCookieVal(j)}i=document.cookie.indexOf(" ",i)+1;if(i==0){break}}return null}var BdNet=function(){var charSet="gb2312",callBackCache=[];function json2Query(json){if(json==null||typeof json!="object"){return json}var query=[];for(var i in json){query[query.length]=i+"="+json[i]}return query.join("&")}window.comment_callback_function=function(jsonObj){var requestHash=jsonObj.query_id;callBackCache[requestHash](jsonObj);delete callBackCache[requestHash];var requestor=G("script"+requestHash);document.getElementsByTagName("HEAD")[0].removeChild(requestor);requestor=null};window.comment_postCallBack_Function=function(jsonObj){var requestHash=jsonObj.query_id;callBackCache[requestHash](jsonObj);delete callBackCache[requestHash];var requestor=G("postDiv"+requestHash);document.body.removeChild(requestor);requestor=null};function getRequest(host,jsonObj,handle){var queryString=json2Query(jsonObj);var requestHash=fe.getRandomKey()+"";var requestor=C("SCRIPT");requestor.setAttribute("type","text/javascript");requestor.setAttribute("charset",charSet);requestor.setAttribute("id","script"+requestHash);handle=handle||function(){};handle.id="script"+requestHash;callBackCache[requestHash]=handle;if(/\?/g.test(host)){if(queryString){requestor.src=host+"&"+queryString+"&query_id="+requestHash}else{requestor.src=host+"&query_id="+requestHash}}else{if(queryString){requestor.src=host+"?"+queryString+"&query_id="+requestHash}else{requestor.src=host+"?query_id="+requestHash}}var headTag=document.getElementsByTagName("HEAD")[0];if(headTag){headTag.appendChild(requestor)}else{throw new Error("No Head Tag")}}function postRequest(host,jsonObj,handle){var postCallBackUrl=CommentConfig.sys.host.postCallBackHost;var hash=fe.getRandomKey();handle=handle||function(){};callBackCache[hash]=handle;if(!!jsonObj){jsonObj.query_id=hash;jsonObj.callback_url=postCallBackUrl}else{var jsonObj={};jsonObj.query_id=hash;jsonObj.callback_url=postCallBackUrl}var divContaniner=C("DIV");divContaniner.style.display="none";divContaniner.id="postDiv"+hash;divContaniner.innerHTML="<iframe name='postFrame"+hash+"'></iframe>";var formObj=C("FORM");formObj.action=host;formObj.target="postFrame"+hash;formObj.method="post";for(var el in jsonObj){var inputObj=C("INPUT");inputObj.name=el+"";inputObj.value=jsonObj[el];formObj.appendChild(inputObj);inputObj.type="text"}divContaniner.appendChild(formObj);document.body.appendChild(divContaniner);formObj.submit()}return{sendGet:getRequest,sendPost:postRequest}}();var EventDispatcher=(function(){var queues={};function indexOf(arr,item){for(var i=0,n=arr.length;i<n;i++){if(arr[i]===item){return i}}return -1}function addEventListener(eventType){if(!queues[eventType]){queues[eventType]=[]}for(var i=1,n=arguments.length,hdl;i<n;i++){hdl=arguments[i];if(indexOf(queues[eventType],hdl)!==-1){continue}switch(typeof hdl){case"object":if(typeof hdl.handleEvent!="function"){throw new Error("Invalid event handler(index "+i+"): handleEvent() is not defined.")}break;case"function":break;default:throw new Error("Invalid event handler(index "+i+"): type of this handler is not supported.")}queues[eventType].push(hdl)}}function removeEventListener(eventType,handler){if(typeof eventType=="undefined"){return }if(typeof handler=="undefined"){return }var q=queues[eventType];if(q==null){return }var nQueue=q.length;for(var i=0;i<nQueue;i++){if(q[i]==handler){q.splice(i,1);return }}}function dispatchEvent(eventObject,errorHandler){if(arguments.length==0){return }if(typeof eventObject.type=="undefined"){throw new Error("Invalid event.")}var eventType=eventObject.type;var q=queues[eventType];if(q==null){return }var nQueue=q.length;for(var i=0;i<nQueue;i++){try{if(typeof q[i]=="function"){q[i](eventObject)}else{if(typeof q[i]=="object"){q[i].handleEvent(eventObject)}else{throw new Error("Unsupport handler type in event queue.")}}}catch(err){if(typeof errorHandler=="function"){errorHandler(err)}}}}return{initialize:function(obj){if(typeof obj!="object"){throw new Error("Invalid event dispatching target.")}obj.addEventListener=addEventListener;obj.removeEventListener=removeEventListener;obj.dispatchEvent=dispatchEvent;return obj}}})();function EventLoader(eventsConfig){if(!eventsConfig||eventsConfig.constructor!=Array){throw new Error("eventsConfig is invalid")}for(var i=0,n=eventsConfig.length;i<n;i++){var controller=eventsConfig[i].controller;var events=eventsConfig[i].event;if(!controller||!controller.addEventListener){throw new Error("The "+(i+1)+" controller's config is invalid!")}if(!events||events.constructor!=Array){throw new Error("The "+(i+1)+"controller's events are invalid!")}for(var j=0;j<events.length;j++){if(!events[j].type||!events[j].handler||events[j].handler.constructor!=Array){throw new Error("The "+(j+1)+" event of the "+(i+1)+" controller's events is invalid!")}var addEventParam=[events[j].type].concat(events[j].handler);controller.addEventListener.apply(controller,addEventParam)}}}function comment_pass_postCallBack_Function(){var sys=CommentConfig.sys;CommentPopupController();var oUrlParams={cmd:"get_reply",product_id:sys.productID,private_data:0,type:0,thread_id:228645,reply_id:0,start:0,count:1,include_top:1,favor:1,orderby_type:1,display:1,query_mask:999,r:fe.getRandomKey()};BdNet.sendGet(CommentConfig.sys.host.getHost,oUrlParams,function(o){setUserName(o)})}function setUserName(o){if(!!o){CommentData.set("USERNAME",o.username)}else{CommentData.set("USERNAME","")}CommentReply.showUserName();CommentQuickReply.handlers.login.succeed()}function passView(){var config=CommentConfig.pass,host=CommentConfig.sys.host.passportLoginHost;var o=config.passPopup;o.innerHTML=format(config.passLoginHtml,host);CommentController(o)}function logoutPassport(){deleteCookie("BDUSS","/","baidu.com");if(CommentData.get("USERNAME")!=null){setUserName()}}window.CommentPassView=passView;window.CommentPassOut=logoutPassport;window.comment_pass_postCallBack_Function=comment_pass_postCallBack_Function;var CommentTab=(function(){var _htmlTpl={tab:'<p><span><i title="tabtitle"></i>#{title}<i></i></span>                <span><i title="tabinfo"></i>#{info}<i></i></span></p>',aside:'<div class="tabAside" style="float:left;"><i title="tabaside"></i>#{html}<i></i></div>',tabbar:"",clear:'<div style="clear:both;"></div>'};var config,sys=CommentConfig.sys;_htmlTpl.tab=config&&config.htmlTpl&&config.htmlTpl.tab?config.htmlTpl.tab:_htmlTpl.tab;function _contructHtml(oOptions){var tabs=oOptions.tabs,cur=oOptions.currentTab,sb=new StringBuffer();for(var i=0,len=tabs.length;i<len;i++){sb.append(format(_htmlTpl.tab,tabs[i]))}sb.append(format(_htmlTpl.aside,oOptions.asideCont));sb.append(_htmlTpl.clear);return sb.toString()}function _getTabs(objCont){var child,len,tabs=[];var collection=objCont.getElementsByTagName("P");for(var i=0,len=collection.length;i<len;i++){tabs.push(collection[i])}return tabs}function __implement(oSrc,oDes){for(var i in oSrc){if(typeof oSrc[i]=="function"){oDes[i]=oSrc[i]}}}function _validatesOptions(oOptions){if(!oOptions){throw new Error("CommentTab.init(oOptions): oOptions is not defined or null!")}if(!oOptions.tabs||!oOptions.tabs.length||oOptions.tabs.length>32){throw new Error("CommentTab.init(oOptions): oOptions.tabs must be defined and a nonempty array whose length is less than 32!")}if(!oOptions.currentTab&&0==oOptions.currentTab){throw new Error("CommentTab.init(oOptions): oOptions.currentTab is not defined or set to an illegal value!")}if(!oOptions.asideCont||oOptions.asideCont.html==undefined){throw new Error("CommentTab.init(oOptions): oOptions.asideCont.html must be defined!")}if(!oOptions.containerId||typeof oOptions.containerId!="string"){throw new Error("CommentTab.init(oOptions): oOptions.containerId must be a string !")}}function showCommentType(tabs){var str="";for(var i=0,len=tabs.length;i<len;i++){str+=tabs[i].type.favor+" ";str+=tabs[i].type.include_top+" ";str+=tabs[i].type.orderby_type+" "}alert(str)}function _getCommentNums(obj){var tabConfig=config.tabs||[];var len=tabConfig.length,host=sys.host["getHost"];if(!host){throw new Error("CommentTab: _getCommentNums, host is undefined!")}var tmpQueryObj={cmd:"get_reply",product_id:sys.productID,thread_id:sys.threadID,reply_id:0,start:0,count:1};for(var i=0;i<len;i++){tmpQueryObj.favor=tabConfig[i].type.favor;tmpQueryObj.include_top=tabConfig[i].type.include_top;tmpQueryObj.orderby_type=tabConfig[i].type.orderby_type;(function(){var total=0,curIndex=i;BdNet.sendGet(host,tmpQueryObj,function(json){if(json.err_no=="0"){total=json.body.total_count}var brackets=CommentConfig.commentTab["bracket"]||["(",")"];obj.setTabInfo(curIndex,brackets[0]+total+brackets[1]);if(obj.currentTab==curIndex){CommentData.set("totalCommentsDisplayed",total)}})})()}}function _setCommentType(aTabs){if(aTabs.length!=undefined){var tabConfig=config.tabs||[];for(var i=0,len=aTabs.length;i<len;i++){aTabs[i].commentType=tabConfig[i].type}}}function _equal(objA,objB){for(var prop in objA){if(objB[prop]!=undefined&&objA[prop]==objB[prop]){continue}else{return false}}for(var prop in objB){if(objA[prop]!=undefined&&objA[prop]==objB[prop]){continue}else{return false}}return true}function _getTabByCommentType(oType,aTabs){if(aTabs.length!=undefined){for(var i=0,len=aTabs.length;i<len;i++){if(_equal(oType,aTabs[i].commentType)){return i}}}return 0}var _prototype={getStates:function(){var tabIndex=Math.abs(this.currentTab)%Math.min(32,this.tabs.length);return 1<<tabIndex},render:function(){var states=this.getStates();var len=this.tabs.length;for(var i=0;i<len;i++){if(states&1){this.setCurrent(i)}else{this.unsetCurrent(i)}states>>=1}if(CommentConfig.commentTab["showNumOfComments"]){this.updateTabInfo()}},handleEvent:function(evt){if(!config.isEnable){return }if(evt&&evt.commentType!=undefined){var currentTab=_getTabByCommentType(evt.commentType,this.tabs);this.setCurrentTab(currentTab);this.render()}},bindEvent:function(){var me=this,eventType="TAB_SWITCH"+this.uid;for(var i=0,len=this.tabs.length;i<len;i++){fe.on(this.tabs[i],"onclick",function(e){me.setCurrentTab(this);me.render();me.dispatchEvent({type:eventType,commentType:Object.clone(this.commentType)})})}},whichTab:function(obj){for(var i=0,len=this.tabs.length;i<len;i++){if(obj==this.tabs[i]){return i}}return false},setCurrentTab:function(){if(arguments.length<1||arguments[0]==null){return false}var obj=arguments[0],current=0;if(obj&&typeof obj=="object"){current=this.whichTab(obj);if(current===false){return false}}else{if(typeof obj=="number"){current=obj}}this.currentTab=Math.abs(current)%this.tabs.length;return this.currentTab},setCurrent:function(i){if(typeof i=="undefined"||i==null){return }this.tabs[i].className="currentTab"},unsetCurrent:function(i){if(typeof i=="undefined"||i==null){return }if("tabAside"!=this.tabs[i].className){this.tabs[i].className=""}},setTabInfo:function(tab,sInfo){if(arguments.length<2||sInfo==null){return false}var iIndex;if(typeof tab=="object"){iIndex=this.whichTab(tab);if(iIndex==false){return false}}if(typeof tab=="number"){iIndex=Math.abs(tab)%this.tabs.length}if(iIndex!=undefined){this.tabs[iIndex].innerHTML=this.tabs[iIndex].innerHTML.replace(/(<i\s+title=[\"]?tabinfo[\"]?><\/i>).*?(<i><\/i>)/i,"$1"+sInfo+"$2")}},updateTabInfo:function(){_getCommentNums(this)},setTabBar:function(sHtml){this.bar.innerHTML=sHtml},setAsideInfo:function(sInfo){var sHtml=this.aside.innerHTML;this.aside.innerHTML=sHtml.replace(/(<i\s+title=[\"]?tabaside[\"]?><\/i>).*?(<i><\/i>)/i,"$1"+sInfo+"$2")},init:function(oOptions){_validatesOptions(oOptions);config=CommentConfig.commentTab;if(config.isEnable===false){return }if(sys.threadID==-1){return }this.container=document.createElement("DIV");this.bar=document.createElement("DIV");this.uid=CommentTab.uid==0?"":CommentTab.uid;this.container.id="Comment_tabContainer"+this.uid;this.bar.id="Comment_tabBar"+this.uid;this.container.innerHTML=_contructHtml(oOptions);this.tabs=_getTabs(this.container);_setCommentType(this.tabs);if(this.tabs.length>0){this.currentTab=this.setCurrentTab(oOptions.currentTab-1);this.setCurrent(this.currentTab);this.parentContainer=G(oOptions.containerId)||document.documentElement||document.body;this.parentContainer.appendChild(this.container);this.parentContainer.appendChild(this.bar);var oDivs=this.container.getElementsByTagName("div"),len=oDivs.length;while(len>0){if("tabAside"==oDivs[len-1].className){this.aside=oDivs[len-1];break}len--}if(!this.aside){throw Error("CommentTab.init: No tab aside!")}this.render();this.bindEvent();CommentTab.uid++}else{throw new Error("CommentTab.init(): no tabs!")}}};var klass=new Function();__implement(_prototype,klass.prototype);return klass})();CommentTab.uid=0;var commentTab=new CommentTab();var CommentPage=function(){var pageConfig;var totalComment;var totalPage;var currentPN;var me;function createPage(currPage){var pageHtml="";if(totalPage<=1){return""}var firstPage,lastPage,leftTag=pageConfig.pageText.leftTag||"",rightTag=pageConfig.pageText.rightTag||"";if(currPage-pageConfig.pageUnit>0){firstPage=currPage-pageConfig.pageUnit}else{firstPage=1}if(currPage+pageConfig.pageUnit-1<=totalPage){lastPage=currPage+pageConfig.pageUnit-1}else{lastPage=totalPage}for(var i=firstPage;i<currPage;i++){pageHtml+="<a rel='"+i+"' href='javascript:void(0)'>"+leftTag+i+rightTag+"</a>"}pageHtml+="<span>"+currPage+"</span>";for(var i=currPage+1;i<=lastPage;i++){pageHtml+="<a rel='"+i+"' href='javascript:void(0)'>"+leftTag+i+rightTag+"</a>"}if(currPage==1){if(pageConfig.nextPage.enable){pageHtml+="<a class='"+pageConfig.nextPage.Class+"' rel='"+(currPage+1)+"' href='javascript:void(0)'>"+pageConfig.nextPage.text+"</a>"}if(pageConfig.lastPage.enable){pageHtml+="<a class='"+pageConfig.lastPage.Class+"' rel='"+totalPage+"' href='javascript:void(0)'>"+pageConfig.lastPage.text+"</a>"}}else{if(currPage==totalPage){if(pageConfig.previousPage.enable){pageHtml="<a class='"+pageConfig.previousPage.Class+"' rel='"+(currPage-1)+"' href='javascript:void(0)'>"+pageConfig.previousPage.text+"</a>"+pageHtml}if(pageConfig.firstPage.enable){pageHtml="<a class='"+pageConfig.firstPage.Class+"' rel='1' href='javascript:void(0)'>"+pageConfig.firstPage.text+"</a>"+pageHtml}}else{if(pageConfig.nextPage.enable){pageHtml+="<a class='"+pageConfig.nextPage.Class+"' rel='"+(currPage+1)+"' href='javascript:void(0)'>"+pageConfig.nextPage.text+"</a>"}if(pageConfig.lastPage.enable){pageHtml+="<a class='"+pageConfig.lastPage.Class+"' rel='"+totalPage+"' href='javascript:void(0)'>"+pageConfig.lastPage.text+"</a>"}if(pageConfig.previousPage.enable){pageHtml="<a class='"+pageConfig.previousPage.Class+"' rel='"+(currPage-1)+"' href='javascript:void(0)'>"+pageConfig.previousPage.text+"</a>"+pageHtml}if(pageConfig.firstPage.enable){pageHtml="<a class='"+pageConfig.firstPage.Class+"' rel='1' href='javascript:void(0)'>"+pageConfig.firstPage.text+"</a>"+pageHtml}}}return pageHtml}function resetPage(num){var currPage=num||1;currentPN=currPage;var pageHtml=createPage(currPage);if(!!pageHtml){for(var i=0;i<pageConfig.pageID.length;i++){var pageObj=G(pageConfig.pageID[i]);pageObj.style.visibility="visible";pageObj.innerHTML=createPage(currPage)}}else{for(var i=0;i<pageConfig.pageID.length;i++){var pageObj=G(pageConfig.pageID[i]);pageObj.style.visibility="hidden"}}}function clickEvent(e){var e=e||window.event;var obj=e.target||e.srcElement;if(obj.nodeName=="A"){var clickPage=parseInt(obj.rel);totalComment=CommentData.get("totalCommentsDisplayed")||0;totalPage=Math.ceil(totalComment/pageConfig.perPageComment);resetPage(clickPage);broadcastEvent();e.returnValue=false;if(e.preventDefault){e.preventDefault()}}}function keyDownEvent(e){var e=e||window.event;var keycode=e.keyCode||e.which;if(e.ctrlKey&&keycode==39){if(currentPN+1<=totalPage){if(window.commentPageTimer){clearTimeout(window.commentPageTimer)}window.commentPageTimer=setTimeout(function(){var tempPage=currentPN+1;totalComment=CommentData.get("totalCommentsDisplayed")||0;totalPage=Math.ceil(totalComment/pageConfig.perPageComment);resetPage(tempPage);broadcastEvent()},300)}}if(e.ctrlKey&&keycode==37){if(currentPN-1>0){if(window.commentPageTimer){clearTimeout(window.commentPageTimer)}window.commentPageTimer=setTimeout(function(){var tempPage=currentPN-1;resetPage(tempPage);broadcastEvent()},300)}}}function handleEvent(evt){if(!pageConfig.isEnable){return }var startPage=evt.start;if(typeof startPage=="undefined"){for(var i=0;i<pageConfig.pageID.length;i++){var pageObj=G(pageConfig.pageID[i]);pageObj.style.visibility="hidden"}}else{totalComment=CommentData.get("totalCommentsDisplayed")||0;totalPage=Math.ceil(totalComment/pageConfig.perPageComment);if(startPage==0){resetPage()}}}function broadcastEvent(){var evt={type:"PAGE_SWITCH",commentType:{start:((currentPN-1)*pageConfig.perPageComment)}};me.dispatchEvent(evt)}function init(config){pageConfig=config;if(!config.isEnable){return }pageConfig.perPageComment=CommentConfig.sys.perPageCommentNum;for(var i=0;i<pageConfig.pageID.length;i++){var pageObj=G(pageConfig.pageID[i]);fe.on(pageObj,"onclick",clickEvent)}if(pageConfig.isKeyboardEvent){fe.on(document,"onkeydown",keyDownEvent)}me=this;totalComment=CommentData.get("totalCommentsDisplayed")||0;totalPage=Math.ceil(totalComment/pageConfig.perPageComment)}return{init:init,handleEvent:handleEvent}}();var CommentQuickReply=(function(){var config=CommentConfig.CommentQuickReply,_replyEnabled=true,dataKey="COMMENT_LIST",passKey="USERNAME",sys=CommentConfig.sys;var htmlTpl={reply:'<a class="reply"><b></b>#{text}<b></b></a>',back:'<a class="back"><b></b>#{text}<b></b><span><i></i>#{count}<i></i></span></a>',anti:'<a class="anti"><b></b>#{text}<b></b><span><i></i>#{count}<i></i></span></a>',report:'<a class="report"><b></b>#{text}<b></b><span></span></a>',opinion:'<a class="opinion"><b></b>#{text}<b></b><i></i>#{count}<i></i></a>',hidden:'<input type="hidden" name="#{name}" value="#{value}">',handler1:'onclick="CommentPopupController();"',handler2:'onkeyup="CommentQuickReply.handlers.popup.onkeyup(event);"',handler3:'onclick="CommentQuickReply.handlers.popup.submit(document.CommentQuickReply_Popup_Content);"',handler4:'onclick="CommentPassView(); return false;"',handler5:"onclick=\"if(this.value=='请输入标题')this.value='';\" onblur=\"if(/^\\s*$/.test(this.value))this.value='请输入标题';\"",logout:'<a style="text-decoration:underline; color:#00F; cursor:pointer;" onclick="CommentQuickReply.handlers.logout.click(this);">退出登录</a>'};var handlerTpl={reply:[{type:"click",handler:"CommentQuickReply.handlers.reply.click({msg:{src:this,info:#{info}}});"}],back:[{type:"click",handler:"CommentQuickReply.handlers.back.click({msg:{src:this,type:'back',info:#{info}}})"}],anti:[{type:"click",handler:"CommentQuickReply.handlers.back.click({msg:{src:this,type:'anti',info:#{info}}})"}],report:[{type:"click",handler:"CommentQuickReply.dispatchEvent({type:'CommentQuickReply_Report_Click', msg:{src:this,info:#{info}}});"}],opinion:[{type:"mouseover",handler:"CommentQuickReply.handlers.opinion.mouseover({msg:{src:this, e: event, info:#{info}}})"}]};var customizedHtmlTpl=config.htmlTpl;for(var i in customizedHtmlTpl){if(htmlTpl[i]!=undefined){htmlTpl[i]=customizedHtmlTpl[i]}}var handlers={reply:{click:function(evt){setText(evt.msg.src,"reply");var reply_id=evt.msg.info.reply_id,loginUserName=CommentData.get(passKey),userName=loginUserName||"",popTpl=config.popupTpl,userNameTpl,userInfoTpl,inputTitleTpl,oData=getRefered(reply_id);if(userName==null){userName=""}userNameTpl=format(popTpl.userName,{userName:userName,logout:htmlTpl.logout});if(loginUserName){userInfoTpl=userNameTpl}else{userInfoTpl=format(popTpl.login,{userName:userName,handler4:htmlTpl.handler4})||""}inputTitleTpl=config.ifIncludeTitle?popTpl.inputTitle:"";var title=truncate(getTitle(),config.titleMax||15),refered=fe.decodeText(truncate(oData.content,config.referedMax||50)),sHtml=format(popTpl.bone,{userInfo:userInfoTpl,title:title,refered:refered,inputTitle:inputTitleTpl,reply_id:reply_id,handler1:htmlTpl.handler1,handler2:htmlTpl.handler2,handler3:htmlTpl.handler3,handler5:htmlTpl.handler5});var o={},popStyle=config.popupLayerStyle||{};o.innerHTML=sHtml;o.width=popStyle.width||500;o.height=popStyle.height||370;o.opacity=popStyle.opacity||0.5;o.popupZindex=3;o.filterZindex=2;o.filterBg=popStyle.filterBg||"#000";CommentController(o,"CommentQuickReply_Popup_Text")}},back:{click:function(evt){var src=evt.msg.src,type=evt.msg.type,info=evt.msg.info,host;if(src.clicked){return }if(!_replyEnabled){CommentError("-709");return }try{host=sys.host.getHost}catch(exp){alert("CommentQuickReply: CommentConfig.sys.host.getHost is undefined!");return }BdNet.sendGet(host,{cmd:"score",product_id:sys.productID,thread_id:sys.threadID,reply_id:info.reply_id,type:type=="back"?1:0},function(json){if(0==json.err_no){inc(src);src.className=type+"ed";setText(src,type);src.clicked=true;setTimer()}else{CommentError(json.err_no)}})}},opinion:{mouseover:function(evt){var e=evt.msg.e;var related=e.relatedTarget||e.fromElement;if(!related||related==this||"li"==related.tagName.toLowerCase()){return }var dim,offsets,src=evt.msg.src;offsets=getOffsets(src);dim={offsetWidth:src.offsetWidth,offsetHeight:src.offsetHeight,offsetsLeft:offsets.x,offsetsTop:offsets.y,evt:evt,innerHTML:src.innerHTML};QuickPopup.render(dim)}},popup:{validate:function(){},onkeyup:function(event){var e=event||window.event,src=e.target||e.srcElement;var code=e.keyCode||e.charCode;if(e.ctrlKey&&code==13){src.form.submit.onclick(src.form)}},submit:function(oForm){var reply_id=oForm.replyId.value,quoteTpl="[_q_][_i_]#{userName}[_/i_][_b_]#{ip}[_/b_][_em_]#{time}[_/em_][_u_]#{area}[_/u_][_br_]#{content}[_/q_]",referedObject=getRefered(reply_id),content=oForm.content.value;var oErr=G("CommentQuickReply_Popup_Error");if(/^\s*$/.test(oForm.content.value)){if(config.alertForEmpty=="popup"){CommentError("-2003")}else{oErr.innerHTML=sys.error["-2003"].info;oErr.style.color="#F00";oErr.style.display="inline"}return }else{oErr.style.display="none"}if((/\[_\/?[a-z]{1,6}_\]/gi).test(content)){CommentError("-2006");return }if(!CommentCheck.test({type:"judgeLength",value:content,minLength:sys.minReplyLength,maxLength:sys.maxReplyLength})){CommentError("-2004");return }var oData={cmd:"add_reply",product_id:sys.productID,thread_id:sys.threadID,title:getTitle(),content:format(config.quoteTpl||quoteTpl,referedObject)+fe.encodeText(content)},host=sys.host.postHost;oForm.submit.disabled=true;BdNet.sendPost(host,oData,function(json){if(0==json.err_no){CommentPopupController();CommentError(json.err_no,"popup","回复成功!");CommentQuickReply.dispatchEvent({type:"QUICK_REPLY_OK",commentType:Object.clone(config.defaultCommentType)})}else{if(-701==json.err_no||-702==json.err_no){CommentPopupController();CommentError(json.err_no)}else{oForm&&(oForm.submit.disabled=false);CommentError(json.err_no)}}})}},login:{succeed:function(){var userInfoDiv=G("CommentQuickReply_Popup_UserInfo"),loginUserName=CommentData.get(passKey),userInfo="",popTpl=config.popupTpl;if(!userInfoDiv){return }if(!loginUserName){return }userInfo=format(popTpl.userName,{userName:loginUserName,logout:htmlTpl.logout});userInfoDiv.innerHTML=userInfo}},logout:{click:function(obj){var userName=CommentData.get(passKey);logoutPassport();obj.parentNode.innerHTML=format(config.popupTpl.login,{handler4:htmlTpl.handler4})}}};function getTitle(){var str;try{var oData=CommentData.get(dataKey);str=(!!oData.body.p_textdata)?oData.body.p_textdata.title:""}catch(exp){alert("CommentData.get('COMMENT_LIST') error!");return }return str}function getRefered(reply_id){var content,userName,ip,area,time;try{var oData=CommentData.get(dataKey).data;content=oData[reply_id]["content"];userName=oData[reply_id]["un"];ip=oData[reply_id]["ip"];area=oData[reply_id]["area"];time=oData[reply_id]["cdatetime"]}catch(exp){alert("CommentData.get('COMMENT_LIST').data error!");return }return{content:content.replace(/\[_q_\].*?\[_\/q_\]/gi,""),userName:userName,ip:ip,area:area,time:time}}function truncate(str,max){str=str.replace(/\[_br_\]/g,"");str=deHtmlEntity(str);return str.replace(new RegExp("^(.{"+max+"}).*"),"$1...")}function isBody(element){return(/^(?:body|html)$/i).test(element.tagName)}function isBorderBox(element){return element.style.mozBoxSizing=="border-box"}function leftBorder(element){return parseInt(element.style.borderLeftWidth)||0}function topBorder(element){return parseInt(element.style.borderTopWidth)||0}function getOffsets(element){var position={x:0,y:0},me=element;if(isBody(element)){return position}while(element&&!isBody(element)){position.x+=element.offsetLeft;position.y+=element.offsetTop;if(Browser.isGecko){if(!isBorderBox(element)){position.x+=leftBorder(element);position.y+=topBorder(element)}var parent=element.parentNode;if(parent&&parent.style.overflow!="visible"){position.x+=leftBorder(parent);position.y+=topBorder(parent)}}element=element.offsetParent;if(Browser.isIE){while(element&&!element.currentStyle.hasLayout){element=element.offsetParent}}}if(Browser.isGecko&&!isBorderBox(me)){position.x-=leftBorder(me);position.y-=topBorder(me)}position.x+=element.offsetLeft;position.y+=element.offsetTop;return position}var QuickPopup=(function(){var pop=null;var sHtml={ul:'<ul class="FloatPopup_List">',li:'<li lang="#{type}"><i title="text"></i><i></i><i title="count"></i><i></i></li>'};function _getAroundHidden(src){var parent=src.parentNode;if(!parent){return[]}var hids=parent.getElementsByTagName("INPUT"),rslt=[];for(var i=0,len=hids.length;i<len;i++){if("hidden"==hids[i].type.toLowerCase()){rslt.push({name:hids[i].name,value:hids[i].value})}}return rslt}function _setAroundHidden(src,data){var parent=src.parentNode;if(!parent){return false}var hids=parent.getElementsByTagName("INPUT"),rslt=[];for(var i=0,len=hids.length;i<len;i++){if("hidden"==hids[i].type.toLowerCase()&&data.name==hids[i].name){hids[i].value=data.value;return true}}return false}function _constructHTML(op,src){var sb=new StringBuffer();var aCount=_getAroundHidden(src),tmp;sb.append(sHtml.ul);for(var i in op){tmp=format(sHtml.li,{type:i});tmp=tmp.replace(/(<i\s+title=[\"]?text[\"]?><\/i>).*?(<i><\/i>)/,"$1"+op[i]+"$2");for(var j=0,len=aCount.length;j<len;j++){if(i==aCount[j].name){tmp=tmp.replace(/(<i\s+title=[\"]?count[\"]?><\/i>).*?(<i><\/i>)/,"$1"+config.bracket[0]+aCount[j].value+config.bracket[1]+"$2")}}sb.append(tmp)}sb.append("</ul>");return sb.toString()}function _create(op,src){if(typeof op!="object"){throw new Error("Popup.create(op): op must be an json object!")}var oDiv=document.createElement("DIV");oDiv.innerHTML=_constructHTML(op,src);oDiv.className="FloatPopup_Container";return oDiv}function _destroy(){if(pop){(document.body||document.documentElement).removeChild(pop)}pop=null}function _bindEvent(info){var oLi=pop.firstChild.firstChild,src=info.msg.src,reply_id=info.msg.info.reply_id;if(oLi){do{fe.on(oLi,"onclick",function(e){var sHtml=this.innerHTML,count,oLi=this,host=sys.host.getHost;sHtml=sHtml.replace(/^[^\d]*/,"");count=parseInt(sHtml);for(var i in config.items.opinion.opinions){var topType=i;break}if(!_replyEnabled){CommentError("-709");return }BdNet.sendGet(host,{cmd:"score",product_id:sys.productID,thread_id:sys.threadID,reply_id:reply_id,type:oLi.lang=="back"?1:0},function(json){if(0==json.err_no){if(topType==oLi.lang){inc(src)}_setAroundHidden(src,{name:oLi.lang,value:++count});setTimer()}else{CommentError(json.err_no)}});window.setTimeout(function(){QuickPopup.close()},1)})}while(oLi=oLi.nextSibling)}}function render(dim){var op=config.items.opinion.opinions;if(pop){_destroy()}pop=_create(op,dim.evt.msg.src);(document.body||document.documentElement).appendChild(pop);_bindEvent(dim.evt);pop.style.left=dim.offsetsLeft+"px";pop.style.top=dim.offsetsTop+"px";pop.onmouseout=function(e){var e=e||window.event;var related=e.relatedTarget||e.toElement;var isOut=true;while(related){if(related.parentNode&&related.parentNode==pop){isOut=false;break}related=related.parentNode}if(isOut){window.setTimeout(function(){QuickPopup.close()},1)}}}document.onclick=_destroy;return{render:render,close:_destroy}})();function _validatesOptions(oOptions){if(oOptions==undefined||oOptions==null){throw new Error("CommentQuickReply.init(oOptions): oOptions must be defined and can not be null!")}if(typeof oOptions!="object"){throw new Error("CommentQuickReply.init(oOptions): oOptions must be an object!")}if(oOptions.items==undefined||oOptions.sep==undefined){throw new Error("CommentQuickReply.init(oOptions): unsupported key exists in oOptions!")}var keys=_getKeys(oOptions.items);for(var i=0,len=keys.length;i<len;i++){if(!_ifContains(htmlTpl,keys[i])){throw new Error("CommentQuickReply.init(oOptions): unsupported key exists in oOptions.items!")}}}function _ifContains(obj,key){if(obj[key]==undefined){return false}return true}function _getKeys(obj){var keys=[];for(var i in obj){keys.push(i)}return keys}function _constructJson(info){var keys=_getKeys(info);var sb=new StringBuffer();sb.append("{");for(var i=0,len=keys.length;i<len;i++){sb.append(keys[i]);sb.append(":");if(typeof info[keys[i]]=="string"){sb.append("'");sb.append(info[keys[i]]);sb.append("'")}else{sb.append(info[keys[i]])}if(i<len-1){sb.append(",")}}sb.append("}");return sb.toString()}function _bind(key,info){var sHtml=htmlTpl[key],hdlTpls=handlerTpl[key],len=hdlTpls.length,count=0,countStr="";oData=CommentData.get(dataKey).data;if("back"==key||"opinion"==key){count=oData&&oData[info.reply_id]["like_count"]?oData[info.reply_id]["like_count"]:0}if("anti"==key){count=oData&&oData[info.reply_id]["dislike_count"]?oData[info.reply_id]["dislike_count"]:0}if(count>0){countStr=config.bracket[0]+count+config.bracket[1]}else{countStr=config.bracket[0]+0+config.bracket[1]}sHtml=format(sHtml,{text:config.items[key].textBefore,count:countStr});for(var i=0;i<len;i++){var rplStr="$1on"+hdlTpls[i].type+'="'+format(hdlTpls[i].handler,{info:_constructJson(info)})+'" ';sHtml=sHtml.replace(/(<(?:a|input)\s*)/,rplStr)}return sHtml}function handleEvent(evt){if(!config.isEnable){return }}function _intersection(arrA,arrB){var arr=[],tmp;for(var i=0,len=arrB.length;i<len;i++){if(_isIn(arrB[i],arrA)){arr.push(arrB[i])}}return arr}function _setNum(obj,i){if(obj){if(i==0){var sHtml=obj.innerHTML,rslt,tmpHtml="",c;rslt=sHtml.match(/<i><\/i>(.*?)<i><\/i>/i);if(rslt){tmpHtml=rslt[1].replace(/^[^\d]*/,"")}c=parseInt(tmpHtml);if(!c){c=0}c++;obj.innerHTML=sHtml.replace(/(<i><\/i>).*?(<i><\/i>)/i,"$1"+config.bracket[0]+c+config.bracket[1]+"$2")}else{obj.innerHTML=obj.innerHTML.replace(/(<i><\/i>).*?(<i><\/i>)/i,"$1"+config.bracket[0]+c+config.bracket[1]+"$2")}}}function inc(obj){_setNum(obj,0)}function _isIn(item,arr){if(undefined==arr||undefined==arr.length||undefined==item){return false}for(var i=0,len=arr.length;i<len;i++){if(item==arr[i]){return true}}return false}function setText(obj,key){if(!obj||!obj.tagName||"a"!=obj.tagName.toLowerCase()){return false}if(!config.items[key]||!config.items[key].textAfter){return false}obj.innerHTML=obj.innerHTML.replace(/(<b><\/b>).*?<b><\/b>/i,"$1"+config.items[key].textAfter)}function setTimer(){_replyEnabled=false;window.setTimeout(function(){_replyEnabled=true},config.timeout||5000)}function init(oOptions){if(!config.isEnable){return }if(CommentConfig.sys.threadID==-1){return }_validatesOptions(oOptions);config=oOptions}function toHTML(info,items){if(!config.isEnable){return""}var keys=_getKeys(config.items),sb=new StringBuffer();if(items&&items.length){keys=_intersection(keys,items)}sb.append('<div class="Comment_quickReply">');for(var i=0,len=keys.length;i<len;i++){sb.append(_bind(keys[i],info));if(i<len-1){sb.append(config.sep)}}var oData=CommentData.get(dataKey).data;if(info.reply_id&&oData[info.reply_id]){sb.append(format(htmlTpl.hidden,{name:"back",value:oData[info.reply_id]["like_count"]}))}if(info.reply_id&&oData[info.reply_id]){sb.append(format(htmlTpl.hidden,{name:"anti",value:oData[info.reply_id]["dislike_count"]}))}if(info.name1||info.name1===0){sb.append(format(htmlTpl.hidden,{name:"name1",value:info.name1}))}if(info.name2||info.name2===0){sb.append(format(htmlTpl.hidden,{name:"name2",value:info.name2}))}if(info.name3||info.name3===0){sb.append(format(htmlTpl.hidden,{name:"name3",value:info.name3}))}sb.append("</div>");return sb.toString()}return{init:init,toHTML:toHTML,handleEvent:handleEvent,handlers:handlers}})();var CommentReply=(function(){var config=CommentConfig.CommentReply,sys=CommentConfig.sys;function getID(){var id=config.id,oPanel=G(id.panel_id),oUserArea=G(id.userarea_id),oTextArea=G(id.textarea_id),oButton=G(id.button_id);return{oPanel:oPanel,oUserArea:oUserArea,oTextArea:oTextArea,oButton:oButton}}function showPanel(){var o=getID();try{o.oPanel.innerHTML=format(config.panelHtml,config.id);showUserName()}catch(e){return;}}function showUserName(){var oUserArea=getID().oUserArea,username=CommentData.get("USERNAME");if(username==null||username==""){oUserArea.innerHTML=config.noLoginHtml;return false}else{oUserArea.innerHTML=format(config.loginHtml,username);return true}}function broadcastEvent(){var evt={type:"COMMENT_REPLY_OK"};evt.commentType=Object.clone(config.defaultCommentType);CommentReply.dispatchEvent(evt)}function handleEvent(evt){if(!config.isEnable){return }}function initEvent(){var o=getID();if(o.oButton&&o.oTextArea){fe.on(o.oButton,"onclick",clickPress);fe.on(o.oTextArea,"onkeydown",keyPress);return true}}function keyPress(e){var e=e||window.event;keycode=e.keyCode;if(keycode==13&&e.ctrlKey){e.returnValue=false;toPublishContent();return }}function clickPress(){toPublishContent()}function toPublishContent(){var o=getID();var oLoginBefore=o.oLoginBefore;var c=CommentCheck.test;var sTextArea=o.oTextArea.value;var content=fe.encodeText(o.oTextArea.value);var title=(sys.privateData==1)?CommentData.get("COMMENT_LIST").body.p_textdata.title:"";if(c({type:"isNull",value:content})){CommentError("-2003");return }if(!c({type:"judgeLength",value:fe.encodeText(content),minLength:sys.minReplyLength,maxLength:sys.maxReplyLength})){CommentError("-2004");return }if(/(&#91;_\/?[a-z]{1,6}_&#93;)/.test(content)){CommentError("-2006");return }BdNet.sendPost(sys.host.postHost,{cmd:"add_reply",product_id:sys.productID,thread_id:sys.threadID,content:content,title:title,r:fe.getRandomKey()},function(obj){if(!CommentError(obj.err_no)){o.oTextArea.value="";CommentError(obj.err_no,"popup","回复成功!");broadcastEvent()}o.oButton.disabled=false})}function init(){if(!config.isEnable){return }var o=getID();if(sys.threadID==-1){if(o.oPanel){o.oPanel.style.display="none"}return }showPanel();initEvent()}return{init:init,showUserName:showUserName}})();var CommentList=(function(){var aIdList=[],cacheKeyName="COMMENT_LIST",config=CommentConfig.CommentList,sys=CommentConfig.sys;function init(){if(!config.isEnable){return }if(sys.threadID==-1){return }showList()}function broadcastEvent(start,un){var evt={type:"COMMENT_LIST_UPDATE",start:start,un:un};CommentList.dispatchEvent(evt)}function handleEvent(evt){if(!config.isEnable){return }showList(evt)}function showList(evt){function _listHtml(s){var panel=G(config.panelID);if(panel==undefined){return }panel.innerHTML=s}if(evt!=undefined){var commentType=evt.commentType;if(CommentData.get("EVENT_PARAMS")==null){CommentData.set("EVENT_PARAMS",commentType)}else{var data=CommentData.get("EVENT_PARAMS");if(evt.type=="TAB_SWITCH"){data.start=0}if(evt.type=="COMMENT_REPLY_OK"||evt.type=="QUICK_REPLY_OK"){data.start=0}data=Object.extend(data,evt.commentType);CommentData.set("EVENT_PARAMS",data)}}else{_listHtml(config.loadHtml)}var oUrlParams=Object.extend({cmd:"get_reply",product_id:sys.productID,private_data:sys.privateData,type:0,thread_id:sys.threadID,reply_id:0,start:0,count:sys.perPageCommentNum,include_top:1,favor:2,orderby_type:1,display:1,query_mask:999,r:fe.getRandomKey()},CommentData.get("EVENT_PARAMS")||{});BdNet.sendGet(CommentConfig.sys.host.getHost,oUrlParams,function(o){setUserName(o);if(o==undefined||CommentError(o.err_no)){_listHtml(config.errorHtml);return }else{var o=serCommentData(o);if(o.body.p_textdata){var p_textdata=o.body.p_textdata.replace(/\\/,"\\\\");o.body.p_textdata=eval("("+p_textdata+")")}CommentData.set(cacheKeyName,o)}if(o.body.total_count==0){_listHtml(config.errorHtml);printData();return }generateList(CommentData.get(cacheKeyName));printData();var loadData=o.body;CommentConfig.CommentList.CommentDataOnload&&CommentConfig.CommentList.CommentDataOnload({title:loadData.p_textdata.title,url:loadData.p_textdata.url,total_count:loadData.total_count,real_ret_count:loadData.real_ret_count});CommentData.set("totalCommentsDisplayed",parseInt(o.body.total_count));if(config.scroll.isScroll){window.scroll(config.scroll.x,config.scroll.y)}broadcastEvent(oUrlParams.start)})}function generateList(o){var d=o.arrData,COMMENT_LIST=G(CommentConfig.CommentList.panelID);if(COMMENT_LIST==undefined){return }if(COMMENT_LIST.innerHTML!=""){G(CommentConfig.CommentList.panelID).innerHTML=""}function _getEllipsis(s,len,e){if(len==0){return s}var ellipsis;if(s.length<len){ellipsis=""}else{ellipsis=e}return s.substring(0,len)+ellipsis}for(var i=0,l=d.length;i<l;i++){d[i].quickreply=CommentQuickReply.toHTML({reply_id:d[i]["reply_id"]});if(d[i]["favor"]==1){d[i]["favor_des"]=config.favor_des}if(d[i]["is_top"]==1){d[i]["top_des"]=config.top_des}if(d[i]["score"]>=config.hot_score){d[i]["hot_des"]=config.hot_des}if(d[i]["content"]!=""){var content=d[i]["content"].replace(/\[_br_\](.+?)\[_\/q_\]/,function(s,s1){var str=fe.decodeHtml(s1),ellipsis="";if(str.length<config.quoteLength){ellipsis=""}else{ellipsis=config.quoteEllipsis}return"[_br_]"+fe.encodeText(_getEllipsis(str,config.quoteLength,config.quoteEllipsis))+"[_/q_]"});(function(){var s,contentEllipsis;if(/(\[_q_\].+\[_\/q_\])(.+)/.test(content)){s=RegExp.$2.substring(0,config.contentLength);content=RegExp.$1+_getEllipsis(s,config.contentLength,config.contentEllipsis)}else{content=_getEllipsis(content,config.contentLength,config.contentEllipsis)}})();if(!config.isQuoteContent){content=content.replace(/\[_q_\].+\[_\/q_\]/,"")}d[i]["content"]=fe.decodeText(content)}var s=format(CommentConfig.CommentList.listHtml,d[i]);createElement(s,d[i].reply_id)}}function printData(){var configData=config.printData,o=CommentData.get(cacheKeyName);for(var i=0,l=configData.length;i<l;i++){var oId=G(configData[i].id),type=configData[i].type,data=o.body[type];if(oId==undefined){continue}if(typeof data=="object"){data="<a href="+data.url+">"+data.title+"</a>"}if(oId.tagName.toLowerCase=="input"||oId.tagName.toLowerCase=="textarea"){oId.value=data}else{oId.innerHTML=data}}}function createElement(s,n){var COMMENT_LIST=G(config.panelID),oDiv=null;oDiv=C("div");var itemId="CommentList__"+n;oDiv.setAttribute("id",itemId);oDiv.innerHTML=s;COMMENT_LIST.appendChild(oDiv)}return{init:init,handleEvent:handleEvent}})();var CommentData=function(){var dataCache={};function get(key){if(dataCache[key]){return dataCache[key]}return null}function set(key,value){dataCache[key]=value}function del(key){delete dataCache[key]}return{get:get,set:set,del:del}}();var CommentCheck=function(){var validateUtil={};validateUtil.isNull=function(jsonObj){var value=jsonObj.value;if(!value){return true}var length=trim(value).length;if(length>0){return false}return true};validateUtil.judgeLength=function(jsonObj){var isMinEq=jsonObj.isMinEq||true,isMaxEq=jsonObj.isMaxEq||true;var value=jsonObj.value,minLength=isMinEq?jsonObj.minLength:(jsonObj.minLength+1),maxLength=isMaxEq?jsonObj.maxLength:(jsonObj.maxLength-1);if(typeof (value)=="undefined"||value==null){return false}value=trim(value);var length=byteLength(trim(value+""));if(minLength==null&&maxLength==null){return true}if(minLength==null){if(length<=maxLength){return true}else{return false}}if(maxLength==null){if(length>=minLength){return true}else{return false}}if(length>=minLength&&length<=maxLength){return true}else{return false}};function main(jsonObj){return validateUtil[jsonObj.type](jsonObj)}return{test:main}}();function CommentError(err_code,type,msg){var flag=true,o=CommentConfig.sys.error,config=CommentConfig.CommentError;var err_code=err_code+"",type=type;switch(err_code){case"0":errorType(err_code,type,msg);flag=false;break;case"-51":case"-52":case"-53":case"-54":case"-201":case"-700":case"-701":case"-702":case"-703":case"-704":case"-705":case"-706":case"-707":case"-708":case"-709":case"-2001":case"-2002":case"-2003":case"-2004":case"-2005":case"-2006":case"-3000":errorType(err_code,type,msg);flag=true;break;default:errorType("-2000",type,msg);flag=true;break}function errorType(key,type,msg){var oConfig={id:config.closeID,msg:msg||o[key].info};var type=o[key].type||type;if(type!="alert"&&type!="popup"){return }if(type=="alert"){alert(oConfig.msg)}else{if(type=="popup"){var p=config.popup;p.innerHTML=format(config.errorHtml,oConfig);CommentController(p);if(G(config.closeID)){setTimeout(function(){G(config.closeID).focus()},50)}}}}return flag}var CommentPopup=function(){var args=arguments,me=this;return me.init.apply(me,args)};CommentPopup.filterCache=[];CommentPopup.popCache=[];CommentPopup.meList=[];CommentPopup.me={};CommentPopup.prototype={init:function(options){CommentPopup.me=this;CommentPopup.meList.push(this);this.options=Object.extend({width:330,height:150,popupZindex:"85",popupBg:"#fff",border:"",innerHTML:"",className:"",filterBg:"",filterZindex:"80",opacity:"0.85",isShowSelect:true,isBg:true,scrollSpeed:200,bgSizeSpeed:100,callBack:function(isReturn){}},options||{});this.index=0;this.isSelect();this.bgController();this.popPanel()},filterPanel:function(){var me=this,options=me.options;options.filter_width=_getFilterSize().width;options.filter_height=_getFilterSize().height;var oDiv=document.createElement("div"),id=me.curFid="COMMENT_FILTER"+fe.getRandomKey();CommentPopup.filterCache.push(oDiv);oDiv.setAttribute("id",id);oDiv.style.width=_getFilterSize().width;oDiv.style.height=_getFilterSize().height;oDiv.style.margin="0px";oDiv.style.padding="0px";oDiv.style.position="absolute";oDiv.style.top="0px";oDiv.style.left="0px";oDiv.style.background=options.filterBg;oDiv.style.filter="alpha(opacity="+options.opacity*100+")";oDiv.style.opacity=options.opacity;oDiv.style.zIndex=options.filterZindex;oDiv.style.display="block";document.body.appendChild(oDiv);this.index=this.index++;function _getFilterSize(){var DW=body().documentWidth,DH=body().documentHeight,ST=body().scrollTop,SL=body().scrollLeft,width=0,height=0;var w=(DW>SL?DW:SL),W=(w>screen.width-25)?"100%":w+"px";width=((!!Browser.isIE)?w+"px":W);height=(DH>ST?DH:ST)+"px";return{width:width,height:height}}function _setFilterSize(){var me=this;setTimeout(function(){if(G(id)){G(id).style.width=_getFilterSize().width;G(id).style.height=_getFilterSize().height}},options.bgSizeSpeed)}fe.on(window,"onresize",_setFilterSize);fe.on(window,"onscroll",_setFilterSize)},position:function(){var centerLeft=parseInt(body().viewWidth/2-this.options.width/2),centerTop=(body().viewHeight/2)-this.options.height/2+body().scrollTop;return{left:parseInt(centerLeft),top:parseInt(centerTop)}},popPanel:function(){var me=this,options=me.options,position=me.position();var oDiv=document.createElement("div"),ifr=document.createElement("iframe");var id=this.curPid="COMMENT_POPUP_"+fe.getRandomKey();CommentPopup.popCache.push(oDiv);ifr.src="about:blank";ifr.style.position="absolute";ifr.style.background=options.popupBg;ifr.style.zIndex="-1";ifr.style.width="100%";ifr.style.height="100%";ifr.style.top="0px";ifr.style.left="0px";ifr.style.margin="0px";ifr.style.padding="0px";ifr.setAttribute("scrolling","no");ifr.setAttribute("frameborder","0");oDiv.setAttribute("id",id);oDiv._privateObject_=me;oDiv.setAttribute("class",options.className);oDiv.style.display="block";oDiv.style.background=options.popupBg;oDiv.style.width=options.width+"px";oDiv.style.height=options.height+"px";oDiv.style.margin="0px";oDiv.style.padding="0px";oDiv.style.position="absolute";oDiv.style.top=position.top+"px";oDiv.style.left=position.left+"px";oDiv.style.border=options.border;oDiv.style.zIndex=options.popupZindex;oDiv.innerHTML=options.innerHTML;oDiv.appendChild(ifr);document.body.appendChild(oDiv);oDiv.style.top=me.position().top+"px";oDiv.style.left=me.position().left+"px";function _setPopupPosition(){setTimeout(function(){oDiv.style.top=me.position().top+"px";oDiv.style.left=me.position().left+"px"},options.scrollSpeed)}fe.on(window,"onresize",_setPopupPosition);fe.on(window,"onscroll",_setPopupPosition)},isSelect:function(){if(!Browser.isIE){return }var aElement=["select","object","embed"];for(var i=0,len=aElement.length;i<len;i++){var elements=document.getElementsByTagName(aElement[i]);for(var j=0,le=elements.length;j<le;j++){if(this.options.isShowSelect){elements[j].disabled=true}else{elements[j].disabled=false}}}this.options.isShowSelect=false},msgContorller:function(o){var o=Object.extend({type:"default",isClose:true,isReturn:true,isReload:false},o||{});var oCurFid=CommentPopup.filterCache[CommentPopup.filterCache.length-1],oCurPid=CommentPopup.popCache[CommentPopup.popCache.length-1],meList=CommentPopup.meList[CommentPopup.meList.length-1],me=CommentPopup.me;if(o!=undefined){if(o.type=="confirm"){if(o.isClose){meList.options.callBack(o.isReturn)}else{return meList.options.callBack(o.isReturn)}}}if(oCurFid){document.body.removeChild(oCurFid);fe.removeAt(CommentPopup.filterCache,CommentPopup.filterCache.length-1)}document.body.removeChild(oCurPid);fe.removeAt(CommentPopup.popCache,CommentPopup.popCache.length-1);fe.removeAt(CommentPopup.meList,CommentPopup.meList.length-1);me.isSelect();if(o.isReload){window.reload()}},bgController:function(){if(this.options.isBg){this.filterPanel()}}};function CommentController(o,focusId){if(typeof o=="string"){o=eval(o)}var o=o||{};var popup=new CommentPopup(o);window.CommentPopupController=popup.msgContorller;if(focusId!=undefined){G(focusId).focus()}}var ModelMap=[{name:"CommentPage",controller:CommentPage},{name:"commentTab",controller:commentTab},{name:"CommentQuickReply",controller:CommentQuickReply},{name:"CommentList",controller:CommentList},{name:"CommentReply",controller:CommentReply}];var CommentLoader=function(CommentConfig){for(var i=0;i<ModelMap.length;i++){var controller=ModelMap[i].controller;var name=ModelMap[i].name;controller.init(CommentConfig[name])}};var EventConfig=[{controller:CommentPage,event:[{type:"PAGE_SWITCH",handler:[CommentList]}]},{controller:commentTab,event:[{type:"TAB_SWITCH",handler:[CommentPage,CommentList]}]},{controller:CommentQuickReply,event:[{type:"QUICK_REPLY_OK",handler:[commentTab,CommentList]}]},{controller:CommentReply,event:[{type:"COMMENT_REPLY_OK",handler:[commentTab,CommentList]}]},{controller:CommentList,event:[{type:"COMMENT_LIST_UPDATE",handler:[CommentPage]}]}];function init(){window.CommentQuickReply=CommentQuickReply;EventDispatcher.initialize(commentTab);EventDispatcher.initialize(CommentReply);EventDispatcher.initialize(CommentPage);EventDispatcher.initialize(CommentList);EventDispatcher.initialize(CommentQuickReply);EventLoader(EventConfig);CommentLoader(CommentConfig)}return{init:init}}();