var JSON;JSON||(JSON={});
(function(){function a(a){return a<10?"0"+a:a}function c(a){d.lastIndex=0;return d.test(a)?'"'+a.replace(d,function(a){var f=o[a];return typeof f==="string"?f:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function g(a,h){var f,m,k,d,n=e,j,b=h[a];b&&typeof b==="object"&&typeof b.toJSON==="function"&&(b=b.toJSON(a));typeof l==="function"&&(b=l.call(h,a,b));switch(typeof b){case "string":return c(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";
e+=i;j=[];if(Object.prototype.toString.apply(b)==="[object Array]"){d=b.length;for(f=0;f<d;f+=1)j[f]=g(f,b)||"null";k=j.length===0?"[]":e?"[\n"+e+j.join(",\n"+e)+"\n"+n+"]":"["+j.join(",")+"]";e=n;return k}if(l&&typeof l==="object"){d=l.length;for(f=0;f<d;f+=1)typeof l[f]==="string"&&(m=l[f],(k=g(m,b))&&j.push(c(m)+(e?": ":":")+k))}else for(m in b)Object.prototype.hasOwnProperty.call(b,m)&&(k=g(m,b))&&j.push(c(m)+(e?": ":":")+k);k=j.length===0?"{}":e?"{\n"+e+j.join(",\n"+e)+"\n"+n+"}":"{"+j.join(",")+
"}";e=n;return k}}if(typeof Date.prototype.toJSON!=="function")Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
d=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,i,o={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},l;if(typeof JSON.stringify!=="function")JSON.stringify=function(a,c,f){var d;i=e="";if(typeof f==="number")for(d=0;d<f;d+=1)i+=" ";else typeof f==="string"&&(i=f);if((l=c)&&typeof c!=="function"&&(typeof c!=="object"||typeof c.length!=="number"))throw Error("JSON.stringify");return g("",
{"":a})};if(typeof JSON.parse!=="function")JSON.parse=function(a,c){function f(a,d){var e,g,b=a[d];if(b&&typeof b==="object")for(e in b)Object.prototype.hasOwnProperty.call(b,e)&&(g=f(b,e),g!==void 0?b[e]=g:delete b[e]);return c.call(a,d,b)}var d,a=String(a);h.lastIndex=0;h.test(a)&&(a=a.replace(h,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return d=eval("("+a+")"),typeof c==="function"?f({"":d},""):d;throw new SyntaxError("JSON.parse");}})();window.XMLHttpRequest||(XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(g){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(h){}throw Error("Could not find an XMLHttpRequest alternative.");});
function Request(a,c,g){for(var h=g!=null,d="action="+a,e=0;e<c.length;e++)d+="&arg"+e+"="+c[e];d+="&time="+(new Date).getTime();var i=new XMLHttpRequest;i.open("GET","/_ajax/"+a+"?"+d,h);if(h)i.onreadystatechange=function(){if(i.readyState==4&&i.status==200){var a=null;try{a=JSON.parse(i.responseText)}catch(c){a=i.responseText}g(a)}};i.send(null)}var lastNumber="",hasToken="";function $(a){return document.getElementById(a)}function doVote(a){Request("vote",[a],onVoteSuccess)}
function onVoteSuccess(a){key=a.key;msg=a.msg;if(document.getElementById("popular_msg:"+key))$("popular_msg:"+key).innerHTML=msg,$("popular_link:"+key).innerHTML="Thank you!";if(document.getElementById("recent_msg:"+key))$("recent_msg:"+key).innerHTML=msg,$("recent_link:"+key).innerHTML="Thank you!"}
function doCall(){$("callButton").disabled=true;showButter(true,"Trying...");var a=document.callForm.areaCode.value,c=document.callForm.first3.value,g=document.callForm.last4.value,h=document.callForm.when.value,d=a+c+g;d!=lastNumber&&(hasToken=="1"&&socket.close(),hasToken="");lastNumber=d;Request("call",[a,c,g,h,hasToken],onCallSuccess)}function onCallSuccess(a){setCallMsg(a.type,a.msg);a.token&&openChannel(a.token);showButter(false);$("callButton").disabled=false}
function setCallMsg(a,c){var g;$("callMsg").innerHTML='<div class="msg '+a+'">'+c+"</div>"}function getTime(){var a=new Date,c=a.getHours(),g=a.getMinutes();g<10&&(g="0"+g);a=a.getSeconds();a<10&&(a="0"+a);var h="AM";c>12&&(h="PM",c-=12);return c+":"+g+":"+a+" "+h}function insertChannelLI(a){currentTime=getTime();newLI=document.createElement("li");newLI.innerHTML=currentTime+" - "+a;$("channelList").appendChild(newLI)}
function showButter(a,c){a?($("butter").innerHTML=c,$("butter").style.display="block"):$("butter").style.display="none"}
function checkSubmit(){var a=document.submitForm.content.value;if(document.submitForm.author.value.length<2)return a="Oops, we know you're shy but can you give us a name?",$("submitError").innerHTML='<div class="submit_error">'+a+"</div>",false;else if(a.length<5)return a="Oops, can you be a bit more detailed?",$("submitError").innerHTML='<div class="submit_error">'+a+"</div>",false;return true}function initialFocus(){document.callForm.areaCode.focus()}
function moveFocus(a){switch(a){case "areaCode":document.callForm.areaCode.value.length==3&&document.callForm.first3.focus();break;case "first3":document.callForm.first3.value.length==3&&document.callForm.last4.focus();break;case "last4":document.callForm.last4.value.length==4&&document.callForm.callButton.focus()}}
function openChannel(a){hasToken="1";channel=new goog.appengine.Channel(a);socket=channel.open();socket.onopen=channelOpened;socket.onmessage=channelMessage;socket.onerror=channelError;socket.onclose=channelClose}function channelMessage(a){insertChannelLI(a.data)}function channelOpened(){}function channelError(){}function channelClose(){};
