Elements.from=function(text,excludeScripts){if(excludeScripts||excludeScripts==null)text=text.stripScripts();var container,match=text.match(/^\s*<(t[dhr]|tbody|tfoot|thead)/i);if(match){container=new Element('table');var tag=match[1].toLowerCase();if(['td','th','tr'].contains(tag)){container=new Element('tbody').inject(container);if(tag!='tr')container=new Element('tr').inject(container)}}return(container||new Element('div')).set('html',text).getChildren()};CNB.Talkback=new Class({Implements:[Options,Events],options:{onReportClicked:function(btn){this.addLoader(btn)},onReplyClicked:function(btn){this.addLoader(btn)},onEditClicked:function(btn){this.addLoader(btn)},onDeleteClicked:function(btn){this.addLoader(btn)},onReportLoad:function(btn){var content=btn.retrieve('content');this.initLoadedContent(btn);content.inject(this.getCmntLoadZone(btn),'bottom');this.removeLoader(btn)},onDeleteLoad:function(btn){var content=btn.retrieve('content');this.initLoadedContent(btn);content.inject(this.getCmntLoadZone(btn),'bottom');this.removeLoader(btn)},onReplyLoad:function(btn){var content=btn.retrieve('content');this.initLoadedContent(btn);content.inject(this.getCmntLoadZone(btn),'bottom');this.removeLoader(btn)},onEditLoad:function(btn){var currentContent=this.getCmntContent(btn);currentContent.setStyle('display','none');var content=btn.retrieve('content');this.initLoadedContent(btn);content.inject(currentContent,'after');this.removeLoader(btn)},onPostSuccess:function(form,data){if(data.redirectUrl){window.location=data.redirectUrl}var cmnt=Elements.from(data.html)[0];var container=(data.injectId)?$(data.injectId):null;if(container){container.empty().adopt(cmnt)}else{this.threadContainer.adopt(cmnt)}if(data.threadId&&data.forumId){var resetData={'forumId':data.forumId,'threadId':data.threadId};this.updatePostData(form,resetData)}this.resetForm(form);this.fireEvent('cmntAdded',cmnt)},onDeleteSuccess:function(btn,data){var container=this.getCmntLoadZone(btn);container.empty().addClass(this.options.cmntClass.deleted).set('html','<p>Message has been deleted.</p>');this.unloadAction(btn)},onReportSuccess:function(btn,data){btn.getParent('li').set('html','Reported');this.unloadAction(btn)},onReplySuccess:function(btn,data){this.unloadAction(btn);var cmnt=Elements.from(data.html)[0];cmnt.inject(this.getCmntContainer(btn),'after');this.fireEvent('cmntAdded',cmnt)},onEditSuccess:function(btn,data){this.unloadAction(btn);var cmnt=Elements.from(data.html)[0];cmnt.replaces(this.getCmntContainer(btn));this.fireEvent('cmntEdited',cmnt)},onEditUnload:function(btn){this.getCmntContent(btn).setStyle('display','block')},onActionUnload:function(btn){var content=btn.retrieve('content');if(content!==null)content.destroy()},cmntClass:{container:'cmnt',content:'content',loadingIcon:'loading',deleted:'cmnt-deleted',added:'cmnt-added',edited:'cmnt-edited',threshold:'cmnt-threshold'},container:document.body,threadContainer:null},initialize:function(options){this.setOptions(options);this.container=$(this.options.container);this.threadContainer=(this.options.threadContainer!==null)?$(this.options.threadContainer):this.container;this.container.addEvents({'click:relay(a[tbkaction])':this.handleClickEvent.bind(this),'click:relay(a[tbkcustomaction])':this.handleCustomClickEvent.bind(this)});this.container.getElements('form[tbkaction]').each(function(form){this.initSubmitEvent(form)},this)},handleClickEvent:function(e,el){e.stop();var action=el.getProperty('tbkaction');CNB.Reg.gatedEvent(null,this.activateAction.pass(el,this),'tkb','Please Log In First')},handleCustomClickEvent:function(e,el){e.stop();var action=el.getProperty('tbkcustomaction');this.fireEvent(action+'Clicked',[el,e])},initSubmitEvent:function(form){var action=form.getProperty('tbkaction');var validator=new CNB.Validator(form,{'validateOnBlur':false,'onValidateSuccess':function(e,form){e.stop();CNB.Reg.gatedEvent(null,this.handleActionRequest.pass(form,this),'tkb','Please Log In First')}.bind(this)})},activateAction:function(btn){if(this.activated.check(btn,true)){this.unloadAction(btn);return false}var container=this.getCmntContainer(btn);var activeAction=this.activated.get(container);if(activeAction!==null){this.unloadAction(activeAction)}this.loadAction(btn)},loadAction:function(btn){var action=btn.getProperty('tbkaction');this.fireEvent(action+'Clicked',btn);this.activated.set(btn,true);this.activated.set(this.getCmntContainer(btn),btn);var request=new Request.JSON({url:btn.getProperty('href'),onSuccess:function(data){if(typeof data.html=='undefined'){CNB.log('bad data')}var content=CNB.htmlToElement(data.html);btn.store('content',content);this.fireEvent(action+'Load',btn)}.bind(this),onFailure:function(){this.fireEvent('actionLoadFailure',btn);this.fireEvent(action+'LoadFailure',btn);this.removeLoader(btn)}.bind(this),onCancel:function(){this.removeLoader(btn)}.bind(this),noCache:true});btn.store('request',request);request.get()},unloadAction:function(btn,options){var action=btn.getProperty('tbkaction');this.activated.remove(btn);this.activated.remove(this.getCmntContainer(btn));var activeRequest=btn.retrieve('request');if(activeRequest!==null){activeRequest.cancel()}this.fireEvent('actionUnload',[btn,options]);this.fireEvent(action+'Unload',[btn,options])},handleActionRequest:function(form,btn){var el=(!btn)?form:btn;if(el.retrieve('isActive')){return false}el.store('isActive',true);var req=new Request.JSON({url:form.getProperty('action'),data:form.toJSON(),onSuccess:function(data){this.handleActionResponse(data,el,form)}.bind(this),onComplete:function(){el.store('isActive',false)}.bind(this),onFailure:this.handleActionResponse.pass([{status:'failure',action:'request'},el],this),noCache:true}).post()},handleActionResponse:function(data,el,form){if(typeof data=='undefined'&&typeof data.status=='undefined'){CNB.log('json data is no good');return false}var action=el.getProperty('tbkaction');if(data.status=='success'){this.refreshMantaAds(["cbsiAd16_100","cbsiAd16_200"]);this.fireEvent(action+'Success',[el,data])}else{if(typeof data.gate!='undefined'){switch(data.gate){case'login':CNB.User.set('isLoggedIn',false);CNB.Reg.gatedEvent(null,this.handleActionRequest.pass([form,el],this),'tkb','Please Log In First');break;case'confirm':CNB.Reg.confirmAccount();break}}else if(typeof data.errors!='undefined'){this.displayErrors(form,data.errors)}this.fireEvent(action+'Failure',[el,data])}},handleActionCancel:function(e,btn){e.stop();this.unloadAction(btn)},initLoadedContent:function(btn){var content=btn.retrieve('content');content.getElements('form').each(function(form){this.getValidator(form).addEvent('validateSuccess',function(e,form){e.stop();this.handleActionRequest(form,btn)}.bind(this))},this);content.getElements('.cancel').each(function(cancel){cancel.addEvent('click',this.handleActionCancel.bindWithEvent(this,btn))},this)},getCmntContainer:function(btn){return btn.getParent('.'+this.options.cmntClass.container)},getCmntContent:function(btn){return this.getCmntContainer(btn).getElement('.'+this.options.cmntClass.content)},getCmntLoadZone:function(btn){var cont=this.getCmntContainer(btn),int=cont.getElement('.int');return int||cont},activated:{set:function(el,value){var store=(value!==null)?value:true;el.store('activated',store)},get:function(el){return el.retrieve('activated')},check:function(el,value){var stored=el.retrieve('activated');if(stored!==null){return stored}else{if(value!==null){this.set(el,value)}return false}},remove:function(el){if(el){el.eliminate('activated')}}},displayErrors:function(form,errors){var validator=this.getValidator(form);$splat(errors).each(function(error){validator.addGlobalError(error)})},addLoader:function(btn){btn.addClass(this.options.cmntClass.loadingIcon)},removeLoader:function(btn){btn.removeClass(this.options.cmntClass.loadingIcon)},getValidator:function(form){var validator=form.retrieve('validator');if(validator===null){validator=new CNB.Validator(form,{validateOnBlur:false})}return validator},resetForm:function(form){form.reset();form.getElements('input[placeholder]').each(function(input){var ph=input.retrieve('placeholder');if(ph!==null){ph.addPlaceholder(input)}})},updatePostData:function(form,data){$each(data,function(val,key){var input=form.getElement('input[name='+key+']');if(input!==null){input.setProperty('value',val)}else{var hiddenInput=new Element('input',{type:'hidden',name:key,value:val});if(form.getElement('.lvl-hidden')){form.getElement('.lvl-hidden').grab(hiddenInput)}else{form.grab(hiddenInput)}}})},refreshMantaAds:function(adsArray){if(typeof cbsiGetDeferredAds!='undefined'&&adsArray){if(this.isAdWaiting)return false;cbsiGetDeferredAds(adsArray,{onembed:CNB.MantaRayEmbed,onload:CNB.MantaRayLoad});var cancel=function(){this.isAdWaiting=false};var adCancel=cancel.delay(2000,this);this.isAdWaiting=true}}});CNB.TR.Talkback=new Class({Extends:CNB.Talkback,options:{onSelectAnswerClicked:function(btn){this.addLoader(btn)},onEditorsPickClicked:function(btn){this.addLoader(btn)},onTakeOfflineClicked:function(btn){this.addLoader(btn)},onReportLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onDeleteLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onReplyLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onEditorsPickLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onSelectAnswerLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onTakeOfflineLoad:function(btn){this.loadContent(btn);this.removeLoader(btn)},onActionUnload:function(btn,options){this.unloadContent(btn,options)},onReportSuccess:function(btn,data){this.unloadAction(btn);btn.getParent().set('html','Flagged')},onEditorsPickSuccess:function(btn,data){this.unloadAction(btn);btn.set('text','Picked')},onSelectAnswerSuccess:function(btn,data){this.unloadAction(btn);btn.set('text','Selected as Answer')},onReplySuccess:function(btn,data){this.unloadAction(btn);var cmnt=Elements.from(data.html)[0];if(data.injectId&&$(data.injectId)){cmnt.inject($(data.injectId),'top')}else{cmnt.inject(this.getCmntContainer(btn),'after')}this.fireEvent('cmntAdded',cmnt)},onPostSuccess:function(form,data){if(data.redirectUrl){window.location=data.redirectUrl}var cmnt=Elements.from(data.html)[0];var container=(data.injectId)?$(data.injectId):null;if(container){container.removeClass('hide').empty().adopt(cmnt)}else{this.threadContainer.removeClass('hide').adopt(cmnt)}if(data.threadId&&data.forumId){var resetData={'forumId':data.forumId,'threadId':data.threadId};this.updatePostData(form,resetData)}this.resetForm(form);this.fireEvent('cmntAdded',cmnt)},onTakeOfflineSuccess:function(btn,data){if(data.redirectUrl){window.location=data.redirectUrl}},onShowHiddenClicked:function(el){this.getCmntContainer(el);var hiddenId=el.getProperty('hiddenid');if(hiddenId){var content=$(hiddenId);if(!content){return false}content.removeClass('hide');var slide=new Fx.Slide(content,{'mode':'vertical','onStart':function(){if(this.open){this.wrapper.setStyle('overflow','hidden')}},'onComplete':function(){if(this.open){this.wrapper.setStyles({'overflow':'visible','height':'auto'})}}}).hide().slideIn();this.getCmntContainer(el).addClass('hide')}},onGetMessageClicked:function(btn){this.msgLoader=new CNB.Loading(this.getCmntLoadZone(btn)).add()},onGetMessageLoad:function(btn){var content=btn.retrieve('content');content.replaces(this.getCmntContainer(btn))},onGetMessageLoadFailure:function(btn){this.msgLoader.remove()},onSelectNextMsgClicked:function(btn){if(!this.isNavActive)return false;this.selectNextMsg()},onSelectPrevMsgClicked:function(btn){if(!this.isNavActive)return false;this.selectPrevMsg()},onSelectMsgClicked:function(btn){var msg=this.getCmntContainer(btn);if(msg.retrieve('isSelected')){return}var offset=msg.getPosition().y-window.getScroll().y;this.selectMsg(msg);if(!this.isNavActive)return;this.gotoMsg(msg,-offset+20)},onSelectMsgInThreadClicked:function(btn,e){var msg=this.getCmntContainer(btn);var msgId=msg.getProperty('data-msg-id');if(!msgId)return;var threadMsg=$('msg-'+msgId);if(threadMsg){this.selectMsg(threadMsg);this.gotoMsg(threadMsg)}else{var sep=(this.options.threadUrl.contains('?'))?'&':'?';window.location=this.options.threadUrl+sep+'messageId='+encodeURIComponent(msgId)}},onCmntAdded:function(cmnt){cmnt.addClass(this.options.cmntClass.added)},onCmntEdited:function(cmnt){cmnt.addClass(this.options.cmntClass.edited)},postForm:null,threadClass:{expanded:'thread-exp',collapsed:'thread-col'},cmntClass:{expanded:'cmnt-exp',collapsed:'cmnt-col',selected:'cmnt-sel',threshold:'cmnt-threshold'},scrollOffset:0,startMsg:null,page:{total:1,current:1},threadView:null,keyEvents:true,threadUrl:null,navScrollOffset:20},initialize:function(options){this.parent(options);this.postForm=$(this.options.postForm);if(this.postForm){this.postForm.getElements('input[type=text], textarea').each(function(el){el.addEvent('focus',function(){if(!CNB.User.get('isLoggedIn')){CNB.Reg.login()}})},this)}this.page={current:this.options.page.current.toInt(),total:this.options.page.total.toInt()};this.threadView=this.options.threadView;this.excludeClasses=[this.options.cmntClass.threshold,this.options.cmntClass.deleted];this.fxScroll=new Fx.Scroll(window,{offset:{x:0,y:0},link:'cancel',duration:300});this.container.addEvents({'click:relay(a[voteaction])':this.handleVote.bind(this)});this.initReplyExpand();this.initContentExpand();if(this.options.keyEvents){window.addEvent('keydown',this.keyEvents.bind(this))}var msg=null;this.isNavActive=true;if(this.options.startMsg=='first'){msg=this.getValidMsg('first');this.selectMsg(msg)}else if(this.options.startMsg){msg=$(this.options.startMsg)||this.getValidMsg('first');this.selectMsg(msg);this.gotoMsg(msg)}},loadContent:function(btn){var content=btn.retrieve('content');var container=this.getCmntLoadZone(btn);this.initLoadedContent(btn);content.inject(container,'bottom');this.removeLoader(btn);var slide=new Fx.Slide(content,{'mode':'vertical','onStart':function(){if(this.open){this.wrapper.setStyle('overflow','hidden')}},'onComplete':function(){if(this.open){this.wrapper.setStyles({'overflow':'visible','height':'auto'})}}}).hide().slideIn();btn.store('slide',slide)},unloadContent:function(btn,options){var slide=btn.retrieve('slide'),content=btn.retrieve('content'),showSlide=(options&&options.showSlide!==undefined)?options.showSlide:true;options=options||{};if(slide!=null&&showSlide){slide.slideOut().chain(function(){content.destroy()}.bind(this))}else{if(content!=null){content.destroy()}}},handleVote:function(e,el){e.stop();var container=el.getParent('.cmnt-vote');var voting=new CNB.Voting({url:el.getProperty('href'),container:container,loadingContainer:container.getElement('.int'),btn:el,regSrc:'vote-cmnt'}).attempt();this.refreshMantaAds(["cbsiAd16_100","cbsiAd16_200"])},notify:function(btn,msg){btn.retrieve('content').set('html','<p>'+msg+'</p>');this.unloadAction.delay(2000,this,btn)},disablePostForm:function(){this.postForm.getElements('input[type=text], textarea').each(function(el){el.setProperty('disabled','disabled')},this);this.postForm.setStyle('opacity','.5')},enablePostForm:function(){this.postForm.getElements('input[type=text], textarea').each(function(el){el.removeProperty('disabled')},this);this.postForm.setStyle('opacity','1')},initReplyExpand:function(){var groups=this.container.getElements('.reply-group');var limit=3;groups.each(function(group){var msgs=group.getElements('.cmnt');if(msgs.length>limit){var cont=new Element('div').inject(group);var removedMsgs=msgs.splice(limit,msgs.length-limit);cont.adopt(removedMsgs);var exand=new CNB.Expander(cont,{'btnClass':'view-more clear','btnText':{'show':'Show '+removedMsgs.length+' More Comments +','hide':'Show Less -'}})}},this)},initContentExpand:function(){var containers=this.container.getElements('.content-expandable');$splat(containers).each(function(container){var excerpt=new CNB.ExcerptContent(container,{textMore:'Read Whole Comment&nbsp;+'})})},selectMsg:function(msg){msg=$(msg);if(!msg||msg.retrieve('isSelected')){return}var currMsg=this.getSelectedMsg();if(currMsg){var activeAction=this.activated.get(currMsg);if(activeAction!==null){this.unloadAction(activeAction,{showSlide:false})}this.deselectMsg(currMsg)}if(msg.hasClass(this.options.cmntClass.threshold)){msg.store('isThreshold',true);msg.removeClass(this.options.cmntClass.threshold)}this.setSelectedMsg(msg);this.expandMsg(msg);msg.store('isSelected',true);msg.addClass(this.options.cmntClass.selected);if(!this.isNavActive)return;this.addPrevNextUi(msg)},hasNextMsg:function(msg){var nextMsg=this.getNextMsg(msg);return(nextMsg||this.page.current<this.page.total)?true:false},hasPrevMsg:function(msg){var prevMsg=this.getPrevMsg(msg);return(prevMsg||this.page.current>1)?true:false},deselectMsg:function(msg){if(msg.retrieve('isThreshold')){msg.addClass(this.options.cmntClass.threshold)}if(this.threadView=='collapsed'){this.collapseMsg(msg)}this.removePrevNextUi(msg);msg.store('isSelected',false);msg.removeClass(this.options.cmntClass.selected)},selectNextMsg:function(){var nextMsg=this.getNextMsg();if(!nextMsg){return}var offset=this.getScrollOffsetFromMsg(this.getSelectedMsg());this.selectMsg(nextMsg);this.gotoMsg(nextMsg,offset)},selectPrevMsg:function(){var prevMsg=this.getPrevMsg();if(!prevMsg){return}var offset=this.getScrollOffsetFromMsg(this.getSelectedMsg());this.selectMsg(prevMsg);this.gotoMsg(prevMsg,offset)},getValidMsg:function(location,msg){var i,isValid,nextMsg=null,excludeClasses=this.excludeClasses;msg=msg||this.getSelectedMsg();location=location||'next';if(!msg&&location!='first'&&location!='last'){return false}for(i=1;i<=10;i++){isValid=true;switch(location){case'previous':nextMsg=msg.getPrevious('.'+this.options.cmntClass.container);break;case'next':nextMsg=msg.getNext('.'+this.options.cmntClass.container);break;case'first':nextMsg=this.threadContainer.getFirst('.'+this.options.cmntClass.container);location='next';break;case'last':nextMsg=this.threadContainer.getLast('.'+this.options.cmntClass.container);location='prev';break}if(!nextMsg){break}excludeClasses.each(function(cl){if(nextMsg.hasClass(cl)){isValid=false}});if(isValid){break}msg=nextMsg}return nextMsg},getNextMsg:function(msg){msg=msg||this.getSelectedMsg();if(!msg){return false}return this.getValidMsg('next',msg)},getPrevMsg:function(msg){msg=msg||this.getSelectedMsg();if(!msg){return false}return this.getValidMsg('previous',msg)},addPrevNextUi:function(msg){var html='',elPrevNext=null,prevDisable=(this.hasPrevMsg(msg))?'':'disabled',nextDisable=(this.hasNextMsg(msg))?'':'disabled',innerHtml='<a class="btn prev '+prevDisable+'" title="Previous" tbkcustomaction="selectPrevMsg">Previous</a>'+'<a class="btn next '+nextDisable+'" title="Next" tbkcustomaction="selectNextMsg">Next</a>';['upper','lower'].each(function(ver){html+='<div class="prev-next prev-next-'+ver+'">'+innerHtml+'</div>'});elPrevNext=CNB.htmlToElement(html);msg.store('prevNext',elPrevNext);elPrevNext.inject(msg,'bottom')},removePrevNextUi:function(msg){var elPrevNext=msg.retrieve('prevNext');if(elPrevNext){elPrevNext.destroy()}},setSelectedMsg:function(msg){this._selectedMsg=msg},getSelectedMsg:function(){return this._selectedMsg},getScrollOffsetFromMsg:function(msg){msg=(msg)?msg.getElement('.int'):null;var yMsg=(msg)?(msg.getPosition().y-this.options.navScrollOffset):0,offset=0,yWin=window.getScroll().y,yWinSize=window.getSize().y;if(yMsg<yWin){offset=yWinSize/8}else if(yMsg>(yWin+(yWinSize*0.8))){offset=yWinSize/2}else{offset=yMsg-yWin}return-offset},gotoMsg:function(msg,offset){if(!msg){return}offset=offset||-(window.getSize().y/8);this.fxScroll.setOptions({offset:{x:0,y:offset}});this.fxScroll.toElement(msg)},expandMsg:function(msg){msg.removeClass(this.options.cmntClass.collapsed);msg.addClass(this.options.cmntClass.expanded)},collapseMsg:function(msg){msg.removeClass(this.options.cmntClass.expanded);msg.addClass(this.options.cmntClass.collapsed)},expandAllMsgs:function(){this.threadContainer.getElements('.'+this.options.cmntClass.container).each(function(elMsg){this.expandMsg(elMsg)},this);this.threadContainer.addClass(this.options.threadClass.expanded);this.threadContainer.removeClass(this.options.threadClass.collapsed);this.threadView='expanded'},collapseAllMsgs:function(){this.threadContainer.getElements('.'+this.options.cmntClass.container).each(function(elMsg){if(!elMsg.retrieve('isSelected')){this.collapseMsg(elMsg)}},this);this.threadContainer.addClass(this.options.threadClass.collapsed);this.threadContainer.removeClass(this.options.threadClass.expanded);this.threadView='collapsed'},keyEvents:function(event){var el=event.target.get('tag');if(el=='input'||el=='textarea'){return}if(event.key=='left'||event.key=='k')this.selectPrevMsg();if(event.key=='right'||event.key=='j')this.selectNextMsg();if(event.key=='t')this.toggleThreadView()},toggleThreadView:function(){if(this.threadView=='collapsed'){this.expandAllMsgs()}else{this.collapseAllMsgs()}var msg=this.getSelectedMsg();if(msg){this.gotoMsg(msg)}this.refreshMantaAds(["cbsiAd16_100","cbsiAd16_200"])}});CNB.TR.StartThread=new Class({Implements:[Options,Events],options:{suggestThreadsUrl:null,postDiscussionUrl:null,postQuestionUrl:null,forumType:'discussions',subjectInjectId:null},initialize:function(form,options){this.setOptions(options);this.form=$(form);this.validator=new CNB.Validator(this.form,{'validateOnBlur':false});this.subjectInject=$(this.options.subjectInjectId);this.subjectField=this.form.getElement('[name=subject]');this.subjectField.addEvent('blur',this.makeSuggestThreadsRequest.bind(this));this.subjectField.addEvent('blur',this.checkForQuestion.bind(this));this.initWaterCoolerTag()},makeSuggestThreadsRequest:function(){var query=this.subjectField.value;if(!query){this.subjectInject.empty();return false}var req=new Request.JSON({url:this.options.suggestThreadsUrl,data:{q:query},onSuccess:this.handleSuggestThreadsResponse.bind(this),noCache:true}).post()},handleSuggestThreadsResponse:function(data){if(typeof data.html=='undefined'||data.html.trim()==''){return false}var content=CNB.htmlToElement(data.html);this.subjectInject.empty().adopt(content)},checkForQuestion:function(e,form){var subject=this.subjectField.value.trim();if(subject!=''&&subject.charAt(subject.length-1)!='?'&&this.options.forumType=='questions'){this.validator.addError(this.subjectField,'Your subject is not in the form of a question. <a href="'+this.options.postDiscussionUrl+'?subject='+encodeURIComponent(subject)+'" class="c-3 heavy">Post as Discussion &raquo;</a>')}else if(subject!=''&&subject.charAt(subject.length-1)=='?'&&this.options.forumType=='discussions'){this.validator.addError(this.subjectField,'Your subject is not in the form of a discussion. <a href="'+this.options.postQuestionUrl+'?subject='+encodeURIComponent(subject)+'" class="c-3 heavy">Post as Question &raquo;</a>')}else{this.validator.removeError(this.subjectField)}},initWaterCoolerTag:function(){var tags=this.form.getElements('[name^=tags]');var wcTag=null;tags.each(function(el,i){if(el.getProperty('id')=='start-thread-tags-watercooler'){wcTag=tags.splice(i,1)}});if(wcTag){wcTag[0].addEvent('click',function(e){var isChecked=$(this).checked;tags.each(function(el){if(isChecked){el.removeProperty('checked')}})});tags.addEvent('click',function(e){var isChecked=$(this).checked;if(isChecked){wcTag[0].removeProperty('checked','checked')}})}}});CNB.InitAssetThread=new Class({Implements:[Options,Events],options:{url:'',data:{}},initialize:function(container,options){this.setOptions(options);window.addEvent('domready',function(){this.container=$(container);if(!this.container){return}this.loader=new CNB.Loader(this.container,{minHeight:100,text:'Loading Talkback...'});this.loader.add();this.requestThread()}.bind(this))},requestThread:function(){var request=new Request.JSON({url:this.options.url,data:this.options.data,onSuccess:this.handleRequestThreadSuccess.bind(this),onFailure:function(){}.bind(this),onComplete:function(){this.loader.remove()}.bind(this),noCache:true}).get()},handleRequestThreadSuccess:function(data){if(typeof data.html=='undefined'){CNB.log('bad data')}var thread=Elements.from(data.html);this.container.adopt(thread);var container=$('discussion-'+data.assetId),threadContainer=$('discussion-'+data.assetId+'-thread'),postForm=$('discussion-'+data.assetId+'-post-form'),pageTotal=data.pageTotal||1;new CNB.TR.Talkback({container:container,threadContainer:threadContainer,postForm:postForm,threadUrl:data.threadUrl,threadView:data.threadView,page:{total:pageTotal,current:'1'},startMsg:'first'});CNB.PopSelect.MultiInit(container.getElements('.sort-1 .btn'),container.getElements('.sort-1 .overlay-pop-2'),{setSelectionOnClick:false,setCookieOnClick:true});new CNB.Expander('bb-code-cont',{btn:'bb-code-btn',btnText:{show:'Formatting +',hide:'Formatting -'}})}});CNB.InitFeaturedMessages=new Class({Implements:[Options,Events],options:{container:null,threadContainer:null,postForm:null,threadUrl:null,threadView:null,url:'',containers:{contacts:null,topRated:null,editorChoice:null,latest:null},data:{contacts:null,topRated:null,editorChoice:null,latest:null},regClasses:{loggedIn:'reg-is-logged-in',loggedOut:'reg-islogged-out',event:'reg-event'}},initialize:function(options){this.setOptions(options);var tb=new CNB.TR.Talkback({container:this.options.container,threadContainer:this.options.threadContainer,postForm:this.options.postForm,threadUrl:this.options.threadUrl,threadView:this.options.threadView});window.addEvent('domready',function(){var containers=new Hash({}).combine(this.options.containers),data=new Hash({}).combine(this.options.data);containers.each(function(id,k){if(id!=undefined&&data.get(k)!=undefined){this.container=$(id);this.containerData=data.get(k);if(this.container){this.activateMessageLoad()}}}.bind(this))}.bind(this))},activateMessageLoad:function(){if(this.container.hasClass(this.options.regClasses.event)){CNB.Reg.addEvents({loginSuccess:this.prepContainer.bind(this),joinSuccess:this.prepContainer.bind(this)})}else{this.prepContainer()}},prepContainer:function(){this.container.empty();this.loader=new CNB.Loader(this.container,{minHeight:100,text:'Loading Talkback...'});this.loader.add();this.requestThread()},requestThread:function(){var request=new Request.JSON({url:this.options.url,data:this.containerData,onSuccess:this.handleRequestThreadSuccess.bind(this),onFailure:function(){}.bind(this),onComplete:function(){this.loader.remove()}.bind(this),noCache:true}).get()},handleRequestThreadSuccess:function(data){if(typeof data.html==='undefined'||data.status==='failure'){return}var thread=Elements.from(data.html);this.container.adopt(thread);this.initContentExpand()},initContentExpand:function(){var containers=this.container.getElements('.content-expandable');$splat(containers).each(function(container){var excerpt=new CNB.ExcerptContent(container,{textMore:'Read Whole Comment&nbsp;+'})})}});
