
var memberId=null;var contentId=null;var coID;var nameDescriptor="Your name";var uwordDescriptor="Enter the code shown below";var memberSubmitButton="Sign In & Post Comment";var nonMemberSubmitButton="Post Comment";var totalCommentsFound=0;var totalCommentsShowing=50;var totalCommentsPosted=0;var commentSetSize=50;var loadInitialSet=true;if(loadInitialSet==false){totalCommentsShowing=0;}
var submitActive=false;Captcha={Load:function(el){if($(el)){var captchaID=(Math.floor(Math.random()*191))+1;$(el).innerHTML='<img src="http://images.eonline.com/static/redcarpet/globes2007/everywhere/shoutouts/images/'+captchaID+'.jpg" border="0" alt="" />'
+'<input type="hidden" value="'+captchaID+'" id="'+el+'_captchaID" class="hidden" />';}}}
Comments={AddFormDescriptors:function(){if($('comment_guest')){$('name').value=nameDescriptor;Event.observe('name','focus',function(){$('name').value='';});Event.observe('name','blur',function(){if($('name').value==''){$('name').value=nameDescriptor;}});$('uword').value=uwordDescriptor;Event.observe('uword','focus',function(){$('uword').value='';});Event.observe('uword','blur',function(){if($('uword').value==''){$('uword').value=uwordDescriptor;}});}},ChangeButtonStatus:function(){var buttonText=document.getElementById("anonPostButton");if(document.user_comments.passwd.value.length>0){buttonText.innerHTML=memberSubmitButton;}else{buttonText.innerHTML=nonMemberSubmitButton;}},DisableSubmitButton:function(){$("anonPostButton").innerHTML="Posting...";$("comment_text").addClassName("disabled");},EnableSubmitButton:function(){$("anonPostButton").innerHTML="Post Comment";$("comment_text").removeClassName("disabled");}}
PostComments={Save:function(edition,blog,url,contentDBID,memberId,commentId){if(submitActive!=true){submitActive=true;Comments.DisableSubmitButton();var isMemberComment=false;var isValid=true;if($('comments_message')){$('comments_message').remove();}
Delete_Cookie("PostCookie","/",".eonline.com");SetCookie("PostCookie",coID,5,"/",".eonline.com");var captchaId='';var captchaEntry='';if($('uword')){captchaEntry=hex_md5(document.getElementById('uword').value);captchaId=$F('comment_captcha_captchaID');}
if($('usrEmail').value==''){alert('You must enter your name.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}
if($('usrEmail').value==''){alert('You must enter a valid email address.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}else{if(PostComments.ValidateEmail($('usrEmail').value,1,1)==false){alert('You must enter a valid email address.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}}
if($('commentTextArea').value==''){alert('You must enter a comment.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}
var nextIndex=parseInt(totalCommentsFound)+1+totalCommentsPosted;var pars='mode=save'+'&contentDBID='+contentDBID+'&commentId='+commentId
+'&memberId='+memberId+'&pageURL='+url+'&blog='+blog+'&nextIndex='+nextIndex
+'&captchaId='+captchaId+'&comment='+escape($('commentTextArea').value);if($('usrEmail')&&$('passwd')){if($('passwd').value!='')isMemberComment=true;pars=pars+'&memberEmail='+$('usrEmail').value+'&password='+$('passwd').value;}
if($('name')&&!isMemberComment){if($('name').value=='Your name'){alert('You must enter a username.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}
if($('uword').value=='Enter the code shown below'||$('uword').value==''){alert('You must enter a valid captcha entry.');isValid=false;Comments.EnableSubmitButton();submitActive=false;}
pars=pars+'&username='+$('name').value+'&captcha='+captchaEntry;}
if(isValid){new Ajax.Updater('comments_set','/mystyle/comments/service/editComment.jsp?'+pars,{insertion:Insertion.Bottom,onComplete:function(){Captcha.Load('comment_captcha');if($('uword'))$('uword').value='';new Effect.Highlight('comments_message');},onSuccess:function(){$('commentTextArea').value='';totalCommentsPosted++;$$('.total_comments').each(function(e){e.update(parseInt(totalCommentsFound)+1);});if(isMemberComment){$('comment_guest').hide();$('comment_member').hide();};alert("Thanks! Your comment has been sent to our moderators for review.");Comments.EnableSubmitButton();submitActive=false;},onFailure:function(){Comments.EnableSubmitButton();submitActive=false;}});}}},Delete:function(commentId){var pars='commentId='+commentId+'&mode=delete';new Ajax.Request('/mystyle/comments/service/editComment.jsp?'+pars);},ReportAbuse:function(commentId){var confirmReport="Report this comment as inappropriate?\n\nIf you feel this comment is inappropriate and feel it should be removed from the E! Online site, let us know by clicking 'OK' below. This will notify us and we can take appropriate action.";var pars='commentId='+commentId+'&mode=report';if(confirm(confirmReport)){new Ajax.Request('/mystyle/comments/service/editComment.jsp?'+pars,{onComplete:function(){alert("Thank you for your input\n\nThis commment has been reported.  We will review this information and take appropriate action");$('report_'+commentId).update('This comment has been reported.');$('report_'+commentId).removeAttribute('href');$('report_'+commentId).addClassName('reported');}});}},GiveProps:function(commentId){var pars='commentId='+commentId+'&mode=props';new Ajax.Request('/mystyle/comments/service/editComment.jsp?'+pars);},ValidateEmail:function(addr,man,db){if(addr=='')return true;var invalidChars='\/\'\\ ";:?!()[]\{\}^|';for(i=0;i<invalidChars.length;i++){if(addr.indexOf(invalidChars.charAt(i),0)>-1){if(db)
return false;}}
for(i=0;i<addr.length;i++){if(addr.charCodeAt(i)>127){if(db)
return false;}}
var atPos=addr.indexOf('@',0);if(atPos==-1){if(db)
return false;}
if(atPos==0){if(db)
return false;}
if(addr.indexOf('@',atPos+1)>-1){if(db)
return false;}
if(addr.indexOf('.',atPos)==-1){if(db)
return false;}
if(addr.indexOf('@.',0)!=-1){if(db)
return false;}
if(addr.indexOf('.@',0)!=-1){if(db)
return false;}
if(addr.indexOf('..',0)!=-1){if(db)
return false;}
var suffix=addr.substring(addr.lastIndexOf('.')+1);if(suffix.length!=2&&suffix!='com'&&suffix!='net'&&suffix!='org'&&suffix!='edu'&&suffix!='int'&&suffix!='mil'&&suffix!='gov'&suffix!='arpa'&&suffix!='biz'&&suffix!='aero'&&suffix!='name'&&suffix!='coop'&&suffix!='info'&&suffix!='pro'&&suffix!='museum'){if(db)
return false;}
return true;}}
GetComments={CalculateNextSetSize:function(){var commentsRemaining=totalCommentsFound-totalCommentsShowing;if(commentsRemaining<commentSetSize){commentSetSize=commentsRemaining;}},GetNextPage:function(){contentId=$('contentId').value;memberId=$('memberId').value;GetComments.CalculateNextSetSize();new Ajax.Updater('display_next_set','/mystyle/comments/service/getPageOfComments.jsp',{method:'get',insertion:Insertion.Before,onComplete:function(){GetComments.TogglePreloader();},parameters:{offset:totalCommentsShowing,length:commentSetSize,memberId:memberId,contentId:contentId}});totalCommentsShowing=totalCommentsShowing+commentSetSize;var linkText="Im empty";var commentsRemaining=0;if(totalCommentsShowing<totalCommentsFound){GetComments.CalculateNextSetSize();linkText="Show the next "+(totalCommentsShowing+1)+" - "+(totalCommentsShowing+commentSetSize)+" of "+totalCommentsFound+" comments";$('display_next_link').innerHTML=linkText;}else{$('display_next_set').hide();}},TogglePreloader:function(){if($('preloader_graphic').style.display=="block"){$('preloader_graphic').style.display='none';}else{$('preloader_graphic').style.display='block';}}}
Event.observe(window,'load',function(){totalCommentsFound=$('totalComments').value;if($('display_next_link')){Event.observe('display_next_link','click',function(){GetComments.TogglePreloader();GetComments.GetNextPage();});};if(loadInitialSet==false&&totalCommentsFound>0){GetComments.TogglePreloader();GetComments.GetNextPage();}
Captcha.Load('comment_captcha');Comments.AddFormDescriptors();});
