var previewComment=function()
{comment_body=$('comment_preview_inner');comment_author=$('preview_name');body_text=$('root_comment_text').value;re=/<\S[^>]*>/g;body_text=body_text.replace(re,"");comment_body.innerHTML=body_text.replace(/\r|\n/g,'<br \/>');HuffPoUtil.show('comment_preview');HuffPoUtil.hide('comment_meta');};var previewCommentForReply=function(cmt_id)
{comment_body=$('comment_preview_inner_'+cmt_id);comment_author=$('preview_name_'+cmt_id);body_text=$('comment_text_'+cmt_id).value;re=/<\S[^>]*>/g;body_text=body_text.replace(re,"");comment_body.innerHTML=body_text.replace(/\r|\n/g,'<br \/>');HuffPoUtil.show('comment_preview_'+cmt_id);HuffPoUtil.hide('comment_meta_'+cmt_id);};var Comments={maxWords:350,lengthOkay:function(el){over=0;this.trimmed=$(el).value;if(this.trimmed.match(/\S/))
{this.trimmed=this.trimmed.replace(/^[\s._\-*+&?\/\\]+/,'');this.trimmed=this.trimmed.replace(/[\s._\-*+&?\/\\]$/,'');}
this.chunkedText=this.trimmed.split(/[\s._\-*+&?\/\\]+/);if(this.chunkedText.length>this.maxWords)
return(this.chunkedText.length-this.maxWords);else if(this.trimmed==''||!$(el).value||$(el).value=='')
return-1;else
return 0;},alertEmpty:function(){alert("Your comment is empty. Please type a comment, then click POST again.");},alertTooLong:function(over){alert("Your comment is too long by "+over+" "+(over==1?'word':'words')+". The maximum length is "+this.maxWords+" words. Please edit your comment and click POST again.");},addComment:function(){var over=this.lengthOkay('root_comment_text');if(over==0){$('post_button_new').disabled=true;HuffPoUtil.hide('post_button_new');D.setStyle('post_spinner_new','display','inline');YAHOO.util.Connect.setForm('comments_form_new');var co=YAHOO.util.Connect.asyncRequest('POST','/comment/postComment.php',this);}else if(over>0){this.alertTooLong(over);}else if(over<0)
this.alertEmpty();},addCommentAsReply:function(parent_id){var over=this.lengthOkay('comment_text_'+parent_id);if(over==0){$('post_button_'+parent_id).disabled=true;HuffPoUtil.hide('post_button_'+parent_id);D.setStyle('post_spinner_'+parent_id,'display','inline');YAHOO.util.Connect.setForm('comments_form_'+parent_id);var co=YAHOO.util.Connect.asyncRequest('POST','/comment/postComment.php',this);}else if(over>0){this.alertTooLong(over);}else if(over<0)
this.alertEmpty();},scrollToComment:function(id){scrollToAnchor('comment_'+id);},scrollToParent:function(id){this.scrollToComment(id);Fat.fade_element('comment_'+id,30,1000);},success:function(o){splits=o.responseText.split(':::');new_html=splits[0];is_new=splits[1]=='new'?true:false;if(!is_new)
var cmt_parent_id=Math.floor(splits[1])+0;cmt_id=splits[2];if(!is_new){var el=$('comment_children_'+cmt_parent_id);$('post_button_'+cmt_parent_id).disabled=false;$('comment_text_'+cmt_parent_id).value='';D.setStyle('post_button_'+cmt_parent_id,'display','inline');D.setStyle('post_spinner_'+cmt_parent_id,'display','none');HuffPoUtil.hide('reply_'+cmt_parent_id);HuffPoUtil.hide('comment_preview_'+cmt_parent_id);Fat.fade_element('comment_children_'+cmt_parent_id);}else{var el=$('comments_inner');$('post_button_new').disabled=false;$('root_comment_text').value='';D.setStyle('post_button_new','display','inline');D.setStyle('post_spinner_new','display','none');Fat.fade_element('comment_'+cmt_id);}
el.innerHTML+=new_html;this.scrollToComment(cmt_id);HuffPoUtil.hide('comment_preview');}}
var Fat={make_hex:function(r,g,b)
{r=r.toString(16);if(r.length==1)r='0'+r;g=g.toString(16);if(g.length==1)g='0'+g;b=b.toString(16);if(b.length==1)b='0'+b;return"#"+r+g+b;},fade_all:function()
{var a=document.getElementsByTagName("*");for(var i=0;i<a.length;i++)
{var o=a[i];var r=/fade-?(\w{3,6})?/.exec(o.className);if(r)
{if(!r[1])r[1]="";if(o.id)Fat.fade_element(o.id,null,null,"#"+r[1]);}}},fade_element:function(id,fps,duration,from,to)
{if(!fps)fps=30;if(!duration)duration=3000;if(!from||from=="#")from="#FFFF33";if(!to)to=this.get_bgcolor(id);var frames=Math.round(fps*(duration/1000));var interval=duration/frames;var delay=interval;var frame=0;if(from.length<7)from+=from.substr(1,3);if(to.length<7)to+=to.substr(1,3);var rf=parseInt(from.substr(1,2),16);var gf=parseInt(from.substr(3,2),16);var bf=parseInt(from.substr(5,2),16);var rt=parseInt(to.substr(1,2),16);var gt=parseInt(to.substr(3,2),16);var bt=parseInt(to.substr(5,2),16);var r,g,b,h;while(frame<frames)
{r=Math.floor(rf*((frames-frame)/frames)+rt*(frame/frames));g=Math.floor(gf*((frames-frame)/frames)+gt*(frame/frames));b=Math.floor(bf*((frames-frame)/frames)+bt*(frame/frames));h=this.make_hex(r,g,b);setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')",delay);frame++;delay=interval*frame;}
setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')",delay);},set_bgcolor:function(id,c)
{var o=document.getElementById(id);o.style.backgroundColor=c;},get_bgcolor:function(id)
{var o=document.getElementById(id);while(o)
{var c;if(window.getComputedStyle)c=window.getComputedStyle(o,null).getPropertyValue("background-color");if(o.currentStyle)c=o.currentStyle.backgroundColor;if((c!=""&&c!="transparent")||o.tagName=="BODY"){break;}
o=o.parentNode;}
if(c==undefined||c==""||c=="transparent")c="#FFFFFF";var rgb=c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);if(rgb)c=this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));return c;}}
var scrollInt;var scrTime,scrSt,scrDist,scrDur,scrInt;function scrollPage()
{scrTime+=scrInt;if(scrTime<scrDur){window.scrollTo(0,easeInOut(scrTime,scrSt,scrDist,scrDur));}else{window.scrollTo(0,scrSt+scrDist);clearInterval(scrollInt);}}
function scrollToAnchor(aname)
{var anchors,i,ele;if(!document.getElementById)
return;anchors=document.getElementsByTagName("div");for(i=0;i<anchors.length;i++){if(anchors[i].id==aname){ele=anchors[i];i=anchors.length;}}
if(window.scrollY)
scrSt=window.scrollY;else if(document.documentElement.scrollTop)
scrSt=document.documentElement.scrollTop;else
scrSt=document.body.scrollTop;scrDist=ele.offsetTop-scrSt;scrDur=100;scrTime=0;scrInt=10;clearInterval(scrollInt);scrollInt=setInterval(scrollPage,scrInt);}
function easeInOut(t,b,c,d)
{return c/2*(1-Math.cos(Math.PI*t/d))+b;}