var Previewstatus=false,Postingstatus=false;function exoSubmit(a){if(a==undefined)a=$("comment_form");if(a.elements.status.value=="login")exoLogin();else if(a.elements.status.value=="register")a.elements.confirm_password.value!=""&&exoRegister();else a.elements.status.value=="comment"&&PostComment()}function exoRequest(a,b,c){a=new Ajax.Request(b,{method:"post",parameters:c,onComplete:a,evalScripts:true,asynchronous:true})}
function exoRequestUpdate(a,b,c){a=new Ajax.Updater(a,b,{method:"post",parameters:c,evalScripts:true,asynchronous:true})}function exoRequestSilentUpdate(a,b,c){a=new Ajax.Updater(a,b,{method:"post",parameters:c,insertion:Insertion.Bottom})}
function exoLogin(){f=$("comment_form");var a=[];a.push("do=login");a.push(Form.Element.serialize(f.elements.username));a.push(Form.Element.serialize(f.elements.password));a.push(Form.Element.serialize(f.elements.remember));a.push(Form.Element.serialize(f.elements.entry_id));a.push(Form.Element.serialize(f.elements.post_id));a=a.join("&");exoRequestUpdate("exo_messages","/comment.php",a)}
function exoRegister(){f=$("comment_form");var a=[];a.push("do=register");a.push(Form.Element.serialize(f.elements.username));a.push(Form.Element.serialize(f.elements.password));a.push(Form.Element.serialize(f.elements.confirm_password));a.push(Form.Element.serialize(f.elements.email));a=a.join("&");exoRequestUpdate("exo_messages","/comment.php",a)}
function getLoginStatus(a){var b=$("comment_form");$("loginstatus").innerHTML=a.responseText;a=$("login");if(a.hasClassName("error")!=true){Element.show("postComment");Element.show("comment_textarea");$("LoginForm").style.display="none";$("post_button").value="submit comment";b.elements.status.value="comment"}}function getLogoutStatus(a){$("loginstatus").innerHTML=a.responseText}
function showForm(a){var b=$("comment_form");b.elements.text.value="";if(a=="RegisterForm"){Element.addClassName("loginWelcome","hide");Element.show("loginRegisterText");Element.show("RegisterForm");$("rememberMe").style.display="block";$("loginRegisterText").style.display="block";$("postComment").style.display="none";$("loginWelcome").style.display="none";$("post_button").value="register";b.elements.status.value="register";$("new_post").style.display="none"}else for(var c=document.getElementsByClassName("switchable"),
d=0;d<c.length;d++)c[d].style.display=c[d].id==a?"block":"none";if(a=="LogoutForm"){c=[];c.push("do=logout");c=c.join("&");exoRequestUpdate(getLogoutStatus,"/comment.php",c);showForm("LoginForm");$("postComment").style.display="none";$("loginWelcome").style.display="block";$("post_button").value="login";b.elements.status.value="login";$("comment_preview").style.display="none";$("loginstatus").style.display="none";$("login").style.display="none"}if(a=="LoginForm"){$("comment_textarea").style.display=
"none";$("rememberMe").style.display="block"}}function CommentPreview(){if(!Postingstatus)try{var a=$("comment_form"),b=$("comment_preview"),c=$("comment_preview_name"),d=$("comment_preview_body");$("comment_preview").style.display="block";if(Previewstatus==false){Previewstatus=true;c.innerHTML=a.elements.preview_name.value;b.style.display="block"}d.innerHTML=CleanComment(a.elements.text.value)}catch(e){alert(e)}}
function CleanComment(a){a=a.replace(/<a.*javascript:.*?>/ig,"");a=a.replace(/<a.*class=.*?>/ig,"");a=a.replace(/<a.*style=.*?>/ig,"");a=a.replace(/<a.*on\w+=.*?>/ig,"");a=a.replace(/<i.*class=.*?>/ig,"");a=a.replace(/<i.*style=.*?>/ig,"");a=a.replace(/<i.*on\w+=.*?>/ig,"");a=a.replace(/<b.*class=.*?>/ig,"");a=a.replace(/<b.*style=.*?>/ig,"");a=a.replace(/<b.*on\w+=.*?>/ig,"");a=a.replace(/<img.*?>/g,"");a=a.replace(/<(?!a.*?|\/a|b|\/b|i|\/i).*?>/ig,"");a=AutoLink(a);a=a.split(/\r?\n\r?\n/);var b=
"";for(i=0;i<a.length;i++){a[i]=a[i].strip();a[i]=a[i].replace(/\r?\n/g,"<br />\n");if(a[i].length>0)b+="<p>"+a[i]+"</p>"+(i+1<a.length?"\n":"")}return b=CleanQuotes(b)}function CleanQuotes(a){a=a.split("");var b="";for(i=0;i<a.length;i++){var c=a[i].charCodeAt(0);switch(c){case 8216:b+="'";break;case 8217:b+="'";break;case 8220:b+='"';break;case 8221:b+='"';break;case 8211:b+="-";break;case 8212:b+="-";break;default:b+=a[i]}}return b}
function AutoLink(a){a=" "+a;a=a.replace(/([^"=])(https?\:\/\/)([^,'"\s\<\>\)\]\!\/]*)((\/)(([^,'"\s\<\>\)\]\!]|[,])*))?/igm,'$1<a rel="nofollow" href="$2$3$4">[$3]</a>');a=a.substring(1,a.length);var b=new RegExp(/href.+>(.*?)<\/a>/g);if(b=b.exec(a))for(i=1;i<b.length;i+=2){var c=b[i];if(c.length>60){var d=c.substr(0,59),e=a.indexOf(c),g=a.substr(0,e);a=a.substr(e+c.length,a.length);a=g+d+"...</a>"+a}}return a}
function PostComment(a){if(a==undefined)a=$("comment_form");if(a.elements.text!=undefined&&a.elements.text.value!=""){var b=[];b.push("do=postcomment");var c=a.elements.text.value;a.elements.text.value=CleanComment(c);b.push(Form.Element.serialize(a.elements.text));b.push(Form.Element.serialize(a.elements.entry_id));b.push(Form.Element.serialize(a.elements.post_id));a.elements.text.value=c;b=b.join("&");exoRequestUpdate("exo_response","/comment.php",b)}}
function CommentSuccess(a){var b=$("comment_form"),c=[],d=$("comment_preview"),e=$("comment_preview_name"),g=$("comment_preview_body");c.push(a+"="+b.elements.entry_id.value);c=c.join("&");exoRequestSilentUpdate("comment_stretch","/comment.php",c);Previewstatus=false;b.elements.text.value="";d.style.display="none";e.innerHTML="";g.innerHTML=""};