// Daily Kos commenting system. (c)2006 Kos Media LLC

var KOS_URL_BASE="/";var kos={DISABLED:false,trollRatingsLeft:5,REFRESH_INTERVAL:20000,OVERFLOW_REFRESH_INTERVAL:60000,REFRESH_TIMEOUT_TIME:30000,NOTIFIER_DURATION:15000,OVERFLOW_COUNT:100,UPDATE_BATCH_COUNT:15,FULL_BATCH_COUNT:5,UPDATE_GAP_DURATION:100,DEBUG:false,LOG:false,ANIMATE:true,IDLE_MONITOR_INTERVAL:2500,URL_BASE:KOS_URL_BASE,IMAGE_BASE:"http://images.dailykos.com/images/admin/",CSS_BASE:KOS_URL_BASE+"css/",STORY_BASE:KOS_URL_BASE+"story/",UPDATE_BASE:KOS_URL_BASE+"update/",SUBMIT_BASE:KOS_URL_BASE+"ajax/",HELP_BASE:KOS_URL_BASE+"help/",TAG_BASE:"http://www.dailykos.com/tag/",DKOSOPEDIA_BASE:"http://www.dkosopedia.com/wiki/",CONFIRM_CANCEL_MSG:"Abandon the comment entry?",STRING_MAXLENGTH:65535,changeCss:function(isFlat,isNarrow){if(window.ActiveXObject){if(kos.commentsDiv){kos.commentsDiv.style.display=kos.DISPLAY_NONE;}}
var userCss=$("userCss");if(isFlat){if(isNarrow){userCss.href=kos.CSS_BASE+"flat.css";}else{userCss.href=kos.CSS_BASE+"flatwide.css";}}else{if(isNarrow){userCss.href=kos.CSS_BASE+"nested.css";}else{userCss.href=kos.CSS_BASE+"nestedwide.css";}}
if($("cDHide").checked&&kos.commentsDiv){kos.commentsDiv.style.display=kos.DISPLAY_NONE;}
if(window.ActiveXObject){setTimeout(kos.fixIECSSSwapHack,10);}},insertAfter:function(newElement,targetElement){var parent=targetElement.parentNode;if(parent.lastChild==targetElement){parent.appendChild(newElement);}else{parent.insertBefore(newElement,targetElement.nextSibling);}},returnFalse:function(evt){evt=evt||window.event;if(evt.preventDefault){evt.preventDefault();evt.stopPropagation();}else if(evt.cancelBubble){evt.cancelBubble=true;}
return false;},returnTrue:function(evt){return true;},getPosX:function(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x){curleft+=obj.x;}
return curleft;},getPosY:function(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y){curtop=obj.y;}
return curtop;},getScrollState:function(container){var scrollY;if(window.pageYOffset){scrollY=window.pageYOffset;}else if(kos.isIE6Css&&document.body.parentElement){scrollY=document.body.parentElement.scrollTop;}else{scrollY=document.body.scrollTop;}
var scrollX;if(window.pageXOffset){scrollX=window.pageXOffset;}else if(kos.isIE6Css&&document.body.parentElement){scrollX=document.body.parentElement.scrollLeft;}else{scrollX=document.body.scrollLeft;}
if(!container){container=$("comments");if(!container){container=$("main");}}
var curHeight;if(container.offsetHeight){curHeight=container.offsetHeight;}else{curHeight=container.clientHeight;}
return{scrollX:scrollX,scrollY:scrollY,height:curHeight};},getWindowInnerHeight:function(){if(window.innerHeight){var winHt=window.innerHeight;}else if(kos.isIE6Css&&document.body.parentElement){winHt=document.body.parentElement.clientHeight;}else{winHt=document.body.clientHeight;}
return winHt;},getWindowInnerWidth:function(){if(window.innerWidth){var winWd=window.innerWidth;}else if(kos.isIE6Css&&document.body.parentElement){winWd=document.body.parentElement.clientWidth;}else{winWd=document.body.clientWidth;}
return winWd;},DISPLAY_NONE:"none",DISPLAY_BLOCK:"block",DISPLAY_INLINE:"inline",DISPLAY_DEFAULT:"",setDisplayStyle:function(panel,displayStyle,scrollState,scrollToView,padding,onComplete){if(!scrollState){scrollState=kos.getScrollState();}
var panelHt;if(panel.style.display!=displayStyle){var animateOverride=(!kos.isIE6Minus||scrollToView);if(kos.ANIMATE&&animateOverride){var newFx=new kos.kfx(panel,displayStyle,onComplete,!scrollToView);panelHt=newFx.startAnimation();}else{var oldHt;if(panel.offsetHeight){oldHt=panel.parentNode.offsetHeight;}else{oldHt=panel.parentNode.clientHeight;}
panel.style.display=displayStyle;if(!scrollToView){var newHt;if(panel.offsetHeight){newHt=panel.parentNode.offsetHeight;}else{newHt=panel.parentNode.clientHeight;}
if(displayStyle==kos.DISPLAY_NONE){window.scrollBy(0,newHt-oldHt);}else{window.scrollBy(0,newHt-oldHt);}}
if(onComplete){setTimeout(onComplete,10);}}}
if(scrollToView&&(displayStyle!=kos.DISPLAY_NONE)){var newScrollState=kos.getScrollState();if(!panelHt){if(panel.offsetHeight){panelHt=panel.offsetHeight;}else{panelHt=panel.clientHeight;}}
if(!padding){padding=24;}
var winHt=kos.getWindowInnerHeight();var topTarget=Math.max(kos.getPosY(panel)-padding,0);var btmTarget=topTarget+panelHt+padding+padding;if(newScrollState.scrollY>topTarget||(newScrollState.scrollY+winHt)<btmTarget){var scrollHt;if((newScrollState.scrollY+winHt)<btmTarget){scrollHt=Math.max(btmTarget-winHt,0);}else{scrollHt=topTarget;}
window.scrollTo(newScrollState.scrollX,scrollHt);}}},setDisplayStyleScrollNeutral:function(panel,displayStyle){if(panel.style.display!=displayStyle){var scrollState=kos.getScrollState();var oldHt;if(kos.mainDiv){if(panel.offsetHeight){oldHt=kos.mainDiv.offsetHeight;}else{oldHt=kos.mainDiv.clientHeight;}}
panel.style.display=displayStyle;var useSC=false;var panelY=kos.getPosY(panel);if(kos.commentEditor&&kos.commentEditor.style.display==kos.DISPLAY_BLOCK){var editorY=kos.getPosY(kos.commentEditor);if(panelY<editorY){useSC=true;}}else if(panelY>200&&panelY<scrollState.scrollY){useSC=true;}
if(useSC&&kos.mainDiv){if(window.ActiveXObject){if(panel.offsetHeight){var panelHt=panel.offsetHeight;}else{panelHt=panel.clientHeight;}
if(panelHt>40){panelHt+=22;}else{panelHt+=5;}
if(displayStyle==kos.DISPLAY_NONE){window.scrollBy(0,(-panelHt));}else{window.scrollBy(0,panelHt);}}else{var newHt;if(panel.offsetHeight){newHt=kos.mainDiv.offsetHeight;}else{newHt=kos.mainDiv.clientHeight;}
if(displayStyle==kos.DISPLAY_NONE){window.scrollBy(0,newHt-oldHt);}else{window.scrollBy(0,newHt-oldHt);}}}}},trim:function(str){return str.replace(/^\s*|\s*$/g,"");},getChildrenByTagName:function(elem,tagName){tagName=tagName.toUpperCase();var children=[];if(elem&&elem.childNodes){for(var i=0;i<elem.childNodes.length;++i){var childNode=elem.childNodes[i];if(childNode.nodeType==1&&childNode.nodeName==tagName){children[children.length]=childNode;}}}
return children;},getChildByTagName:function(elem,tagName){tagName=tagName.toUpperCase();if(elem&&elem.childNodes){for(var i=0;i<elem.childNodes.length;++i){var childNode=elem.childNodes[i];if(childNode.nodeType==1&&childNode.nodeName==tagName){return childNode;}}}
return null;},getChildrenByClassName:function(elem,className){var children=[];if(elem&&elem.childNodes){var re=new RegExp('\\b'+className+'\\b');for(var i=0;i<elem.childNodes.length;++i){var childNode=elem.childNodes[i];if(childNode.nodeType==1&&childNode.className&&childNode.className.match(re)){children[children.length]=childNode;}}}
return children;},getChildByClassName:function(elem,className){if(elem&&elem.childNodes){var re=new RegExp('\\b'+className+'\\b');for(var i=0;i<elem.childNodes.length;++i){var childNode=elem.childNodes[i];if(childNode.nodeType==1&&childNode.className&&childNode.className.match(re)){return childNode;}}}
return null;},getChildById:function(elem,id){if(elem&&elem.childNodes){for(var i=0;i<elem.childNodes.length;++i){var childNode=elem.childNodes[i];if(childNode.nodeType==1&&childNode.id==id){return childNode;}}}
return null;},getElementById:function(elem,id,tagName){if(elem){if(!tagName){tagName="*";}
var elems=elem.getElementsByTagName(tagName);for(var i=0;i<elems.length;++i){var childNode=elems[i];if(childNode.id==id){return childNode;}}}
return null;},getElementsByClassName:function(elem,className,tagName){var children=[];if(elem){var re=new RegExp('\\b'+className+'\\b');if(!tagName){tagName="*";}
var elems=elem.getElementsByTagName(tagName);for(var i=0;i<elems.length;++i){var childNode=elems[i];if(childNode.className&&childNode.className.match(re)){children[children.length]=childNode;}}}
return children;},getElementsByName:function(elem,elName,tagName){var children=[];if(elem){if(!tagName){tagName="*";}
var elems=elem.getElementsByTagName(tagName);for(var i=0;i<elems.length;++i){var childNode=elems[i];if(childNode.name&&childNode.name==elName){children[children.length]=childNode;}}}
return children;},getElementByClassName:function(elem,className,tagName){if(elem){var re=new RegExp('\\b'+className+'\\b');if(!tagName){tagName="*";}
var elems=elem.getElementsByTagName(tagName);for(var i=0;i<elems.length;++i){var childNode=elems[i];if(childNode.className&&childNode.className.match(re)){return childNode;}}}
return null;},getAncestorByTagName:function(elem,tagName){tagName=tagName.toUpperCase();while(elem&&elem.parentNode){if(elem.parentNode.nodeName==tagName){return elem.parentNode;}
elem=elem.parentNode;}
return null;},getAncestorByClassName:function(elem,className){var re=new RegExp('\\b'+className+'\\b');while(elem&&elem.parentNode){if(elem.parentNode.className&&elem.parentNode.className.match(re)){return elem.parentNode;}
elem=elem.parentNode;}
return null;},setupEditorComment:function(evt){return kos.setupEditor(this,"c",evt);},setupEditorDiary:function(evt){return kos.setupEditor(this,"diary",evt);},setupEditor:function(anchor,mode,evt){if(!kos.commentEditor){return true;}
var previewLi=$("eP");if(!previewLi){return true;}
if(kos.commentsDiv&&kos.commentsDiv.style.display==kos.DISPLAY_NONE){$("cDHide").checked=false;kos.commentsDiv.style.display=kos.DISPLAY_BLOCK;var cda=$("cDAlways");cda.checked=false;cda.disabled=true;$("cDAL").disabled=true;}
kos.commentEditor.postKey=(kos.uid+"-"+new Date().getTime());kos.commentEditor.invokingAnchor=anchor;var scrollState=kos.getScrollState(kos.commentsDiv);if(!anchor||mode=="diary"){var commentUl=kos.commentsDiv.getElementsByTagName("UL")[0];if(!commentUl){return true;}
if(commentUl==kos.commentEditor.parentNode&&kos.commentEditor.style.display!=kos.DISPLAY_NONE){return kos.cancelEditor(evt);}else{kos.commentEditor.parentNode.removeChild(kos.commentEditor);kos.commentEditor.style.display=kos.DISPLAY_NONE;kos.commentEditor.style.width=kos.commentsDiv.style.width;previewLi.style.display=kos.DISPLAY_NONE;previewLi.parentNode.removeChild(previewLi);}
if(commentUl.firstChild){commentUl.insertBefore(kos.commentEditor,commentUl.firstChild);commentUl.insertBefore(previewLi,commentUl.firstChild);}else{commentUl.appendChild(previewLi);commentUl.appendChild(kos.commentEditor);}
kos.commentEditor.style.marginLeft="0px";kos.commentEditor.replyToId="-1";}else{var commentLi=kos.getAncestorByTagName(anchor,"LI");kos.markAsRead(commentLi);kos.commentEditor.replyToId=commentLi.id.substring(1);var childUl=kos.getChildByTagName(commentLi,"UL");if(childUl&&childUl==kos.commentEditor.parentNode&&kos.commentEditor.style.display!=kos.DISPLAY_NONE){return kos.cancelEditor(evt);}else{kos.commentEditor.parentNode.removeChild(kos.commentEditor);kos.commentEditor.style.display=kos.DISPLAY_NONE;kos.commentEditor.style.width=kos.commentsDiv.style.width;previewLi.style.display=kos.DISPLAY_NONE;previewLi.parentNode.removeChild(previewLi);}
if(!childUl){childUl=kos.makeIndentedUl(commentLi);commentLi.appendChild(childUl);}
if(childUl.firstChild){childUl.insertBefore(kos.commentEditor,childUl.firstChild);childUl.insertBefore(previewLi,childUl.firstChild);}else{childUl.appendChild(previewLi);childUl.appendChild(kos.commentEditor);}
var editorOffset=kos.getPosX(kos.commentsDiv)-kos.getPosX(commentLi);kos.commentEditor.style.marginLeft=editorOffset+"px";}
var editorSubject=$("eSubject");var onComplete=kos.selectThis.bind(editorSubject);kos.setDisplayStyle(kos.commentEditor,kos.DISPLAY_BLOCK,scrollState,true,20,onComplete);return false;},makeIndentedUl:function(commentLi){var childUl=document.createElement("ul");childUl.className="cm i1";return childUl;},makeHighBitHtmlEntities:function(r){if(navigator.userAgent.toLowerCase().indexOf("khtml")===-1){var re=new RegExp('[\u201c]','g');r=r.replace(re,'&ldquo;');re=new RegExp('[\u201d]','g');r=r.replace(re,'&rdquo;');re=new RegExp('[\u2018]','g');r=r.replace(re,'&lsquo;');re=new RegExp('[\u2019]','g');r=r.replace(re,'&rsquo;');re=new RegExp('[\u2026]','g');r=r.replace(re,'...');re=new RegExp('[\u00a9]','g');r=r.replace(re,'&copy;');re=new RegExp('[\u00ae]','g');r=r.replace(re,'&reg;');re=new RegExp('[\u2122]','g');r=r.replace(re,'&trade;');re=new RegExp('[\u00b6]','g');r=r.replace(re,'&para;');re=new RegExp('[\u2014]','g');r=r.replace(re,'&mdash;');re=new RegExp('[\u00a7]','g');r=r.replace(re,'&sect;');re=new RegExp('[\u20ac]','g');r=r.replace(re,'&euro;');re=new RegExp('[\u00a5]','g');r=r.replace(re,'&yen;');re=new RegExp('[\u00a3]','g');r=r.replace(re,'&pound;');re=new RegExp('[\u00bd]','g');r=r.replace(re,'&frac12;');re=new RegExp('[\u00bc]','g');r=r.replace(re,'&frac14;');}
var t="";for(var i=0;i<r.length;++i){if(r.charCodeAt(i)>128){t+="&#"+r.charCodeAt(i)+";";}else{t+=r.charAt(i);}}
return t;},titleClean:function(t){t=t.replace(/<(\/)?([^>]*)>/g,"&lt;$1$2&gt;");return t;},maxString:function(s){if(s.length>kos.STRING_MAXLENGTH){s=s.substring(0,kos.STRING_MAXLENGTH);}
return s;},textile:function(s){if(!s||s.length===0){return"";}
if(navigator.userAgent.indexOf('MSIE 5.0')!=-1){return s;}
var pre=new RegExp("\\s?[^\\\\]<pre>[\\s\\S]*?[^\\\\]</pre>\\s?",'gi');var preSaves=[];var preMatch;var preCount=0;var preToken="KOS_PRE_FORMATTED";while((preMatch=pre.exec(s))!==null){log("match found");preSaves[preCount]=kos.makeHighBitHtmlEntities(preMatch[0]);s=s.replace(pre,preToken);++preCount;}
var NL="\n";var r=NL+s+NL;var re=new RegExp('([^\\\\])\\\\([\\-\\?\\*\\+\\[\\]\\{\\}\\^\\(\\)!~@<>&#_/])');var escMatch;while((escMatch=re.exec(r))!==null){var entityRef="&#"+escMatch[2].charCodeAt(0)+";";r=r.replace(re,"$1"+entityRef);}
re=new RegExp('\\\\\\\\','g');r=r.replace(re,'\\');re=new RegExp('(\\s)(<)(\\s)');r=r.replace(re,'$1&lt;$3');re=new RegExp('(\\s)(>)(\\s)');r=r.replace(re,'$1&gt;$3');re=new RegExp('"\\b(.+?)\\(\\b(.+?)\\b\\)":([^\\s]+)','g');r=r.replace(re,'<a href="$3" title="$2">$1</a>');re=new RegExp('"\\b(.+?)\\b":([^\\s]+)','g');r=r.replace(re,'<a href="$2">$1</a>');re=new RegExp('\\[\\[(\\s*)(.+?)(\\s*)\\]\\]');var dksMatch;while((dksMatch=re.exec(r))!==null){var dksStr=dksMatch[2].replace(/\s+/g,"_");r=r.replace(re,'<a href="'+kos.DKOSOPEDIA_BASE+dksStr+'" class="dk">$2</a>');}
re=new RegExp('\\[([^"]*?)(https?://[^\\]\\s]+)(.*?)\\]','g');r=r.replace(re,'<a href="$2">$1$3</a>');re=new RegExp('(\\s)(https?://\\S*)(\\s)');while((dksMatch=re.exec(r))!==null){dksStr=dksMatch[2].length>40?dksMatch[2].substring(0,36)+"...":dksMatch[2];r=r.replace(re,'$1<a href="$2">'+dksStr+'</a>$3');}
var ur='UNDERSCOREREPLACER';re=new RegExp('(href=")(.*?_.*?)(")','i');while((dksMatch=re.exec(r))!==null){var linkFix=dksMatch[2];linkFix=linkFix.replace(/_/g,ur);r=r.replace(re,'href="'+linkFix+'"');}
re=new RegExp('\\b_(.+?)_','g');r=r.replace(re,'<em>$1</em>');re=new RegExp(ur,'g');r=r.replace(re,'_');re=new RegExp('([\\s\\n]+)/\\b(.+?)/','g');r=r.replace(re,'$1<em>$2</em>');re=new RegExp('([\\s\\n]+)\\*\\b(.+?)\\*','g');r=r.replace(re,'$1<strong>$2</strong>');re=new RegExp('([\\s\\n])-\\b(.+?)-','g');r=r.replace(re,'$1<del>$2</del>');re=new RegExp('dk\\{\\{(.+?)\\}\\}');while((dksMatch=re.exec(r))!==null){dksStr=dksMatch[1].replace(/\s+/g,"_");r=r.replace(re,'<a href="'+kos.DKOSOPEDIA_BASE+dksStr+'" class="dk">$1</a>');}
re=new RegExp('<b>','gi');r=r.replace(re,'<strong>');re=new RegExp('</b>','gi');r=r.replace(re,'</strong>');re=new RegExp('<i>','gi');r=r.replace(re,'<em>');re=new RegExp('</i>','gi');r=r.replace(re,'</em>');re=new RegExp('<s>','gi');r=r.replace(re,'<del>');re=new RegExp('</s>','gi');r=r.replace(re,'</del>');re=new RegExp('<strike>','gi');r=r.replace(re,'<del>');re=new RegExp('</strike>','gi');r=r.replace(re,'</del>');re=new RegExp('<u>','gi');r=r.replace(re,'<ins>');re=new RegExp('</u>','gi');r=r.replace(re,'</ins>');re=new RegExp('<br>','gi');r=r.replace(re,'<br />');re=new RegExp('  ','g');r=r.replace(re,' &nbsp;');re=new RegExp('<img (.+?)([^/])>','gi');r=r.replace(re,'<img $1$2 />');re=new RegExp('!\\b(.+?)\\(\\b(.+?)\\b\\)!','g');r=r.replace(re,'<img src="$1" alt="$2" />');re=new RegExp('!\\b(.+?)\\b!','g');r=r.replace(re,'<img src="$1" />');re=new RegExp('([^\n])<blockquote>','gi');r=r.replace(re,'$1\n<blockquote>');re=new RegExp('<blockquote>([^\n])','gi');r=r.replace(re,'<blockquote>\n$1');re=new RegExp('([^\n])</blockquote>','gi');r=r.replace(re,'$1\n</blockquote>');re=new RegExp('</blockquote>([^\n\r])','gi');r=r.replace(re,'</blockquote>\n$1');re=new RegExp('\n?(</?t[rd]>)\n?','g');r=r.replace(re,'$1');r=kos.makeHighBitHtmlEntities(r);re=new RegExp('&rdquo;','gi');r=r.replace(re,'"');re=new RegExp('&ldquo;','gi');r=r.replace(re,'"');var lines=r.split('\n');var endtags=['','</ul>\n','</ol>\n','</p>\n'];var listtype=0;for(var i=0;i<lines.length;++i){var line=lines[i].replace(/\s*$/,'');var bqlidx=line.lastIndexOf('</blockquote>');if(line.search(/^\s*[\*\-]\s+/)!=-1){listtype=3;/* line=line.replace(/^\s*[\*\-]\s+/,'\t<li>')+'</li>';if(listtype!=1){line=endtags[listtype]+'<ul>\n'+line;listtype=1;} */}else if(line.search(/^\s*#\s+/)!=-1){listype=3;/* line=line.replace(/^\s*#\s+/,'\t<li>')+'</li>';if(listtype!=2){line=endtags[listtype]+'<ol>\n'+line;listtype=2;} */}else if(line.search(/^\s*bq\.\s+/)!=-1){line=endtags[listtype]+line.replace(/^\s*bq\.\s+/,'<blockquote><p>')+'</p></blockquote>';listtype=3;}else if(line.indexOf('<blockquote')===0||line.indexOf('<p')===0||line.indexOf('<li')===0||line.indexOf('<ul')===0||line.indexOf('<div')===0){line=endtags[listtype]+line;listtype=0;}else if(bqlidx>-1&&bqlidx===(line.length-13)){line=endtags[listtype]+line;listtype=0;}else if(line.search(/^\s*\d+[\.\):]\s+/)!=-1){re=new RegExp('(\\d+)[\.\):](.+)','g');line=endtags[listtype]+line.replace(re,'<ol><li value="$1">$2</li></ol>');listtype=0;}else if(line.search(/^\s*h[1|2|3|4|5|6]\.\s+/)!=-1){re=new RegExp('h([1|2|3|4|5|6])\.(.+)','g');line=endtags[listtype]+line.replace(re,'<h$1>$2</h$1>');listtype=0;}else if((line.replace(/\s/g,'').length>0)){if(listtype!=3){line=endtags[listtype]+'<p>'+line;listtype=3;}else{line='<br />'+line;}}else{if(listtype==3){lines[i-1]=lines[i-1].substring(0,lines[i-1].length-1)+endtags[listtype]+NL;line='';listtype=0;}else if(listtype===0){line='';}}
if(line.length>0){lines[i]=line+NL;}else{lines[i]='';}}
r=lines.join('');if(listtype){r=r+endtags[listtype];listtype=0;}
pre=new RegExp(preToken,'g');preCount=0;while((preMatch=pre.exec(r))!==null){r=r.replace(pre,preSaves[preCount]);++preCount;}
var jqReplace = ["script", "style", "big", "small", "dfn", "code", "samp", "kbd", "abbr", "acronym", "sub", "bdo", "basefont", "font", "body", "address", "center", "map", "area", "link", "applet", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "q", "dir", "menu", "form", "label", "input", "select", "optgroup", "option", "textarea", "fieldset", "legend", "button", "caption", "colgroup", "col", "frameset", "frame", "noframes", "head", "title", "isindex", "meta", "base", "noscript", "html"];
for (var ii = 0; ii < 54; ii++){ r = r.replace(new RegExp("<(/)?(" + jqReplace[ii] + ")[^>]*>", "g"), "&lt;$1$2&gt;") }
return r;},editorPreview:function(evt){if(!kos.commentEditor){return true;}
var previewLi=$("eP");if(!previewLi){return true;}
var previewCx=kos.getChildByClassName(previewLi,"cx");if(previewCx){previewCx.style.display=kos.DISPLAY_BLOCK;}
var scrollState=kos.getScrollState();var editorErrorMessage=$("eErrorMessage");var editorSubject=$("eSubject");var editorSubjectValue=editorSubject.value;if(!editorSubjectValue||editorSubjectValue.length===0){var onComplete=kos.selectThis.bind(editorSubject);kos.setDisplayStyle(editorErrorMessage,kos.DISPLAY_BLOCK,scrollState,true,20,onComplete);return false;}
editorSubjectValue=kos.makeHighBitHtmlEntities(editorSubjectValue);if(editorSubjectValue.length>49){editorSubjectValue=editorSubjectValue.substring(0,48);}
editorSubjectValue=kos.titleClean(editorSubjectValue);
var previewSubject=$("previewSubject");previewSubject.innerHTML=editorSubjectValue;var editorComment=$("eComment");var editorCommentValue=editorComment.value;var textiledValue=kos.textile(editorCommentValue);textiledValue=kos.maxString(textiledValue);textiledValue=textiledValue.replace(/(<a href)/gi,'<a target="_blank" href');var previewComment=$("previewComment");previewComment.innerHTML=textiledValue;var previewName=$("previewName");if(previewName){previewName.innerHTML=kos.uname;}
var previewDateValue=new Date().toLocaleString();var previewDate=$("previewDate");if(previewDate){previewDate.innerHTML=previewDateValue;}
editorSubject.kosValue=editorSubject.value;editorComment.kosValue=editorComment.value;editorSubject.onkeypress=kos.editorContentChanged;editorSubject.ondrop=editorSubject.onkeypress;editorComment.onkeypress=kos.editorContentChanged;editorComment.ondrop=editorComment.onkeypress;var editorPostButton=$("ePostButton");if(editorPostButton){editorPostButton.disabled=false;editorPostButton.onclick=kos.editorPost;}
var pC=$("previewConfirm");if(pC){pC.style.display=kos.DISPLAY_BLOCK;}
var pE=$("previewError");if(pE){pE.style.display=kos.DISPLAY_NONE;}
previewLi.disabled=false;if(kos.isIE6Minus){previewLi.style.filter="alpha(opacity=100)";}
previewLi.style.opacity=1;var onotherComplete=kos.focusThis.bind(editorPostButton);if(kos.isIE){var tempAnimate=kos.ANIMATE;kos.ANIMATE=false;}
kos.setDisplayStyle(previewLi,kos.DISPLAY_BLOCK,scrollState,true,40,onotherComplete);if(kos.isIE){kos.ANIMATE=tempAnimate;}
editorErrorMessage.style.display=kos.DISPLAY_NONE;return false;},editorPost:function(evt){if(!kos.commentEditor){return true;}
var previewLi=$("eP");if(!previewLi){return true;}
var scrollState=kos.getScrollState();var editorErrorMessage=$("eErrorMessage");var editorSubject=$("eSubject");var editorSubjectValue=editorSubject.value;if(!editorSubjectValue||editorSubjectValue.length===0){var onComplete=kos.selectThis.bind(editorSubject);kos.setDisplayStyle(editorErrorMessage,kos.DISPLAY_BLOCK,scrollState,true,20,onComplete);return false;}
var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,this);this.style.display=kos.DISPLAY_NONE;kos.addBusyBall(bbs);editorSubjectValue=kos.makeHighBitHtmlEntities(editorSubjectValue);if(editorSubjectValue.length>49){editorSubjectValue=editorSubjectValue.substring(0,48);}
editorSubjectValue=kos.titleClean(editorSubjectValue);
var editorComment=$("eComment");var textiledValue=kos.textile(editorComment.value);textiledValue=kos.maxString(textiledValue);var bag={but:this,bbs:bbs};var params="sid="+kos.sid+"&cid="+kos.commentEditor.replyToId+"&posttype=html"+"&subject="+kos.encodeParamValue(editorSubjectValue)+"&comment="+kos.encodeParamValue(textiledValue)+
(kos.commentEditor.postKey?"&postKey="+kos.commentEditor.postKey:"");kos.commentEditor.kjaxReq=new kos.kjax(kos.finishEditorPost,bag,kos.SUBMIT_BASE+"post",params,"POST");return false;},finishEditorPost:function(kjaxReq){if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false);this.but.style.display=kos.DISPLAY_INLINE;setTimeout(kos.refreshContentNow,20);return false;}
if(kos.commentEditor.kjaxReq){kos.commentEditor.kjaxReq=null;if(!window.ActiveXObject){delete kos.commentEditor.kjaxReq;}}
var errMsg=kjaxReq.xhr.responseText;if(errMsg.indexOf("error")>-1){kos.removeBusyBall(this.bbs,false);var pC=$("previewConfirm");var pE=$("previewError");if(pC){pC.style.display=kos.DISPLAY_NONE;if(!pE){pE=document.createElement("div");pE.id="previewError";pC.parentNode.insertBefore(pE,pC);}
pE.innerHTML=errMsg.substring(errMsg.indexOf('<div class="error">')+19,errMsg.indexOf("</div>"));kos.setDisplayStyle(pE,kos.DISPLAY_BLOCK,null,true);}
this.but.style.display=kos.DISPLAY_INLINE;return false;}
if(errMsg.indexOf('<p>OK</p>')==-1){kos.removeBusyBall(this.bbs,false);this.but.style.display=kos.DISPLAY_INLINE;setTimeout(kos.refreshContentNow,20);return false;}
kos.editorCleanup(kos.commentEditor);kos.removeBusyBall(this.bbs,true,true);this.but.style.display=kos.DISPLAY_INLINE;setTimeout(kos.refreshContentNow,20);return true;},editorCleanup:function(editor,scrollState){if(!editor){editor=kos.commentEditor;}
if(editor.kjaxReq){var tempReq=editor.kjaxReq;editor.kjaxReq=null;if(!window.ActiveXObject){delete editor.kjaxReq;}
tempReq.onTimeout();}
if(!scrollState){scrollState=kos.getScrollState();}
var previewLi=$("eP");if(previewLi){kos.setDisplayStyle(previewLi,kos.DISPLAY_NONE,scrollState,true,40);var pC=$("previewConfirm");if(pC){pC.style.display=kos.DISPLAY_BLOCK;}
var pE=$("previewError");if(pE){pE.style.display=kos.DISPLAY_NONE;}}
var onComplete=null;if(editor.invokingAnchor){onComplete=kos.focusThis.bind(editor.invokingAnchor);editor.invokingAnchor=null;}
kos.setDisplayStyle(editor,kos.DISPLAY_NONE,scrollState,true,40,onComplete);var editorPostButton=$("ePostButton");if(editorPostButton){editorPostButton.disabled=true;editorPostButton.onclick=null;}
editor.postKey=null;var editorSubject=$("eSubject");var editorComment=$("eComment");editorSubject.value="";editorComment.value="";editorSubject.kosValue="";editorComment.kosValue="";editorSubject.onkeypress=null;editorSubject.ondrop=null;editorComment.onkeypress=null;editorComment.ondrop=null;var editorLink=$("eLink");if(editorLink){editorLink.style.display=kos.DISPLAY_NONE;$("eLinkUrl").value="http://";$("eLinkLabel").value="";}},editorContentChanged:function(evt,context){if(context&&context.id&&context.id.charAt(0)!="e"&&typeof kst!="undefined"){kst.editorContentChanged(evt,context);}else if(!kos.editorContentChangeTimeout){kos.editorContentChangeTimeout=setTimeout(kos.didEditorContentChange,10);}},didEditorContentChange:function(){kos.editorContentChangeTimeout=null;var editorSubject=$("eSubject");var editorComment=$("eComment");if(editorSubject.kosValue==editorSubject.value&&editorComment.kosValue==editorComment.value){return true;}
var editorPostButton=$("ePostButton");if(editorPostButton){editorPostButton.disabled=true;}
var previewLi=$("eP");if(previewLi&&previewLi.style.display!=kos.DISPLAY_NONE){if(kos.isIE6Minus){previewLi.style.filter="alpha(opacity=40)";}
previewLi.disabled=true;previewLi.style.opacity=0.4;}
editorSubject.onkeypress=null;editorSubject.ondrop=null;editorComment.onkeypress=null;editorComment.ondrop=null;return true;},cancelEditor:function(evt){if(!kos.commentEditor){return true;}
var editorSubject=$("eSubject");var editorComment=$("eComment");var editorSubjectValue=editorSubject.value;var editorCommentValue=editorComment.value;if((editorSubjectValue&&editorSubjectValue.length>0)||(editorCommentValue&&editorCommentValue.length>0)){if(!confirm(document.title+":\n"+kos.CONFIRM_CANCEL_MSG)){return false;}}
kos.editorCleanup(kos.commentEditor);return false;},toggleEditorHelp:function(evt){var editorHelp=kos.getEditorTarget(this,"Help");if(!editorHelp){return true;}
var newStyle=kos.DISPLAY_NONE;if(!editorHelp.style.display||editorHelp.style.display==kos.DISPLAY_NONE){newStyle=kos.DISPLAY_BLOCK;if(!editorHelp.firstChild){var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,editorHelp);kos.addBusyBall(bbs);var bag={input:this,target:editorHelp,bbs:bbs};var helpUrl="commentEditorHelp.html";if(editorHelp.id.charAt(0)!="e"){helpUrl="diaryEditorHelp.html";}
var kjaxreq=new kos.kjax(kos.finishLoadingHelp,bag,kos.HELP_BASE+helpUrl,null,"GET");}}
kos.setDisplayStyle(editorHelp,newStyle,null,false);return false;},toggleCommentHelp:function(evt){var commentHelp=$("cHelp");if(!commentHelp){return true;}
var newStyle=kos.DISPLAY_NONE;if(!commentHelp.style.display||commentHelp.style.display==kos.DISPLAY_NONE){newStyle=kos.DISPLAY_BLOCK;var commentHelpContent=$("cHelpContent");if(!commentHelpContent.firstChild){var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,commentHelpContent);kos.addBusyBall(bbs);var bag={input:this,target:commentHelpContent,bbs:bbs};var kjaxreq=new kos.kjax(kos.finishLoadingHelp,bag,kos.HELP_BASE+"commentHelp.html",null,"GET");}}
kos.setDisplayStyle(commentHelp,newStyle,null,true);if(this.blur){this.blur();}
return false;},finishLoadingHelp:function(kjaxReq){if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false);return false;}
kos.removeBusyBall(this.bbs,true,true);var hlp=kjaxReq.xhr.responseText;this.target.innerHTML=hlp.substring(hlp.indexOf("<body>")+6,hlp.indexOf("</body>"));return true;},editorHelpKey:function(evt){if(kos.isButtonPressingKey(evt)){return kos.toggleEditorHelp(evt);}
return true;},toggleEditorLinkPanel:function(evt){if(this.id){var thisPrefix=this.id.charAt(0);}
if(!this.id||thisPrefix!="e"){thisPrefix+="e";}
var editorLink=$(thisPrefix+"Link");if(!editorLink){return true;}
var scrollState=kos.getScrollState();var newStyle=kos.DISPLAY_NONE;if(!editorLink.style.display||editorLink.style.display==kos.DISPLAY_NONE){newStyle=kos.DISPLAY_BLOCK;var editorComment=kos.getEditorTarget(this,"Text","Comment");var editorLinkLabel=$(thisPrefix+"LinkLabel");var editorLinkUrl=$(thisPrefix+"LinkUrl");var isImage=$(thisPrefix+"LinkImage");var curStr=kos.getBrowserSelectedText()+"";if(editorComment.selectionStart!=editorComment.selectionEnd){curStr=editorComment.value.substring(editorComment.selectionStart,editorComment.selectionEnd);}else if(document.selection){curStr=document.selection.createRange().text;}
isImage.checked=false;if(curStr){if(curStr.indexOf("<a ")===0){var linkPieces=curStr.match(new RegExp('<a.+?href="(.+?)">(.*?)</a>'));editorLinkUrl.value=linkPieces[1];editorLinkLabel.value=linkPieces[2];}else if(curStr.indexOf("http:")===0){editorLinkUrl.value=curStr;editorLinkLabel.value="";}else if(curStr.indexOf("<img ")===0){linkPieces=curStr.match(new RegExp('<img.+?src="(.+?)".+?alt="(.*?)".*?>'));editorLinkUrl.value=linkPieces[1];editorLinkLabel.value=linkPieces[2];isImage.checked=true;}else{editorLinkLabel.value=curStr;}}else{editorLinkLabel.value="";}}
var onComplete=null;if(editorLinkUrl){onComplete=kos.selectThis.bind(editorLinkUrl);}
kos.setDisplayStyle(editorLink,newStyle,scrollState,false,24,onComplete);return false;},editorLinkKey:function(evt){if(kos.isButtonPressingKey(evt)){return kos.toggleEditorLinkPanel(evt);}
return true;},editorLinkFieldKey:function(evt){var charCode=kos.getKeyCharCode(evt);if(charCode==13){return kos.editorAddLink(evt);}
return true;},editorAddLink:function(evt){var editorComment=kos.getEditorTarget(this,"Text","Comment");if(editorComment){var thisPrefix=this.id.charAt(0);if(thisPrefix!="e"){thisPrefix+="e";}
var linkUrlField=$(thisPrefix+"LinkUrl");var linkUrl=linkUrlField.value;var linkLabelField=$(thisPrefix+"LinkLabel");var linkLabel=linkLabelField.value;var isImageField=$(thisPrefix+"LinkImage");var isImage=isImageField.checked;if(linkUrl.indexOf("http://http://")===0){linkUrl=linkUrl.substring(7);}
linkUrl=linkUrl.replace(/^\s+/g,'').replace(/\s+$/g,'');linkUrl=linkUrl.replace(/ /g,"%20");linkUrl=linkUrl.replace(/\s/g,"");if((!linkLabel||linkLabel.length===0)&&!isImage){linkLabel=linkUrl+"";if(linkLabel.length>40){linkLabel=linkLabel.substring(0,36)+"...";}}
if(!isImage){kos.insertTaggedContent(editorComment,"<a href=\""+linkUrl+"\">",linkLabel,"</a>",true);}else{kos.insertTaggedContent(editorComment,'','<img src="'+linkUrl+'" alt="'+linkLabel+'" title="'+linkLabel+'" />','',true);}
kos.toggleEditorLinkPanel.apply(this,[evt]);linkUrlField.value="http://";linkLabelField.value="";kos.editorContentChanged(evt,editorComment);editorComment.focus();}
return false;},getEditorTarget:function(context,name,commentSpecificName){var thisPrefix=context.id.charAt(0);if(thisPrefix=="e"){if(!commentSpecificName){var editorTarget=$("e"+name);}else{editorTarget=$("e"+commentSpecificName);}}else{editorTarget=$(thisPrefix+"e"+name);}
return editorTarget;},getBrowserSelectedText:function(){var txt="";if(window.getSelection){txt=window.getSelection();}else if(document.getSelection){txt=document.getSelection();}else if(document.selection){var range=document.selection.createRange();if(range){txt=range.text;}}
return txt;},insertTaggedContent:function(editorComment,startTag,contentToInsert,endTag,allowOverwrite){if(editorComment.selectionStart!==undefined){editorComment.focus();var startPos=editorComment.selectionStart;var endPos=editorComment.selectionEnd;var scrollTop=editorComment.scrollTop;var curSelection=editorComment.value.substring(startPos,endPos);var appending=false;if(editorComment.value.length<=startPos){appending=true;}
if(!allowOverwrite&&curSelection&&curSelection.length>0&&curSelection.indexOf(startTag)===0){if(endTag==curSelection.substring(curSelection.length-endTag.length,curSelection.length)){editorComment.value=editorComment.value.substring(0,startPos)+
curSelection.substring(startTag.length,curSelection.length-endTag.length)+
editorComment.value.substring(endPos,editorComment.value.length);editorComment.selectionStart=startPos;editorComment.selectionEnd=endPos-(startTag.length+endTag.length);editorComment.scrollTop=scrollTop;}
return false;}
if(contentToInsert){editorComment.value=editorComment.value.substring(0,startPos)+startTag+contentToInsert+endTag+
editorComment.value.substring(endPos,editorComment.value.length);}else{editorComment.value=editorComment.value.substring(0,startPos)+startTag+curSelection+endTag+
editorComment.value.substring(endPos,editorComment.value.length);}
var contentToInsertLength=contentToInsert?contentToInsert.length:(endPos-startPos);editorComment.selectionStart=startPos;editorComment.selectionEnd=startPos+startTag.length+contentToInsertLength+endTag.length;if(appending){editorComment.scrollTop=9999;}else{editorComment.scrollTop=scrollTop;}}else if(document.selection){var sel=document.selection.createRange();if(sel.parentElement()!=editorComment){var pos=editorComment.value.length;var m=editorComment.createTextRange();m.moveStart('character',pos);m.collapse();m.select();sel=document.selection.createRange();}else{editorComment.focus();}
if(!allowOverwrite&&sel.text&&sel.text.length>0&&sel.text.indexOf(startTag)===0){if(endTag==sel.text.substring(sel.text.length-endTag.length,sel.text.length)){sel.text=sel.text.substring(startTag.length,sel.text.length-endTag.length);}
return false;}
if(contentToInsert){sel.text=startTag+contentToInsert+endTag;}else{sel.text=startTag+sel.text+endTag;}}else{editorComment.focus();if(contentToInsert){editorComment.value+=(startTag+contentToInsert+endTag);}else{editorComment.value+=(startTag+endTag);}
if(typeof editorComment.scrollTop!="undefined"){editorComment.scrollTop=9999999;}}
return true;},getKeyCharCode:function(evt){evt=(evt||window.event);var charCode=(evt.charCode)?evt.charCode:((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));return charCode;},isButtonPressingKey:function(evt){var charCode=kos.getKeyCharCode(evt);return(charCode==32||charCode==13);},editorBlockquote:function(evt){var editorComment=kos.getEditorTarget(this,"Text","Comment");if(editorComment){var selectedText=kos.getBrowserSelectedText();if(selectedText.length===0){selectedText=null;}else{selectedText=selectedText+"";}
kos.insertTaggedContent(editorComment,"<blockquote>",selectedText,"</blockquote>");kos.editorContentChanged(evt,editorComment);}
return false;},editorBlockquoteKey:function(evt){if(kos.isButtonPressingKey(evt)){return kos.editorBlockquote();}
return true;},editorBold:function(evt){var editorComment=kos.getEditorTarget(this,"Text","Comment");if(editorComment){var selectedText=null;kos.insertTaggedContent(editorComment,"<strong>",selectedText,"</strong>");kos.editorContentChanged(evt,editorComment);}
return false;},editorBoldKey:function(evt){if(kos.isButtonPressingKey(evt)){return kos.editorBold(evt);}
return true;},editorItalic:function(evt){var editorComment=kos.getEditorTarget(this,"Text","Comment");if(editorComment){var selectedText=null;kos.insertTaggedContent(editorComment,"<em>",selectedText,"</em>");kos.editorContentChanged(evt,editorComment);}
return false;},editorItalicKey:function(evt){if(kos.isButtonPressingKey(evt)){return kos.editorItalic(evt);}
return true;},editorCommentFocus:function(evt){var editorComment=kos.getEditorTarget(this,"Text","Comment");if(editorComment){editorComment.focus();}
return false;},createPopupTab:function(tabId){var tab=document.createElement("div");tab.appendChild(document.createTextNode(" "));tab.id=tabId;tab.className="popupTab tab";tab.style.display=kos.DISPLAY_NONE;return tab;},popupRecommenders:function(evt){var recommenders=$("recommenders");if(!recommenders){return false;}
var container=$("container");var recTab=$("recTab");if(!recTab){recTab=kos.createPopupTab("recTab");recommenders.parentNode.insertBefore(recTab,recommenders);}
if(!recommenders.style.display||recommenders.style.display==kos.DISPLAY_NONE){var cntWd;if(container.offsetWidth){cntWd=container.offsetWidth;}else{cntWd=container.clientWidth;}
var recLi=this.parentNode;var linkPosX=kos.getPosX(recLi);var linkPosY=kos.getPosY(recLi);var linkHt;if(recLi.offsetHeight){linkHt=recLi.offsetHeight;}else{linkHt=recLi.clientHeight;}
var linkWd;if(recLi.offsetWidth){linkWd=recLi.offsetWidth;}else{linkWd=recLi.clientWidth;}
var htAdj=1;recommenders.style.top=(linkPosY+linkHt+htAdj-kos.getPosY(container))+"px";recommenders.style.left=(cntWd-600)+"px";kos.setDisplayStyle(recommenders,kos.DISPLAY_BLOCK,null,false);recTab.style.left=(linkPosX-kos.getPosX(container)+1)+"px";recTab.style.top=(linkPosY-kos.getPosY(container))+"px";recTab.style.height=(linkHt)+"px";recTab.style.width=(linkWd-5)+"px";recTab.style.display=kos.DISPLAY_BLOCK;recTab.onclick=kos.popupRecommenders;if(this.blur){this.blur();}}else{var onComplete=kos.removeThis.bind(recTab);kos.setDisplayStyle(recommenders,kos.DISPLAY_NONE,null,false,null,onComplete);}
return false;},removeThis:function(){this.style.display=kos.DISPLAY_NONE;if(this.parentNode){this.parentNode.removeChild(this);}},selectThis:function(){this.focus();this.select();},focusThis:function(){this.focus();},focusThenBlurThis:function(){if(this.focus){this.focus();}
if(this.blur){this.blur();}},popupRatings:function(evt){var raters;var cxDiv=kos.getAncestorByTagName(this,"DIV");var divs=cxDiv.getElementsByTagName("DIV");for(var i=0;i<divs.length;++i){if(divs[i].className.indexOf("crs")!=-1){raters=divs[i];}}
if(!raters){return false;}
var toggleTo=false;if(!raters.style.display||raters.style.display==kos.DISPLAY_NONE){toggleTo=true;}
var bb="1px solid black";evt=evt||window.event;if(kos.isModifiedClick(evt)){var oldPosY=kos.getPosY(this.parentNode);var alldivs=kos.getElementsByClassName($("comments"),"crs","DIV");for(var k=0;k<alldivs.length;++k){var ra=alldivs[k];var raTab=kos.getElementByClassName(ra.parentNode,"crd","span");if(toggleTo){raTab.className=raTab.className.replace(/ntb/g,'tab');ra.style.visibility="visible";ra.style.opacity="1";ra.style.display=kos.DISPLAY_BLOCK;}else{ra.style.display=kos.DISPLAY_NONE;raTab.className=raTab.className.replace(/tab/g,'ntb');}}
var thisScrolled=kos.getPosY(this.parentNode)-oldPosY;if(thisScrolled){window.scrollBy(0,thisScrolled);}}else{if(this.nodeName.toUpperCase()=="A"){raTab=this.parentNode;}else{raTab=this;}
if(toggleTo){raTab.className=raTab.className.replace(/ntb/g,'tab');kos.setDisplayStyle(raters,kos.DISPLAY_BLOCK,null,true);}else{var onComplete=kos.hideTab.bind(raTab);kos.setDisplayStyle(raters,kos.DISPLAY_NONE,null,true,null,onComplete);}}
if(this.blur){this.blur();}
return kos.returnFalse(evt);},hideTab:function(){this.className=this.className.replace(/tab/g,'ntb');},selectRating:function(evt){var commentLi=kos.getAncestorByTagName(this,"LI");kos.markAsRead(commentLi);var cid=commentLi.id.substring(1);var rating=this.value;var cxDiv=kos.getChildByClassName(commentLi,"cx");var ch=kos.getChildByTagName(cxDiv,"h3");var crsDiv=kos.getChildByClassName(cxDiv,"crs");if(!crsDiv){crsDiv=document.createElement("div");crsDiv.className="crs";var crsDl=document.createElement("dl");crsDiv.appendChild(crsDl);kos.insertAfter(crsDiv,ch);}else{crsDl=crsDiv.getElementsByTagName("DL")[0];}
var crsDts=kos.getChildrenByTagName(crsDl,"DT");var rdd=null;var tdd=null;for(var i=0;i<crsDts.length;++i){if(crsDts[i].innerHTML.charAt(0)=="R"){rdd=crsDts[i].nextSibling;while(rdd.nodeType!=1&&crsDts[i].nextSibling){rdd=crsDts[i].nextSibling;}}else{tdd=crsDts[i].nextSibling;while(tdd.nodeType!=1&&crsDts[i].nextSibling){tdd=crsDts[i].nextSibling;}}}
var currentRating=-1;if(tdd){var rtHtml=tdd.innerHTML;if(rtHtml&&rtHtml.length>0){var idx=rtHtml.indexOf(">"+kos.uname+"<");if(idx!=-1){var priorHtml=rtHtml.substring(0,idx);priorHtml=priorHtml.substring(0,priorHtml.lastIndexOf("<"));var removeComma=(rtHtml.charAt(idx+kos.uname.length+5)==",");if(!removeComma){priorHtml+="&nbsp;";}
tdd.innerHTML=priorHtml+rtHtml.substring(idx+kos.uname.length+5+
(removeComma?2:0),rtHtml.length);currentRating=0;}}}
if(rating=="0"&&currentRating){if(kos.trollRatingsLeft<1||!confirm(document.title+":\nYou have "+kos.trollRatingsLeft+" Hide rating"+
(kos.trollRatingsLeft==1?"":"s")+" left today."+"\nAre you sure you wish to Hide this comment?")){this.checked=false;if(this.blur){this.blur();}
return false;}}
if(rdd){rtHtml=rdd.innerHTML;if(rtHtml&&rtHtml.length>0){idx=rtHtml.indexOf(">"+kos.uname+"<");if(idx!=-1){priorHtml=rtHtml.substring(0,idx);priorHtml=priorHtml.substring(0,priorHtml.lastIndexOf("<"));removeComma=(rtHtml.charAt(idx+kos.uname.length+5)==",");if(!removeComma){priorHtml+="&nbsp;";}
rdd.innerHTML=priorHtml+rtHtml.substring(idx+kos.uname.length+5+
(removeComma?2:0),rtHtml.length);currentRating=4;}}}
var inputs=this.parentNode.getElementsByTagName("INPUT");for(var p=0;p<inputs.length;++p){inputs[p].disabled=true;inputs[p].checked=false;if(inputs[p].blur){inputs[p].blur();}}
var focusA=kos.getChildByTagName(this.parentNode,"A");if(focusA&&!kos.isKonqueror){if(focusA.focus){focusA.focus();}
if(focusA.blur){focusA.blur();}}
if(rating==currentRating){rating=-1;this.checked=false;}else{this.checked=true;}
var crd=kos.getChildByClassName(ch,"crd");if(crd){var ratingA=kos.getChildByTagName(crd,"A");if(ratingA){var priorDisplay=ratingA.innerHTML;var rateCounts=priorDisplay.match(/\d+/g);if(currentRating==4){--rateCounts[0];}else if(currentRating!=-1){--rateCounts[1];}
var display=rateCounts[0]+(rateCounts[0]>0?"+":"+")+" / "+
rateCounts[1]+(rateCounts[1]>0?"-":"-");ratingA.innerHTML=display;var csx=kos.getChildByClassName(commentLi,"csx");if(csx){var csr=kos.getElementByClassName(csx,"csr","span");if(csr){csr.innerHTML=display;}}}}
var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,this.parentNode.lastChild);kos.addBusyBall(bbs);var bag={input:this,rating:rating,commentLi:commentLi,crsDl:crsDl,ch:ch,bbs:bbs};var params="sid="+kos.sid+"&cid="+cid+"&rating="+rating;var kjaxreq=new kos.kjax(kos.finishRating,bag,kos.SUBMIT_BASE+"rate",params,"POST");return true;},finishRating:function(kjaxReq){if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false);var inputs=this.input.parentNode.getElementsByTagName("INPUT");for(var p=0;p<inputs.length;++p){if(kos.trollRatingsLeft<1&&inputs[p].id&&inputs[p].id.charAt(0)=='t'){inputs[p].disabled=true;}else{inputs[p].disabled=false;}
inputs[p].checked=false;}
return false;}
if(kjaxReq.xhr.responseText.indexOf('id="noTrollRatingsLeft"')>-1){kos.removeBusyBall(this.bbs,false);inputs=this.input.parentNode.getElementsByTagName("INPUT");for(p=0;p<inputs.length;++p){inputs[p].disabled=false;inputs[p].checked=false;}
kos.setTrollRatingsLeft(0,false);alert(document.title+":\nRating failed: You have no more Hide ratings left today.");return false;}
var rating=this.rating;var commentLi=this.commentLi;var crsDl=this.crsDl;var ch=this.ch;kos.removeBusyBall(this.bbs,true);var crsDts=kos.getChildrenByTagName(crsDl,"DT");if(rating!=-1){this.input.checked=true;var rateInitial=(rating==4?"R":"T");crsDts=kos.getChildrenByTagName(crsDl,"DT");for(var i=0;i<crsDts.length;++i){var crsDt=crsDts[i];var dtRt=crsDt.innerHTML.charAt(0);if(dtRt==rateInitial){var crsDd=crsDt.nextSibling;while(crsDd.nodeType!=1&&crsDt.nextSibling){crsDd=crsDt.nextSibling;}
break;}else if(dtRt>rateInitial){var beforeDt=crsDt;break;}}
if(!crsDd){crsDd=document.createElement("dd");crsDt=document.createElement("dt");crsDt.appendChild(document.createTextNode(rating==4?"Recommended by:":"Hidden by:"));if(beforeDt){crsDl.insertBefore(crsDd,beforeDt);crsDl.insertBefore(crsDt,crsDd);}else{crsDl.appendChild(crsDt);crsDl.appendChild(crsDd);}}
var ulink='<a href="'+kos.URL_BASE+'user/uid:'+kos.uid+'">'+kos.uname+'</a>';var ddHtml=crsDd.innerHTML;if(ddHtml&&ddHtml.length>7){crsDd.innerHTML=ulink+", "+ddHtml;}else{crsDd.innerHTML=ulink;}
var crd=kos.getChildByClassName(ch,"crd");if(crd){var ratingA=kos.getChildByTagName(crd,"A");if(ratingA){var priorDisplay=ratingA.innerHTML;var rateCounts=priorDisplay.match(/\d+/g);if(rating==4){++rateCounts[0];}else{++rateCounts[1];}
var display=rateCounts[0]+(rateCounts[0]>0?"+":"+")+" / "+
rateCounts[1]+(rateCounts[1]>0?"-":"-");ratingA.innerHTML=display;var csx=kos.getChildByClassName(commentLi,"csx");if(csx){var csr=kos.getElementByClassName(csx,"csr","span");if(csr){csr.innerHTML=display;}}}}}else{this.input.checked=false;}
inputs=this.input.parentNode.getElementsByTagName("INPUT");for(p=0;p<inputs.length;++p){if(kos.trollRatingsLeft<1&&inputs[p].id&&inputs[p].id.charAt(0)=='t'){inputs[p].disabled=true;}else{inputs[p].disabled=false;}
if(inputs[p].blur){inputs[p].blur();}}
var ratingsLeft=kos.trollRatingsLeft-1;var searchText='<p id="trollRatingsLeft">';var trtIdx=kjaxReq.xhr.responseText.indexOf(searchText);if(trtIdx>-1){var startIdx=trtIdx+searchText.length;ratingsLeft=kjaxReq.xhr.responseText.substring(startIdx,kjaxReq.xhr.responseText.indexOf("<",startIdx));}
kos.setTrollRatingsLeft(ratingsLeft,false);return true;},setTrollRatingsLeft:function(value,showAlert){if(kos.trollRatingsLeft==value){return false;}
kos.trollRatingsLeft=value;var trString="You have "+kos.trollRatingsLeft+" Hide rating"+
(kos.trollRatingsLeft==1?"":"s")+" left today.";if(showAlert){alert(document.title+":\n"+trString);}
var noneLeft=kos.trollRatingsLeft<1;if(kos.commentsDiv){var subLis=kos.commentsDiv.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){var cx=kos.getChildByClassName(subLis[i],"cx");if(cx){var pcl=kos.getElementByClassName(cx,"cl","P");if(pcl){var inputs=pcl.getElementsByTagName("input");for(var j=0;j<inputs.length;++j){if(inputs[j].id.charAt(0)=='t'){inputs[j].title=trString;if(noneLeft&&!inputs[j].checked){inputs[j].disabled=true;inputs[j].nextSibling.disabled=true;}else{inputs[j].disabled=false;inputs[j].nextSibling.disabled=false;}}}}}}}
return false;},recommendButton:function(evt){var but=$("recommendButton");if(!but){return false;}
var recoMenu=$("recoMenu");var ulink='<a href="/user/uid:'+kos.uid+'">'+kos.uname+'</a>';var recommenders=$("recommenders");if("Recommend"==but.value){var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,but);but.style.display=kos.DISPLAY_NONE;kos.addBusyBall(bbs);var bag={bbs:bbs,but:but,recommenders:recommenders,recoMenu:recoMenu,ulink:ulink};var params="sid="+kos.sid+"&recommend=Recommend";var kjaxreq=new kos.kjax(kos.finishRecommend,bag,kos.SUBMIT_BASE+"recommend",params,"POST");}else if(confirm(document.title+":\nAre you sure you want to unrecommend?\nYou can't re-recommend once you unrecommend.")){bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,but);but.style.display=kos.DISPLAY_NONE;kos.addBusyBall(bbs);var bag2={bbs:bbs,but:but,recommenders:recommenders,recoMenu:recoMenu};var params2="sid="+kos.sid+"&recommend=Unrecommend";var kjaxreq2=new kos.kjax(kos.finishUnrecommend,bag2,kos.SUBMIT_BASE+"recommend",params2,"POST");}
if(but.blur){but.blur();}
return false;},finishRecommend:function(kjaxReq){if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false,true);this.but.style.display=kos.DISPLAY_INLINE;return false;}
this.but.style.display=kos.DISPLAY_INLINE;kos.removeBusyBall(this.bbs,true,true);this.but.value="Unrecommend";this.but.title="Retract your recommendation of this Diary";if(this.recoMenu){this.recoMenu.innerHTML="Diary Recommended";}
if(!this.recommenders){this.recommenders=document.createElement("div");this.recommenders.id="recommenders";this.recommenders.className="popup";this.recommenders.style.display=kos.DISPLAY_NONE;$("main").appendChild(this.recommenders);}
if(this.recommenders){var recHtml=this.recommenders.innerHTML;if(recHtml&&recHtml.length>0){this.recommenders.innerHTML=this.ulink+", "+recHtml;}else{this.recommenders.innerHTML=this.ulink;}}
return true;},finishUnrecommend:function(kjaxReq){if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false,true);this.but.style.display=kos.DISPLAY_INLINE;return false;}
this.but.disabled=true;this.but.style.display=kos.DISPLAY_INLINE;kos.removeBusyBall(this.bbs,true,true);if(this.recoMenu){this.recoMenu.innerHTML="Diary Unrecommended";}
if(this.recommenders){var recHtml=this.recommenders.innerHTML;if(recHtml&&recHtml.length>0){var idx=recHtml.indexOf(">"+kos.uname+"<");if(idx!=-1){var priorHtml=recHtml.substring(0,idx);priorHtml=priorHtml.substring(0,priorHtml.lastIndexOf("<"));var atEnd=((idx+kos.uname.length+6)>=recHtml.length);this.recommenders.innerHTML=priorHtml+(atEnd?"":recHtml.substring(idx+kos.uname.length+7,recHtml.length));}}}
return true;},editTags:function(evt,forceVisible){var tagEditor=$("tagEditor");if(tagEditor){if(forceVisible||tagEditor.style.display!=kos.DISPLAY_BLOCK){tagEditor.style.display=kos.DISPLAY_BLOCK;var tagInput=$("tagInput");if(tagInput&&tagInput.focus){tagInput.focus();}}else{tagEditor.style.display=kos.DISPLAY_NONE;}}
return false;},getTagText:function(){var newtags="";var tagInput=$("tagInput");if(tagInput){var tags=tagInput.value.split(',');for(var i=0;i<tags.length;++i){var tag=tags[i];tag=tag.replace(/^\s+/g,'').replace(/\s+$/g,'');if(tag.length<1){continue;}
if(newtags.length>0){newtags+=",";}
newtags+=tag;}}
return newtags;},tagInputFieldKey:function(evt){var charCode=kos.getKeyCharCode(evt);if(charCode==13){return kos.submitTags.apply(this);}
return true;},submitTags:function(evt){var tagEditor=$("tagEditor");var tagInput=$("tagInput");if(tagEditor&&tagInput){var newtags=kos.getTagText();newtags=kos.makeHighBitHtmlEntities(newtags);this.disabled=true;var bbs=kos.createBusyBallSpan(" ");kos.insertAfter(bbs,this.parentNode.lastChild);kos.addBusyBall(bbs);var bag={input:this,bbs:bbs};var params="sid="+kos.sid+"&newtags="+kos.encodeParamValue(newtags)+"&tagsave=Add%2FEdit+Tags";var kjaxreq=new kos.kjax(kos.finishSubmitTags,bag,kos.SUBMIT_BASE+"tags",params,"POST");}
return false;},finishSubmitTags:function(kjaxReq){this.input.disabled=false;if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false);return false;}
kos.removeBusyBall(this.bbs,true);var tagEditor=$("tagEditor");if(tagEditor){kos.makeNewTags();tagEditor.style.display=kos.DISPLAY_NONE;}
return true;},makeNewTags:function(){var tagInput=$("tagInput");var tagLinks=$("tagLinks");if(tagInput&&tagLinks){var tags=tagInput.value.split(',');var allTags="";for(var i=0;i<tags.length;++i){var tag=tags[i];tag=tag.replace(/^\s+/g,'').replace(/\s+$/g,'');if(tag.length<1){continue;}
if(encodeURIComponent){var etag=encodeURIComponent(tag);}else{etag=escape(tag);}
etag=kos.TAG_BASE+etag;if(allTags.length>0){allTags+=", ";}
allTags+='<a href="'+etag+'">'+tag+'</a>';}
tagLinks.innerHTML=allTags+" ";}
return false;},pollChoiceChanged:function(){if(kos.mainDiv.className.indexOf("ing")>-1){return false;}
var pollDiv=kos.getAncestorByClassName(this,"poll");if(!pollDiv){return false;}
var pollSubmit=kos.getElementByClassName(pollDiv,"pollSubmit","input");if(pollSubmit){pollSubmit.disabled=false;pollSubmit.onclick=kos.submitPoll;}
return true;},submitPoll:function(evt){var pollDiv=kos.getAncestorByClassName(this,"poll");if(!pollDiv){return false;}
var opts=kos.getElementsByClassName(pollDiv,"aid","input");var aid=-1;for(var i=0;i<opts.length;++i){if(opts[i].checked){aid=i+1;var po=opts[i].id.slice(2);break;}}
if(aid<1){return false;}
var qid=kos.getElementsByName(pollDiv,"qid","input")[0].value;var ispoll=kos.getElementsByName(pollDiv,"ispoll","input")[0].value;this.disabled=true;var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,this.parentNode.firstChild);kos.addBusyBall(bbs);var bag={input:this,po:po,bbs:bbs,pollDiv:pollDiv};var params="sid="+kos.sid+"&qid="+qid+"&ispoll="+ispoll+"&aid="+aid;var kjaxreq=new kos.kjax(kos.finishSubmitPoll,bag,kos.SUBMIT_BASE+"poll",params,"POST");return false;},finishSubmitPoll:function(kjaxReq){this.input.disabled=false;if(kjaxReq.FAILED){kos.removeBusyBall(this.bbs,false);return false;}
kos.removeBusyBall(this.bbs,true);var pr=$("pr"+this.po);if(pr){pr.lastChild.firstChild.innerHTML=1+(pr.lastChild.firstChild.innerHTML-0);}
var pollDiv=this.pollDiv;var vtotal=kos.getElementByClassName(pollDiv,"vtotal","span");if(vtotal){var total=1+(vtotal.innerHTML-0);vtotal.innerHTML=total;}
var prs=kos.getElementsByClassName(pollDiv,"pr","tr");for(var p=0;p<prs.length;++p){var prop=prs[p].lastChild.firstChild.innerHTML/total;var pct=Math.round(prop*100)+"%";prs[p].firstChild.innerHTML=pct;var offset=-400+Math.round(prop*400);prs[p].lastChild.style.backgroundPosition=offset+"px 0px";}
kos.pollResults.apply(vtotal);var pvv=kos.getElementByClassName(pollDiv,"pvv","span");if(pvv){pvv.style.display=kos.DISPLAY_NONE;}
return true;},pollResults:function(evt){var pollDiv=kos.getAncestorByClassName(this,"poll");if(!pollDiv){return false;}
var pollForm=kos.getChildByTagName(pollDiv,"form");var prs=kos.getElementsByClassName(pollDiv,"pr","tr");var kpoll=new kos.kpoll(pollForm,prs);if(prs[0]&&prs[0].lastChild.style.backgroundPosition&&kos.ANIMATE){kpoll.startAnimation();}else if(pollForm){pollForm.className="voted";}
return false;},pollVote:function(evt){var pollDiv=kos.getAncestorByClassName(this,"poll");if(!pollDiv){return false;}
var pollForm=kos.getChildByTagName(pollDiv,"form");if(pollForm){pollForm.className="vote";if(window.ActiveXObject){var prs=kos.getElementsByClassName(pollDiv,"pr","tr");for(var p=0;p<prs.length;++p){prs[p].style.display=kos.DISPLAY_NONE;prs[p].firstChild.style.display=kos.DISPLAY_NONE;prs[p].lastChild.style.display=kos.DISPLAY_NONE;}}}
return false;},markAsRead:function(li){if(typeof li=="string"){li=$(li);}
if(!li){return false;}
var csx=kos.getChildByClassName(li,"csx");if(csx){var h4=kos.getChildByTagName(csx,"h4");var newSpan=kos.getElementByClassName(h4,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}}
var cx=kos.getChildByClassName(li,"cx");if(cx){var h3=kos.getChildByTagName(cx,"h3");newSpan=kos.getElementByClassName(h3,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}}
return true;},markAllAsRead:function(evt){var readBar=$("readBar");if(readBar){var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,readBar.lastChild);kos.addBusyBall(bbs);var bag={input:this,bbs:bbs};var serial=Math.max(kos.mostRecentSummarySerial,kos.mostRecentFullSerial);var params="sid="+kos.sid+"&serial="+serial;var kjaxreq=new kos.kjax(kos.finishBusyBall,bag,kos.SUBMIT_BASE+"markasread",params,"POST");}
if(kos.commentsDiv){var subLis=kos.commentsDiv.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.markAsRead(subLis[i]);}}
return false;},goToFirstNew:function(evt){return false;},getCommentCount:function(){if(typeof kos.commentCount!="undefined"){return kos.commentCount;}
var acb=$("autorefresh");if(acb){var cct=kos.getChildByClassName(acb.parentNode,"cct");if(cct){kos.commentCount=cct.innerHTML;return kos.commentCount;}}
var comments=$("comments");if(comments){var rateForm=$("rateAllForm");if(rateForm){var ul=kos.getChildByTagName(rateForm,"ul");if(ul){var re=new RegExp('\\bcm\\b');var lis=ul.getElementsByTagName("li");var commentCount=0;for(var i=0;i<lis.length;++i){var li=lis[i];if(!li.id||!li.parentNode.className.match(re)){continue;}
++commentCount;}
kos.commentCount=commentCount;return kos.commentCount;}}}
return kos.OVERFLOW_COUNT;},reloadPage:function(){log("force-reloading page...");document.location.reload(true);},loadStoryWithComments:function(useFull){var uri=kos.STORY_BASE+kos.sid;if(useFull){uri+="?detail=f";}
document.location.replace(uri);},expandComments:function(evt){if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){var isEditingStory=false;if(typeof kst!="undefined"&&kst&&kos.mainDiv.className.indexOf("ing")>-1){isEditingStory=true;}
if(isEditingStory||(kos.commentEditor&&(kos.commentEditor.style.display==kos.DISPLAY_BLOCK))){alert("There are too many comments in this story to expand all of them in-place."+"\nPlease finish editing/posting and try again.");return false;}else{kos.loadStoryWithComments(true);return true;}}
var cda=$("cDAlways");cda.checked=false;cda.disabled=false;$("cDAL").disabled=false;if(kos.commentsDiv){var subLis=kos.commentsDiv.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.doExpandComment(subLis[i],false);}
kos.commentsDiv.style.display=kos.DISPLAY_BLOCK;}else{kos.loadStoryWithComments();}
if(this.blur){this.blur();}
return true;},isRightClick:function(evt){evt=evt||window.event;if(typeof evt.button!="undefined"){if(evt.button==2){return true;}}
return false;},isModifiedClick:function(evt){evt=evt||window.event;return(evt.altKey||evt.ctrlKey||evt.metaKey||evt.shiftKey);},expandComment:function(evt){evt=evt||window.event;if(!kos.isRightClick(evt)){var commentDisplayShrink=$("cDShrink");if(commentDisplayShrink){commentDisplayShrink.checked=false;$("cDAlways").checked=false;$("cDAlways").disabled=true;}
var li=kos.getAncestorByTagName(this,"LI");if(kos.isModifiedClick(evt)){kos.doExpandComment(li,true,false,li.id);var subLis=li.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.markAsRead(subLis[i]);kos.doExpandComment(subLis[i],false,false,li.id);}}else{kos.doExpandComment(li,true);}}
return kos.returnFalse(evt);},doExpandComment:function(li,useFx,doNotLoad,expandFromId){if(li.id=="eP"){return false;}
var csx=kos.getChildByClassName(li,"csx");if(!csx){return false;}
var cx=kos.getChildByClassName(li,"cx");if(!cx&&!doNotLoad&&!kos.loadingFullComments){if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){var useId=true;var detailToUse=kos.DETAIL_COMMENT;kos.loadingFullComments=false;}else{detailToUse=kos.DETAIL_FULL;useId=useFx;kos.loadingFullComments=true;}
var bbs=kos.createBusyBallSpan("Loading...");bbs.style.display=kos.DISPLAY_BLOCK;kos.insertAfter(bbs,csx.lastChild);kos.addBusyBall(bbs);var bag={liID:li.id,useFx:useFx,bbs:bbs,expandFromId:expandFromId};var kloadReq=new kos.kload(kos.finishExpandComment,bag,detailToUse,useId?li.id:null);}else if(cx){if(useFx){var newSpan=kos.getElementByClassName(cx,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}
newSpan=kos.getElementByClassName(csx,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}
var onComplete=null;var dea=kos.getElementByClassName(cx,"de","a");if(dea){onComplete=kos.focusThenBlurThis.bind(dea);}
kos.setDisplayStyle(cx,kos.DISPLAY_BLOCK,null,true,null,onComplete);}else{if(doNotLoad){kos.setDisplayStyleScrollNeutral(cx,kos.DISPLAY_BLOCK);}else{cx.style.display=kos.DISPLAY_BLOCK;}
cx.style.visibility="visible";cx.style.opacity="1";}
if(doNotLoad){kos.setDisplayStyleScrollNeutral(csx,kos.DISPLAY_NONE);}else{csx.style.display=kos.DISPLAY_NONE;}
return true;}
return false;},finishExpandComment:function(kloadReq){kos.loadingFullComments=false;var li=$(this.liID);var cx=null;if(li){cx=kos.getChildByClassName(li,"cx");}
if(this.bbs){kos.removeBusyBall(this.bbs,!!cx,!!cx);}
if(!cx){return false;}
var inExpandMode=$("cDExpand").checked;if(inExpandMode){if(kos.commentsDiv){var subLis=kos.commentsDiv.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.doExpandComment(subLis[i],false,true);}}}else if(this.expandFromId){var doNotLoad=true;if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){doNotLoad=false;}
var topLi=$(this.expandFromId);if(topLi){kos.doExpandComment(topLi,!doNotLoad,doNotLoad,(doNotLoad?null:this.expandFromId));subLis=topLi.getElementsByTagName("LI");for(i=0;i<subLis.length;++i){kos.doExpandComment(subLis[i],false,true);}}}else if(li){return kos.doExpandComment(li,this.useFx,true);}
return true;},shrinkComments:function(evt){if(kos.commentsDiv){var cda=$("cDAlways");cda.checked=false;cda.disabled=false;$("cDAL").disabled=false;var subLis=kos.commentsDiv.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.doCollapseComment(subLis[i],false);}
kos.commentsDiv.style.display=kos.DISPLAY_BLOCK;}else{kos.loadStoryWithComments();}
if(this.blur){this.blur();}
return true;},collapseComment:function(evt){evt=evt||window.event;if(!kos.isRightClick(evt)){var commentDisplayExpand=$("cDExpand");if(commentDisplayExpand){commentDisplayExpand.checked=false;var cda=$("cDAlways");cda.checked=false;cda.disabled=true;$("cDAL").disabled=true;}
var li=kos.getAncestorByTagName(this,"LI");if(kos.isModifiedClick(evt)){var subLis=li.getElementsByTagName("LI");for(var i=0;i<subLis.length;++i){kos.markAsRead(subLis[i]);kos.doCollapseComment(subLis[i],false);}}
kos.doCollapseComment(li,true);}
return kos.returnFalse(evt);},doCollapseComment:function(li,useFx){if(li.id=="eP"){return false;}
var cx=kos.getChildByClassName(li,"cx");if(!cx){return false;}
var csx=kos.getChildByClassName(li,"csx");if(!csx){csx=kos.createCommentSummary(cx);kos.insertAfter(csx,cx);}
if(csx){if(useFx){kos.setDisplayStyle(cx,kos.DISPLAY_NONE,null,true);var newSpan=kos.getElementByClassName(cx,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}
newSpan=kos.getElementByClassName(csx,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}
csx.style.display=kos.DISPLAY_BLOCK;}else{cx.style.display=kos.DISPLAY_NONE;csx.style.display=kos.DISPLAY_BLOCK;csx.style.visibility="visible";csx.style.opacity="1";}
return true;}
return false;},createCommentSummary:function(cx){var csx=document.createElement("div");csx.className="csx";csx.style.display=kos.DISPLAY_NONE;var cxh=kos.getChildByTagName(cx,"H3");var cu=kos.getElementByClassName(cxh,"cu","span");var cmSub=cu.firstChild.nodeValue;var cf=kos.getChildByClassName(cx,"cf");var pcb=kos.getChildByClassName(cf,"cb");var cfas=pcb.getElementsByTagName("A");var cmAuth=cfas[0].firstChild.nodeValue;var cmDate=cfas[1].firstChild.nodeValue;var cmLink=cfas[1].href;var crd=kos.getChildByClassName(cxh,"crd");var crda=kos.getChildByTagName(crd,"A");var cmRate=crda.firstChild.nodeValue;var cmNw='';if(kos.getChildByClassName(cxh,"nw")){cmNw='<span class="nw">* [new] </span>';}
csx.innerHTML='<h4><a class="dc" href="'+
cmLink+'">'+
cmNw+'<span class="cu">'+
cmSub+'</span></a> by '+
cmAuth+', '+
cmDate+' <span class="crd ntb">(<span class="csr">'+
cmRate+'</span>)</span></h4>';var csxa=csx.getElementsByTagName("A")[0];csxa.onclick=kos.expandComment;return csx;},hideComments:function(evt){var cda=$("cDAlways");cda.checked=false;if(kos.commentsDiv){if(kos.commentsDiv.style.display==kos.DISPLAY_NONE){$("cDHide").checked=false;kos.commentsDiv.style.display=kos.DISPLAY_BLOCK;cda.disabled=true;$("cDAL").disabled=true;}else{kos.commentsDiv.style.display=kos.DISPLAY_NONE;cda.disabled=false;$("cDAL").disabled=false;}}else{kos.loadStoryWithComments();}
if(this.blur){this.blur();}
return true;},fixIECSSSwapHack:function(){if(kos.commentsDiv){kos.commentsDiv.style.display=kos.DISPLAY_BLOCK;}},changeIndenting:function(evt){var isFlat=$("cIFlat").checked;var userCss=$("userCss");var isNarrow=!userCss.href.match(/Wide/i);kos.changeCss(isFlat,isNarrow);$("cIAlways").checked=false;return true;},changeWidth:function(evt){var isFlat=$("cIFlat").checked;var isNarrow=(this==$("pageNarrow"));kos.changeCss(isFlat,isNarrow);var params="pageDisplayWidth="+(isNarrow?"narrow":"wide");var kjaxreq=new kos.kjax(null,null,kos.SUBMIT_BASE+"prefs",params,"POST");return kos.returnFalse(evt);},postDisplayPrefs:function(evt){var displayMode="";if($("cDHide").checked){displayMode="hide";}else if($("cDExpand").checked){displayMode="expand";}else if($("cDShrink").checked){displayMode="shrink";}
this.disabled=true;var cbar=kos.getAncestorByClassName(this,"cbar");var permaP=cbar.getElementsByTagName("P")[0];var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,permaP.lastChild);kos.addBusyBall(bbs);var bag={input:this,bbs:bbs};var params="commentDisplayMode="+displayMode;var kjaxreq=new kos.kjax(kos.finishBusyBall,bag,kos.SUBMIT_BASE+"prefs",params,"POST");return true;},postIndentingPrefs:function(evt){var displayMode="";if($("cIIndented").checked){displayMode="indented";}else if($("cIFlat").checked){displayMode="flat";}
this.disabled=true;var cbar=kos.getAncestorByClassName(this,"cbar");var permaP=cbar.getElementsByTagName("P")[0];var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,permaP.lastChild);kos.addBusyBall(bbs);var bag={input:this,bbs:bbs};var params="commentIndentingMode="+displayMode;var kjaxreq=new kos.kjax(kos.finishBusyBall,bag,kos.SUBMIT_BASE+"prefs",params,"POST");return true;},finishBusyBall:function(kjaxReq){kos.removeBusyBall(this.bbs,!kjaxReq.FAILED);if(this.input){this.input.disabled=false;}
return!kjaxReq.FAILED;},precacheImages:function(){if(document.images){log("precaching images...");kos.precache=[];kos.precache[1]=new Image(14,14);kos.precache[1].src=kos.IMAGE_BASE+"DiscloseUpActive14.gif";kos.precache[2]=new Image(14,14);kos.precache[2].src=kos.IMAGE_BASE+"DiscloseDownActive14.gif";kos.precache[3]=new Image(14,14);kos.precache[3].src=kos.IMAGE_BASE+"CloseDown14.gif";kos.precache[4]=new Image(288,16);kos.precache[4].src=kos.IMAGE_BASE+"BusyBall16.gif";kos.precache[5]=new Image(10,10);kos.precache[5].src=kos.IMAGE_BASE+"star_black.gif";kos.precache[6]=new Image(20,20);kos.precache[6].src=kos.IMAGE_BASE+"NotifyBezel20.gif";kos.precache[7]=new Image(16,16);kos.precache[7].src=kos.IMAGE_BASE+"HelpDown16.gif";kos.precache[8]=new Image(20,2);kos.precache[8].src=kos.IMAGE_BASE+"NotifyBack20.gif";kos.precache[9]=new Image(800,17);kos.precache[9].src=kos.IMAGE_BASE+"Thermometer17.gif";kos.precache[10]=new Image(14,14);kos.precache[10].src=kos.IMAGE_BASE+"DiscloseDown14.gif";}
return false;},createBusyBallSpan:function(feedbackText){if(!feedbackText){feedbackText="Submitting...";}
var containerSpan=document.createElement("span");containerSpan.setAttribute("class","busyBall");containerSpan.setAttribute("title","We're talking to the server."+" You don't need to wait for this to finish.");containerSpan.className="busyBall";containerSpan.innerHTML='<span class="bbi"><img src="'+kos.IMAGE_BASE+'BusyBall16.gif" width="288" height="16" /></span><span class="bbc">'+
feedbackText+'</span>';return containerSpan;},addBusyBall:function(busyBallSpan){var busyBallImg=busyBallSpan.firstChild.firstChild;if(!kos.busyBalls){kos.busyBalls=[busyBallImg];kos.busyBallOffset=0;kos.busyBallInterval=setInterval(kos.animateBusyBalls,120);}else{kos.busyBalls[kos.busyBalls.length]=busyBallImg;}},removeBusyBall:function(busyBallSpan,succeeded,removeImmediately){var busyBallImg=busyBallSpan.firstChild.firstChild;if(kos.busyBalls){var newBusyBalls=[];for(var i=0,j=0;i<kos.busyBalls.length;++i){if(kos.busyBalls[i]!=busyBallImg){newBusyBalls[j]=kos.busyBalls[i];++j;}}
if(j>0){kos.busyBalls=newBusyBalls;}else{if(kos.busyBallInterval){clearInterval(kos.busyBallInterval);delete kos.busyBallInterval;}
delete kos.busyBalls;delete kos.busyBallOffset;}}
if(removeImmediately){if(busyBallSpan.parentNode){busyBallSpan.parentNode.removeChild(busyBallSpan);}}else{var bbimg=busyBallSpan.firstChild.firstChild;var duration=2000;if(!succeeded){bbimg.style.marginLeft="-272px";busyBallSpan.lastChild.innerHTML="FAILED.";busyBallSpan.setAttribute("title","Server update failed. Check your connection, and please try again.");duration=6000;}else{bbimg.style.marginLeft="-256px";busyBallSpan.lastChild.innerHTML="Complete.";busyBallSpan.setAttribute("title","Server updated successfully.");}
setTimeout(kos.completeBusyBall.bind(busyBallSpan),duration);}},completeBusyBall:function(){var busyBallSpan=this;if(busyBallSpan.parentNode){busyBallSpan.parentNode.removeChild(busyBallSpan);}},animateBusyBalls:function(){if(kos.busyBalls){for(var i=0;i<kos.busyBalls.length;++i){kos.busyBalls[i].style.marginLeft=(kos.busyBallOffset+"px");}
kos.busyBallOffset-=16;kos.busyBallOffset%=-256;}},DETAIL_FULL:"f",DETAIL_SUMMARY:"s",DETAIL_STORYONLY:"o",DETAIL_COMMENT:"c",hasBeenIdle:false,unidle:function(evt){if(typeof kos!="undefined"&&kos.hasBeenIdle){kos.hasBeenIdle=false;window.onkeypress=null;if(kos.idleMonitorTimeout){clearTimeout(kos.idleMonitorTimeout);kos.idleMonitorTimeout=null;}
if(!kos.isIE6Minus){document.body.onmousemove=null;}
if(kos.commentsDiv){if(!window.ActiveXObject){kos.commentsDiv.onmousemove=null;}else{kos.commentsDiv.onmouseleave=null;kos.commentsDiv.onmouseenter=null;}}
if(kos.awaitingUnidle){setTimeout(kos.autoRefresh,10);kos.awaitingUnidle=false;}}
return true;},resetIdle:function(){if(typeof kos!="undefined"){window.onkeypress=kos.unidle;kos.priorScrollState=kos.getScrollState();if(!kos.idleMonitorTimeout){kos.idleMonitorTimeout=setTimeout(kos.idleMonitor,kos.IDLE_MONITOR_INTERVAL);}
if(!kos.isIE6Minus){document.body.onmousemove=kos.unidle;}else{window.onscroll=kos.windowScrollIE;}
if(kos.commentsDiv){if(!window.ActiveXObject){kos.commentsDiv.onmousemove=kos.unidle;}else{kos.commentsDiv.onmouseleave=kos.unidle;kos.commentsDiv.onmouseenter=kos.unidle;}}
kos.hasBeenIdle=true;}},idleMonitor:function(){var newScrollState=kos.getScrollState();if(kos.priorScrollState.scrollY!=newScrollState.scrollY){kos.unidle();}else{kos.idleMonitorTimeout=setTimeout(kos.idleMonitor,kos.IDLE_MONITOR_INTERVAL);}
kos.priorScrollState=newScrollState;},autoRefresh:function(){if(typeof kos!="undefined"){if(!kos.hasBeenIdle){var kloadReq=new kos.kload();}else{kos.awaitingUnidle=true;}}},setupAutorefresh:function(){var autorefresh=false;var autorefreshCheckbox=$("autorefresh");if(autorefreshCheckbox){autorefreshCheckbox.style.display=kos.DISPLAY_INLINE;autorefreshCheckbox.onclick=kos.changeAutorefresh;if(autorefreshCheckbox.nextSibling){var tl="title";autorefreshCheckbox.setAttribute(tl,autorefreshCheckbox.nextSibling.getAttribute(tl));autorefreshCheckbox.nextSibling.style.display=kos.DISPLAY_INLINE;}
autorefresh=autorefreshCheckbox.checked;}
if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){if(kos.OVERFLOW_REFRESH_INTERVAL<1){autorefresh=false;}}else if(kos.REFRESH_INTERVAL<1){autorefresh=false;}
var refreshNow=$("refreshNow");if(autorefresh){if(refreshNow){refreshNow.disabled=true;refreshNow.style.opacity="0.5";refreshNow.innerHTML="Autorefresh On";refreshNow.onclick=kos.returnFalse;}
window.onfocus=kos.unidle;window.onresize=kos.windowResize;kos.resetIdle();kos.restartAutorefresh();}else{window.onresize=kos.windowResize;if(kos.isIE6Minus){window.onscroll=kos.windowScrollIE;}
if(refreshNow){refreshNow.disabled=false;refreshNow.style.opacity="1";refreshNow.innerHTML="Check for More";refreshNow.onclick=kos.refreshContentNow;}}},restartAutorefresh:function(delayTime){if(!delayTime){if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){delayTime=kos.OVERFLOW_REFRESH_INTERVAL;}else{delayTime=kos.REFRESH_INTERVAL;}}
if(kos.refreshInterval){clearTimeout(kos.refreshInterval);kos.refreshInterval=null;}
var autorefresh=false;var autorefreshCheckbox=$("autorefresh");if(autorefreshCheckbox){autorefresh=autorefreshCheckbox.checked;}
if(kos.getCommentCount()>=kos.OVERFLOW_COUNT){if(kos.OVERFLOW_REFRESH_INTERVAL<1){autorefresh=false;}}else if(kos.REFRESH_INTERVAL<1){autorefresh=false;}
if(autorefresh){kos.refreshInterval=setTimeout(kos.autoRefresh,delayTime);}},changeAutorefresh:function(evt){var autorefresh=$("autorefresh").checked;if(autorefresh){kos.setupAutorefresh();}else{var refreshNow=$("refreshNow");if(refreshNow){refreshNow.disabled=false;refreshNow.style.opacity="1";refreshNow.innerHTML="Check for More";refreshNow.onclick=kos.refreshContentNow;}}
kos.restartAutorefresh(1000);var cbar=kos.getAncestorByClassName(this,"cbar");var permaP=cbar.getElementsByTagName("P")[0];var bbs=kos.createBusyBallSpan();kos.insertAfter(bbs,permaP.lastChild);kos.addBusyBall(bbs);var bag={input:this,bbs:bbs};var params="autorefreshMode="+(autorefresh?"on":"off");var kjaxreq=new kos.kjax(kos.finishBusyBall,bag,kos.SUBMIT_BASE+"prefs",params,"POST");return true;},refreshContentNow:function(){var kloadReq=new kos.kload();return false;},removeIframe:function(){if(window.ActiveXObject){var iframe=$(kos.iframeID);if(iframe){document.body.removeChild(iframe);}
if(!window.frames[kos.iframeID]){kos.iframeID=null;}}},refreshBinding:function(){log("in refreshBinding");kos.refreshContent(this.detail,this.cid);},refreshContent:function(detail,cid){log("in refreshContent with detail: "+detail+" cid: "+cid);kos.refreshUnderway=true;kos.awaitingUnidle=false;kos.refreshTimeout=setTimeout(kos.onRefreshTimeout,kos.REFRESH_TIMEOUT_TIME);if(kos.refreshInterval){clearTimeout(kos.refreshInterval);kos.refreshInterval=null;}
if(!kos.iframeID||(typeof kos.iframeID=="undefined")){kos.iframeID="dataFeed";var ifr=document.createElement('iframe');ifr.setAttribute('id',kos.iframeID);ifr.setAttribute('name',kos.iframeID);if(kos.DEBUG){ifr.style.width="900px";ifr.style.height="400px";}else{ifr.style.visibility='hidden';ifr.style.position='absolute';var op="0px";ifr.style.width=op;ifr.style.height=op;ifr.borderWidth=op;}
ifr.onload=kos.loadUpdate;kos.ignoreInitialIframeOnload=true;document.getElementsByTagName('body')[0].appendChild(ifr);log("iframe created; binding and bailing");var bag={detail:detail,cid:cid};setTimeout(kos.refreshBinding.bind(bag),50);return;}
kos.ignoreInitialIframeOnload=false;if(!window.opera&&window.frames&&window.frames[kos.iframeID]){var iframe=window.frames[kos.iframeID];}else{iframe=$(kos.iframeID);}
if(!iframe){log("iframe not found");kos.onRefreshTimeout();}
if(!detail){if(!kos.commentsDiv){detail=kos.DETAIL_STORYONLY;}else{var inExpandMode=$("cDExpand").checked;if(inExpandMode){detail=kos.DETAIL_FULL;}else{detail=kos.DETAIL_SUMMARY;}}}
if(detail==kos.DETAIL_FULL&&kos.getCommentCount()>=kos.OVERFLOW_COUNT){detail=kos.DETAIL_SUMMARY;}
var uri=kos.UPDATE_BASE+kos.sid+"?detail="+detail+"&id="+kos.story_id;var serial=null;if(detail==kos.DETAIL_SUMMARY&&(!kos.mostRecentFullSerial||kos.mostRecentSummarySerial>kos.mostRecentFullSerial)){serial=kos.mostRecentSummarySerial;}else{serial=kos.mostRecentFullSerial;}
if(serial&&detail!=kos.DETAIL_COMMENT){uri+="&serial="+serial;}
if(detail==kos.DETAIL_COMMENT&&cid){if(cid.charAt(0)=='c'){cid=cid.substring(1);}
uri+="&cid="+cid;}
if(window.opera&&!kos.isOpera9Plus){uri+="&try="+new Date().getTime();log("loading new 'try' into iframe doc Opera8.5-");}
log("Loading uri "+uri+" with SummarySerial: "+kos.mostRecentSummarySerial+" FullSerial: "+kos.mostRecentFullSerial);var ifrDoc=iframe.contentDocument||iframe.document;if(ifrDoc&&ifrDoc.location&&ifrDoc!=document){ifrDoc.location.replace(uri);}else{log("iframe.src = uri;");iframe.src=uri;}
if(window.ActiveXObject){log("setting checkIframe timeout for IE");setTimeout(kos.checkIframe,250);}},onRefreshTimeout:function(){kos.refreshUnderway=false;log("refresh timed out");for(var i=0;i<kos.loadObservers.length;++i){if(kos.loadObservers[i]){kos.loadObservers[i].onTimeout();}}
kos.loadObservers=[];kos.refreshTimeout=null;kos.resetIdle();kos.restartAutorefresh();},checkIframe:function(){if(window.frames&&window.frames[kos.iframeID]){var iframe=window.frames[kos.iframeID];}else{iframe=$(kos.iframeID);}
if(iframe){var doc=iframe.contentDocument||iframe.document;if(doc&&doc.readyState){var dr=doc.readyState;if(dr=='complete'){kos.loadUpdate();}else{setTimeout(kos.checkIframe,100);}
return;}}
kos.onRefreshTimeout();},loadObservers:[],loadUpdate:function(){if(kos.ignoreInitialIframeOnload){log("Ignoring first iframe onload firing when adding to document");return;}
log("Update loaded...Now updating DOM");if(kos.refreshTimeout){clearTimeout(kos.refreshTimeout);kos.refreshTimeout=null;}
if(kos.refreshInterval){clearTimeout(kos.refreshInterval);kos.refreshInterval=null;}
if(!window.opera&&window.frames&&window.frames[kos.iframeID]){var iframe=window.frames[kos.iframeID];}else{iframe=$(kos.iframeID);}
var doc=iframe.contentDocument||iframe.document;doc=(doc.documentElement||doc);if(doc){var body=doc.getElementsByTagName("body")[0];if(body){var container=kos.getChildById(body,"container");}}
if(doc&&body&&container){var isPreviewing=(kos.mainDiv.className.indexOf("preview")>-1);var isEditing=(kos.mainDiv.className.indexOf("editing")>-1);var head=doc.getElementsByTagName("head")[0];var title=head.getElementsByTagName("title")[0];if(title&&!isPreviewing&&!isEditing){document.title=title.innerHTML;}
var main=kos.getChildById(container,"main");var curMain=kos.mainDiv;var story=kos.getElementById(main,"story","div");var curStory=$("story");var storyUpdated=false;if(story&&curStory){var diaryTitle=kos.getElementByClassName(story,"diaryTitle","span");var curDiaryTitle=kos.getElementByClassName(curStory,"diaryTitle","span");if(diaryTitle&&curDiaryTitle){if(kos.currentTitleHtml!=diaryTitle.innerHTML){storyUpdated=true;kos.currentTitleHtml=diaryTitle.innerHTML;}
if(!isPreviewing){curDiaryTitle.innerHTML=diaryTitle.innerHTML;}}
var entry=kos.getChildByClassName(story,"entry");var curEntry=kos.getElementByClassName(kos.mainDiv,"entry","div");if(entry&&curEntry){var curPostDate=kos.getElementByClassName(curEntry,"date","h4");var postDate=kos.getElementByClassName(entry,"date","h4");if(postDate&&curPostDate&&!isEditing&&!isPreviewing){curPostDate.innerHTML=postDate.innerHTML;}}
var intro=kos.getElementByClassName(entry,"intro","div");var curIntro=kos.getElementByClassName(curEntry,"intro","div");if(intro&&curIntro){if(kos.trim(kos.currentIntroHtml)!=kos.trim(intro.innerHTML)){storyUpdated=true;kos.currentIntroHtml=intro.innerHTML;if(!isPreviewing){curIntro.innerHTML=intro.innerHTML;}}}
var extended=kos.getElementById(story,"extended","div");var curExtended=$("extended");if(extended&&curExtended){if(kos.trim(kos.currentBodyHtml)!=kos.trim(extended.innerHTML)){storyUpdated=true;kos.currentBodyHtml=extended.innerHTML;if(!isPreviewing){curExtended.innerHTML=extended.innerHTML;}}}
var poll=kos.getChildByClassName(main,"poll","div");var curPoll=kos.getChildByClassName(kos.mainDiv,"poll","div");if(poll||curPoll){var overwritePoll=false;if(curPoll&&(curPoll.className.indexOf("add")!=-1||curPoll.className.indexOf("voteform")!=-1)){overwritePoll=true;}
if(curPoll&&!poll){if(typeof kst=="undefined"||!kst){log("deleting poll...");curPoll.parentNode.removeChild(curPoll);storyUpdated=true;}}else if(poll&&(!curPoll||overwritePoll)){if(overwritePoll&&curPoll){curPoll.parentNode.removeChild(curPoll);}
log("adding new poll...");var curTagsP=$("tags");if(document.importNode){curTagsP.parentNode.insertBefore(document.importNode(poll,true),curTagsP);}else{curTagsP.insertAdjacentHTML('beforeBegin',poll.outerHTML);}
kos.rewirePoll();storyUpdated=true;}else{var prs=kos.getElementsByClassName(poll,"pr","tr");var curPrs=kos.getElementsByClassName(curPoll,"pr","tr");for(var p=0;p<prs.length&&p<curPrs.length;++p){curPrs[p].firstChild.innerHTML=prs[p].firstChild.innerHTML;curPrs[p].lastChild.style.backgroundPosition=prs[p].lastChild.style.backgroundPosition;curPrs[p].lastChild.innerHTML=prs[p].lastChild.innerHTML;}
var vtotal=kos.getElementByClassName(poll,"vtotal","span");if(vtotal){kos.getElementByClassName(curPoll,"vtotal","span").innerHTML=vtotal.innerHTML;}}}}
if(storyUpdated&&typeof kst!="undefined"){kst.storyUpdated();}
var tagsP=kos.getChildById(main,"tags");if(tagsP){var tags=kos.getChildById(tagsP,"tagLinks");if(tags){var curTags=$("tagLinks");if(!curTags&&curStory){if(document.importNode){var importedTags=document.importNode(tags,true);kos.insertAfter(importedTags,curStory);}else{curStory.insertAdjacentHTML('afterEnd',tags.outerHTML);}}else if(curTags){curTags.innerHTML=(tags.innerHTML+" ");}}}
var curTagInput=$("tagInput");var tagE=kos.getChildById(main,"tagEditor");if(tagE&&curTagInput&&tagE.style.display!=kos.DISPLAY_BLOCK){var tagInput=kos.getElementById(tagE,"tagInput","input");if(tagInput&&kos.trim(tagInput.value).length>0){curTagInput.value=tagInput.value;}}
var recommenders=kos.getChildById(main,"recommenders");if(recommenders){var curRecommenders=$("recommenders");if(!curRecommenders){if(document.importNode){var importedRecs=document.importNode(recommenders,true);curMain.appendChild(importedRecs);}else{curMain.insertAdjacentHTML('beforeEnd',recommenders.outerHTML);}}else{curRecommenders.innerHTML=recommenders.innerHTML;}}
var comments=kos.getChildById(main,"comments");var curComments=$("comments");if(comments){var rateForm=kos.getChildById(comments,"rateAllForm");var hiddenDiv=kos.getChildByTagName(rateForm,"div");var serialField=kos.getChildById(hiddenDiv,"serial");var serial=null;if(serialField){serial=serialField.value;}
var detailField=kos.getChildById(hiddenDiv,"detail");if(detailField){if(detailField.value==kos.DETAIL_SUMMARY){kos.mostRecentSummarySerial=serial;}else{kos.mostRecentFullSerial=serial;}}
var ul=kos.getChildByTagName(rateForm,"ul");var lis=ul.getElementsByTagName("li");if(curComments){var kupd=new kos.kupdater(null,null,serial,lis,curComments,storyUpdated);return;}else{var commentCount=0;var re=new RegExp('\\bcm\\b');for(var i=0;i<lis.length;++i){var li=lis[i];if(!li.id||!li.parentNode.className.match(re)){continue;}
++commentCount;}
kos.updateCommentCount(commentCount);}}}else if(doc&&body){var cul=kos.getChildByTagName(body,"ul");if(cul){li=kos.getChildByTagName(cul,"li");if(li&&li.id){log("Loaded individual comment cid="+li.id);var matchingLi=$(li.id);if(matchingLi){kupd=new kos.kupdater(li,matchingLi,0);}}}else{var overflowToken=kos.getChildById(body,"overflow");if(overflowToken){log("Overflow token sent from server; ajusting comment count to overflow");kos.commentCount=kos.OVERFLOW_COUNT;}else{log("No update: we are current");}}}
kos.completeUpdate();},completeUpdate:function(){log("Update complete.");for(var i=0;i<kos.loadObservers.length;++i){if(kos.loadObservers[i]){kos.loadObservers[i].onComplete();}}
kos.loadObservers=[];kos.removeIframe();kos.refreshUnderway=false;kos.resetIdle();kos.restartAutorefresh();},kupdater:function(li,matchingLi,serial,lis,curComments,storyUpdated){log("kupdater created "+(li?"for single comment":"for complete update")+" with serial: "+serial);this.li=li;this.matchingLi=matchingLi;this.serial=serial;if(this.li){this.loadUpdatedComment(this.li,this.matchingLi);return;}
this.curComments=curComments;this.storyUpdated=storyUpdated;this.curUl=kos.getChildByTagName(kos.getChildById(this.curComments,"rateAllForm"),"ul");this.re=new RegExp('\\bcm\\b');this.inExpandMode=$("cDExpand").checked;this.lis=lis;this.allNewLis=[];this.curOffset=0;this.loadUpdateBatch();},updateCommentCount:function(commentCount){if(kos.inCommentFocusMode){return;}
kos.commentCount=commentCount;var cbarTop=kos.getChildByClassName(kos.mainDiv,"cbar");if(cbarTop){var cct=kos.getElementByClassName(cbarTop,"cct","span");if(cct){cct.innerHTML=commentCount+"";}}
if(kos.commentsDiv){var cbarBot=kos.getChildByClassName(kos.commentsDiv,"cbar");if(cbarBot){cct=kos.getElementByClassName(cbarBot,"cct","span");if(cct){cct.innerHTML=commentCount+"";}}}},hideNotifier:function(){if(typeof kos!="undefined"){if(!kos.hasBeenIdle){if(kos.notifier&&kos.notifier.style.display!=kos.DISPLAY_NONE){var newFx=new kos.kslide(kos.notifier,true);newFx.startAnimation();}}else{if(kos.notifierTimeout){clearTimeout(kos.notifierTimeout);}
kos.notifierTimeout=setTimeout(kos.hideNotifier,kos.NOTIFIER_DURATION);}}},windowResize:function(){if(typeof kos!="undefined"){if(kos.notifier&&kos.notifier.style.display!=kos.DISPLAY_NONE){if(kos.notifier.offsetHeight){var panelHt=kos.notifier.offsetHeight;}else{panelHt=kos.notifier.clientHeight;}
var winHt=kos.getWindowInnerHeight();if(window.ActiveXObject){winHt=kos.getScrollState().scrollY+winHt;}
kos.notifier.style.top=((winHt-panelHt)+1)+"px";}}
return true;},windowScrollIE:function(){if(typeof kos!="undefined"){if(kos.notifier&&kos.notifier.style.display!=kos.DISPLAY_NONE){var winHt=kos.getScrollState().scrollY+kos.getWindowInnerHeight();kos.notifier.style.top=((winHt-kos.notifier.clientHeight)+1)+"px";}}
return true;},checkRequirements:function(){log("Checking requirements for "+navigator.userAgent);kos.DISABLED=true;if(navigator.userAgent.indexOf('MSIE 5')!=-1&&navigator.userAgent.indexOf('Mac')!=-1){return false;}
if(navigator.userAgent.indexOf('MSIE 5.0')!=-1){return false;}
if(!document.getElementsByTagName||!document.createElement){return false;}
var appleIdx=navigator.userAgent.indexOf('AppleWebKit');if(appleIdx!=-1){log("isSafari");kos.isSafari=true;var appleRev=navigator.userAgent.substring(appleIdx+12,navigator.userAgent.indexOf("(",appleIdx+12));var appleMajor=parseInt(appleRev,10);if(appleMajor<120){return false;}}else if(navigator.userAgent.indexOf('Konqueror')!=-1){log("isKonqueror");kos.isKonqueror=true;}
kos.isIE6Css=(document.compatMode&&document.compatMode.indexOf("CSS1")>=0)?true:false;log((window.ActiveXObject?"Has":"Does not have")+" window.ActiveXObject");if(window.opera){log("window.opera.version(): "+window.opera.version());if(parseInt(window.opera.version(),10)>=9){log("is Opera9 Plus");kos.isOpera9Plus=true;}}else{kos.isIE6Minus=!!window.ActiveXObject;var msieIdx=navigator.userAgent.indexOf('MSIE');if(msieIdx!=-1){kos.isIE=true;var msieMajor=parseInt(navigator.userAgent.substring(msieIdx+5,msieIdx+7),10);if(msieMajor>6){kos.isIE6Css=true;kos.isIE6Minus=false;}}}
kos.DISABLED=false;log("Requirements met.");return true;},rewireControls:function(){log("Rewiring controls...");var uidField=$("uid");if(uidField){kos.uid=uidField.value;}
var unameField=$("uname");if(unameField){kos.uname=unameField.value;}
var recommendForm=$("recommendForm");if(recommendForm){recommendForm.onsubmit=kos.returnFalse;}
var recommendButton=$("recommendButton");if(recommendButton){recommendButton.onclick=kos.recommendButton;}
var recommendersLink=$("recommendersLink");if(recommendersLink){recommendersLink.onclick=kos.popupRecommenders;}
var pageWide=$("pageWide");if(pageWide){pageWide.onclick=kos.changeWidth;}
var pageNarrow=$("pageNarrow");if(pageNarrow){pageNarrow.onclick=kos.changeWidth;}
var tagEdit=$("tagEdit");if(tagEdit){tagEdit.onclick=kos.editTags;}
var tagSubmit=$("tagSubmit");if(tagSubmit){tagSubmit.onclick=kos.submitTags;}
var tagInput=$("tagInput");if(tagInput){tagInput.setAttribute("autocomplete","off");tagInput.onkeydown=kos.tagInputFieldKey;}
kos.commentsDiv=$("comments");var ac="autocomplete";var off="off";var postAComment=$("postAComment");if(postAComment){postAComment.onclick=kos.setupEditorDiary;}
var commentDisplayForm=$("cDForm");if(commentDisplayForm){commentDisplayForm.onsubmit=kos.returnFalse;commentDisplayForm.setAttribute(ac,off);if(kos.commentsDiv){commentDisplayForm.style.display=kos.DISPLAY_BLOCK;}}
var tl="title";var cdadisable=true;var commentDisplayExpand=$("cDExpand");if(commentDisplayExpand){commentDisplayExpand.onclick=kos.expandComments;if(commentDisplayExpand.checked){cdadisable=false;}
if(commentDisplayExpand.nextSibling){commentDisplayExpand.setAttribute(tl,commentDisplayExpand.nextSibling.getAttribute(tl));}}
var commentDisplayShrink=$("cDShrink");if(commentDisplayShrink){commentDisplayShrink.onclick=kos.shrinkComments;if(commentDisplayShrink.nextSibling){commentDisplayShrink.setAttribute(tl,commentDisplayShrink.nextSibling.getAttribute(tl));}
if(commentDisplayShrink.checked){cdadisable=false;}}
var commentDisplayHide=$("cDHide");if(commentDisplayHide){commentDisplayHide.checked=!kos.commentsDiv;commentDisplayHide.onclick=kos.hideComments;if(commentDisplayHide.nextSibling){commentDisplayHide.setAttribute(tl,commentDisplayHide.nextSibling.getAttribute(tl));}
if(commentDisplayHide.checked){cdadisable=false;}}
var commentDisplayAlways=$("cDAlways");if(commentDisplayAlways){commentDisplayAlways.onclick=kos.postDisplayPrefs;var cDAL=$("cDAL");if(cDAL){commentDisplayAlways.setAttribute(tl,cDAL.getAttribute(tl));cDAL.disabled=cdadisable;}
commentDisplayAlways.disabled=cdadisable;commentDisplayAlways.checked=!cdadisable;}
var commentHelpButton=$("cHelpButton");if(commentHelpButton){commentHelpButton.onclick=kos.toggleCommentHelp;}
var commentHelpCloseButton=$("cHelpCloseButton");if(commentHelpCloseButton){commentHelpCloseButton.onclick=kos.toggleCommentHelp;}
var userCss=$("userCss");var isFlat=userCss.href.match(/flat/i);var commentIndentingIndented=$("cIIndented");if(commentIndentingIndented){commentIndentingIndented.checked=!isFlat;commentIndentingIndented.onclick=kos.changeIndenting;if(commentIndentingIndented.nextSibling){commentIndentingIndented.setAttribute(tl,commentIndentingIndented.nextSibling.getAttribute(tl));}}
var commentIndentingFlat=$("cIFlat");if(commentIndentingFlat){commentIndentingFlat.checked=isFlat;commentIndentingFlat.onclick=kos.changeIndenting;if(commentIndentingFlat.nextSibling){commentIndentingFlat.setAttribute(tl,commentIndentingFlat.nextSibling.getAttribute(tl));}}
var commentIndentingAlways=$("cIAlways");if(commentIndentingAlways){commentIndentingAlways.onclick=kos.postIndentingPrefs;commentIndentingAlways.checked=true;if(commentIndentingAlways.nextSibling){commentIndentingAlways.setAttribute(tl,commentIndentingAlways.nextSibling.getAttribute(tl));}}
var notifierDiv=document.createElement("div");notifierDiv.id="notifier";notifierDiv.style.display=kos.DISPLAY_NONE;var notifierHTML='<div id="notifyContent"><span id="notifyStory">Story Updated.</span> '+'<span id="notifyReplies"> </span> <span id="notifyComments"> </span> </div>';if(kos.isIE6Minus){notifierHTML='<img id="notifyImg" src="'+kos.IMAGE_BASE+"NotifyBezel20.gif"+'" style="vertical-align:top;border:0;margin:-4px 0 0 0;padding:1px 0 0 0;" height="20" width="20" />'+notifierHTML;}else{notifierHTML='<span id="notifyBezel">&nbsp;</span>'+notifierHTML;}
notifierDiv.innerHTML=notifierHTML;var container=$("container");container.parentNode.insertBefore(notifierDiv,container);kos.notifier=$("notifier");if(kos.notifier){kos.notifier.style.display=kos.DISPLAY_NONE;if(kos.isIE6Minus){kos.notifier.style.position="absolute";kos.notifier.style.margin="0 0 0 0";kos.notifier.style.padding="3px 0 0 0";}}
kos.mostRecentSummarySerial=0;kos.mostRecentFullSerial=0;var detailField=$("detail");var serialField=$("serial");if(detailField&&serialField){if(detailField.value==kos.DETAIL_SUMMARY){kos.mostRecentSummarySerial=serialField.value;}else{kos.mostRecentFullSerial=serialField.value;}}
kos.mainDiv=$("main");kos.storyDiv=$("story");kos.inCommentFocusMode=!kos.storyDiv;if(kos.storyDiv){var curDiaryTitle=kos.getElementByClassName(kos.storyDiv,"diaryTitle","span");if(curDiaryTitle){kos.currentTitleHtml=curDiaryTitle.innerHTML;}
var curEntry=kos.getElementByClassName(kos.storyDiv,"entry","div");if(curEntry){var curIntro=kos.getElementByClassName(curEntry,"intro","div");if(curIntro){kos.currentIntroHtml=curIntro.innerHTML;}}
var curExtended=$("extended");if(curExtended){kos.currentBodyHtml=curExtended.innerHTML;}}
kos.rewirePoll();if(kos.commentsDiv){var readBar=$("readBar");if(readBar){readBar.style.display=kos.DISPLAY_BLOCK;var markRead=$("markRead");if(markRead){markRead.onclick=kos.markAllAsRead;}
var refreshNow=$("refreshNow");if(refreshNow){refreshNow.onclick=kos.refreshContentNow;}
var goToFirst=$("goToFirst");if(goToFirst){goToFirst.onclick=kos.goToFirstNew;}}
kos.setupAutorefresh();setTimeout(kos.rewireComments,10);var rateAllForm=$("rateAllForm");if(rateAllForm){rateAllForm.onsubmit=kos.returnFalse;rateAllForm.setAttribute(ac,off);}
kos.commentEditor=$("e");if(kos.commentEditor){log("Rewiring comment editor...");kos.commentEditor.editorPrefix="e";kos.rewireEditor("e");}}else{var autorefreshCheckbox=$("autorefresh");if(autorefreshCheckbox){autorefreshCheckbox.checked=false;}}
if(typeof kst!="undefined"){kst.rewireStory();}
kos.precacheImages();log("Rewiring complete.");return true;},rewirePoll:function(){var entryDiv=kos.getElementByClassName(kos.storyDiv,"entry","div");if(entryDiv){var pollDiv=kos.getElementByClassName(kos.mainDiv,"poll","div");}
if(pollDiv){var pollSubmit=kos.getElementByClassName(pollDiv,"pollSubmit","input");if(pollSubmit){pollSubmit.onclick=kos.submitPoll;pollSubmit.disabled=true;}
var pollResult=kos.getElementByClassName(pollDiv,"pollResult","a");if(pollResult){pollResult.onclick=kos.pollResults;}
var pollVote=kos.getElementByClassName(pollDiv,"pollVote","a");if(pollVote){pollVote.onclick=kos.pollVote;}
var pollRs=kos.getElementsByClassName(pollDiv,"aid","input");for(var i=0;i<pollRs.length;++i){pollRs[i].checked=false;pollRs[i].onclick=kos.pollChoiceChanged;}}},rewireComments:function(){if(kos.commentsDiv){log("Rewiring comments...");var postBot=$("postBot");if(postBot){postBot.onclick=kos.setupEditorDiary;}
var re=new RegExp('\\bcm\\b');var topUl=kos.getChildByTagName($("rateAllForm"),"ul");if(topUl){var allLis=topUl.getElementsByTagName("li");for(var i=0;i<allLis.length;++i){var li=allLis[i];if(!li.id||!li.parentNode.className.match(re)){continue;}else{kos.rewireComment(li);}}}
log("Rewiring comments complete.");}},rewireComment:function(li){var cx=kos.getChildByClassName(li,"cx");if(cx){kos.rewireCx(cx);}
var csx=kos.getChildByClassName(li,"csx");if(csx){var h4=kos.getChildByTagName(csx,"h4");var dc=kos.getChildByTagName(h4,"a");dc.onclick=kos.expandComment;}},rewireCx:function(cx){if(!cx){return;}
var h3=kos.getChildByTagName(cx,"h3");var anchors=h3.getElementsByTagName("a");for(var i=0;i<anchors.length;++i){var anchor=anchors[i];if(anchor.className.indexOf("de")!=-1){anchor.onclick=kos.collapseComment;}else if(anchor.parentNode.className.indexOf("crd")!=-1){anchor.parentNode.onclick=kos.popupRatings;anchor.onclick=null;}}
var cf=kos.getChildByClassName(cx,"cf");if(!cf){return;}
var cl=kos.getChildByClassName(cf,"cl");if(cl){anchors=cl.getElementsByTagName("a");for(i=0;i<anchors.length;++i){anchor=anchors[i];if(anchor.firstChild&&anchor.firstChild.nodeType==3&&anchor.firstChild.nodeValue.indexOf("Reply")!=-1){anchor.onclick=kos.setupEditorComment;}}
var inputs=cl.getElementsByTagName("input");for(i=0;i<inputs.length;++i){if(inputs[i].name=="rate"||(inputs[i].type=="submit"&&inputs[i].value=="Rate All")){inputs[i].disabled=true;}else{inputs[i].onclick=kos.selectRating;if(inputs[i].id.charAt(0)=='t'){inputs[i].title="You have "+kos.trollRatingsLeft+" Hide rating"+
(kos.trollRatingsLeft==1?"":"s")+" left today.";if(kos.trollRatingsLeft<1&&!inputs[i].checked){inputs[i].disabled=true;inputs[i].nextSibling.disabled=true;}}}}}},rewireEditor:function(editorPrefix){var ac="autocomplete";var off="off";var editorPreviewButton=$(editorPrefix+"PButton");if(editorPreviewButton){if(editorPrefix=='ie'||editorPrefix=='be'){editorPreviewButton.onclick=kst.previewDiary;}else{editorPreviewButton.onclick=kos.editorPreview;}}
var editorPostButton=$(editorPrefix+"PostButton");if(editorPostButton){editorPostButton.disabled=true;}
var editorCancelButton=$(editorPrefix+"CancelButton");if(editorCancelButton){editorCancelButton.onclick=kos.cancelEditor;}
var editorComment=$(editorPrefix+"Comment");if(editorComment){editorComment.setAttribute(ac,off);}
var editorSubject=$(editorPrefix+"Subject");if(editorSubject){editorSubject.setAttribute(ac,off);}
var editorLinkUrl=$(editorPrefix+"LinkUrl");if(editorLinkUrl){editorLinkUrl.setAttribute(ac,off);editorLinkUrl.onkeydown=kos.editorLinkFieldKey;}
var editorLinkLabel=$(editorPrefix+"LinkLabel");if(editorLinkLabel){editorLinkLabel.setAttribute(ac,off);editorLinkLabel.onkeydown=kos.editorLinkFieldKey;}
var editorBlockquoteButton=$(editorPrefix+"Blockquote");if(editorBlockquoteButton){editorBlockquoteButton.onmousedown=kos.editorBlockquote;editorBlockquoteButton.onkeydown=kos.editorBlockquoteKey;editorBlockquoteButton.onclick=kos.editorCommentFocus;}
var editorBoldButton=$(editorPrefix+"Bold");if(editorBoldButton){editorBoldButton.onmousedown=kos.editorBold;editorBoldButton.onkeydown=kos.editorBoldKey;editorBoldButton.onclick=kos.editorCommentFocus;}
var editorItalicButton=$(editorPrefix+"Italic");if(editorItalicButton){editorItalicButton.onmousedown=kos.editorItalic;editorItalicButton.onkeydown=kos.editorItalicKey;editorItalicButton.onclick=kos.editorCommentFocus;}
var editorLinkButton=$(editorPrefix+"LinkButton");if(editorLinkButton){editorLinkButton.onmousedown=kos.toggleEditorLinkPanel;editorLinkButton.onkeydown=kos.editorLinkKey;editorLinkButton.onclick=kos.returnFalse;}
var editorAddLinkButton=$(editorPrefix+"AddLink");if(editorAddLinkButton){editorAddLinkButton.onclick=kos.editorAddLink;}
var editorHelpButton=$(editorPrefix+"HelpButton");if(editorHelpButton){editorHelpButton.onmousedown=kos.toggleEditorHelp;editorHelpButton.onkeydown=kos.editorHelpKey;editorHelpButton.onclick=kos.returnFalse;}
return true;},init:function(){log("in init()");if(arguments.callee.done){return;}
arguments.callee.done=true;if(!kos.DISABLED){kos.rewireControls();}},loadUnderway:true,nowFullyLoaded:function(){log("Now fully loaded. Allowing further loading...");kos.loadUnderway=false;kos.init();},checkDOM:function(){log("Checking to see if the DOM is ready for rewiring...");if(kos.DISABLED){log("Requirements NOT met.");return;}else if($("pageWidth")){kos.init();}else if(!$("story")&&$("eCancelButton")){kos.init();}else{setTimeout(kos.checkDOM,100);}},kjaxTimeout:function(){this.onTimeout();},kjaxReady:function(){this.onReadyStateChange();},kjaxRetry:function(){this.onRetry();},encodeParamValue:function(value){if(encodeURIComponent){var enc=encodeURIComponent(value);}else{enc=escape(value);}
if(enc){enc=enc.replace(/%20/g,'+');}
return enc;},READY_STATE_COMPLETE:4,kjax:function(callbackFunction,callbackContext,url,params,method,contentType){this.callbackFunction=callbackFunction;this.callbackContext=callbackContext;this.contentType=contentType;if(!this.contentType){this.contentType="application/x-www-form-urlencoded";}
this.url=url;this.params=params;this.xhr=null;if(typeof XMLHttpRequest!='undefined'){this.xhr=new XMLHttpRequest();}else if(window.ActiveXObject){this.xhr=new ActiveXObject("Microsoft.XMLHTTP");}
if(!method){this.method="GET";}else{this.method=method.toUpperCase();}
if(this.xhr){this.timeout=setTimeout(kos.kjaxTimeout.bind(this),kos.REFRESH_TIMEOUT_TIME);this.xhr.onreadystatechange=kos.kjaxReady.bind(this);if(this.xhr.overrideMimeType){this.xhr.overrideMimeType('text/xml');}
this.xhr.open(this.method,this.url,true);this.xhr.setRequestHeader("Content-Type",this.contentType);this.xhr.send(this.method=="POST"?this.params:null);}},kload:function(callbackFunction,callbackContext,detail,cid){this.callbackFunction=callbackFunction;this.callbackContext=callbackContext;this.cid=cid;this.detail=detail;if(this.detail==kos.DETAIL_FULL){if(kos.fullLoadUnderway){if(!kos.loadObservers){kos.loadObservers=[];}
kos.loadObservers[kos.loadObservers.length]=this;return;}else{kos.fullLoadUnderway=true;}}
this.timeout=setTimeout(kos.kjaxTimeout.bind(this),kos.REFRESH_TIMEOUT_TIME+100);kos.startKload.apply(this);},startKload:function(){if(!kos.loadUnderway){kos.loadUnderway=true;kos.loadObservers[kos.loadObservers.length]=this;kos.refreshContent(this.detail,this.cid);}else{setTimeout(kos.kjaxRetry.bind(this),100);}},kfx:function(panel,displayStyle,onComplete,scrollNeutral){this.el=panel;this.displayStyle=displayStyle;this.onComplete=onComplete;this.scrollNeutral=scrollNeutral;if(scrollNeutral){this.origScrollState=kos.getScrollState();if(this.el.parentNode.offsetHeight){this.origHt=this.el.parentNode.offsetHeight;}else{this.origHt=this.el.parentNode.clientHeight;}}
this.el.style.overflow="hidden";},kslide:function(panel,hide){this.el=panel;this.hide=hide;},kpoll:function(pollForm,prs){log("kpoll created");this.pollForm=pollForm;this.prs=prs;}};kos.kjax.prototype={onReadyStateChange:function(){var ready=this.xhr.readyState;if(ready==kos.READY_STATE_COMPLETE){if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}
this.status=this.xhr.status;if(this.xhr.status>=400){this.FAILED=true;var debugMsg="There is a problem communicating with the server:\nresponse code: HTTP "+
this.xhr.status+" "+this.xhr.statusText;log(debugMsg);if(kos.DEBUG){alert(document.title+":\n"+debugMsg);}}
this.statusText=this.xhr.statusText;this.responseText=this.xhr.responseText;this.responseXml=this.xhr.responseXML;if(this.callbackFunction){this.callbackFunction.apply(this.callbackContext,[this]);}}},onTimeout:function(){this.xhr.abort();this.FAILED=true;log("FAILURE: kjax request to url "+this.url+" timed out, with params: "+this.params);if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}
if(this.callbackFunction){this.callbackFunction.apply(this.callbackContext,[this]);}}};kos.kload.prototype={onComplete:function(){kos.loadUnderway=false;log("kload complete with detail: "+this.detail+" cid: "+this.cid);if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}
if(this.detail==kos.DETAIL_FULL){kos.fullLoadUnderway=false;}
if(this.callbackFunction){this.callbackFunction.apply(this.callbackContext,[this]);}},onRetry:function(){kos.startKload.apply(this);},onTimeout:function(){kos.loadUnderway=false;log("kload TIMED OUT with detail: "+this.detail+" cid: "+this.cid);if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}
this.FAILED=true;if(this.detail==kos.DETAIL_FULL){kos.fullLoadUnderway=false;}
if(this.callbackFunction){this.callbackFunction.apply(this.callbackContext,[this]);}}};kos.kupdater.prototype={loadUpdateBatch:function(){var countConstant=((this.detail==kos.DETAIL_FULL)?kos.FULL_BATCH_COUNT:kos.UPDATE_BATCH_COUNT);var batchCount=Math.min(this.lis.length-this.curOffset,countConstant);if(batchCount<=0){setTimeout(this.removeDeletions.bind(this),kos.UPDATE_GAP_DURATION);return;}
var thisCount=this.curOffset+batchCount;for(var i=this.curOffset;i<thisCount;++i){var li=this.lis[i];if(!li.id||!li.parentNode.className.match(this.re)){continue;}
var matchingLi=$(li.id);if(matchingLi){matchingLi.serial=this.serial;this.loadUpdatedComment(li,matchingLi);}else{this.loadNewComment(li);}}
this.curOffset+=batchCount;setTimeout(this.loadUpdateBatch.bind(this),kos.UPDATE_GAP_DURATION);},loadUpdatedComment:function(li,matchingLi){var licx=kos.getChildByTagName(li,"div");var lih3=kos.getChildByTagName(licx,"h3");if(lih3){var licrd=kos.getChildByClassName(lih3,"crd");var newRating=kos.getChildByTagName(licrd,"a");}else{var lih4=kos.getChildByTagName(licx,"h4");if(lih4){licrd=kos.getChildByClassName(lih4,"crd");newRating=kos.getChildByTagName(licrd,"span");}}
var licrs=kos.getChildByClassName(licx,"crs");var hasCx=false;var cxDivs=kos.getChildrenByTagName(matchingLi,"div");for(var k=0;k<cxDivs.length;++k){var cxDiv=cxDivs[k];cxDiv.serial=this.serial;var h3=kos.getChildByTagName(cxDiv,"h3");if(h3){hasCx=true;var crd=kos.getChildByClassName(h3,"crd");var crda=kos.getChildByTagName(crd,"a");crda.innerHTML=newRating.innerHTML;if(licrs){var crs=kos.getChildByClassName(cxDiv,"crs");if(crs){crs.innerHTML=licrs.innerHTML;}else{if(document.importNode){crs=document.importNode(licrs,true);kos.insertAfter(crs,h3);}else{h3.insertAdjacentHTML('afterEnd',licrs.outerHTML);}}}}else{var h4=kos.getChildByTagName(cxDiv,"h4");if(h4){crd=kos.getChildByClassName(h4,"crd");var crds=kos.getChildByTagName(crd,"span");crds.innerHTML=newRating.innerHTML;}}}
if(!hasCx&&lih3){if(h4&&!kos.getElementByClassName(h4,"nw","span")){var newSpan=kos.getElementByClassName(lih3,"nw","span");if(newSpan&&newSpan.parentNode){newSpan.parentNode.removeChild(newSpan);}}
if(document.importNode){var newCx=document.importNode(licx,true);newCx.style.display=kos.DISPLAY_NONE;newCx.setAttribute("style","display:none;");matchingLi.insertBefore(newCx,matchingLi.firstChild);}else{var licxhtml='<DIV style="display:none" '+licx.outerHTML.substring(6);matchingLi.insertAdjacentHTML('afterBegin',licxhtml);}
this.removeSelfRatingControls(matchingLi);newCx=kos.getChildByClassName(matchingLi,"cx");kos.rewireCx(newCx);}},loadNewComment:function(li){var parentId=null;if(li.parentNode.parentNode.nodeName.toLowerCase()=="li"){parentId=li.parentNode.parentNode.id;}
var priorSibling=null;var liPrior=li;while(liPrior.previousSibling){if(liPrior.previousSibling.nodeType==1&&liPrior.previousSibling.id){priorSibling=$(liPrior.previousSibling.id);break;}
liPrior=liPrior.previousSibling;}
var parentUl=null;if(parentId){var parentLi=$(parentId);if(parentLi){parentUl=kos.getChildByTagName(parentLi,"ul");if(!parentUl){parentUl=kos.makeIndentedUl(parentLi);parentLi.appendChild(parentUl);}}}
if(!parentUl){if(kos.inCommentFocusMode){return;}
parentUl=this.curUl;}
if(priorSibling){while(priorSibling.nextSibling){if(priorSibling.nextSibling.nodeType==1&&priorSibling.nextSibling.id!="eP"&&priorSibling.nextSibling.id!="e"){break;}
priorSibling=priorSibling.nextSibling;}}
li.setAttribute("style","display:none;");var newLiId=li.id;if(document.importNode){var newLi=document.importNode(li,true);if(priorSibling){kos.insertAfter(newLi,priorSibling);}else{parentUl.appendChild(newLi);}}else{if(priorSibling){priorSibling.insertAdjacentHTML('afterEnd',li.outerHTML);}else{parentUl.insertAdjacentHTML('beforeEnd',li.outerHTML);}}
newLi=$(newLiId);newLi.serial=this.serial;var newLiUL=kos.getChildByTagName(newLi,"ul");if(newLiUL){newLi.removeChild(newLiUL);}
var newDiv=kos.getChildByTagName(newLi,"div");if(newDiv.className.indexOf("cx")!=-1){var newCsx=kos.createCommentSummary(newDiv);kos.insertAfter(newCsx,newDiv);if(!this.inExpandMode){newCsx.style.display=kos.DISPLAY_BLOCK;newDiv.style.display=kos.DISPLAY_NONE;}else{newDiv.style.display=kos.DISPLAY_BLOCK;}
this.removeSelfRatingControls(newLi);}
kos.rewireComment(newLi);kos.setDisplayStyleScrollNeutral(newLi,kos.DISPLAY_BLOCK);this.allNewLis[this.allNewLis.length]=newLi;},parseUnameFromComment:function(aReply){var replyUname=null;var replyCx=kos.getChildByClassName(aReply,"cx");if(replyCx){var replyCb=kos.getElementByClassName(replyCx,"cb","P");if(replyCb){var ua=kos.getChildByTagName(replyCb,"a");replyUname=ua.innerHTML;}}else{var replyCsx=kos.getChildByClassName(aReply,"csx");if(replyCsx){var replyHTML=replyCsx.innerHTML;var byIdx=replyHTML.lastIndexOf("by ")+3;replyUname=replyHTML.substring(byIdx,replyHTML.indexOf(",",byIdx));}}
return replyUname;},removeSelfRatingControls:function(anLi){var anLiCx=kos.getChildByClassName(anLi,"cx");if(anLiCx){var pcl=kos.getElementByClassName(anLiCx,"cl","P");if(pcl){var newLiUname=this.parseUnameFromComment(anLi);if(newLiUname==kos.uname){var removing=false;for(var p=pcl.childNodes.length;p>-1;--p){if(removing){pcl.removeChild(pcl.childNodes[p]);}
if(pcl.childNodes[p-1]){if(pcl.childNodes[p-1].nodeType=="1"&&pcl.childNodes[p-1].nodeName.toUpperCase()=="A"){break;}else if(pcl.childNodes[p-1].name=="rate"){removing=true;}}}}else{var recd=false;var trld=false;var crs=kos.getChildByClassName(anLiCx,"crs");if(crs){var dds=crs.getElementsByTagName("DD");if(dds[0]){var uns=">"+kos.uname+"<";if(dds[0].innerHTML.indexOf(uns)!=-1){var dts=crs.getElementsByTagName("DT");if(dts[0]&&dts[0].innerHTML.charAt(0)=="R"){recd=true;}else{trld=true;}}else if(dds[1]&&(dds[1].innerHTML.indexOf(uns)!=-1)){trld=true;}}}
var inputs=pcl.getElementsByTagName("INPUT");if(inputs[0]){inputs[0].checked=recd;}
if(inputs[1]&&inputs[1].name!="rate"){inputs[1].checked=trld;}}}}},removeDeletions:function(){log("removing deletions");var commentCount=0;var existingLis=this.curUl.getElementsByTagName("li");for(var i=0;i<existingLis.length;++i){var oldLi=existingLis[i];if(!oldLi.id||!oldLi.parentNode.className.match(this.re)||oldLi.id=="eP"){continue;}
if(oldLi.serial!=this.serial&&oldLi.parentNode){log("deleting old comment id: "+oldLi.id);var oldParentUl=oldLi.parentNode;kos.setDisplayStyleScrollNeutral(oldLi,kos.DISPLAY_NONE);oldParentUl.removeChild(oldLi);if(kos.getChildrenByTagName(oldParentUl,"li").length<1&&oldParentUl.className.indexOf("i0")==-1){kos.setDisplayStyleScrollNeutral(oldParentUl,kos.DISPLAY_NONE);oldParentUl.parentNode.removeChild(oldParentUl);}}else{++commentCount;}}
kos.updateCommentCount(commentCount);setTimeout(this.showNotifier.bind(this),kos.UPDATE_GAP_DURATION);},showNotifier:function(){log("showing notifier");if((this.allNewLis.length>0||this.storyUpdated)&&kos.NOTIFIER_DURATION>0){if(kos.notifier){var notifyStory=$("notifyStory");if(this.storyUpdated){notifyStory.style.display=kos.DISPLAY_INLINE;}else{notifyStory.style.display=kos.DISPLAY_NONE;}
var repliesArray=[];var nonRepliesArray=[];for(var r=0;r<this.allNewLis.length;++r){var anLi=this.allNewLis[r];var isReply=false;if(anLi.parentNode.className.indexOf("i0")==-1){var replyTo=anLi.parentNode.parentNode;var replyToUname=this.parseUnameFromComment(replyTo);if(replyToUname==kos.uname){isReply=true;}}
if(isReply){repliesArray[repliesArray.length]=anLi;}else{nonRepliesArray[nonRepliesArray.length]=anLi;}}
var maxNs=6;var replyCount=0;var replies="";for(r=0;r<repliesArray.length&&r<maxNs;++r){var replyUname=this.parseUnameFromComment(repliesArray[r]);if(replyUname){++replyCount;replies+=(replyCount>1?", ":"")+'<a href="#'+repliesArray[r].id+'">'+replyUname+'</a>';}}
if(repliesArray.length>replyCount){replies+="... ";}else{replies+=". ";}
var nonReplyCount=0;var nonReplies="";for(r=0;r<nonRepliesArray.length&&r<(maxNs-replyCount);++r){replyUname=this.parseUnameFromComment(nonRepliesArray[r]);if(replyUname){++nonReplyCount;nonReplies+=(nonReplyCount>1?", ":"")+'<a href="#'+nonRepliesArray[r].id+'">'+replyUname+'</a>';}}
if(nonRepliesArray.length>nonReplyCount){nonReplies+="... ";}else{nonReplies+=". ";}
var notifyReplies=$("notifyReplies");if(replyCount>0){notifyReplies.innerHTML='<span class="notifyCount">'+repliesArray.length+' new repl'+(replyCount>1?'ies':'y')+'</span>: from '+replies;notifyReplies.style.display=kos.DISPLAY_INLINE;}else{notifyReplies.style.display=kos.DISPLAY_NONE;}
var notifyComments=$("notifyComments");if(nonRepliesArray.length>0){notifyComments.innerHTML='<span class="notifyCount">'+nonRepliesArray.length+' new comment'+(nonRepliesArray.length>1?'s':'')+'</span>'+
(nonReplyCount>0?': from '+nonReplies:'...');notifyComments.style.display=kos.DISPLAY_INLINE;}else{notifyComments.style.display=kos.DISPLAY_NONE;}
if(kos.notifier.style.display!=kos.DISPLAY_BLOCK){log("notifier sliding up...");var newFx=new kos.kslide(kos.notifier);newFx.startAnimation();}
if(kos.notifierTimeout){clearTimeout(kos.notifierTimeout);}
kos.notifierTimeout=setTimeout(kos.hideNotifier,kos.NOTIFIER_DURATION);}}
kos.completeUpdate();setTimeout(this.postUpdate.bind(this),kos.UPDATE_GAP_DURATION);},postUpdate:function(){log("postUpdate");this.li=null;this.matchingLi=null;this.curComments=null;this.curUl=null;this.re=null;this.inExpandMode=null;this.lis=null;this.allNewLis=null;}};kos.kfx.prototype={startAnimation:function(){var panelHt;if(this.displayStyle==kos.DISPLAY_NONE){if(this.el.offsetHeight){panelHt=this.el.offsetHeight;}else{panelHt=this.el.clientHeight;}
this.from=panelHt;this.to=0;this.opto=0;this.opfrom=1;}else{var oldHt;if(this.el.parentNode.offsetHeight){oldHt=this.el.parentNode.offsetHeight;}else{oldHt=this.el.parentNode.clientHeight;}
this.el.style.visibility="hidden";this.el.style.height="0px";this.el.style.display=this.displayStyle+"";panelHt=this.el.scrollHeight;this.el.style.visibility="visible";this.el.style.opacity="1";if(this.scrollNeutral){var newHt;if(this.el.parentNode.offsetHeight){newHt=this.el.parentNode.offsetHeight;}else{newHt=this.el.parentNode.clientHeight;}
window.scrollBy(0,newHt-oldHt);}
this.to=panelHt;this.from=0;this.opfrom=0;this.opto=1;}
this.opnow=1;this.duration=500;this.startTime=new Date().getTime();this.timer=setInterval(this.step.bind(this),13);return panelHt;},step:function(){var time=new Date().getTime();if(time>=this.duration+this.startTime){clearInterval(this.timer);this.timer=null;this.now=this.to;this.opnow=this.opto;this.el.style.overflow="visible";this.el.style.height=this.now+"px";this.el.style.opacity="1";this.el.style.display=this.displayStyle+"";this.el.style.visibility="visible";this.el.style.height="auto";if(this.scrollNeutral){var newHt;if(this.el.parentNode.offsetHeight){newHt=this.el.parentNode.offsetHeight;}else{newHt=this.el.parentNode.clientHeight;}
window.scrollTo(this.origScrollState.scrollX,this.origScrollState.scrollY+(newHt-this.origHt));this.scrollNeutral=null;this.origHt=null;this.origScrollState=null;}
this.el=null;this.displayStyle=null;if(this.onComplete){setTimeout(this.onComplete,10);}}else{var Tpos=(time-this.startTime)/(this.duration);this.now=((-Math.cos(Tpos*Math.PI)/2)+0.5)*(this.to-this.from)+this.from;if(this.scrollNeutral){var oldHt;if(this.el.parentNode.offsetHeight){oldHt=this.el.parentNode.offsetHeight;}else{oldHt=this.el.parentNode.clientHeight;}
this.el.style.height=this.now+"px";if(this.el.parentNode.offsetHeight){newHt=this.el.parentNode.offsetHeight;}else{newHt=this.el.parentNode.clientHeight;}
window.scrollBy(0,newHt-oldHt);}else{this.el.style.height=this.now+"px";}
this.opnow=((-Math.cos(Tpos*Math.PI)/2)+0.5)*(this.opto-this.opfrom)+this.opfrom;if(this.opnow==1){this.opnow=0.9999;}
this.el.style.opacity=this.opnow;}}};kos.kslide.prototype={startAnimation:function(){this.el.style.display=kos.DISPLAY_BLOCK;if(this.el.offsetHeight){var panelHt=this.el.offsetHeight;}else{panelHt=this.el.clientHeight;}
if(this.hide){this.from=panelHt;this.to=0;}else{this.to=panelHt;this.from=0;if(!kos.isIE6Minus){this.el.style.position="fixed";}}
this.duration=500;this.startTime=new Date().getTime();this.timer=setInterval(this.step.bind(this),13);},step:function(){var winHt=kos.getWindowInnerHeight();if(kos.isIE6Minus){winHt=kos.getScrollState().scrollY+winHt;}
var time=new Date().getTime();if(time>=this.duration+this.startTime){clearInterval(this.timer);this.timer=null;this.now=this.to;if(this.hide){this.el.style.display=kos.DISPLAY_NONE;this.el.style.position="absolute";}else{this.el.style.top=((winHt-this.now)+1)+"px";}
this.el=null;}else{var Tpos=(time-this.startTime)/(this.duration);this.now=((-Math.cos(Tpos*Math.PI)/2)+0.5)*(this.to-this.from)+this.from;this.el.style.top=((winHt-this.now)+1)+"px";}}};kos.kpoll.prototype={startAnimation:function(){for(var p=0;p<this.prs.length;++p){if(window.ActiveXObject){this.prs[p].style.display=kos.DISPLAY_BLOCK;this.prs[p].firstChild.style.display=kos.DISPLAY_BLOCK;this.prs[p].lastChild.style.display=kos.DISPLAY_BLOCK;}
var backPos=this.prs[p].lastChild.style.backgroundPosition;this.prs[p].lastChild.toPosition=backPos;this.prs[p].lastChild.toPos=backPos.match(/-?\d+px/)[0].slice(0,-2);this.prs[p].lastChild.toPos-=-400;this.prs[p].firstChild.toPct=this.prs[p].firstChild.innerHTML.slice(0,-1);this.prs[p].firstChild.innerHTML="0%";this.prs[p].firstChild.style.width="9%";this.prs[p].lastChild.style.width="91%";this.prs[p].lastChild.toCt=this.prs[p].lastChild.firstChild.innerHTML;this.prs[p].lastChild.firstChild.innerHTML="0";this.prs[p].lastChild.style.backgroundPosition="-400px 0px";}
this.pollForm.className="voted";this.from=this.now=0;this.to=1.0;this.duration=2000;this.startTime=new Date().getTime();this.timer=setInterval(this.step.bind(this),13);},step:function(){var time=new Date().getTime();if(time>=this.duration+this.startTime){clearInterval(this.timer);this.timer=null;this.now=this.to;for(var p=0;p<this.prs.length;++p){this.prs[p].lastChild.style.backgroundPosition=this.prs[p].lastChild.toPosition;this.prs[p].lastChild.firstChild.innerHTML=this.prs[p].lastChild.toCt;this.prs[p].firstChild.innerHTML=this.prs[p].firstChild.toPct+"%";}
this.prs=null;log("kpoll complete.");}else{var Tpos=(time-this.startTime)/(this.duration);this.now=((-Math.cos(Tpos*Math.PI)/2)+0.5)*(this.to-this.from)+this.from;for(p=0;p<this.prs.length;++p){var newX=(Math.round(this.now*this.prs[p].lastChild.toPos)-400);this.prs[p].lastChild.style.backgroundPosition=newX+"px 0px";this.prs[p].lastChild.firstChild.innerHTML=Math.round(this.prs[p].lastChild.toCt*this.now);this.prs[p].firstChild.innerHTML=Math.round(this.now*this.prs[p].firstChild.toPct)+"%";}}}};function $(elId){return document.getElementById(elId);}
Function.prototype.bind=function(object){var __method=this;return function(){return __method.apply(object,arguments);};};function log(msg){if(kos.LOG){if(typeof msg=="string"){var isStr=true;var d=new Date().getTime();msg=d+" "+(d-kos.logtime)+": "+msg;kos.logtime=d;}
if(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1&&window.console){if(arguments.length>1){var args=[];for(var i=1;i<arguments.length;++i){args[i-1]=arguments[i];}
window.console.log(msg,args);}else{window.console.log(msg);}}else if(msg&&isStr){var feedback=$("feedback");if(!feedback){var body=document.getElementsByTagName('body')[0];if(document.body&&window.ActiveXObject){var feedhtml='<textarea id="feedback" style="width:900px;height:100px;margin:20px auto;"></textarea>';document.body.insertAdjacentHTML('afterBegin',feedhtml);}else if(body&&!window.ActiveXObject){feedback=document.createElement("textarea");feedback.id="feedback";feedback.style.width="500px";feedback.style.height="100px";feedback.style.margin="20px auto";feedback.style.clear="both";body.appendChild(feedback);}
feedback=$("feedback");}
if(feedback){if(kos.logBuffer){feedback.value+=kos.logBuffer;kos.logBuffer=null;}
feedback.value+=(msg+"\n");}else{if(!kos.logBuffer){kos.logBuffer="";}
kos.logBuffer+=(msg+"\n");document.title=msg;}}}}
log("comments.js loaded and running...");if((!kos.DISABLED)&&kos.checkRequirements()){log("Writing style override element...");document.write('<style type="text/css" media="all">.rab { display:none; }</style>');}
if(document.addEventListener){document.addEventListener("DOMContentLoaded",kos.init,null);}
window.onload=kos.nowFullyLoaded;

