
if(typeof(Prototype)!=="undefined"){jQuery.noConflict();}
jQuery(window).load(function(){if(window.location.hash.indexOf("#ping-")===0){jQuery(window.location.hash.replace("#ping-","#")).effect("highlight",{color:"#FAD678"},3000);}});new function($){$.fn.setCursorPosition=function(pos){if($(this).length===0)return;var el=$(this).get(0);if(el.setSelectionRange){el.setSelectionRange(pos,pos);}
else if(el.createTextRange){var range=el.createTextRange();range.collapse(true);range.moveEnd('character',pos);range.moveStart('character',pos);range.select();}}}(jQuery);jQuery(function($){function SubmitWikiForm(event,action){event.preventDefault();var f=$(event.target).closest("form").get(0);f.buttonPressed.value=action;f.submit();}
$(".wiki-edit").find(".toolbar").attr("style","").children("div").remove().end().end().find(".savebutton").click(function(e){SubmitWikiForm(e,'Submit');});$(".timeline").click(function(e){var $p=$(e.target).parent();if(!$(e.target).is("a")||!$p.is(".more.loader"))return true;e.preventDefault();$.get(e.target.href,function(data){$p.replaceWith(data);});$(e.target).replaceWith("<span class='spinner'></span>");});$("#explore").find("#explore-options").submit(function(e){e.preventDefault();}).click(function(e){if($(e.target).is("input:checkbox")){var $rows=$("#explore tr."+e.target.value);e.target.checked?$rows.show():$rows.hide();}}).end().find("table").tablesorter({cssAsc:"asc",cssDesc:"desc",textExtraction:function(node){var klass=$(node).children().eq(0).attr("class");return klass?klass:$(node).text();}});$('a[rel*=facebox]').facebox({opacity:0.5,loadingImage:'/_s/img/fb/loading.gif',closeImage:'/_s/img/fb/closelabel.png'})
function maxLength($form){return parseInt($form.attr("max"))||140;}
$(document).bind("counter",function(e){var interval=10;function updateCounters(){var found=0;$(".counter").each(function(){var $f=$(this).closest("form");var left=maxLength($f)-$f.find("textarea").eq(0).val().length;$(this).text(left);found++;});if(found)setTimeout(updateCounters,interval);}
setTimeout(updateCounters,interval);});function showError(text,form){var $err=$("h1:first + p.error");if($err.length===0)$err=$("<p class='error'></p>").insertAfter("h1:first");$(form).trigger("halt");$err.html(text);}
function reload(hash){window.location.reload(true);}
$("form.contribute").bind("reveal",function(e,action){this.action=action;var text="",m;if(m=action.match(/\bScreenName=(.*?)(&|$)/))text="@"+m[1]+" ";$(this).fadeIn(800).find("textarea").val(text).setCursorPosition(text.length);if((window.scrollY||document.body.scrollTop)!==0){$.scrollTo(this,{duration:800,axis:"y",offset:-15});}
$(document).trigger("counter");}).bind("hideaway",function(e){$(this).trigger("halt").fadeOut(200).find("textarea").val("").end().find(".gather-option input:checkbox").attr("checked",false).end().find(".gather-detail").hide();}).bind("spin",function(e){var $controls=$(".controls",this);var $spinner=$(".spinner",this);if($spinner.length===0){var pos=$controls.position();$spinner=$("<div class='spinner'><span>Submitting&hellip;</span></div>").css({"position":"absolute","top":pos.top,"left":pos.left,"height":$controls.height(),"width":$controls.width()}).insertAfter($controls);}
$controls.css("visibility","hidden");$spinner.show();}).bind("halt",function(e){$(".controls",this).css("visibility","visible");$(".spinner",this).hide();}).click(function(e){if($(e.target).hasClass("cancel")){$(this).trigger("hideaway");e.preventDefault();}}).submit(function(e){e.preventDefault();var form=this;var maxLen=maxLength($(form));function showCommentError(text){showError(text,form);}
if($.trim(form.Comment.value).length===0||$.trim(form.Comment.value).length>maxLen){showCommentError("Please enter a comment of one to "+maxLen+" characters.");return;}
var options={url:form.action,type:"POST",dataType:"json",data:$(form).serialize(),success:function(data,textStatus){if(data.status==="SUCCESS"){$(form).trigger("hideaway");reload("#ping-comment-"+data.commentId);}
else{showCommentError(data.errMsg||"");}},error:function(XMLHttpRequest,textStatus,errorThrown){if(console)console.log("ERROR!",textStatus||errorThrown);showCommentError("Contributions appear to be unavailable at the moment. Please try again in a little while.");},complete:function(){$(form).trigger("hideaway");}}
$(form).trigger("spin");$.ajax(options);}).find(".gather-option input:checkbox").click(function(e){$(this).closest("form").find(".gather-detail").toggle();}).end().find(".gather-detail").hide();$(".box .hd .contribute, .timeline .reply").live("click",function(e){var $f=$("form.contribute:first");if($f.length>0){$f.trigger("reveal",[$(this).attr("href")]);e.preventDefault();}});$(".timeline .spam").live("click",function(e){e.preventDefault();var options={url:this.href,type:"POST",dataType:"json",success:function(data,textStatus){if(data.status==="SUCCESS"){$(".timeline #comment-"+data.commentId).css("backgroundColor","#F6989C").fadeOut(1000);}
else{alert(data.errMsg||textStatus);}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Received an error while attempting to mark spam. Please try again, and report this issue to support if it persists.");}}
$.ajax(options);});$("form.login").bind("spin",function(){var $mask=$("#login-process-mask");if($mask.length===0){$mask=$("<div id='login-process-mask'><span>Logging in&hellip;</span></div>").height($(this).height()).width($(this).width()).insertAfter(this);}
$(this).hide();$mask.show();}).bind("halt",function(){$("#login-process-mask").hide();$(this).show();}).submit(function(e){e.preventDefault();var form=this;function showLoginError(text){showError(text,form);}
if($.trim(form.EmailAddress.value).length===0||$.trim(form.Password.value).length===0){showLoginError("Please enter both e-mail address and password to log in.");return;}
var options={url:form.action,type:"POST",dataType:"json",data:$(form).serialize(),success:function(data,textStatus){if(data.loginStatus==="Success"){window.location.replace(form.ReturnPage.value||"/index.cfm");}
else{showLoginError(data.errMsg||data.loginStatus);}},error:function(XMLHttpRequest,textStatus,errorThrown){if(console)console.log(textStatus||errorThrown);showLoginError("Login services appear to be unavailable at the moment. Please try again in a little while.");}}
$(form).trigger("spin");$.ajax(options);});});