var Mustache=function(){var b=function(){};b.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":true},render:function(f,e,d,g){if(f.indexOf(this.otag)==-1){if(g){return f}else{this.send(f);return}}if(!g){this.buffer=[]}f=this.render_pragmas(f);var c=this.render_section(f,e,d);if(g){return this.render_tags(c,e,d,g)}this.render_tags(c,e,d,g)},send:function(c){if(c!=""){this.buffer.push(c)}},render_pragmas:function(c){if(c.indexOf(this.otag+"%")==-1){return c}var e=this;var d=new RegExp(this.otag+"%([\\w_-]+) ?([\\w]+=[\\w]+)?"+this.ctag);return c.replace(d,function(h,f,g){if(!e.pragmas_implemented[f]){throw ({message:"This implementation of mustache doesn't understand the '"+f+"' pragma"})}e.pragmas[f]={};if(g){var i=g.split("=");e.pragmas[f][i[0]]=i[1]}return""})},render_partial:function(c,e,d){if(!d||!d[c]){throw ({message:"unknown_partial '"+c+"'"})}if(typeof(e[c])!="object"){return d[c]}return this.render(d[c],e[c],d,true)},render_section:function(e,d,c){if(e.indexOf(this.otag+"#")==-1){return e}var g=this;var f=new RegExp(this.otag+"\\#(.+)"+this.ctag+"\\s*([\\s\\S]+?)"+this.otag+"\\/\\1"+this.ctag+"\\s*","mg");return e.replace(f,function(i,h,j){var k=g.find(h,d);if(g.is_array(k)){return g.map(k,function(l){return g.render(j,g.merge(d,g.create_context(l)),c,true)}).join("")}else{if(k){return g.render(j,d,c,true)}else{return""}}})},render_tags:function(k,c,e,g){var f=this;var j=function(){return new RegExp(f.otag+"(=|!|>|\\{|%)?([^/#]+?)\\1?"+f.ctag+"+","g")};var h=j();var l=k.split("\n");for(var d=0;d<l.length;d++){l[d]=l[d].replace(h,function(n,i,m){switch(i){case"!":return n;case"=":f.set_delimiters(m);h=j();return"";case">":return f.render_partial(m,c,e);case"{":return f.find(m,c);default:return f.escape(f.find(m,c))}},this);if(!g){this.send(l[d])}}if(g){return l.join("\n")}},set_delimiters:function(d){var c=d.split(" ");this.otag=this.escape_regex(c[0]);this.ctag=this.escape_regex(c[1])},escape_regex:function(d){if(!arguments.callee.sRE){var c=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+c.join("|\\")+")","g")}return d.replace(arguments.callee.sRE,"\\$1")},find:function(c,d){c=this.trim(c);if(typeof d[c]==="function"){return d[c].apply(d)}if(d[c]!==undefined){return d[c]}return""},escape:function(c){return((c==null)?"":c).toString().replace(/[&"<>\\]/g,function(d){switch(d){case"&":return"&amp;";case"\\":return"\\\\";case'"':return'"';case"<":return"&lt;";case">":return"&gt;";default:return d}})},merge:function(d,c){var f={};for(var e in d){if(d.hasOwnProperty(e)){f[e]=d[e]}}for(var e in c){if(c.hasOwnProperty(e)){f[e]=c[e]}}return f},create_context:function(d){if(this.is_object(d)){return d}else{if(this.pragmas["IMPLICIT-ITERATOR"]){var e=this.pragmas["IMPLICIT-ITERATOR"].iterator||".";var c={};c[e]=d;return c}}},is_object:function(c){return c&&typeof c=="object"},is_array:function(c){return Object.prototype.toString.call(c)==="[object Array]"},trim:function(c){return c.replace(/^\s*|\s*$/g,"")},map:function(g,e){if(typeof g.map=="function"){return g.map(e)}else{var f=[];var c=g.length;for(var d=0;d<c;d++){f.push(e(g[d]))}return f}}};return({name:"mustache.js",version:"0.2.3-dev",to_html:function(e,c,d,g){var f=new b();if(g){f.send=g}f.render(e,c,d);if(!g){return f.buffer.join("\n")}}})}();(function($){$.toJSON=function(o){if(typeof(JSON)=="object"&&JSON.stringify){return JSON.stringify(o)}var type=typeof(o);if(o===null){return"null"}if(type=="undefined"){return undefined}if(type=="number"||type=="boolean"){return o+""}if(type=="string"){return $.quoteString(o)}if(type=="object"){if(typeof o.toJSON=="function"){return $.toJSON(o.toJSON())}if(o.constructor===Date){var month=o.getUTCMonth()+1;if(month<10){month="0"+month}var day=o.getUTCDate();if(day<10){day="0"+day}var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10){hours="0"+hours}var minutes=o.getUTCMinutes();if(minutes<10){minutes="0"+minutes}var seconds=o.getUTCSeconds();if(seconds<10){seconds="0"+seconds}var milli=o.getUTCMilliseconds();if(milli<100){milli="0"+milli}if(milli<10){milli="0"+milli}return'"'+year+"-"+month+"-"+day+"T"+hours+":"+minutes+":"+seconds+"."+milli+'Z"'}if(o.constructor===Array){var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i])||"null")}return"["+ret.join(",")+"]"}var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number"){name='"'+k+'"'}else{if(type=="string"){name=$.quoteString(k)}else{continue}}if(typeof o[k]=="function"){continue}var val=$.toJSON(o[k]);pairs.push(name+":"+val)}return"{"+pairs.join(", ")+"}"}};$.evalJSON=function(src){if(typeof(JSON)=="object"&&JSON.parse){return JSON.parse(src)}return eval("("+src+")")};$.secureEvalJSON=function(src){if(typeof(JSON)=="object"&&JSON.parse){return JSON.parse(src)}var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,"@");filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,"");if(/^[\],:{}\s]*$/.test(filtered)){return eval("("+src+")")}else{throw new SyntaxError("Error parsing JSON, source is not valid.")}};$.quoteString=function(string){if(string.match(_escapeable)){return'"'+string.replace(_escapeable,function(a){var c=_meta[a];if(typeof c==="string"){return c}c=a.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16)})+'"'}return'"'+string+'"'};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}})(jQuery);var bccs_helpers={flag_url:function(b){return bccs_helpers.profile_server_url()+"/comments/"+b+"/flag.js"},reject_url:function(b){return bccs_helpers.profile_server_url()+"/comments/"+b+"/reject.js"},comments_url:function(){return bccs_helpers.profile_server_url()+"/comments.json?commentable_url="+bccs_helpers.commentable_url()},create_comment_url:function(){return bccs_helpers.profile_server_url()+"/comments/create.json"},log_in_url:function(){return bccs_helpers.profile_server_url()+"/log_in?return_to="+window.location.href},log_out_url:function(){return bccs_helpers.profile_server_url()+"/log_out?return_to="+window.location.href},change_avatar_url:function(){return bccs_helpers.profile_server_url()+"/edit_my_info/avatar"},profile_server_url:function(){if(window.location.host.match(/stage/)){var b="profile-stage"}else{if(window.location.host.match(/local/)){var b="profile-local"}else{var b="profile"}}return"http://"+b+"."+bccs_helpers.domain()},domain:function(){var c=window.location.host.split(".");var b=c[c.length-1];var d=c[c.length-2];return d+"."+b},avatar_image_tag:function(c){var b=bccs_helpers.profile_server_url().replace("-stage","")+"/api/avatars/"+c;return'<img src="'+b+'" width="55" height="55" class="bccs-avatar"/>'},cookie_domain:function(){return"."+bccs_helpers.domain()},user_info_url:function(b){if(b){return bccs_helpers.profile_server_url()+"/api/users/sat/"+b+".json"}else{return""}},commentable_url:function(){if(typeof(bccs_commentable_url)=="undefined"){var d=window.location.href;var b=d.indexOf("#");var c=d.indexOf("?");if(b!=-1){d=d.substring(0,b)}else{if(c!=-1){d=d.substring(0,c)}}return d}else{return bccs_commentable_url}},add_script_tag:function(c){var b='<script type="text/javascript" src="'+c+'"><\/script>';document.write(b)},add_stylesheet_tag:function(c){var b='<link href="'+c+'" media="screen" rel="stylesheet" type="text/css" />';document.write(b)}};jQuery.preloadImages=function(){for(var b=0;b<arguments.length;b++){jQuery("<img>").attr("src",arguments[b])}};var DateHelper={time_ago_in_words_with_parsing:function(c){a=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(c);if(a){var b=new Date(Date.UTC(+a[1],+a[2]-1,+a[3],+a[4],+a[5],+a[6]))}else{var b=Date.parse(c)}return this.time_ago_in_words(b)},time_ago_in_words:function(b){return this.distance_of_time_in_words(new Date,b)},distance_of_time_in_words:function(e,d){var c=((e-d)/1000);var b=Math.floor(c/60);if(b==0){return"less than a minute ago"}if(b==1){return"a minute ago"}if(b<45){return b+" minutes ago"}if(b<90){return"about 1 hour ago"}if(b<1440){return"about "+Math.floor(b/60)+" hours ago"}if(b<2880){return"1 day ago"}if(b<43200){return Math.floor(b/1440)+" days ago"}if(b<86400){return"about 1 month ago"}if(b<525960){return Math.floor(b/43200)+" months ago"}if(b<1051199){return"about 1 year ago"}return"over "+Math.floor(b/525960)+" years ago"}};var bccs_templates={comment_form:function(){return'			<div id="bccs-user-info">				{{{avatar_image_tag}}}				<a href="{{ change_avatar_url }}">Edit Pic</a>				<a href="{{ log_out_url }}" id="bccs-log-out-link">Log out</a>			</div>			<div class="bccs-comment-body">			<form action="{{ create_comment_url }}" method="get">				<p><textarea cols="50" id="bccs-comment-body" name="comment[body]" rows="5"></textarea></p>				<p class="bccs-form-submit">					<input type="submit" name="commit" value="Post"/>				</p>				<input type="hidden" name="comment[commentable_url]" value="{{ url }}"/>				<input type="hidden" name="comment[referrer]" value="{{ referrer }}"/>				<input type="hidden" name="uuid" value="{{ uuid }}"/>			</form> <!-- end #bccs-comment-form -->			</div> 		'},render_comment_form:function(){var b=bccs_auth.current_user();var c={url:bccs_helpers.commentable_url(),create_comment_url:bccs_helpers.create_comment_url(),username:b.username,avatar_image_tag:bccs_helpers.avatar_image_tag(b.uuid),change_avatar_url:bccs_helpers.change_avatar_url(),log_out_url:bccs_helpers.log_out_url(),uuid:b.uuid,referrer:document.referrer};return Mustache.to_html(bccs_templates.comment_form(),c)},log_in_link:function(){return'<p id="bccs-log-in-link"><a href="{{ log_in_url }}">Log in to comment</a></p>'},render_log_in_link:function(){return Mustache.to_html(bccs_templates.log_in_link(),{log_in_url:bccs_helpers.log_in_url()})},comment:function(){return'			<li class="bccs-comment clearfix">				<div id="bccs-user-info">					{{{avatar_image_tag}}}				</div>				<div class="bccs-comment-body">					<div class="bccs-who">by <em><strong>{{ author_username }}</strong></em>, <span class="bccs-created">{{ created_at }}</span></div>					<div class="bccs-textiled">						{{{ body }}}					</div>					<div class="bccs-mod-link">						{{#is_not_admin}}							<a href="{{ flag_url }}" class="flag">Bad Words!</a>						{{/is_not_admin}}						{{#is_admin}}								<a href="{{ reject_url }}" class="reject">Reject!</a>						{{/is_admin}}					</div>				</div> <!-- end .bccs-comment-body -->			</li>'},render_comment:function(d){var b=bccs_auth.current_user();var c={created_at:DateHelper.time_ago_in_words_with_parsing(d.created_at),body:d.body,author_username:d.author.username,flag_url:bccs_helpers.flag_url(d.id),reject_url:bccs_helpers.reject_url(d.id),avatar_image_tag:bccs_helpers.avatar_image_tag(d.author.uuid),is_admin:function(){if(typeof(b)!="undefined"&&b.admin=="true"){return true}else{return false}},is_not_admin:function(){if(typeof(b)=="undefined"||b.admin!="true"){return true}else{return false}}};return Mustache.to_html(bccs_templates.comment(),c)}};var bccs_current_user;var bccs_auth={initialize:function(){if($.cookie("sat")&&$.cookie("bccs")){bccs_auth.logged_in()}else{if($.cookie("sat")){bccs_auth.initialize_current_user($.cookie("sat"))}else{bccs_auth.logged_out()}}},logged_in:function(){bccs.insert_comment_form()},logged_out:function(){$.cookie("bccs",null,{path:"/",domain:bccs_helpers.cookie_domain()});$.cookie("sat",null,{path:"/",domain:bccs_helpers.cookie_domain()});bccs.insert_log_in_link()},initialize_current_user:function(b){var c=bccs_helpers.user_info_url(b);if(c!=""){$.ajax({url:c,dataType:"jsonp",data:null,success:function(d){if(typeof(d.error)=="undefined"){bccs_auth.set_current_user(d);bccs_auth.logged_in()}else{bccs_auth.logged_out()}}})}},set_current_user:function(c){bccs_current_user=c;var d=new Date(),b=new Date(d);b.setMinutes(d.getMinutes()+20);$.cookie("bccs",$.toJSON(c),{expires:b,path:"/",domain:bccs_helpers.cookie_domain()});return bccs_current_user},current_user:function(){if(typeof(bccs_current_user)==="undefined"&&$.cookie("bccs")){bccs_current_user=$.evalJSON($.cookie("bccs"))}return bccs_current_user}};var bccs={comment_default_text:"Post a comment!",initialize:function(){bccs_auth.initialize();bccs.init_comments();bccs.init_loaders();bccs.init_ga()},insert_comment_form:function(){$("#bccs-comment-form").append(bccs_templates.render_comment_form());$("#bccs-comment-form form").ajaxForm({clearForm:true,dataType:"jsonp",beforeSubmit:bccs.prevent_bad_comments,success:function(b){if(typeof(b.error)=="undefined"){bccs.insert_new_comment(b)}$(".bccs-form-submit").removeClass("loading");bccs.init_comment_defaults()},error:function(b,d,c){alert("there was an error")}});bccs.init_comment_defaults()},prevent_bad_comments:function(){var b=$("#bccs-comment-form form textarea").val();if(b==bccs.comment_default_text||b==""){$(".bccs-form-submit").removeClass("loading");return false}},init_comment_defaults:function(){var b=$("#bccs-comment-form textarea");b.val(bccs.comment_default_text);b.focus(function(){b.val("")}).blur(function(){var c=b.val();if(c==""){b.val(bccs.comment_default_text)}})},insert_new_comment:function(b){$("#bccs-comments").prepend(bccs_templates.render_comment(b))},init_comments:function(){$("#bccs-comments").after('<p class="bccs-load-comments"><a href="">Load more comments</a></p>');bccs.load_comments(1);bccs.load_more_comments();bccs.init_moderation()},init_moderation:function(){$("#bccs-comments").click(function(c){var b=$(c.target).closest(".bccs-mod-link a");if(b&&b.attr("href")){$.ajax({url:b.attr("href"),dataType:"jsonp",data:null,success:function(d){if(b.attr("class")=="flag"){b.replaceWith("<span>"+d.message+"</span>")}else{b.parents(".bccs-comment").fadeOut("slow",function(){$(this).remove()})}}});return false}})},load_more_comments:function(){$(".bccs-load-comments").click(function(){var c=$("#bccs ol .bccs-comment").length;var b=Math.ceil((c/10)+1);bccs.load_comments(b);return false})},load_comments:function(b){$.ajax({url:bccs_helpers.comments_url(),dataType:"jsonp",data:{page:b},success:function(c){$.each(c,function(d,e){$("#bccs-comments").append(bccs_templates.render_comment(e))});$(".bccs-load-comments").removeClass("loading")}})},insert_log_in_link:function(){$("#bccs-comment-form").append(bccs_templates.render_log_in_link())},init_loaders:function(){$.preloadImages(bccs_helpers.profile_server_url()+"/images/bccs/ajax-loader.gif");$(".bccs-form-submit input, .bccs-load-comments a").click(function(){$(this).parent().addClass("loading")})},init_ga:function(){$(".bccs-form-submit input").click(function(){if(typeof(_gaq)!="undefined"){_gaq.push(["t1._trackEvent","comment","submitted"])}})}};document.write('<div id="bccs">');bccs_helpers.add_stylesheet_tag(bccs_helpers.profile_server_url()+"/stylesheets/bccs/main.css");document.write('<div id="bccs-comment-form" class="bccs-comment clearfix"></div>');document.write('<ol id="bccs-comments"></ol>');document.write("</div>");$(document).ready(bccs.initialize);