function saveNewArticle(g,d,f,e,a){var b=$(e).value;
if(b==null||b.length<1||b=="Title..."){alert("Please give your new article a title.");
return
}var c=tinyMCE.get(f).getContent();
if(c==null||c.length<1){alert("Please give your new article some content.");
return
}var h=$(document.body);
if(h!=null){h.appendChild(getProcessIndicator())
}new Ajax.Request(g+"saveNewVersion",{method:"POST",parameters:{actorId:d,createNew:true,newContent:c,newTitle:b,newLocale:a},onSuccess:function(j){var i=j.responseText.evalJSON();
if(i.newVersionId!=null&&i.newArticleId!=null){window.location="article.jsp?id="+i.newArticleId+"&versionId="+i.newVersionId
}else{if(i.error!=null){alert("Sorry, an error occurred: "+i.error)
}}},onComplete:function(){removeProgressIndicator(h)
}})
}function saveNewVersion(e,b,c,a,d){var f=$(document.body);
if(f!=null){f.appendChild(getProcessIndicator())
}new Ajax.Request(e+"saveNewVersion",{method:"POST",parameters:{actorId:b,articleId:c,versionId:a,newContent:tinyMCE.get(d).getContent()},onSuccess:function(h){var g=h.responseText.evalJSON();
if(g.newVersionId!=null){window.location="article.jsp?id="+c+"&versionId="+g.newVersionId
}else{if(g.error!=null){alert("Sorry, an error occurred: "+g.error)
}else{if(g.duplicate!=null){alert("Sorry, that text duplicates an existing article.")
}}}},onComplete:function(){removeProgressIndicator(f)
}})
}function rateArticle(d,a,b,c){var e=$(document.body);
if(e!=null){e.appendChild(getProcessIndicator())
}new Ajax.Request(d+"rateVersion",{method:"POST",parameters:{actorId:a,articleId:b,score:c},onSuccess:function(g){var f=g.responseText.evalJSON();
if(f.newRatingId!=null){window.location=window.location
}else{if(f.error!=null){alert("Sorry, an error occurred: "+f.error)
}}},onComplete:function(){removeProgressIndicator(e)
}})
}function rateVersion(d,b,a,c){new Ajax.Request(d+"rateVersion",{method:"POST",parameters:{actorId:b,versionId:a,score:c},onSuccess:function(f){var e=f.responseText.evalJSON();
if(e.newRatingId!=null){window.location=window.location
}else{if(e.error!=null){alert("Sorry, an error occurred: "+e.error)
}}}})
}function runAsyncMLT(b,a,c){var e=$(b);
if(e==null){return
}var d=($("hidden-currentArticleId")!=null)?$("hidden-currentArticleId").innerHTML:-1;
new Ajax.Request(getAppURL()+"asyncMLT",{parameters:{numMatches:c,query:a,currentArticleId:d,articleTimeMS:$("hidden-articleTimeMS").innerHTML,articleRangeUnits:"DAYS",articleRangeBefore:90,articleRangeAfter:90},onSuccess:function(f){if(f.responseText==""){stripExistingChildren(e);
_populateMLTShowNoEntries(e)
}else{handleMLTSuccess(e,f.responseText.evalJSON())
}}})
}var g_MLT_MaxFontSize=14;
var g_MLT_MinFontSize=10;
function handleMLTSuccess(p,o){stripExistingChildren(p);
if(o.matches==null||o.matches.length==0){_populateMLTShowNoEntries(p);
return
}var a=new Date().getTime();
var j=($("hidden-articleTimeMS")!=null)?parseInt($("hidden-articleTimeMS").innerHTML):a;
for(var h=0;
h<o.matches.length;
h++){var r=o.matches[h];
if(r==null){continue
}var f=document.createElement("DIV");
f.setAttribute("class","channelsContainer");
var q=100;
var l="";
if(r.date>=0){var c=Math.round((j-r.date)/(MSECS_IN_SECOND*SECS_IN_MIN*MINS_IN_HR*HRS_IN_DAY));
q=Math.round(100-1.65*Math.sqrt(c));
l=" posted @ "+getFormattedTimeDiffForTime(r.date,a)
}var e=58-((r.targetName!=null)?r.targetName.length:0);
var m=((r.title!=null&&r.title.length>0)?replace(r.title,'"',"'"):"")+l;
var g=(r.title!=null&&r.title.length>0)?_adjustChannelTitle(r.title.stripHTMLEntities(),e):"???";
var k="";
var n=Math.round((o.matches.length-h)/o.matches.length*(g_MLT_MaxFontSize-g_MLT_MinFontSize))+g_MLT_MinFontSize;
var d=Builder.node("div",{className:"title",style:"font-size: "+n+"px; filter: alpha(opacity="+q+"); opacity:"+(q/100)+";"});
d.innerHTML='<a target="'+getArticleLinkTarget()+'" title="'+m+'" href="http://www.poblish.org/article.jsp?id='+r.articleId+k+'">'+g+"</a>";
f.appendChild(d);
var b=_adjustChannelTitle(r.targetName);
if(r.targetType=="Blog"){f.appendChild(_createBlogBoxElem(r.targetId,b))
}else{if(r.targetType=="Feed"){f.appendChild(_createFeedBoxElem(r.targetId,b))
}else{if(r.targetType=="Wiki"){f.appendChild(_createWikiBoxElem(r.targetId,b))
}else{f.appendChild(_createActorBoxElem(b))
}}}p.appendChild(f)
}}function _populateMLTShowNoEntries(a){a.appendChild(Builder.node("div",{className:"channelsContainer"},[Builder.node("div",{className:"title"},Builder.node("em","No entries at present"))]))
}function runAsyncDG_API(b,a,c){var d=$(b);
if(d==null){return
}new Ajax.Request(getAppURL()+"asyncDG_API",{parameters:{numMatches:c,query:a},onSuccess:function(k){stripExistingChildren(d);
var e=k.responseText.evalJSON();
if(e.matches==null||e.matches.length==0){_populateMLTShowNoEntries(d);
return
}for(var g=0;
g<e.matches.length;
g++){var j=e.matches[g];
if(j==null){continue
}var h=document.createElement("div");
h.setAttribute("class","channelsContainer dg-elem-"+j.type);
var f=Builder.node("p",{style:"padding: 3px"});
f.innerHTML='<a title="'+j.type+'" href="debategraph/element.jsp?id='+j.elemId+'" target="dgElement">'+j.title+"</a>";
h.appendChild(f);
d.appendChild(h)
}}})
}function runAsyncSemanticTopicSearch(a){new Ajax.Request(getAppURL()+"asyncArticleTopics",{parameters:{articleId:a},onSuccess:function(g){var b=g.responseText.evalJSON();
var c=Builder.node("p",{id:"semanticResults",style:"margin: 3px 5px 0 5px"});
var f=0;
f+=_buildTopicsLine(c,b.people,"People","person.jsp",f);
f+=_buildTopicsLine(c,b.locs,"Places","location.jsp",f);
f+=_buildTopicsLine(c,b.nouns,"Nouns","noun.jsp",f);
f+=_buildTopicsLine(c,b.other,"Others",null,f);
if(f==0){c.appendChild(Builder.node("em","No sentiment analysis for this post. Please try again in a few minutes."))
}var e=[];
_buildWordsList(e,b.people);
_buildWordsList(e,b.locs);
var d={getPatterns:function(j,i){var h=_getSeparators(j);
this.r1=new RegExp("(["+h+"])("+i+")(["+h+"])","g");
this.r2=new RegExp("^("+i+")","g");
this.r3=new RegExp("("+i+")(["+h+"]?)$","g");
this.r4=new RegExp("^("+i+")(["+h+"]?)$","g");
this.r5=new RegExp("("+i+")(["+h+"])","g")
},test:function(h){return(this.r1.test(h)||this.r2.test(h)||this.r3.test(h)||this.r4.test(h))
},getReplacementPattern:function(){return this.r5
},getWrapperReplacement:function(){return'<span title="Name or Location" style="padding: 1px 4px 1px 4px; border: 1px dotted #999; background-color: #FFC">$1</span>$2'
}};
highlightEntries(tinyMCE.activeEditor,e,d)
}})
}function _buildWordsList(c,b){if(b!=null&&b.length>0){for(var a=0;
a<b.length;
a++){c.push(b[a])
}}}function _buildTopicsLine(b,d,e,c,a){if(d!=null&&d.length>0){b.appendChild(Builder.node("span",{style:"font-weight: bold"},[(a>0)?"  |  ":"",e+": "]));
for(var f=0;
f<d.length;
f++){if(f>0){b.appendChild(document.createTextNode(", "))
}b.appendChild(getSentimentSpanForType(d[f].sentiment,d[f].name));
if(c!=null){b.appendChild(Builder.node("a",{style:"margin-left: 2px",href:"http://www.poblish.org/"+c+"?name="+d[f].name,title:"More about "+d[f].name,target:"semanticTarget"},"*"))
}}return 1
}return 0
}function getWidgetDetails(a,b,c){var d=$(a);
if(d==null||c==""){return
}new Ajax.Request(getAppURL()+"callWidget",{parameters:{resId:b,resType:c,articleId:$("hidden-currentArticleId").innerHTML},onSuccess:function(e){handleWidgetResponse(d,e.responseText.evalJSON())
}})
}function handleWidgetResponse(h,e){var b=$("widgetAuthorSection");
if(b!=null){while(b.firstChild){b.removeChild(b.firstChild)
}var g;
if(e.targetUserName!=null){g=_createActorBoxElem(e.targetUserName)
}else{if(e.targetClass=="Blog"){g=_createBlogBoxElem(e.targetResId,e.targetDisplayName)
}else{if(e.targetClass=="Feed"){g=_createFeedBoxElem(e.targetResId,e.targetDisplayName)
}else{g=_createWikiBoxElem(e.targetResId,e.targetDisplayName)
}}}b.appendChild(g)
}if(e.numIncomingLinks!=null&&$("incomingLinksCount")!=null){var d=parseInt(e.numIncomingLinks);
$("incomingLinksCount").innerHTML="<strong>("+d+")</strong>";
$("incomingLinksCount").highlight()
}h.childElements().each(function(k){if($w(k.className).indexOf("widgetInfo")>=0){k.parentNode.removeChild(k)
}});
h.appendChild(Builder.node("p",{className:"widgetInfo",style:"padding-top: 2px"},["Total reads: ",[Builder.node("strong",(e.numArticleReads==null||e.numArticleReads<1)?"none":e.numArticleReads)]]));
var f=Builder.node("div",{style:"float: left; padding: 1px 5px 0 0"},[(e.followsForMe!=null)?[Builder.node("strong",e.followsForMe),((e.followsForMe==1)?" follower":" followers")]:"No followers",".  Totals:"]);
var j=Builder.node("div",{className:"widgetInfo"},[f]);
addFaveIndicatorToContainer(j,e.favesForMe!=null?e.favesForMe:0,"widgetFlagContainer","widgetFlagNumber");
addFlagIndicatorToContainer(j,e.flagsForMe!=null?e.flagsForMe:0,"widgetFlagContainer","widgetFlagNumber");
h.appendChild(j);
h.appendChild(Builder.node("div",{style:"clear: both"}));
if(e.assFlaggedAgainstMe!=null||e.assMyPercResp!=null){var c=(e.assFlaggedAgainstMe!=null)?Builder.node("span",[Builder.node("strong",e.assFlaggedAgainstMe),((e.assFlaggedAgainstMe==1)?" assertion flagged by others":" assertions flagged by others")]):"No assertions flagged by others";
var i=(e.assMyPercResp!=null)?Builder.node("span",[Builder.node("strong",parseInt(100*e.assMyPercResp)),"%"]):"none";
h.appendChild(Builder.node("p",{className:"widgetInfo"},[c," (",i," responded-to)."]))
}if(e.assFlaggedByMe!=null){var a=(e.assFlaggedByMe!=null)?Builder.node("span",[Builder.node("strong",e.assFlaggedByMe),((e.assFlaggedByMe==1)?" assertion":" assertions")]):"No assertions";
h.appendChild(Builder.node("p",{className:"widgetInfo"},[a," flagged by them."]))
}}function callFlagAssertion(a){var b=(a!=null)?$(a).value:tinyMCE.activeEditor.selection.getContent();
if(b==null||b==""){alert("Please select the assertion you intend to flag.");
return
}new Ajax.Request(getAppURL()+"flagAssertion",{parameters:{loggedInActorId:getActorId(),articleId:$("hidden-currentArticleId").innerHTML,comment:"Hello",snippet:b},onSuccess:function(d){var c=d.responseText.evalJSON();
alert(c)
}})
}function deleteArticle(){new Ajax.Request(getAppURL()+"deleteArticle",{parameters:{articleId:$("hidden-currentArticleId").innerHTML},onSuccess:function(b){var a=b.responseText.evalJSON();
if(a.error!=null){alert(a.error)
}}})
}function runBlogMLT(b,c,d,a){var e=$(b);
if(e==null){return
}if(e!=null){e.appendChild(getProcessIndicator())
}new Ajax.Request(getAppURL()+"blogSimilarity",{parameters:{numMatches:25,resId:c,resType:d},onSuccess:function(g){var f=g.responseText.evalJSON();
handleBlogMLTSuccess(e,f,a)
},onComplete:function(){removeProgressIndicator(e)
}})
}function handleBlogMLTSuccess(g,f,e){stripExistingChildren(g);
var k=(f.matches!=null)?f.matches.length:0;
var h=$$("#actorResInfoTabber li:nth-child("+e+") a");
if(f!=null&&f.next_update_ms!=null&&parseInt(f.next_update_ms)>0&&$("next_blog_similarity_update_ms")!=null){$("next_blog_similarity_update_ms").innerHTML="on or before "+new Date(f.next_update_ms).toLocaleString()
}if(h!=null){h[0].innerHTML="Similar Blogs ("+k+")"
}if(k==0){_populateMLTShowNoEntries(g);
return
}for(var d=0;
d<f.matches.length;
d++){var j=f.matches[d];
if(j==null){continue
}var c=document.createElement("DIV");
c.setAttribute("class","channelsContainer");
var b=j.blogName;
c.appendChild(Builder.node("div",{style:"float: left"},getPercentageScoreElem(j.score)));
c.appendChild(_createBlogBoxElem(j.blogId,b));
if(j.groupInfo!=null){c.appendChild(Builder.node("span",{style:"padding: 1px 5px 0 5px; color: #919DBD; float: left"},"associated with:"));
var a=(j.groupInfo.length>8)?8:j.groupInfo.length;
for(var l=0;
l<a;
l++){c.appendChild(_createGroupBoxElem(j.groupInfo[l].id,j.groupInfo[l].name,null))
}if(a<j.groupInfo.length){c.appendChild(Builder.node("span",{style:"padding: 1px 5px 0 5px; color: #919DBD; float: left"},["and "+(j.groupInfo.length-a)+" others"]))
}}g.appendChild(c)
}}function requestBitlyInfo(){new Ajax.Request(getAppURL()+"bitlyResults",{parameters:{url:$("hidden-articleURL").innerHTML},method:"GET",onSuccess:function(c){var a=c.responseText.evalJSON();
if(a!=null&&a.clicks!=null){var b=$("articleBitlyElem");
if(b!=null){$("articleBitlyElem.count").innerHTML=a.clicks;
$("articleBitlyElem.label").innerHTML=(a.clicks=="1")?"click":"clicks";
b.appear({duration:0.5})
}}}})
}var g_PrevContent="";
function initTinyMCE(){tinyMCE.init({mode:"textareas",entity_encoding:"named",content_css:"css/main.css",plugins:"autoresize,save",theme:"advanced",theme_advanced_toolbar_location:"bottom",theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist,|,link,unlink,|,save,cancel",theme_advanced_buttons2:"",save_enablewhendirty:true,save_onsavecallback:"toolbarSave",setup:function(a){a.onInit.add(function(c){getWidgetDetails("asyncWidgetContainer",$("hidden-resId").innerHTML,$("hidden-resType").innerHTML);
highlightAssertionSnippets();
tryToUpdateAsyncStuff(getArticleContentForAsyncStuff(),true);
new PeriodicalExecuter(function(d){tryToUpdateAsyncStuff(getArticleContentForAsyncStuff(),false)
},5);
for(var b=0;
b<2;
b++){new PeriodicalExecuter(function(d){try{c.execCommand("mceAutoResize")
}catch(f){}d.stop()
},5)
}});
a.onChange.add(function(c,b){tryToUpdateAsyncStuff(getArticleContentForAsyncStuff(),false)
})
}})
}function tryToUpdateAsyncStuff(a,b){if(a!=g_PrevContent){runAsyncMLT("asyncMLTContainer",a,20);
runAsyncDG_API("asyncDGContainer",a,10);
if(b){requestBitlyInfo();
runAsyncSemanticTopicSearch(parseInt($("hidden-currentArticleId").innerHTML))
}g_PrevContent=a
}}function getArticleContentForAsyncStuff(){var a=($("newArticleTitleFld")!=null)?$("newArticleTitleFld").value:$("existingArticleTitle").innerHTML.stripTags().stripHTMLEntities();
var b=(tinyMCE.activeEditor!=null)?tinyMCE.activeEditor.getContent().stripTags().stripHTMLEntities():"";
return(a+". "+b).strip()
}function highlightAssertionSnippets(){var a=[];
var d=0;
var c={getPatterns:function(f,e){this.r1=new RegExp("("+e+")","g")
},test:function(e){return this.r1.test(e)
},getReplacementPattern:function(){return this.r1
},getWrapperReplacement:function(){return'<span title="Flagged Assertion" style="padding: 1px 4px 1px 4px; border: 1px dotted #999; background-color: #CFF">$1</span>'
}};
while($("assertionSnippets."+d)!=null){var b=replace($("assertionSnippets."+(d++)).innerHTML,"&nbsp;","(?:&nbsp;|\\s)");
a.push({name:b})
}highlightEntries(tinyMCE.activeEditor,a,c)
}function highlightEntries(f,b,e){if(b.length<1){return
}var a="";
var d=f.dom;
var c=[];
b.each(function(g){a+=(a?"|":"")+g.name
});
e.getPatterns(f,a);
_walk(f,f.getBody(),function(g){if(g.nodeType==3){c.push(g)
}});
c.each(function(h){var g;
if(h.nodeType==3){g=h.nodeValue;
if(e.test(g)){try{g=d.encode(g);
g=g.replace(e.getReplacementPattern(),e.getWrapperReplacement());
d.replace(d.create("span",{"class":""},g),h)
}catch(i){}}}})
}function _walk(g,e,b){var c=g.getDoc(),a;
if(c.createTreeWalker){a=c.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,false);
while((e=a.nextNode())!=null){b.call(this,e)
}}else{tinymce.walk(e,b,"childNodes")
}}function _getSeparators(d){var b="",a,c=d.getParam("spellchecker_word_separator_chars",'\\s!"#$%&()*+,-./:;<=>?@[]^_{|}����������������\u201d\u201c');
for(a=0;
a<c.length;
a++){b+="\\"+c.charAt(a)
}return b
};