'use strict';(function(e){function c(){this._events={};this._maxListeners=10}function b(a,b,d,c,e){this.type=a;this.listener=b;this.scope=d;this.once=c;this.instance=e}b.prototype.fire=function(a){this.listener.apply(this.scope||this.instance,a);if(this.once)return this.instance.removeListener(this.type,this.listener,this.scope),!1};c.prototype.eachListener=function(a,b){var d=null,c=null,e=null;if(this._events.hasOwnProperty(a)){c=this._events[a];for(d=0;d<c.length;d+=1)if(e=b.call(this,c[d],d),
!1===e)d-=1;else if(!0===e)break}return this};c.prototype.addListener=function(a,f,d,c){this._events.hasOwnProperty(a)||(this._events[a]=[]);this._events[a].push(new b(a,f,d,c,this));this.emit("newListener",a,f,d,c);this._maxListeners&&!this._events[a].warned&&this._events[a].length>this._maxListeners&&("undefined"!==typeof console&&console.warn("Possible EventEmitter memory leak detected. "+this._events[a].length+" listeners added. Use emitter.setMaxListeners() to increase limit."),this._events[a].warned=
!0);return this};c.prototype.on=c.prototype.addListener;c.prototype.once=function(a,b,d){return this.addListener(a,b,d,!0)};c.prototype.removeListener=function(a,b,d){this.eachListener(a,function(c,e){c.listener===b&&(!d||c.scope===d)&&this._events[a].splice(e,1)});this._events[a]&&0===this._events[a].length&&delete this._events[a];return this};c.prototype.off=c.prototype.removeListener;c.prototype.removeAllListeners=function(a){a&&this._events.hasOwnProperty(a)?delete this._events[a]:a||(this._events=
{});return this};c.prototype.listeners=function(a){if(this._events.hasOwnProperty(a)){var b=[];this.eachListener(a,function(a){b.push(a.listener)});return b}return[]};c.prototype.emit=function(a){for(var b=[],d=null,d=1;d<arguments.length;d+=1)b.push(arguments[d]);this.eachListener(a,function(a){return a.fire(b)});return this};c.prototype.setMaxListeners=function(a){this._maxListeners=a;return this};"function"===typeof define&&define.amd?define(function(){return c}):e.EventEmitter=c})(this);
StackExchange.realtime=function(){function e(a){StackExchange.options.user.isDeveloper&&console.log(a)}function c(){p.on("hb",function(a){l.send(a)})}function b(a){v?(e("sending: "+a),l.send(a)):u.push(a)}function a(a,b){1!=$("#vote-accepted-"+a.answerid).length&&($(".vote-accepted-on").remove(),b||$('.vote input[value="'+a.answerid+'"]').parent().append('<span class="vote-accepted-on" title="The question owner accepted this as the best answer">accepted</span>'))}function f(){$("#new-post-activity").remove();
$("#answers-header").prepend(q)}function d(a){var b=$(".question[data-questionid="+a.id+"], .answer[data-answerid="+a.id+"]").find(".postcell, .answercell");0<b.find("#new-post-activity").length||b.prepend('<div id="new-post-activity">an edit has been made to this post: show the <a href="/posts/'+a.id+'/revisions">revision</a></div>').click(function(){$.get("/posts/"+a.id+"/ajax-load-mini",r(b,a))})}function h(a,b){return a.index<b.index?-1:a.index>b.index?1:0}function j(){$("#new-post-activity").remove();
var a=o.sort(h),b;for(b in a){var d=a[b];$("#question-summary-"+d.id).remove();$(d.body).prependTo("#question-mini-list, #questions").hide().fadeIn()}i(0);null!=StackExchange.options.user.accountId&&StackExchange.tagPreferences.applyPrefs(!0,t);"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]);k();o=[]}function i(a){var b=document.title.replace(/^\(\d*\*?\) /,"");0<a&&(b="("+a+") "+b);window.setTimeout(function(){$(document).attr("title",b)},200)}function k(){for(var a=$("span.relativetime"),
b=0;b<a.length;b++)if(a[b].title){var d;d=new Date(a[b].title);d=((new Date).getTime()-d.getTime())/1E3;var c=Math.floor(d/86400);if(d=isNaN(c)||0>c||31<=c?void 0:0==c&&(2>d&&"just now"||60>d&&Math.floor(d)+(s?"s ago":" secs ago")||120>d&&(s?"1m ago":"1 min ago")||3600>d&&Math.floor(d/60)+(s?"m ago":" mins ago")||7200>d&&(s?"1h ago":"1 hour ago")||86400>d&&Math.floor(d/3600)+(s?"h ago":" hours ago")))a[b].innerHTML=d}}var g,l,o=[],n=[],m=0,u=[],v=!1,s=!1,t,p=new EventEmitter,q=function(){var a=Object.keys(n).length;
return $('<div id="new-post-activity">'+a+" new answer"+(1<a?"s":"")+" to this question</div>").click(function(){StackExchange.realtime.expandAnswers()})},r=function(a,b){return function(d){d=$(d).find(".postcell, .answercell");a.replaceWith(d);d.hide().fadeIn(400,function(){"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]);StackExchange.question.canViewVoteCounts()&&StackExchange.vote.bindFetchVoteCounts()});StackExchange.comments.init({post:d});StackExchange.vote.init(b.id);
StackExchange.vote||StackExchange.question.bindAnonymousVoteDisclaimers();a.find("a[id^='link-post-']").click(function(a){if(!a.ctrlKey&&!a.metaKey)return StackExchange.question.showShareTip($(this),options.showCitation),!1});StackExchange.question.bindSuggestedEditPopupLinks();StackExchange.question.initShareLinks();window.history.pushState(b,"new post","#"+b.id)}},w=function(){var a=Object.keys(o).length;i(a);return $('<div id="new-post-activity">'+a+" question"+(1<a?"s":"")+" with new activity</div>").click(function(){StackExchange.realtime.expandActiveQuestions()})};
return{init:function(a){g=a;if("WebSocket"in window||"MozWebSocket"in window){if(l)try{e("closing WebSocket"),l.close()}catch(b){}l||(e("opening WebSocket"),l="WebSocket"in window?new WebSocket(g):new MozWebSocket(g),l.onopen=function(){if(!v){v=!0;for(var a=0,b=u.length;a<b;a++)e("sending: "+u[a]),l.send(u[a]);u=[]}e("WebSocket opened");c();setInterval(k,6E4)},l.onmessage=function(a){a=$.parseJSON(a.data);p.emit(a.action,a.data)},l.onclose=function(){l=null;e("WebSocket closed");5>m&&(m++,e("reconnect attempt:"+
m),setTimeout('StackExchange.realtime.init("'+g+'")',500))},l.onerror=function(){e("WebSocket failed");l=null})}},expandActiveQuestions:j,expandAnswers:function(){var a=$("#answers #answers-header .answers-subheader h2"),b=parseInt(a.text().match(/^\d*\*?/))+n.length;isNaN(b)&&(b=n.length);a.text(b+" Answer"+(1<b?"s":""));$("#new-post-activity").remove();var d=$("#answers #answers-header");$.each(n,function(a,b){$.get("/posts/"+b+"/ajax-load-mini",function(a){a=$(a);a.insertAfter(d).hide().fadeIn(400,
function(){"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]);StackExchange.question.canViewVoteCounts()&&StackExchange.vote.bindFetchVoteCounts()});StackExchange.comments.init({post:a});StackExchange.vote.init(b)})});StackExchange.vote||StackExchange.question.bindAnonymousVoteDisclaimers();d.find("a[id^='link-post-']").click(function(a){if(!a.ctrlKey&&!a.metaKey)return StackExchange.question.showShareTip($(this),options.showCitation),!1});StackExchange.question.bindSuggestedEditPopupLinks();
StackExchange.question.initShareLinks();n=[]},subscribeToActiveQuestions:function(a,d,c,g,f,e,i){a=a+"-"+d;t=c;s=e;b(a);p.on(a,function(a){a=$.parseJSON(a);if(null!=f)for(var b=0;b<f.length;b++)if(-1==$.inArray(f[b],a.tags))return;null!=StackExchange.options.user.accountId&&StackExchange.tagPreferences.isIgnored(a.body)||(o[a.id]={id:a.id,body:a.body,index:(new Date).getTime(),siteid:a.siteid},$("#new-post-activity").remove(),$("#question-mini-list, #questions").prepend(w),g&&j());null!=i&&i(a)})},
subscribeToInboxNotifications:function(){if(null!=StackExchange.options.user.accountId){var a=StackExchange.options.user.accountId+"-inbox";b(a);p.on(a,function(a){$(".unreadCount").remove();var b=$('<a class="unreadCount" title="unread messages in your inbox">'+a+"</a>").insertAfter(".genu");$("#portalLink .unreadCount").css({marginTop:b.css("margin-top"),opacity:1},2E3);genuwine.setUnreadCount(a)})}},subscribeToQuestion:function(c,g){var e=c+"-question-"+g;b(e);p.on(e,function(b){b=$.parseJSON(b);
switch(b.a){case "score":var c=$('.vote input[value="'+b.id+'"]').siblings(".vote-count-post");c.text()!=b.score&&(c.text(b.score),0==$(":animated").length&&c.fadeTo("fast",0.7).fadeTo("fast",1),StackExchange.question.canViewVoteCounts()&&StackExchange.vote.bindFetchVoteCounts());break;case "comment-add":0==$("#comment-"+b.commentid).length&&(b=$("#comments-link-"+b.id),c=b.data("comments-count")||0,c++,b.data("comments-count",c),b.html("add / show <b>"+c+"</b> more comment"+(1<c?"s":"")).show().fadeTo("fast",
0.7).fadeTo("fast",1));break;case "answer-add":0==$("#answer-"+b.answerid).length&&(n.push(b.answerid),StackExchange.cardiologist.isHeartBeating()?StackExchange.helpers.DelayedReaction(f,5E3).trigger():f(),StackExchange.cardiologist.notifiedOfNewAnswer());break;case "accept":a(b);break;case "unaccept":a(b,!0);break;case "post-edit":d(b)}})},subscribeToReputationNotifications:function(a){null!=StackExchange.options.user.accountId&&(a=a+"-"+StackExchange.options.user.userId+"-reputation",b(a),p.on(a,
function(a){var b=$("#hlinks .reputation-score");b.text()!=a.score&&(0==$(":animated").length&&b.fadeTo("fast",0.8).fadeTo("fast",1),b.text(a))}))},updateRelativeDates:k}}();"use strict";StackExchange.anonymous={};
var gauth=function(){return{informStackAuth:function(e){if(gauth.enabled()){var c=document.domain;"meta."==c.substr(0,5)&&(c=c.substr(4,c.length-4));var b=$.cookie("gauth");if(null==b)$.cookie("gauth",null,{path:"/",domain:c}),$.cookie("gauth",null,{path:"/",domain:document.domain});else{"."!=c.charAt(0)&&(c="."+c);$.cookie("gauth",null,{path:"/",domain:c});$.cookie("gauth",null,{path:"/",domain:document.domain});var a=b.indexOf(":"),c=b.substr(0,a),b=b.substr(a+1),f=e+"/auth/global/write?authToken="+
encodeURIComponent(c)+"&nonce="+encodeURIComponent(b);$(document).ready(function(){$("#footer").append("<iframe style='display:none' src='"+f+"'></iframe>")})}}},checkStackAuth:function(e){if(gauth.enabled()&&null==$.cookie("gauthed")){$.cookie("gauthed","1",{path:"/"});var c=function(b){if(b.origin==e)if("No Local Storage"==b.data)gauth.noGAuthStorage();else if("No Session"==b.data)gauth.noGAuthSession();else{var a=b.data.substr(0,b.data.indexOf(",")),b=b.data.substr(b.data.indexOf(",")+1);$.post("/users/login/global",
{authToken:a,nonce:b},function(a){gauth.globallyAuthed(a)},"json")}};window.attachEvent?window.attachEvent("onmessage",c):window.addEventListener("message",c,!1);$.post("/users/login/global/request","",function(b){var a=e+"/auth/global/read?request="+encodeURIComponent(b.token)+"&nonce="+encodeURIComponent(b.nonce);$(document).ready(function(){$("#footer").append("<iframe id='global-auth-frame' style='display:none' src='"+a+"'></iframe>")})},"json")}},enabled:function(){$.cookie("enabledCheck","1");
if(null==$.cookie("enabledCheck"))return!1;$.cookie("enabledCheck",null);return"undefined"==typeof localStorage?!1:!0},noGAuthStorage:function(){},noGAuthSession:function(){},globallyAuthed:function(e){if(e&&e.Message){var e=e.Message+" ",c,b=!1,a=""+window.location,f=a.indexOf("returnurl=");if(-1!=f){var d=a.indexOf("&",f);-1==d&&(d=a.length);c=decodeURIComponent(a.substring(f+10,d));c=/^(?:http:\/\/|\/)/.test(c)?c.replace(/[^-a-z0-9+&@#\/%?=~_|!:,.;()]/g,""):null}-1!=a.indexOf("/users/login")&&
(b=!0,c=c||"/");StackExchange.helpers.showFancyOverlay({message:b?e+"<br>You are being redirected...":e+(c?"<a href=\"javascript:window.location='"+c+"'\">Click here</a> to return to your last location.":'<a href="javascript:location.reload(true)">Click here</a> to refresh the page.'),showClose:!b,complete:function(){b&&(window.location=c)}})}}}}(),genuwine=function(){var e,c="",b,a,f=function(){return $(".genu").hasClass("genu-on")},d=function(){var d=$(".genu"),c=$("#seWrapper");if(0==c.length){j();
var c=$("#seWrapper"),g;0<b?(g=$("#seTabInbox"),u(g)):a?(g=$("#seTabNotices"),i(g)):(g=$("#seTabHot"),l(g));g.addClass("seCurrent")}(g=d.hasClass("genu-on"))?($(".unreadCountTab").hide(),$(".itemBoxNew").removeClass("itemBoxNew"),c.fadeOut("fast")):(c.fadeIn("fast"),$(".unreadCount").hide());d.toggleClass("genu-on",!g);-1==b&&$(d).ready(function(){$("#seTabInbox").hide()});h($("#seTabInbox"),$("#seTabNotices"))},h=function(d,c){StackExchange.options.site.isNoticesTabEnabled&&a&&0==c.find(".unreadCountTab").length&&
c.prepend('<span class="unreadCountTab newNotices">'+a+"</span>");0<b&&0==d.find(".unreadCountTab").length&&d.prepend('<span class="unreadCountTab">'+b+"</span>")},j=function(){var a='<div id="seWrapper" style="position:absolute; display:none;"><div class="seIntro"><a href="'+c+'">Stack Exchange</a> is a network of free, community-driven Q&A sites.</div><div class="seNav"><ul class="seNavLinks"><li><a id="seTabHot">Hot Questions</a></li><li><a id="seTabSites">All Sites</a></li><li><a id="seTabInbox">Inbox</a></li>'+
(StackExchange.options.site.isNoticesTabEnabled?'<li><a id="seTabNotices">Notifications</a></li>':"")+'</ul></div><div class="seContainer"></div><div class="seFooter"><div id="seTabEmail" class="seEmailAccount"><a>email settings</a></div><a id="seClose">close</a></div></div>',b=$("#hlinks"),b=b.height()+b.offset().top+5;$(a).appendTo("#portalLink").css({top:b}).find("ul.seNavLinks a, #seTabEmail").click(function(){var a=$(this);$(".seNavLinks a").removeClass("seCurrent");a.addClass("seCurrent");switch(a.attr("id")){case "seTabHot":l(a);
$("#seContainerSites, #seContainerInbox, #seContainerEmail, #seContainerNotices").hide();$("#seContainerHot").fadeIn("fast");break;case "seTabSites":0==$("#seContainerSites").length&&g(a);$("#seContainerHot, #seContainerInbox, #seContainerEmail, #seContainerNotices").hide();$("#seContainerSites").fadeIn("fast");break;case "seTabInbox":u(a);$("#seContainerHot, #seContainerSites, #seContainerEmail, #seContainerNotices").hide();$("#seContainerInbox").fadeIn("fast");break;case "seTabEmail":0==$("#seContainerEmail").length&&
o(a);$("#seContainerHot, #seContainerSites, #seContainerInbox, #seContainerNotices").hide();$("#seContainerEmail").fadeIn("fast");break;case "seTabNotices":i(a),$("#seContainerHot, #seContainerSites, #seContainerInbox, #seContainerEmail").hide(),$("#seContainerNotices").fadeIn("fast")}});$("#seClose").live("click",d)},i=function(a){0==$("#seContainerNotices").length&&t(a,"/notices/genuwine?userId="+StackExchange.options.user.id,"jsonp",k,!0)},k=function(a,b){for(var d='<div id="seContainerNotices" style="display:none">',
c=0;c<b.length;c++)var g=b[c],d=d+('<div class="noticeBox'+(g.is_unread?" itemBoxNew":"")+'"><a href="'+g.site_url+'" class="siteLinkFavicon"><img src="'+g.icon+'"></a><div class="siteInfo"><p>'+g.text+"</p></div></div>");p(a,d+"</div>")},g=function(a){t(a,c+"/genuwine/sites?callback=?&host="+document.location.host+(e?"&accountId="+e:""),"jsonp",m)},l=function(a){0==$("#seContainerHot").length&&t(a,c+"/genuwine?callback=?","jsonp",n)},o=function(a){t(a,"/accounts/email-settings","json",function(a,
b){function d(){$("#email-save").removeAttr("disabled");$("#email-confirmation").html("")}p(a,'<div id="seContainerEmail" style="display:none; font-size:11px;"><div class="itemBox" style="border-bottom: 0px"><p>Would you like to receive unread inbox messages via email?</p><div>Email: <input id="email-notify" name="email-notify" style="width:300px;" value="'+b.verifiedEmail+'"></input></div><div><input type="radio" name="optIn" value="true" id="email-enable"'+(!0==b.optIn?'checked="checked"':"")+'"> <label for="email-enable">Email me my unread inbox messages </label> <select id="email-freq"><option value="3">every 3 hours</option><option value="24">daily</option><option value="168">weekly</option></select> </div><div><input type="radio" name="optIn" value="false" id="email-disable"'+
(!0!=b.optIn?'checked="checked"':"")+'"> <label for="email-disable">Do not email me inbox messages</label></input></div><div><input type="button" name="save" id="email-save" value="Save" disabled="disabled"></input></div><div id="email-confirmation" style="display:none;"></div></div></div>');$("#email-freq").val(b.freq).on("click focus",function(){$("#email-enable").prop("checked",!0)});$("#email-notify").focus().keyup(d);$("#email-enable, #email-disable, #email-freq").change(d);$("#email-save").click(function(){q();
$.post("/accounts/verified-email-set",{email:$("#email-notify").val(),fkey:StackExchange.options.user.fkey,optin:$("input[name=optIn]:checked").val(),freq:$("#email-freq").val()},function(a){StackExchange.helpers.removeSpinner();$("#email-confirmation").html(a.message).fadeIn();a.success&&$("#email-save").attr("disabled","disabled")},"json")})},!0)},n=function(a,b){for(var d=$("<div/>"),c='<div id="seContainerHot" style="display:none">',g=0;g<b.length;g++)var f=b[g],e=f.SiteId,i='href="http://'+e+
"/q/"+f.Id+'?hq=1"',h=parseInt(f.DisplayScore,10),c=c+('<div class="itemBox"><a '+i+' class="seNumAnswer">'+h+'</a><div class="siteInfo"><p><a '+i+">"+d.text(f.Title).html()+'</a></p><a href="http://'+e+'" class="siteLink">'+e+"</a></div></div>");p(a,c+"</div>")},g=function(a){t(a,c+"/genuwine/sites?callback=?&host="+document.location.host+(e?"&accountId="+e:""),"jsonp",m)},m=function(a,b){for(var d='<div id="seContainerSites" style="display:none">',c=0;c<b.length;c++)var g=b[c],f=g.Name,e='href="http://'+
g.Id+'?as=1"',d=d+('<div class="itemBox"><a '+e+' class="siteFavicon"><img src="'+g.FaviconUrl+'" alt="'+f+'"></a><div class="siteInfo"><p><a '+e+">"+f+"</a></p><a "+e+' class="siteLink">'+g.Description+"</a></div></div>");p(a,d+"</div>")},u=function(a){-1!=b&&0==$("#seContainerInbox").length&&t(a,"/inbox/genuwine","json",v,!0)},v=function(a,b){for(var d='<div id="seContainerInbox" style="display:none">',c=0;c<b.length;c++){var g=b[c],f='href="'+g.Url+'"',i='title="'+g.CreationDate+'"',h=g.Count,
d=d+('<div class="itemBox'+(g.IsNew?" itemBoxNew":"")+'"><a '+f+' class="siteLinkFavicon"><img src="'+g.FaviconUrl+'" alt="'+g.SiteUrl+'"></a><div class="siteInfo">');"careers message"==g.Type?d+="<p><a "+f+' style="font-weight:normal"><b>'+g.Title+"</b> wants to contact you on <b>Stack Overflow Careers</b></a></p>":"invitation"==g.Type?(i=g.Count,d+="<p><a "+f+' style="font-weight:normal"><b>'+i+"</b> "+("invitation"+(1<i?"s":""))+" awarded on <b>Stack Overflow Careers</b></a></p>"):d+="<p>"+(1<
h?h+" ":"")+g.Type+" on <a "+f+" "+i+">"+g.Title+"</a></p>";d+='<p class="inboxSummary">'+(g.Summary||"")+"</p></div></div>"}e&&5<=b.length&&(d+='<div class="itemMoreContainer"><div class="seIntro"><a href="http://stackexchange.com/users/'+e+'?tab=inbox">more inbox messages &hellip;</a></div></div>');p(a,d+"</div>")},s={},t=function(a,b,d,c,g){var f=a.attr("id");if(s[f])q();else{s[f]=!0;q();var e=function(){s[f]=!1;StackExchange.helpers.showErrorPopup($(".seContainer"),"An error occurred while loading - please try again.")};
$.ajax({type:"GET",url:b,dataType:d,success:function(b){b&&(0<b.length||g)?c(a,b):e()},error:e,complete:StackExchange.helpers.removeSpinner()})}},p=function(a,b){var d=$(b);d.appendTo(".seContainer");a.hasClass("seCurrent")&&d.fadeIn("fast")},q=function(){StackExchange.helpers.removeSpinner();StackExchange.helpers.addSpinner(".seContainer",{position:"relative",left:"10px",top:"10px"})},r=function(){var a=$("#portalLink .unreadCount"),b=a.css("margin-top");a.css({marginTop:-20,opacity:0}).show().animate({marginTop:b,
opacity:1},2E3)},w=function(d){a=d;!(0<b)&&StackExchange.options.site.isNoticesTabEnabled&&(99<a&&(a=99),0<a&&$("#portalLink .unreadCount").text(""+a).addClass("newNotices").click(function(){$(".genu").click()}).show())};return{isVisible:f,click:d,setUnreadCount:function(a){b=a;0<a?($("#portalLink .unreadCount").text(b).click(function(){$(".genu").click()}).show(),r()):$("#portalLink .unreadCount").text("").hide();$("#portalLink .unreadCount").removeClass("newNotices")},animateInbox:r,init:function(a,
g,i){var h=$(".genu");1<=h.length&&(h[0].onclick=null);e=a;c=h.attr("href");b=g;w(i);h.removeAttr("href").add(".unreadCount").click(d);$(document).click(function(a){f()&&!$.contains($("#portalLink")[0],a.target)&&d()})}}}();
StackExchange.notify=function(){function e(a,b){var d=$("#dismissed-messages");d.val(d.val()+"~"+a+(b?" "+b:"")+"~")}function c(a,b){var d=$("#dismissed-messages").val();return!d?!1:RegExp("~"+a+(b?" "+b:"")+"~").test(d)}function b(a,b,d){var c=parseInt($("body").css("margin-top").match(/\d+/)),a=b*c/a;d?$("body:not(.no-message-slide)").animate({marginTop:a+"px"},"fast","linear"):$("body:not(.no-message-slide)").css("marginTop",a+"px")}var a=0,f=function(d,c){var g=$("#notify-"+d+(c?"-"+c:""));-1==
d?$.cookie("m","0",{expires:90,path:"/"}):-1<d&&$.post("/messages/mark-as-read",{messagetypeid:d,id:c?c:null});e(d,c);a--;g.fadeOut("fast",function(){b(a+1,a,!0);g.remove()})},d=function(b){if(StackExchange.options.site.isNoticesTabEnabled)return!0;a++;if(c(b.messageTypeId,b.id))return!1;var d="";b.messageTypeId&&(d=' id="notify-'+b.messageTypeId+(b.id?"-"+b.id:"")+'"');d="<div"+d+' style="display:none"><span class="notify-close"><a title="dismiss this notification">&times;</a></span><span class="notify-text">'+
b.text+"</span>";if(b.showProfile)var g=encodeURIComponent("/users/"+b.userId+"?tab=badges&sort=recent"),d=d+(' See your <a href="/messages/mark-as-read?messagetypeid='+b.messageTypeId+"&returnurl="+g+'">profile</a>.');d=$(d+"</div>");d.find(".notify-close").click(function(){b.close&&b.close();f(b.messageTypeId,b.id)});$("#notify-container").append(d);return!0},h=function(){$("#notify-container div").fadeIn("slow")},j=function(a,b){var c=$('<div class="link-more"><a>view '+a+" more notification"+
(1!=a?"s":"")+"</a></div>");$("#notify-container").append(c);c.click(function(){c.detach();for(var a=0;a<b.length;a++)d(b[a]);h()})};return{showMessages:function(c,f){for(var g=0,e=f?2:c.length,o=0;o<e&&o<c.length;o++)d(c[o])&&g++;b(a,g,!1);h();f&&g<c.length&&(e=c.slice(e),j(c.length-g,e))},show:function(a,b){$("body:not(.no-message-slide)").animate({marginTop:"2.5em"},"fast","linear");d({text:a,messageTypeId:b});h()},close:f,getMessageText:function(a){return $("#notify-"+a+" .notify-text").text()}}}();
function moveScroller(){var e=$("#scroller").width(),c=function(){var b=$(window).scrollTop(),a=$("#scroller-anchor").offset().top,c=$("#scroller");b>a?c.height()>$(window).height()?c.css({position:"fixed",top:"",bottom:"0px",width:e}):c.css({position:"fixed",top:"0px",bottom:"",width:e}):b<=a&&c.css({position:"relative",top:"",bottom:""})};$(window).scroll(c).resize(c);c()}
var styleCode=function(){return function(){"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]);var e=!1;$("pre code").parent().each(function(){$(this).hasClass("prettyprint-override")&&($(this).removeClass("prettyprint-override").addClass("prettyprint"),e=!0);var c;if(c=!$(this).hasClass("prettyprint")){c=$(this);var b=$("#prettify-lang").text();""!=b?(c.addClass(b),c=!0):c=!1}c&&($(this).addClass("prettyprint"),e=!0)});e&&("undefined"!=typeof jtab?jtab.renderimplicit():StackExchange.using("prettify",
function(){StackExchange.prettify.applyCodeStyling()}))}}();
StackExchange.helpers.MagicPopup=function(e){function c(a,d){var c=$("<div id='"+e.id+"'/>").html(d),h=$("<div />").css({overflow:"hidden",position:"absolute",width:1,height:1,top:0,left:0}).append(c).appendTo("body"),j=e.showing(a,c),n={left:j.left};j.hasOwnProperty("bottom")?(n.bottom=j.bottom,n.top="auto"):n.top=j.top;var m;e.shown&&(m=function(){e.shown(a,c)});h.css(n).animate({height:c.outerHeight()+8,width:c.outerWidth()+8},300,m);b=function(){h.stop().remove();e.removed&&e.removed(a,c);b=f=
null};f=StackExchange.helpers.DelayedReaction(b,5);n=h;j.additional&&(n=n.add(j.additional));n.hover(f.cancel,f.trigger)}var b,a,f,d,h={},j=StackExchange.helpers.DelayedReaction(function(a,f){if(!d&&a){var g;e.cache&&"c_"+a in h?g=$.Deferred().resolve(h["c_"+a]):(g=$.ajax({type:"GET",url:a,dataType:"html"}),e.cache&&g.done(function(b){h["c_"+a]=b}));g.done(function(a){b&&b();""!=a&&c(f,a)})}},500);$(document).delegate(e.selector,{mouseenter:function(){if(f&&this===a)f.cancel();else return a=this,
j.trigger(e.getUrl(this),this),d=!1},mouseleave:function(){d=!0;j.cancel();f&&f.trigger()}})};
StackExchange.tagmenu=function(){function e(a){var a=$(a),b=a.attr("href");if(!b||"/"!=b.charAt(0))return null;b=a.text();if(-1<b.indexOf("*"))return null;a.attr("title","");return"/tags/"+encodeURIComponent(b)+"/subscriber-info"}function c(a,b){var c=$(a),e=c.offset(),i=c.outerHeight(),c={left:e.left},k=e.top+i,i=e.left+b.outerWidth();b.height()+k>$(window).height()+$(window).scrollTop()?c.bottom=$(window).height()-e.top-8:c.top=k;e=Math.max(1024,$(window).width());i>e&&(c.left-=i-e);return c}var b,
a;return{init:function(f){b=f;a||(a=!0,StackExchange.options.isMobile||(StackExchange.helpers.MagicPopup({selector:".post-tag:not(.user-tag)",id:"tag-menu",getUrl:e,showing:c,shown:function(a,c){b&&b(c,$(a).text())}}),$("#interesting-tags .post-tag").addClass("user-tag")))}}}();
StackExchange.usermenu=function(){function e(b,d){var c=$(b).find("img:first"),e=c.offset(),i=c.height(),k=c.width(),g=Math.max(k,i),l=64*i/g,g=64*k/g,o=d.find("img:first").css({width:g,height:l}),n=o.offset();o.css("visibility","hidden");a=c.clone().css({position:"absolute",zIndex:300,left:e.left,top:e.top,width:k,height:i}).appendTo("body");var m=function(){o[0].complete?(o.css("visibility","visible"),a.fadeOutAndRemove()):setTimeout(m,500)};a.animate({width:g,height:l,top:e.top+n.top},200,m);return{top:e.top,
left:e.left-n.left,additional:a}}function c(){a.remove()}var b,a;return{init:function(){b||(b=!0,StackExchange.options.isMobile||StackExchange.helpers.MagicPopup({selector:".user-hover .user-gravatar48, .user-hover .user-gravatar32",getUrl:function(a){a=/\/users\/([^/]+).*$/.exec($(a).closest(".user-hover").find(".user-details a").attr("href"));return!a?null:"/users/user-info/"+a[1]},cache:!0,id:"user-menu",showing:e,removed:c}))}}}();
StackExchange.chatAd=function(){function e(){var a=$(".question .post-taglist .post-tag");return!a.length?null:a.map(function(a,b){return $(b).text()}).get().join(" ")}function c(a){return 10>a?"0"+a:a}function b(a){var b=new Date;b.setTime(1E3*a);return[b.getUTCFullYear(),"-",c(b.getUTCMonth()+1),"-",c(b.getUTCDate())," ",c(b.getUTCHours()),":",c(b.getUTCMinutes()),":",c(b.getUTCSeconds()),"Z"].join("")}function a(a){var b=Math.floor((new Date).getTime()/1E3)-a,d=b%60,g=Math.floor(b/60),e=Math.floor(b/
3600);if(1>b)return"just now";if(60>b)return 1==d?"1 sec ago":d+" secs ago";if(3600>b)return 1==g?"1 min ago":g+" mins ago";if(86400>b)return 1==e?"1 hour ago":e+" hours ago";b=Math.floor(b/86400);if(1==b)return"yesterday";if(2>=b)return b+" days ago";a=new Date(1E3*a);return m[a.getMonth()]+" "+a.getDate()+" at "+a.getHours()+":"+c(a.getMinutes())}function f(a){var b=$("<div />");b.text(a);return b.html().replace('"',"&quot;")}function d(){$.get(g,null,function(a,b,d){i(a,b,d)})}function h(b){for(var d=
$('<div class="ad502-users" />'),c=0;c<b.length&&7>c;c++){var g=b[c],e=g.name;g.lastPost&&(e+=": "+a(g.lastPost));var f="http://www.gravatar.com/avatar/"+g.emailhash+"?s=23&d=identicon&r=PG",g=$('<a href="'+(k+"/users/"+g.id)+'" />');$("<img />").attr("title",e).attr("src",f).appendTo(g);d.append(g)}return d}function j(a){var b=a.user;return(a=a.userid)?'<a href="'+k+"/users/"+a+'">'+f(b)+"</a>":f(b)}function i(c){var g=$("#ad502-rooms");if(!c.error){g.html("");for(var e=c.rooms,i=0;i<e.length&&2>
i;i++){var m=e[i],q=k+"/rooms/"+m.id,r=$('<div class="ad502-room"></div>');r.append($('<h3 class="ad502-room-h3"><span class="ad502-room-title" title="'+f(m.name)+'"><a href="'+q+'">'+f(m.name)+"</a></span></h3>"));m.messages&&0<m.messages.length&&r.append($('<span title="'+b(m.lastPost)+'" class="ad502-last-message">'+a(m.lastPost)+" - "+j(m.messages[0])+"</span><br>"));m.singleImage?r.append($('<div class="ad502-users"><img src="'+k+"/rooms/users/"+m.id+'.jpeg" /></div>')):r.append(h(m.users));
g.append(r)}1<c.activeUsers?$("#h-chat-link").text(c.activeUsers+" People Chatting"):$("#h-chat-link").text("Visit Chat");$("#h-chat-link").attr("title",c.activeUsers+" users active in "+c.activeRooms+" rooms the last 60 minutes")}l<=n&&window.setTimeout(d,1E3*l);l+=o}var k,g,l=180,o=30,n=480,m="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(",");/^\/questions\/\d+/i.test(window.location.pathname)&&(n=0);return{init:function(a){k=a.chatUrl;g=a.reloadUrl;if(a.tagBased){var b=e();if(!b)return;
g+=(/\?/.test(g)?"&":"?")+"tags="+encodeURIComponent(b)}null===a.preloadData?d():i(a.preloadData,null,null)}}}();
StackExchange.helpers.noDiacritics=function(){var e={"\u00e0\u00e5\u00e1\u00e2\u00e4\u00e3\u00e5\u0105":"a","\u00e8\u00e9\u00ea\u00eb\u0119":"e","\u00ec\u00ed\u00ee\u00ef\u0131":"i","\u00f2\u00f3\u00f4\u00f5\u00f6\u00f8\u0151":"o","\u00f9\u00fa\u00fb\u00fc":"u","\u00e7\u0107\u010d":"c","\u017c\u017a\u017e":"z","\u015b\u015f\u0161":"s","\u00f1\u0144":"n","\u00fd\u0178":"y","\u0142":"l","\u0111":"d","\u00df":"ss","\u011f":"g","\u00de":"th"};return function(c){for(var b in e)e.hasOwnProperty(b)&&(c=
c.replace(RegExp("["+b+"]"),e[b]));return c}}();function sanitizeAndSplitTags(e,c){for(var e=$.trim(e).replace(/([A-Za-z0-9])\+(?=[A-Za-z0-9])/g,"$1 "),b=e.split(/[\s|,;]+/),a=[],f=0;f<b.length;f++){var d=StackExchange.helpers.noDiacritics(b[f].toLowerCase()).replace(/_/g,"-"),d=d.replace(RegExp("[^a-z0-9.#+"+(c?"*":"")+"-]","g"),""),d=d.replace(/^[#+-]+/,""),d=d.replace(/[.-]+$/,"");0<d.length&&-1==$.inArray(d,a)&&a.push(d)}return a}
StackExchange.question=function(){var e=function(a,b){var c=null!=a;a||(a=$('div.question div.post-menu a:contains("link")'));var d=a.closest(".post-menu, .help-menu");if(a.hasClass("share-link"))d.find(".close-share-tip").click();else{a.addClass("share-link");var e=a.attr("id").substring(10),f=a.closest(".col-section").length?"section":a.closest("div.question").length?"question":"answer",h=$('<div class="share-tip" style="display:none">share a link to this '+f+'<input type="text" value="http://'+
document.location.host+a.attr("href")+'" style="display:block; width:292px;"><a class="close-share-tip" style="float:right">close</a></div>');b&&h.find(".close-share-tip").before('<a id="link-post-'+e+'" style="float:left">cite</a>');h.appendTo(d).fadeIn(c?"fast":0).bind("removing",function(){a.removeClass("share-link")}).find(".close-share-tip").click(function(){h.fadeOutAndRemove()}).end().find("input[type=text]").select()}},c=function(a){var b=$("#post-form h2:first"),c=b.wrap("<div />").parent(),
d=c.wrap("<div />").parent(),e=$("<div />").prependTo(d),f=d.height(),h=$("<div />"),a=$(a),j=parseInt(b.css("margin-bottom")),i=$("#content"),k=$("#wmd-input").outerWidth(),q=i.offset().left>b.offset().left-5&&"visible"!=i.css("overflow-x");h.css({height:0,overflowY:"hidden"}).appendTo(c).append(a);d.css({height:f,position:"relative"});c.css({position:"absolute",bottom:-j,width:k});e.addClass("answer-help-background").css({position:"absolute",bottom:-j,height:0,width:k});q&&(e.css("left",0),c.animate({paddingLeft:5},
1E3));h.animate({height:a.height()+j+10},1E3);e.animate({height:a.height()+j+10+f},1E3);$("<div style='float:right;margin-top:10px;'><a href='#'>ok</a></div>").hide().prependTo(c).fadeIn(1E3).find("a").one("click",function(a){var d=$(this).parent();setTimeout(function(){d.remove()},1);h.animate({height:0},1E3,function(){h.add(e).remove();b.unwrap().unwrap()});e.animate({height:0},1E3);q&&c.animate({paddingLeft:0},1E3);a.preventDefault()})},b=function(){$.get("/posts/answer-help").then(c)},a,f,d,h=
function(){var a=window.location.href;0>a.indexOf("#")||(a=a.match(/#(\d+|comment(\d+)_(\d+))/i))&&(a[2]?j(a[2],a[3]):i($(".answer[data-answerid="+a[1]+"]")))},j=function(a,b){var c="#comment-"+a,d=$(c);d.length?i(d):StackExchange.comments.loadAll($("#comments-link-"+b)).done(function(){i($(c))})},i=function(b){var c=d;b.css({backgroundColor:a}).animate({backgroundColor:c},2E3,"linear",function(){$(this).css("background-color","")});b.is(".comment")&&b[0].scrollIntoView(!0)},k=function(a){a=a||{};
$('.post-menu a:contains("link")').live("click",function(b){if(!b.ctrlKey&&!b.metaKey)return e($(this),a.showCitation),!1})};return{showShareTip:e,getQuestionId:function(a){a=(a?a.closest(".question"):$(".question")).data("questionid");if(!a)throw Error("getQuestionId could not find an id");return a},highlightComment:j,initShareLinks:k,canViewVoteCounts:function(){return f},init:function(c){StackExchange.question.fullInit?StackExchange.question.fullInit(c):StackExchange.question.bindAnonymousVoteDisclaimers();
StackExchange.comments.init({autoShowCommentHelp:c.autoShowCommentHelp});c.showShareTip&&e();$("input.anon-vote").live("click",function(){var a=$(this),b=a.postId(),c=a.parent();c.closest(".question,.answer").unbind("mouseenter.helpful").unbind("mouseleave.helpful");c.text("sending feedback ...");setTimeout(function(){c.text("Thank you for your feedback.")},500);$.ajax({type:"POST",url:"/vote/anon/"+b,data:{votetypeid:"Yes"==a.val()?2:3},complete:function(){}})});var j=$(".was-this-helpful"),i=j.css("color"),
n=$(".post-text").css("color");j.each(function(){var a=$(this),b=a.text();a.closest(".answer, .question").bind("mouseenter.helpful",function(){a.html("Was this post useful to you? &nbsp;&nbsp;<input style='display:none;' class='anon-vote' type='button' value='Yes'/> &nbsp;<input style='display:none;' class='anon-vote' type='button' value='No'/>").animate({color:n},"fast","linear").find("input").fadeIn("fast")}).bind("mouseleave.helpful",function(){a.text(b).animate({color:i},"fast","linear")})});
k(c);if(c.showAnswerHelp)$("#wmd-input").one("focus",b);c.showCitation&&$("div.share-tip a[id^='link-post-']").live("click",function(){$(this).closest(".post-menu").find(".close-share-tip").click();citation.show($(this))});d=c.backgroundColor;a=c.highlightColor;f=c.canViewVoteCounts;h(c)}}}();
StackExchange.question.bindAnonymousVoteDisclaimers=function(){function e(c){return function(b){var a='Please <a href="/users/login?returnurl='+escape(document.location)+'">login or register</a> to '+c+" this post.";StackExchange.helpers.showErrorPopup($(this).parent(),a);var a="",e=$(this).prop("className"),d=$(this).closest(".answer").length?"answer":"question";/vote-up/.test(e)?a="?vote=up&type="+d:/vote-down/.test(e)?a="?vote=down&type="+d:/star/.test(e)&&(a="?vote=favorite");StackExchange.helpers.fireAndForget("/analytics/user/try-vote"+
a);b.preventDefault()}}$(".vote-up-off, .vote-down-off").click(e("vote for"));$("div.post-menu a[id^='flag-post-']").unbind("click").click(e("flag"));$(".star-off:not(.disabled)").live("click",e("favorite"))};
StackExchange.comments=function(){function e(a,b){this.postId=a;this.jDiv=b;this.jCommentsLink=$("#comments-link-"+a)}function c(b){var c=(b.constructor===$?b:$(b)).closest(".question, .answer, div[id^='post-']").find(".comments"),b=c.attr("id").replace(/^comments-/,"");if(a[b])return a[b];c=new e(b,c);return a[b]=c}function b(){if(0!=$(".question[data-questionid]").length){var a=StackExchange.question.getQuestionId();$(".comment .comment-date > span").each(function(){var b=$(this),c=b.closest(".answer"),
c=c&&c.length?c.data("answerid"):0,e=b.closest(".comment").attr("id").substr(8);b.wrap('<a class="comment-link" onclick="StackExchange.question.highlightComment({cid}, {aid})" href="{hash}"></a>'.format({hash:"#comment"+e+"_"+(c?c:a),cid:e,aid:c}))})}}var a={},f=function(){};e.prototype={checkDiscussion:f,ensureInput:f,commentsShown:function(){this.jCommentsLink.hide();this.jCommentsLink.data("comments-count",0)},addShow:function(a){var b=this;this.loadAllComments().done(function(){b.jCommentsLink.hide();
b.checkDiscussion()});var c=this.ensureInput();c&&!a&&c.focus()},ajax:function(a,b,c,e){c&&!e&&StackExchange.helpers.addSpinner(c,{"margin-left":"10px"});var f=this;return $.ajax(a).fail(function(a){$(".error-notification").fadeOut("fast",function(){$(this).remove()});a=a.responseText;if(!a||100<=a.length)a="An error occured"+(b?" "+b:"");StackExchange.helpers.showErrorPopup(c||f.jDiv,a);c&&!e&&StackExchange.helpers.removeSpinner()}).done(StackExchange.helpers.removeSpinner).promise()},showComments:function(a){this.jDiv.find(" > table > tbody").html(a);
this.jCommentsLink.text("add comment");"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]);b();this.commentsShown()},loadAllComments:function(a){this.jDiv.removeClass("dno");if(!a&&!/more comment/.test($("#comments-link-"+this.postId).text()))return $.Deferred().resolve().promise();var b=this;return this.ajax({type:"GET",url:"/posts/"+this.postId+"/comments",dataType:"html"},"while fetching comments").done(function(a){b.showComments(a)}).promise()}};return{init:function(a){a=a&&
a.post||document;$("a[id^='comments-link-']",a).click(function(){var a=/more comment/.test($(this).text());c(this).addShow(a)});a==document&&b()},loadAll:function(a){return c(a).loadAllComments(!0)},extendPostUi:function(a){for(var b in a)a.hasOwnProperty(b)&&(e.prototype[b]=a[b])},uiForPost:c}}();
StackExchange.share=function(){function e(b,a,c){window.open(b,a,c)||(window.location.href=b)}function c(b,a){var c=b.indexOf("?"),d=b.indexOf("#");return-1==c?-1==d?b+"?"+a:b.substring(0,d)+"?"+a+b.substring(d):-1==d?b+"&"+a:b.substring(0,d)+"&"+a+b.substring(d)}return{gplus:function(b,a){a=c(a,"sgp=1");b.click(function(){e("https://plus.google.com/share?url="+a,"sharegplus","toolbar=1,status=1,resizable=1,scrollbars=1,width=600,height=500")})},twitter:function(b,a,f){a=c(a,"stw=1");b.click(function(){e("http://twitter.com/share?url="+
a+"&ref=twitbtn&text="+f,"sharetwitter","toolbar=1,status=1,resizable=1,scrollbars=1,width=800,height=526")})},facebook:function(b,a,f){a=c(a,"sfb=1");b.click(function(){e("http://www.facebook.com/sharer.php?u="+a+"&ref=fbshare&t="+f,"sharefacebook","toolbar=1,status=1,resizable=1,scrollbars=1,width=626,height=436")})}}}();
function initTagRenderer(e,c){window.tagRenderer||(window.tagRendererRaw=function(b,a){var a=a||"",f="";a||(e&&-1<$.inArray(b,e)?f=" required-tag":c&&-1<$.inArray(b,c)&&(f=" moderator-tag"));return"<a class='post-tag"+f+"' href='"+a+"/questions/tagged/"+encodeURIComponent(b)+"' title=\"show questions tagged '"+b+"'\" rel='tag'>"+b+"</a>"},window.tagRenderer=function(b,a){return $(tagRendererRaw(b,a))})}
function showFadingHelpText(e){e.wrap('<div class="dno" />').show().parent().fadeIn("slow",function(){$(this).children().unwrap()})}
function initFadingHelpText(){var e={"wmd-input":"#how-to-format",tagnames:"#how-to-tag","tag-editor":"#how-to-tag",title:"#how-to-title"},c=$("#wmd-input, #tagnames, #title, .tag-editor input"),b=function(a){return $(a).parent().hasClass("tag-editor")?e["tag-editor"]:e[$(a).attr("id")]};c.focus(function(){var a=b(this);c.each(function(){var c=b(this);c!=a&&$(c).hide()});var e=$(a);e.is(":visible")||showFadingHelpText(e)})}
$.fn.extend({postId:function(){var e=this.first();if(!e.hasClass("answer")||!e.hasClass("question"))e=e.closest(".answer, .question");return parseInt(e.find(".vote input")[0].value)}});
StackExchange.newsletterAd=function(){function e(b){b=$('<div id="lightbox-panel" class="popup" style="display:block"></div>').append('<div class="popup-close"><a title="close this popup (or hit Esc)">&times;</a></div>').append(b);$('<div id="lightbox"></div>').appendTo($("body")).css("height",$(document).height()).fadeIn("fast");b.appendTo($("body")).center().fadeIn("fast").find(".popup-close").click(function(){$("#lightbox, #lightbox-panel").fadeOutAndRemove()})}function c(){var b=StackExchange.options.site.name,
a=$(['<div style="text-align: left;">','<h2 style="margin-bottom: 15px;">Subscribe to the '+b+" weekly newsletter</h2>",'<p><strong><a href="/users/login?returnurl=/newsletter/signup/redirect">Create an account on '+b+'</a> or <a href="/users/login?returnurl=/newsletter/signup/redirect">log in</a> if you already have one.</strong></p>','<form><label for="newsletter-email-input">Or, send newsletter emails to:</label> <input type="text" id="newsletter-email-input" maxlength="100" title="your email address" /> <input type="submit" value="Subscribe" id="newsletter-email-submit" /></form></div>'].join(""));
a.find("form").submit(function(){var b=$(this),c=$.trim(a.find("#newsletter-email-input").val());if(0==c.length)return!1;StackExchange.helpers.addSpinner(b);$.ajax({url:"/newsletter/signup/anon",type:"POST",dataType:"json",data:{email:c},success:function(a){"confirmed"==a.status&&!a.error?(b.find("#newsletter-email-input").attr("disabled",!0),b.find("#newsletter-email-submit").replaceWith('<span style="line-height: 120%; text-align: center;"><strong>Subscribed!</strong></span>'),$("#newsletter-signup-container").replaceWith('<div style="line-height: 200%; text-align: center;"><strong>Subscribed!</strong></div>')):
"unconfirmed"==a.status&&!a.error?(b.find("#newsletter-email-input").attr("disabled",!0),b.find("#newsletter-email-submit").replaceWith('<span style="line-height: 120%; text-align: center;"><strong>Subscribed!</strong></span>'),b.append("<br /><br/><p><em>Please click the link in the confirmation email to activate your subscription.</em></p>"),$("#newsletter-signup-container").replaceWith('<span style="line-height: 120%;"><strong>Success!</strong> Please click the link in the confirmation email to activate your subscription.</span>')):
b.showErrorPopup(a.error||"there was a problem signing up for the newsletter<br />please try again later")},error:function(){b.showErrorPopup("there was a problem signing up for the newsletter<br />please try again later")},complete:function(){StackExchange.helpers.removeSpinner(b)}});return!1});e(a)}return{init:function(){$("#newsletter-signup").click(function(){var b=$(this);if(StackExchange.options.user.isAnonymous)return c(),!1;StackExchange.helpers.addSpinner("#newsletter-signup-container");
$.ajax({url:"/newsletter/signup",type:"POST",dataType:"json",success:function(a){a.url?window.location.href=a.url:"confirmed"==a.status?$("#newsletter-signup-container").replaceWith('<div style="line-height: 200%; text-align: center;"><strong>Subscribed!</strong></div>'):"unconfirmed"==a.status?$("#newsletter-signup-container").replaceWith('<span style="line-height: 120%;"><strong>Success!</strong> Please click the link in the confirmation email to activate your subscription.</span>'):b.parent().showErrorPopup("there was a problem signing up for the newsletter<br />please try again later")},
error:function(){b.parent().showErrorPopup("there was a problem signing up for the newsletter<br />please try again later")},complete:function(){StackExchange.helpers.removeSpinner("#newsletter-signup-container")}})});$("#newsletter-preview").click(function(){var b=$(window).height(),b=Math.min(600,b-100),b=['<div id="newsleter-preview-pane" style="overflow: hidden; width: 660px; height: ',b,'px;"><iframe src="',$(this).attr("href"),'" width="660" height="',b,'" frameborder="0"></iframe></div>'].join("");
e(b);return!1})},loader:function(b,a){var b=a||b,c=$(".newuser-greeting");$.ajax({url:"/newsletter/targetted/ajax",data:{domain:b},success:function(a){$("#newsletter-ad").remove();c.empty().append($(a))},complete:function(){c.attr("class","").attr("style","")}});a||(window.sessionStorage.tNewsletter=b+"-continued")}}}();
(function(e,c,b,a){e.fn.caret=function(f,d){var h,j,i=this[0],k=e.browser.msie;"object"===typeof f&&"number"===typeof f.start&&"number"===typeof f.end?(h=f.start,j=f.end):"number"===typeof f&&"number"===typeof d?(h=f,j=d):"string"===typeof f?-1<(h=i.value.indexOf(f))?j=h+f[c]:h=null:"[object RegExp]"===Object.prototype.toString.call(f)&&(f=f.exec(i.value),null!=f&&(h=f.index,j=h+f[0][c]));if("undefined"!=typeof h)return k?(k=this[0].createTextRange(),k.collapse(!0),k.moveStart("character",h),k.moveEnd("character",
j-h),k.select()):(this[0].selectionStart=h,this[0].selectionEnd=j),this[0].focus(),this;if(k)if(j=document.selection,"textarea"!=this[0].tagName.toLowerCase()){k=this.val();h=j[b]()[a]();h.moveEnd("character",k[c]);var g=""==h.text?k[c]:k.lastIndexOf(h.text);h=j[b]()[a]();h.moveStart("character",-k[c]);var l=h.text[c]}else h=j[b](),j=h[a](),j.moveToElementText(this[0]),j.setEndPoint("EndToEnd",h),g=j.text[c]-h.text[c],l=g+h.text[c];else g=i.selectionStart,l=i.selectionEnd;h=i.value.substring(g,l);
return{start:g,end:l,text:h,replace:function(a){return i.value.substring(0,g)+a+i.value.substring(l,i.value[c])}}}})(jQuery,"length","createRange","duplicate");
