Object.append=function(A){for(var C=1;
C<arguments.length;
C++){var D=arguments[C];
for(var B in D){if(D.hasOwnProperty(B)){A[B]=D[B]
}}}return A
};
Object.$empty=function(){};
Object.$base=function $base(){var A=$base.caller||arguments.callee.caller;
return A.$class.$super.prototype[A.$name].apply(this,arguments.length?arguments:A.arguments)
};
Object.$super=function $super(){var A=$super.caller||arguments.callee.caller;
return A.$class.$super.prototype
};
Object.append(Object,{merge:function(){return Object.append.apply(this,[{}].concat(Array.make(arguments)))
},extend:function(A,F){var D=function D(){if(D.prototype.$constructor){D.prototype.$constructor.apply(this,arguments)
}};
var C={},E=(this==Object?null:this);
if(E){if(C.__proto__){C.__proto__=E.prototype
}else{Object.$empty.prototype=E.prototype;
C=new Object.$empty()
}C.constructor=D
}D.$super=E;
D.prototype=C;
D.extend=Object.extend;
C.$class=D;
C.$super=Object.$super;
C.$base=Object.$base;
if(A.constructor&&A.constructor!=Object){A.$constructor=A.constructor;
delete A.constructor
}for(var B in A){var G=A[B];
if(G instanceof Function){G.$name=B;
G.$class=D
}C[B]=G
}if(F){for(var B in F){D[B]=F[B]
}}return D
},implement:function(C,A){var B=C.prototype;
for(var D in A){if(A.hasOwnProperty(D)&&!(D in B)){B[D]=A[D]
}}}});
Object.implement(Function,{bind:function(B){var A=arguments,C=this;
return function(){return C.apply(B,Array.prototype.slice.call(A,1).concat(Array.prototype.slice.call(arguments,0)))
}
},timeout:function(B,C){var D=this,A=Array.prototype.slice.call(arguments,1);
C=C||1;
return window.setTimeout(function(){return D.apply(B,A)
},C)
},filter:function(){var A=arguments,B=this;
clearTimeout(this.timer);
this.timer=setTimeout(function(){B.apply(B.context||null,Array.prototype.slice.call(A))
},this.delay||500)
}});
Object.append(Array,{make:function(A){return[].slice.call(A,0)
}});
Object.implement(Array,{pushUnique:function(A){if(this.indexOf(A)==-1){return this.push(A)
}},exists:function(A){return this.indexOf(A)>=0
},replace:function(B,C){var A=this.indexOf(B);
if(A!=-1){return this[A]=C
}},remove:function(B){var A=this.indexOf(B);
if(A!=-1){return this.splice(A,1)[0]
}},toggle:function(A){if(this.exists(A)){this.remove(A)
}else{this.push(A)
}},forEach:function(D,B){var C=this.length>>>0;
if(typeof D!="function"){throw new TypeError()
}for(var A=0;
A<C;
A++){if(A in this){D.call(B,this[A],A,this)
}}},JOIN:function(){return this.join(", ")
}});
Object.implement(String,{escapeRegExp:function(){return this.replace(/([\|\!\[\]\^\$\(\)\{\}\+\=\?\.\*\\])/g,"\\$1")
},trim:function(){return this.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g,"")
},normalize:function(A){return this.trim(this.replace(/[\s\xA0]{2,}/g,""))
},hash:function(C){var A=27183,E=0,B=31415,D=this;
E=(this.length*B)%C;
for(i=this.length;
i--;
){E=(B*E+B*this.charCodeAt(i))%C;
B=((B%C)*(A%C))%(C)
}return E
}});
String.prototype.SPLIT=function xxx(){var B=this==""?[]:this.split(","),C=[];
for(var D=B.length;
D--;
){var A=(B[D]||"").normalize();
if(A){C.pushUnique(A)
}}C.sort();
return C
};
String.prototype.test=function(A){return((A==(lower=A.toLowerCase()))?this.toLowerCase().indexOf(lower):this.indexOf(A))!=-1
};
(function(){var C=Date.prototype;
var B=[null,function(G){this.setFullYear(G<100?(G<70?2000+G:1900+G):G)
},function(G){this.setMonth(G-1)
},C.setDate,C.setHours,C.setMinutes,C.setSeconds,function(G){if(G.toLowerCase()=="pm"){this.setHours(this.getHours()+12)
}},function(G){var H=this.getDate();
this.setDate(G);
if(H>G){this.setMonth(this.getMonth()+1)
}},function(G){this.setFullYear(this.getFullYear()+G)
},function(G){this.setMonth(this.getMonth()+G)
},function(G){this.setDate(this.getDate()+G*7)
},function(G){this.setDate(this.getDate()+G)
},function(G){this.setHours(this.getHours()+G)
}];
var D=[{e:/(-?\d+)\s*\-?\s*th\w*/i,p:[8]},{e:/(-?\d+)\s*y\w*/i,p:[9]},{e:/(-?\d+)\s*m\w*/i,p:[10]},{e:/(-?\d+)\s*w\w*/i,p:[11]},{e:/(-?\d+)\s*d\w*/i,p:[12]},{e:/(-?\d+)\s*h\w*/i,p:[13],time:1},{e:/(^|[^\d])([012]?\d|21|22|23)\s*([\:\-\.]+)\s*([0-5]?\d)\s*(am|pm)?/i,p:[0,4,0,5,7],time:1}],F={e:/(^|[^\d])(0?\d|10|11|12)\s*(\/+)\s*([012]?\d|30|31)\s*\3\s*((19|20)?\d\d)([^\d]|$)/,p:[0,2,0,3,1]},A={e:/(^|[^\d])([012]?\d|30|31)\s*([\.\-\,\/]+)\s*(0?\d|10|11|12)\s*\3\s*((19|20)?\d\d)([^\d]|$)/,p:[0,3,0,2,1]},E={e:/(^|[^\d])((19|20)?\d\d)\s*([\.\-\/]+)\s*(0?\d|10|11|12)\s*\4\s*([012]?\d|30|31)([^\d]|$)/,p:[0,1,0,0,2,3]};
Object.append(Date,{locale:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},matching:{methods:B,patterns:{"%d.%m.%Y":D.concat([E,F,A]),"%m/%d/%y":D.concat([E,A,F]),"%Y-%m-%d":D.concat([F,A,E])}},military:function(){return this.format.time.indexOf("%p")<0
},detect:function(){var I=new Date();
I.setFullYear(2013,10,12);
var H=I.toLocaleDateString(),K,G=H.indexOf("12"),M=H.indexOf("11"),J=H.indexOf("13");
if((G==0)||(G<M&&G<J)){K="%d.%m.%Y"
}else{if(G<J){K="%m/%d/%y"
}else{K="%Y-%m-%d"
}}var L=!/\b(am|pm)\b/i.test(new Date().toLocaleTimeString());
return{date:K,time:this.military?"%H:%M":"%I:%M %p",weekStarts:0}
}});
Date.format=Date.detect()
})();
Date.prototype.parse=function(J){var I=true,A=Date.matching.patterns[Date.format.date],B=Date.matching.methods;
for(var D=A.length;
D--;
){var F=A[D],E=J.match(F.e);
if(E){if(F.time){I=false
}var H=F.p;
for(var C=0;
C<H.length;
C++){if(H[C]&&E[C+1]){var G=parseInt(E[C+1],10);
B[H[C]].call(this,isNaN(G)?E[C+1]:G)
}}J=J.replace(F.e,"")
}}this.allDay(I);
return this
};
Date.prototype.format=function(G){if(!G){G="%c"
}function B(H){return(H<10?"0":"")+H
}var E={A:function(){return this.days[this.getDay()]
},B:function(){return Date.locale.months[this.getMonth()]
},c:function(){return this.format("%x"+(this.allDay()?"":" %X"))
},d:function(){return B(this.getDate())
},H:function(){return B(this.getHours())
},I:function(){return B(this.getHours()%12)
},m:function(){return B(this.getMonth()+1)
},M:function(){return B(this.getMinutes())
},p:function(){return this.getHours()<12?"AM":"PM"
},S:function(){return B(this.getSeconds())
},x:function(){return this.format(Date.format.date)
},X:function(){return this.format(Date.format.time)
},y:function(){return B(this.getFullYear()%100)
},Y:function(){return""+this.getFullYear()
},Z:function(){return""
}};
var D=this,A=G,F;
function C(){return E[F].call(D)
}for(F in E){A=A.replace("%"+F,C)
}return A
};
Date.prototype.timestamp=function(A){if(A){this.setTime(A*1000);
return this
}return parseInt(this.valueOf()/1000)
};
Date.prototype.allDay=function(A){if(A==undefined){return this.getSeconds()==1
}this.setSeconds(A?1:0);
return this
};
Date.prototype.clone=function(){return new Date(this.valueOf())
};
Date.prototype.date=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate())
};
Date.prototype.getDaysInMonth=function(){var A=this.getFullYear(),B=this.getMonth();
return[31,(((A%4==0&&A%100!=0)||A%400==0)?29:28),31,30,31,30,31,31,30,31,30,31][B]
};
(function(){if(
/*@cc_on!@*/
0){delete HTMLElement.prototype.removeNode
}if("\v"=="v"){HTMLElement=Element;
var listening={addEventListener:function(type,listener,capture){var element=this;
var wrapper=function(){listener.call(element,window.event)
};
this.attachEvent("on"+type,wrapper)
},removeEventListener:function(){this.detachEvent("on"+type,listener)
}};
Object.implement(HTMLElement,listening);
Object.append(document,listening);
Object.append(window,listening);
Event.implement({preventDefault:function(){this.returnValue=false
},stopPropagation:function(){this.cancelBubble=true
}});
Object.defineProperty(Event.prototype,"target",{get:function(){return this.srcElement
}})
}})();
Object.append(navigator,{isOpera:function(){return !!window.opera
},isGecko:function(){return !!window.mozInnerScreenX
},isIE:function(){return"\v"=="v"
},isWebKit:function(){return navigator.userAgent.indexOf("WebKit")>=0
}});
function Cookies(A){this.document=A
}Cookies.prototype={set:function(C,D,B){B=B||{};
if(B.encode!=false){D=encodeURIComponent(D)
}if(B.domain){D+="; domain="+B.domain
}if(B.path){D+="; path="+B.path
}else{D+="; path=/"
}if(B.duration){var A=new Date();
A.setTime(A.getTime()+B.duration*24*60*60*1000);
D+="; expires="+A.toGMTString()
}if(B.secure){D+="; secure"
}this.document.cookie=C+"="+D
},get:function(A){var B=this.document.cookie.match("(?:^|;)\\s*"+A+"=([^;]*)");
return B?decodeURIComponent(B[1]):null
},remove:function(A){this.set(A,"",{duration:-1})
}};
document.cookies=new Cookies(document);
(function(){var B={};
function C(E){var F,D="",G;
if(E instanceof RegExp){G=E.source;
F=E.toString();
D+=E.ignoreCase?"i":""
}else{G=F=E.toString().escapeRegExp()
}if(!(F in B)){return B[F]=new RegExp("(^|\\s+)"+G+"(\\s+|$)",D)
}return B[F]
}Object.implement(HTMLElement,{contains:function(D){return !!(this.compareDocumentPosition(D)&16)
},insertAfter:function(E,D){if(D=D.nextSibling){this.insertBefore(E,D)
}else{this.appendChild(E)
}},insertSiblingBefore:function(D){this.parentNode.insertBefore(D,this)
},insertSiblingAfter:function(D){this.parentNode.insertAfter(D,this)
},insertSibling:function(D,E){if(E||E===undefined){this.insertSiblingBefore(D)
}else{this.insertSiblingAfter(D)
}},prependChild:function(D){if(this.firstChild){this.insertBefore(D,this.firstChild)
}else{this.appendChild(D)
}},removeNode:function(){if(this.parentNode){this.parentNode.removeChild(this)
}},replaceNode:function(D){this.insertSibling(D);
this.removeNode()
},clearNode:function(){while(this.firstChild){this.removeChild(this.firstChild)
}},getParent:function(D){var E=this;
while(E){if(E.hasClass&&E.hasClass(D)){return E
}E=E.parentNode
}return null
},getChildren:function(D){var E=[],F=this.firstChild;
while(F){if(F.hasClass&&F.hasClass(D)){E.push(F)
}F=F.nextSibling
}return E
},getDescendants:function(E,G){var D=[];
var F=this.firstChild;
do{if(F&&F.nodeType==1){if(F.hasClass(E)){D.push(F)
}if(!G||F.hasClass(G)){D=D.concat(F.getDescendants(E,G))
}}}while(F&&(F=F.nextSibling));
return D
},redraw:function(){var D=this;
var E="random"+Math.round(Math.random()*10000);
D.addClass(E);
setTimeout(function(){D.removeClass(E)
},1)
},offset:function(E){var F=this.getBoundingClientRect();
if(!E){return{left:F.left+window.pageXOffset,top:F.top+window.pageYOffset}
}var D=E.getBoundingClientRect();
return{left:F.left-D.left,top:F.top-D.top}
},repaint:function(){},reflow:function(){},addClass:function(D){var E=E=D.split(" ").filter(function(F){return !this.hasClass(F)
},this);
if(E.length){this.className+=" "+E.join(" ")
}},removeClass:function(D){var E=this.className.normalize().split(" ");
if(E.exists(D)){E.remove(D);
this.className=E.join(" ")
}},assignClass:function(E,D){if(D){this.addClass(E)
}else{this.removeClass(E)
}},toggleClass:function(D){if(this.hasClass(D)){this.removeClass(D)
}else{this.addClass(D)
}},hasClass:function(D){var E=this.className;
if(D instanceof RegExp){return D.test(E)
}return(" "+E+" ").indexOf(" "+D+" ")>=0
}});
function A(D,F,E){var I=D.createElement(F);
for(var H in E){I.setAttribute(H,E[H])
}var G=D.getElementsByTagName("head")[0];
G.insertBefore(I,G.firstChild);
return I
}document.importScript=function(E){var D=A(document,"script",{src:E,type:"text/javascript"});
return D
};
document.create=function(D){if(typeof D=="string"){return document.createTextNode(D)
}if((typeof Widget!="undefined")&&(D instanceof Widget)){D=D.main()
}if(D.nodeType){return D
}var H=null;
if(D.node){H=D.node;
H.clearNode()
}else{H=document.createElement(D.tag?D.tag:"div")
}if(D.name){H.className=D.name
}var E=D.text||D.content;
if(E){E=document.createTextNode(E);
H.appendChild(E)
}E=D.html;
if(E){H.innerHTML=E
}E=D.child;
if(E){if(!(E instanceof Array)){E=[E]
}for(var G=0;
G<E.length;
G++){if(E[G]){H.appendChild(document.create(E[G]))
}}}E=D.attribute;
if(E){for(var G in E){if(E[G]){H.setAttribute(G,E[G])
}else{H.removeAttribute(G)
}}}E=D.style;
if(E){for(var G in E){H.style[G]=E[G]||""
}}E=D.property;
if(E){for(var G in E){H[G]=E[G]
}}E=D.event;
if(E){if(!(E instanceof Array)){E=[E]
}for(var G=E.length;
G--;
){H.on(E[G].name||E[G].type,E[G].listener,{context:E[G].context})
}}E=D.on;
if(E){for(var G in E){if(typeof E[G]=="function"){H.on(G,E[G])
}else{H.on(G,E[G].listener,E[G])
}}}if(E=D.reference){if(!(E instanceof Array)){E=[E]
}for(var G=E.length;
G--;
){for(var F in E[G]){E[G][F][F]=H
}}}if(D.link){D.link.hash[D.link.name]=H
}if(D.service){if(D.service instanceof Function){D.service(H)
}else{Widget.service(H)
}}if(D.append){D.append.appendChild(H)
}return H
}
})();
(function(){function B(D,E,F,C){this.element=D;
this.type=E instanceof Array?E:[E];
this.options=C||{};
this.listener=this.options.context?F.bind(this.options.context):F;
this.enabled=false;
if(this.options.add!==false){this.enable()
}}Object.implement(B,{enable:function(){if(this.enabled){return 
}for(var C=0;
C<this.type.length;
C++){this.element.addEventListener(this.type[C],this.listener,this.options.capture)
}this.enabled=true
},disable:function(){if(!this.enabled){return 
}for(var C=0;
C<this.type.length;
C++){this.element.removeEventListener(this.type[C],this.listener,this.options.capture)
}this.enabled=false
}});
var A={on:function(D,E,C){return new B(this,D,E,C)
},fire:function(C){if(document.createEvent){var D=document.createEvent("HTMLEvents");
D.initEvent(C,true,true);
return this.dispatchEvent(D)
}else{if(document.createEventObject){var D=document.createEventObject();
return this.fireEvent("on"+C,D)
}}}};
Object.implement(Event,{stop:function(){this.preventDefault();
this.stopPropagation()
},modifierKey:function(){return this.ctrlKey||this.altKey||this.metaKey||this.shiftKey
},optionKey:function(){return this.ctrlKey||this.altKey||this.metaKey
},isTextbox:function(){var E=this.target;
if(E.getAttribute){var C=E.localName.toLowerCase(),D=E.getAttribute("type");
return(C=="input"&&/^(text|password|search)$/.test(D))||C=="textarea"
}return false
}});
Object.implement(XMLHttpRequest,{addEventListener:function(D,E,C){this["on"+D]=function(){E({target:this})
}
},removeEventListener:function(){}});
Object.implement(HTMLElement,A);
Object.implement(XMLHttpRequest,A);
Object.append(window,A);
Object.append(document,A)
})();
var Utils={typograf:function(A){if(A==""){return A
}A=" "+A+" ";
A=A.replace("&","&amp;");
A=A.replace("<","&lt;");
A=A.replace(">","&gt;");
A=A.replace(/\*\*(.*?)\*\*/gm,"<b>$1</b>");
A=A.replace(/(\b|[^:])\/\/(.*?[^:])\/\//g,"$1<i>$2</i>");
A=A.replace(/__(.*?)__/gm,"<u>$1</u>");
A=A.replace(/--(.*?)--/gm,"<s>$1</s>");
A=A.replace(/(\s)-{1,3}(\s)/g,"$1\u2014$2");
A=A.replace(/\s\"/g," \u00ab");
A=A.replace(/\"/g,"\u00bb");
A=A.replace(/\b(http|https|file|ftp):\/\/(\S*)/g,'<a href="$1://$2" target="_blank">$1://$2</a>');
A=A.replace(/([a-z0-9_\-.]+)@([a-z0-9\.\-]+)/ig,'<a href="mailto:$1@$2">$1@$2</a>');
return A.trim()
},simpleHash:function(D){var B=9;
for(var C=D.length-1;
C>=0;
C--){var A=Math.abs(Math.sin(D.charCodeAt(C)))*10000;
A=A-Math.floor(A);
B=(B+Math.floor(A*10000))%360
}return B
},hslToRgb:function(F,J,E){function D(M,L,K){if(K<0){K+=1
}else{if(K>1){K-=1
}}if(K<1/6){return M+(L-M)*6*K
}if(K<1/2){return L
}if(K<2/3){return M+(L-M)*(2/3-K)*6
}return M
}function I(L){var K="0123456789ABCDEF".split("");
return K[L>>4]+K[L&15]
}if(J==0){E/=100;
return[E*255,E*255,E*255]
}F=F/360;
J/=100;
E/=100;
var A,G,H,B=E<0.5?E*(1+J):E+J-E*J,C=2*E-B;
A=D(C,B,F+1/3);
G=D(C,B,F);
H=D(C,B,F-1/3);
return"#"+I(Math.round(A*255))+I(Math.round(G*255))+I(Math.round(H*255))
}};
window.setTimeoutEx=function(B,C,A){return window.setTimeout((function(F,E,D){return function(){F.apply(E,D)
}
})(B,A,Array.prototype.slice.call(arguments,3)),C)
};
var Gears=Object.extend({constructor:function(){if(this.necessity()){this.init()
}},init:function(){var A=null;
if(window.google&&window.google.gears&&window.google.gears.factory){A=window.google.gears.factory
}else{if(typeof GearsFactory!="undefined"){A=new GearsFactory()
}else{try{A=new ActiveXObject("Gears.Factory");
if(A.getBuildInfo().indexOf("ie_mobile")!=-1){A.privateSetGlobalObject(this)
}}catch(B){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){A=document.createElement("object");
A.type="application/x-googlegears";
document.documentElement.appendChild(A)
}}}}try{A.style.position="absolute"
}catch(B){}this.factory=A;
if(this.available()){this.database=this.factory.create("beta.database");
this.database.open("smthngs");
this.database.execute("CREATE TABLE IF NOT EXISTS storage (name TEXT UNIQUE, value TEXT)");
if(!this.get("shortcut")){this.set("shortcut",1);
this.createShortcut()
}return true
}},available:function(){return !!(this.factory&&this.factory.getPermission&&this.factory.getPermission("Smthngs","/client/smthngs/images/icons/shortcut/32.png","This feature enables you to manage your tasks even when your computer is not connected to the Internet."))
},necessity:function(){return !navigator.geolocation||!window.localStorage||!window.applicationCache
},get:function(B,D){var C=D||null;
var A=this.database.execute("SELECT * FROM storage WHERE name = ?",[B]);
if(A.isValidRow()){C=A.field(1)
}A.close();
return C
},set:function(A,B){try{this.database.execute("REPLACE INTO storage VALUES (?, ?)",[A,B])
}catch(C){}},createShortcut:function(){try{var B={};
for(var A in {16:1,32:1,48:1,128:1}){B[A+"x"+A]="/client/smthngs/images/icons/shortcut/"+A+".png"
}this.factory.create("beta.desktop").createShortcut("Smthngs (thn.gs)","/",B,"This shortcut launches the Smthngs (thn.gs).")
}catch(C){}},install:function(){var A="http://gears.google.com/?action=install&message="+encodeURIComponent("To use Smthngs (http://thn.gs/) in offline mode, you must first install Gears.")+"&return="+encodeURIComponent(window.location.href);
var B=window.open(A,"gears");
if(!B){window.location.href=A
}}});
function disable(){var A=document.activeElement.tagName;
if(A=="TEXTAREA"||A=="INPUT"){return true
}return false
}document.onselectstart=disable;
document.ondragstart=disable;
(function(){var A=0,D={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup"};
function C(G,E){var I=E.changedTouches[0];
if(!I){return 
}var F=document.elementFromPoint(I.pageX,I.pageY);
if(!F){return 
}var H=document.createEvent("MouseEvents");
H.initMouseEvent(G,true,true,window,E.detail,I.screenX,I.screenY,I.clientX,I.clientY,E.ctrlKey,E.altKey,E.shiftKey,E.metaKey,E.button,E.relatedTarget);
F.dispatchEvent(H)
}function B(E){if(E.type=="touchstart"){var F=E.target;
while(F){if(F.hasAttribute&&F.hasAttribute("touchable")){A=1;
break
}F=F.parentNode
}}if(A){if(E.touches.length<=1){C(D[E.type],E);
if(E.type=="touchmove"){E.preventDefault()
}if(E.type=="touchend"){A=0
}}else{C("mouseup",E);
A=0
}}}document.on("touchstart",B);
document.on("touchmove",B);
document.on("touchend",B)
})();
var Issue=Object.extend({pattern:{id:0,title:"",notes:"",mark:"undone",type:"task",folder:"inbox",tags:[],start:null,startRemind:null,due:null,dueRemind:null,parent:0,geolocation:null,weight:0},constructor:function(A){if(A){}else{A={}
}for(var B in this.pattern){this[B]=A[B]||this.pattern[B]
}this.tags.sort();
this.cache={}
},data:function(B){if(B){for(var A in this.pattern){if(A in B){this[A]=B[A]
}}this.cache={}
}else{B={};
for(var A in this.pattern){B[A]=this[A]
}return B
}},timely:function(){var E=this.mark,B=this.folder,C=this.due,D=this.start;
if((!C&&!D)||(E!="undone"&&E!="area")||(B=="trash"||B=="archive")){return this.cache.timely=false
}var A=new Date().date().timestamp()+3600*24;
if(D){console.log(this.title,D,A,new Date(D*1000))
}return this.cache.timely=((C&&(C-(this.dueRemind||0)<A))||(D&&(D-(this.startRemind||0)<A)))
},badges:function(){var A={},C,D;
function B(G){var E=(new Date()).date().timestamp()-G;
var F=E>0;
E=Math.abs(E);
return{past:F,date:(new Date).timestamp(G),days:Math.floor(E/(3600*24)),months:Math.floor(E/(3600*24*30)),years:Math.floor(E/(3600*24*30*12))}
}if(this.due){C=B(this.due);
if(C.years>1){D=C.past?C.years+" years overdue":"due "+C.date.format("%B %Y")
}else{if(C.months>=2){D=C.past?C.months+" months overdue":C.months+" months left"
}else{if(C.days>=1){D=C.past?C.days+" days overdue":C.days+" days left"
}else{D="due today"
}}}A.due={overdue:C.past,text:D}
}if(this.start){C=B(this.start);
if(C.years>1){D=C.past?"started "+C.years+" years ago":"starts in "+C.date.format("%B %Y")
}else{if(C.months>=2){D=C.past?"started "+C.months+" months ago":"starts in "+C.months+" months"
}else{if(C.days>=1){D=C.past?"started "+C.days+" days ago":"starts in "+C.days+" days"
}else{D="starts today"
}}}A.start={text:D}
}if(this.geolocation){A.geolocation={text:this.geolocation[3]}
}return A
}});
var API=Object.extend({constructor:function(A){this.smthngs=A;
try{this.button=this.smthngs.toolbar.node.connection
}catch(B){}this.threads=0
},request:function(D){var B={status:"error",error:500,comment:"Whoops! Something went wrong. Please refresh the page and try again!"};
function E(I){var H=I.target;
var G=B;
try{G=JSON.parse(H.responseText)
}catch(J){track("error","server","request: "+F+", response: "+H.responseText);
return A.call(this,I,G)
}if(G.status=="error"){return A.call(this,I,G)
}this.indicator();
if(D.response){D.response.call(D.context,G)
}}function A(I,G){var H=I.target;
this.indicator();
if(G.error==401||G.error==500){this.smthngs.logic.auth("#authentication-lost");
return 
}if(D.error){D.error.call(D.context,D,G||B)
}}var C=new XMLHttpRequest();
C.on("load",E.bind(this));
C.on("error",A.bind(this));
C.open("POST","/api",!D.sync);
var F="action="+encodeURIComponent(D.action)+"&parameters="+encodeURIComponent(JSON.stringify(D.parameters));
C.setRequestHeader("Content-type","application/x-www-form-urlencoded");
this.indicator(1);
C.send(F)
},indicator:function(A){this.threads+=A?1:-1;
if(this.button){this.button.assignClass("sync",this.threads)
}}});
var Logic=Object.extend({constructor:function(A){this.smthngs=A;
this.issues={};
this.tagsCache=null;
this.node={button:this.smthngs.toolbar.node.connection};
var D=new StorageW3C(this),C=new StorageGears(this),B=new StorageCookie(this);
this.storages={local:D.available()?D:(C.available()?C:B),remote:new StorageRemote(this)};
this.storage=null;
this.retrieve();
window.on("online",this.onOnline.bind(this));
window.on("offline",this.onOffline.bind(this))
},retrieve:function(){var B=this.storages.remote,A=this.storages.local;
if(B.authenticated()===false){return this.auth()
}if(A.enable()||!B.available()){if(A.empty()){return this.auth()
}this.issues=A.issues();
this.set(A);
if(A.enable()){this.connect(true)
}}else{if(B.available()){this.set(B);
this.issues=B.issues();
A.sync(B)
}else{this.auth()
}}},auth:function(B){document.cookies.remove("ticket");
document.body.clearNode();
var A=window.location;
A.assign(A.protocol+"//"+A.host+"/auth"+(B||""))
},onOnline:function(A){console.log("onOnline");
this.connect(true)
},onOffline:function(A){console.log("onOffline");
if(this.smthngs.preferences.get().offline){this.disconnect()
}},online:function(){return this.storage==this.storages.remote
},set:function(B){if(this.storage==B){return 
}this.storage=B;
this.smthngs.toolbar.node.connection.assignClass("offline",!this.online());
if(this.smthngs.state){this.smthngs.state.restore({offline:this.online()?null:true})
}try{this.smthngs.state.title()
}catch(A){}},neighbourWeight:function(F,E){var B=this.issues,D=F.weight,H=E?-99:99;
for(var C in B){var A=B[C],G=A.weight-D;
if(E?(G<0&&G>H):(G>0&&G<H)){H=G
}}return D+H
},createIssue:function(E,D){var C=this.smthngs.state.state;
var A=E?E.type:"task",B=0,F;
if(E){B=this.neighbourWeight(E,D)
}else{for(F in this.issues){if(this.issues[F].weight>=B){B=this.issues[F].weight+1
}}}F=-1;
while(F in this.issues){F--
}return this.issues[F]=new Issue({id:F,title:A=="project"?"New Project":"New Task",type:A,folder:this.smthngs.focus.current.folder,parent:E?E.parent:C.root,tags:(C.tags||[]).slice(),weight:B})
},changeIds:function(A){this.storage.changeIds(A);
var F=this.issues;
for(var D in F){var K=F[D];
if(K.parent in A){K.parent=A[K.parent]
}}for(var J in A){var B=A[J],K=F[J];
if(K){delete F[J];
K.id=B;
F[B]=K
}}var L=this.smthngs,C=L.state,H=L.list.view,I=C.state.select,G=false;
for(var J in A){var B=A[J];
J=parseInt(J);
var E=H.issueNode(J);
if(E){E.issue=B
}if(I&&I.exists(J)){I.replace(J,B);
G=true
}}if(G){C.restore({select:I},this,true)
}},request:function(E,D,G,A,C){if(G){this.tagsCache=null
}function F(H){if(A){A.call(this,H)
}this.storages.local.affect(G,this.storage.type!="remote")
}function B(H){this.toggle(H)
}return this.storage.request({action:E,parameters:D,response:F,error:B,sync:C,context:this})
},toggle:function(K){var B=this.smthngs.gears;
var E=B.necessity()&&!B.available();
var C=this;
function A(){if(K){setTimeout(function(){C.storage.request(K)
},100)
}}function L(){C.disconnect();
A()
}if(K&&this.smthngs.preferences.get().offline){return L()
}var P={caption:"Stay offline",comment:"Stay in <b>offline</b> mode. Close the dialog."},G={caption:"Stay online",comment:"Stay in <b>online</b> mode. Close the dialog."},J={caption:"Retry online",comment:"Check your Internet connection and try again.",listener:function D(){A()
}},N={caption:"Switch to offline mode"+(this.storages.local.type=="gears"?" <em>using Gears</em>":""),comment:""+(!this.storages.local.cache?"Probably, if you close this web page you will need Internet connection to continue working.":""),listener:function D(){L()
}},F={caption:"Switch to online mode.",comment:"",listener:function D(){this.connect()
}},I={caption:"Install Gears",comment:"Gears is the most comfortable way to work with Smthngs for your browser when you're offline. It is a plug-in developed by Google.",listener:function D(){B.install()
}};
var H,M,O;
if(K){M="Connection lost";
O="Internet connection was lost. You should switch connection to offline mode or try to connect once again.";
H=[N,J,E?I:null]
}else{if(this.online()){M="Connection";
O="You are in <b>online</b> mode.<br/>Smthngs is able to work even without Internet Connection. When you are <b>offline</b>, Smthngs will store you data locally on your computer. When connection is on, we will synchronize all your data.";
H=[N,E?I:null,G]
}else{M="Connection";
O="You are in <b>offline</b> mode.";
H=[F,P]
}}H[0].focus=1;
new Widget.Confirm({width:500,base:this.node.button,context:this,caption:M,message:O,buttons:H})
},disconnect:function(){this.set(this.storages.local);
this.storage.disconnect()
},connect:function(B){function A(E){if(E){this.changeIds(E.ids)
}this.storages.local.purge();
this.set(this.storages.remote)
}function C(){new Widget.Confirm({width:500,base:this.node.button,context:this,caption:"Synchronization fail",message:"Sorry...",buttons:[{caption:"Stay offline",comment:"Stay in <b>offline</b> mode. Close the dialog."},{caption:"Discard changes",comment:"Локальное хранилище будет очищено. Your changes in offline mode will be lost.",listener:function E(){A.call(this)
}}]})
}var D=this.storages.local.difference();
if(D){this.storages.remote.request({action:"sync",parameters:D,response:A,error:B?null:C,context:this})
}else{A.call(this)
}},save:function(D){var C=D.id,A=this.issues[C],E=[C];
if((A.type=="project")&&(D.type=="task")){for(var F in this.issues){if(this.issues[F].parent==C){this.issues[F].parent=A.parent;
E.push(F)
}}}A.data(D);
function B(G){if(G.id){var H={};
H[A.id]=G.id;
this.changeIds(H);
E.push(G.id)
}}this.request("save",A.data(),E,B)
},mark:function(A){this.request("mark",{id:A.id,mark:A.mark},[A.id])
},tag:function(E){var B=E.issues,D=this.ids(B),A=E.tag;
for(var C in B){B[C].tags.pushUnique(A)
}this.request("tag",{ids:D,operation:E.operation||"add",tag:A},D)
},remove:function(B){for(var A=B.length;
A--;
){delete this.issues[B[A]]
}this.request("delete",{issues:B},B)
},emptyTrash:function(){var D,B=this.issues,A,C=[];
for(D in B){A=this.issues[D];
if(A.parent&&B[A.parent]&&(B[A.parent].folder=="trash")){A.parent=0;
C.push(D)
}}for(D in B){if(B[D].folder=="trash"){delete this.issues[D];
C.push(D)
}}this.request("empty-trash",null,C)
},move:function(D){D.issues=this.ids(D.issues);
var J=this.issues,M=D.issues,A=M.slice(),N;
if(("relative" in D)&&("position" in D)){var P=[],Q=this.issues[D.relative],I=D.position=="before",R=Q.weight,B=this.neighbourWeight(Q,I);
if(I){var O=R;
R=B;
B=O
}var H=(B-R)/(M.length+1);
for(N=M.length;
N--;
){P.push(this.issues[M[N]])
}P.sort(this.ruleByWeight);
for(N=P.length;
N--;
){P[N].weight=R+(N+1)*H
}if(!("parent" in D)){D.parent=Q.parent
}}if("parent" in D){var F=D.parent;
N=F;
while(N){M.remove(N);
N=(J[N]||{}).parent
}for(N=M.length;
N--;
){J[M[N]].parent=F
}if(F&&(N=J[F]).type!="project"){N.type="project";
A.push(F)
}}if("folder" in D){var E=D.folder,K=D.focus,L=M.slice();
function G(U,T){return !T||(T==U)||(T=="next"&&U=="today")
}while(L.length){for(N=L.length;
N--;
){issue=J[L[N]];
if(issue&&G(issue.folder,K)){issue.folder=E
}}var C=[];
for(N in J){if(L.indexOf(J[N].parent)!=-1){C.push(+N)
}}L=C;
A=A.concat(L)
}}if("tag" in D){var S=D.tag;
for(N=M.length;
N--;
){J[M[N]].tags.pushUnique(S)
}}this.request("move",D,A)
},ids:function(A){if(A instanceof Array){return A
}var C=[];
for(var B in A){C.push(parseInt(B))
}return C
},ruleByWeight:function(B,A){if(B.issue){B=B.issue;
A=A.issue
}if(B.weight>A.weight){return 1
}if(B.weight<A.weight){return -1
}return 0
},tags:function(){if(this.tagsCache){return this.tagsCache
}var E={};
var C=this.issues;
for(var G in C){var B=C[G].tags;
for(var D=B.length;
D--;
){var A=B[D];
if(A in E){E[A]++
}else{E[A]=1
}}}var B=[];
for(var A in E){B.push({name:A,count:E[A]})
}function F(I,H){return I.name>H.name?-1:+1
}B.sort(F);
this.tagsCache=B;
return B
}});
var Storage=Object.extend({type:"generic",constructor:function(A){this.logic=A;
this.smthngs=A.smthngs;
this.data=null;
if(this.available()){this.restore()
}},enable:function(){return !!(this.available()&&this.data&&this.data.modified)
},empty:function(){return !this.data
},online:function(){return false
},disconnect:function(){},issues:function(){var A={},B=this.data.issues;
for(var C in B){A[C]=new Issue(B[C])
}return A
},preferences:function(){return this.data.preferences
},changeIds:function(C){var B=this.data.issues;
for(var D in C){var E=C[D],A=B[D];
if(A){delete B[D];
A.id=E;
B[E]=A
}}this.store()
},request:function(A){if(A.response){A.response.call(A.context,{status:"ok"})
}},affect:function(F,C){if(!F){return 
}var E=this.data;
switch(F.space){case"preferences":E.preferences=Object.merge(E.preferences,parameters.parameters);
break;
default:var D,B=this.logic.issues;
for(var D=F.length;
D--;
){var G=F[D],A=B[G];
if(A){E.issues[G]=A.data();
if(C){E.issues[G].modified=1
}}else{delete E.issues[G];
if(C){E.remove.push(G)
}}}}if(C){E.modified=true
}this.store()
},serialize:function(A){if(A==null){return null
}try{return JSON[typeof A=="string"?"parse":"stringify"](A)
}catch(B){return null
}},sync:function(B){var A=B.data||{};
this.data={modified:!!A.modified,issues:A.issues,preferences:A.preferences,remove:A.remove||[]};
this.store()
},difference:function(){if(!this.data.modified){return null
}var B=this.data,A={remove:B.remove,issues:{},preferences:B.preferences};
for(var C in B.issues){if(B.issues[C].modified){A.issues[C]=new Issue(B.issues[C]).data()
}}return A
},purge:function(){var A=this.data;
issues=A.issues;
A.modified=false;
A.remove=[];
for(var B in issues){delete issues[B].modified
}this.store()
},clear:function(){this.set("data",null);
this.data={modified:false,preferences:null,issues:{},remove:[]}
},store:function(){this.set("data",this.serialize(this.data))
},restore:function(){this.data=this.serialize(this.get("data",null))
}});
var StorageRemote=Storage.extend({type:"remote",count:0,constructor:function(){this.$base()
},available:function(){return this.authenticated()&&!!window.data
},enable:function(){return true
},authenticated:function(){if(window.data){return window.data.preferences.mail!=null
}},online:function(){return false
},indicator:function(A){this.count+=A?1:-1;
this.logic.node.button.assignClass("sync",this.count)
},request:function(A){this.smthngs.api.request(A)
},restore:function(){var D=window.data,B={};
for(var C=D.issues.length;
C--;
){var A=D.issues[C];
B[A.id]=A
}this.data={preferences:D.preferences,issues:B,remove:[]}
},sync:function(){},store:function(){}});
var StorageW3C=Storage.extend({type:"w3c",storage:window.localStorage||(window.globalStorage?globalStorage[document.domain]:0)||null,cache:window.applicationCache||null,constructor:function(){if(this.cache){var C=["checking","noupdate","downloading","progress","cached","updateready","obsolete","error"];
var B=this;
B.onCache({type:"[start]"});
for(var A=0;
A<C.length;
A++){this.cache.addEventListener(C[A],function(D){B.onCache(D)
},false)
}}this.$base()
},onCache:function(A){if(A.type=="updateready"){console.log("call swapCache()");
this.cache.swapCache();
window.location.reload()
}},available:function(){return !!this.storage
},get:function(A,B){return this.storage[A]||B
},set:function(A,B){try{this.storage.removeItem(A);
this.storage[A]=B||""
}catch(C){console.log(C)
}}});
var StorageCookie=Storage.extend({type:"cookie",constructor:function(){this.$base()
},available:function(){return true
},enable:function(){return false
},get:function(A,B){return document.cookies.get(A)||B
},set:function(A,B){document.cookies.set(A,B)
}});
var StorageGears=Storage.extend({type:"gears",constructor:function(A){this.logic=A;
this.smthngs=A.smthngs;
this.gears=this.smthngs.gears;
this.server=null;
if(this.gears.available()){this.server=this.gears.factory.create("beta.localserver");
this.cache=this.server.createManagedStore("smthngs");
this.cache.manifestUrl="/client/manifests/smthngs-cache-gears.manifest";
this.cache.oncomplete=function(B){if(B.newVersion){window.location.reload()
}};
this.cache.checkForUpdate()
}this.$base()
},available:function(){return this.gears.available()
},online:function(){return !this.cache||!this.cache.enabled
},get:function(A,B){return this.gears.get(A,B)
},set:function(A,B){this.gears.set(A,B)
}});
GeolocationService=Object.extend({service:null,watcher:null,options:{gearsRequestAddress:true},constructor:function(A){this.geolocation=A;
this.position=null
},watch:function(){if(this.available()){this.watcher=this.service.watchPosition(this.change.bind(this),this.fail.bind(this),this.options)
}},available:function(){return !!this.service
},enable:function(){return !!this.watcher
},change:function(A){this.position=A;
this.geolocation.change(A)
},fail:function(){}});
GeolocationServiceGears=GeolocationService.extend({type:"gears",constructor:function(A){this.smthngs=A.smthngs;
this.gears=this.smthngs.gears;
if(this.available()){this.factory=this.gears.factory;
this.service=this.factory.create("beta.geolocation")
}this.$base()
},available:function(){return this.gears.available()
}});
GeolocationServiceW3C=GeolocationService.extend({type:"w3c",constructor:function(){this.service=navigator.geolocation;
this.$base()
}});
Geolocation=Object.extend({constructor:function(A){this.smthngs=A;
this.callback=null;
this.services=[new GeolocationServiceGears(this),new GeolocationServiceW3C(this)];
for(var B=this.services.length;
B--;
){if(this.services[B].available()){this.service=this.services[B];
break
}}this.observers=[];
this.listeners=[]
},position:function(A){if(A){if(this.service.position){A(this.service.position)
}else{this.listeners.pushUnique(A);
this.service.watch()
}}else{return this.service.position
}},change:function(A){var B,C=this.listeners,D=this.observers;
if(C.length){for(B=C.length;
B--;
){C[B](A)
}C.length=0
}for(B=D.length;
B--;
){D[B](A)
}},addObserver:function(A){this.observers.pushUnique(A)
},removeObserver:function(A){this.observers.remove(A)
}});
var _gaq=_gaq||[];
var Statistics=Object.extend({account:"UA-241120-5",constructor:function(A){window.statistics=this;
this.smthngs=A;
this.init();
this.buffer=[];
this.history=[];
this.flush=this.send.bind(this);
window.on("unload",this.onUnload.bind(this))
},init:function(){var B=document.createElement("script");
B.type="text/javascript";
B.async=true;
B.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";
var A=document.getElementsByTagName("script")[0];
A.parentNode.insertBefore(B,A);
_gaq.push(["_setAccount",this.account],["_trackPageview"])
},track:function(B,D,A,C){this.buffer.push(["_trackEvent",B,D,A,C]);
this.history.push([B,D,A,C]);
clearTimeout(this.timeout);
this.timeout=setTimeout(this.flush,5*1000)
},send:function(){clearTimeout(this.timeout);
_gaq.push.apply(_gaq,this.buffer);
this.buffer.length=0
},onUnload:function(){this.track("unload");
this.send()
}});
function track(B,D,A,C){window.statistics.track(B,D,A,C)
}function trackButton(C,A,B){track("button",C,A,B)
}window.onerror=function(C,B,A){track("error","client",C+" ("+B+"@"+A+"), navigator: "+navigator.userAgent+", history: "+JSON.stringify(window.statistics.history.slice(-10)))
};
var State=Object.extend({state:{},hash:"",constructor:function(E){this.smthngs=E;
function A(K,J){if(J){return K?"":null
}else{return true
}}function B(K,J){if(J){return K.toString()
}else{return parseInt(K)
}}function I(K,J){if(J){return K.sort().join(",")
}else{K=K.split(",");
K.forEach(function(M,L,N){N[L]=parseInt(M)
});
return K
}}function C(K,J){if(J){return encodeURIComponent(K)
}else{K=decodeURIComponent(K);
return K
}}function G(K,J){if(J){K=K.slice().sort();
K.forEach(function(M,L,N){N[L]=encodeURIComponent(M)
});
return K.join(",")
}else{K=K.split(",");
K.forEach(function(M,L,N){N[L]=decodeURIComponent(M)
});
return K
}}var F=/^\d+$/,D=/^\d+(,\d+)*$/;
this.condition={order:["focus","list","sidebar","root","tags","search","open","more","select","edit","offline"],except:[["select","edit"]],pattern:{focus:/^inbox|today|next|someday|archive|trash$/,sidebar:/^cloud|navigate|search$/,list:/^fold|tree|flat$/,edit:F,root:F,open:D,more:D,select:D},format:{focus:C,list:C,sidebar:C,root:B,tags:G,search:C,open:I,more:I,select:I,edit:B,offline:A}};
window.on("hashchange",this.onLocation.bind(this));
function H(){H.context.onLocation()
}H.context=this;
this.interval=setInterval(H,1000)
},init:function(){var B=this.state;
for(var A in B){delete B[A]
}B.edit=null;
B.select=null;
this.getLocation();
B.offline=!this.smthngs.logic.online()?true:null;
this.defaults(this.smthngs.preferences.state());
this.restore()
},title:function(){var A=this.smthngs.focus.current.title,C=this.smthngs.preferences.get().mail,B=this.smthngs.logic.online();
document.title="Smthngs"+(B?"":" (offline mode)")+" → "+C+" → "+A
},restore:function(C,B,A){if(C){this.overlay(C,A)
}this.smthngs.focus.restore(C||this.state,B||null);
this.title()
},overlay:function(A,C){for(var F in A){if(A[F] instanceof Array&&A[F].length==0){A[F]=null
}}for(var B in A){var I=A[B];
if(I==null){delete this.state[B]
}else{this.state[B]=I
}}var G=this.condition.except;
for(var F=G.length;
F--;
){var H=G[F];
for(var E=H.length;
E--;
){if(this.state[H[E]]){for(var D=H.length;
D--;
){if((H[E]!=H[D])&&(H[D] in this.state)){delete this.state[H[D]];
A[H[D]]=null
}}}}}this.setLocation(C)
},defaults:function(C){var A=false;
for(var B in C){if(!this.state[B]){this.state[B]=C[B]
}}this.setLocation(true)
},read:function(){return this.hash=(window.location.href.split("#")[1]||"")
},write:function(B,A){if(B!=this.hash){if(A&&!navigator.isOpera()){window.location.replace(window.location.href.replace(/#*[^#]*$/,"")+"#"+B)
}else{window.location.hash="#"+B
}this.read()
}},getLocation:function(){var H=this.read().split(";"),B=this.state,C=this.condition,G=C.pattern,J=C.format,D=C.order;
for(var F=H.length;
F--;
){var E=H[F].match(/^(\w+)(\=(.*))?$/);
if(E){var A=E[1],I=E[3]||"";
if((D.indexOf(A)!=-1)&&(!G[A]||G[A].test(I))){if(J[A]){B[A]=J[A](I,false)
}}}}},setLocation:function(C){var A=this.state,D=this.condition,H=D.format,E=D.order;
var I=[];
for(var F=0;
F<E.length;
F++){if(this.state[E[F]]){var B=E[F],G=H[B](this.state[B],true);
if(G!=null){I.push(B+(G==""?"":"="+G))
}}}this.write(I.join(";"),C)
},onLocation:function(A){if(A){clearInterval(this.interval)
}if((this.hash+"")!=this.read()){this.init()
}}});
var Preferences=Object.extend({defaults:{collapse:false,animation:true,focus:"today",sidebar:"navigate",width:200,format:{time:Date.format.time,date:Date.format.date,weekStarts:0},offline:true,search:{title:true,notes:true,tags:false,location:false},list:{inbox:"flat",today:"flat",next:"flat",someday:"fold",archive:"fold",trash:"fold"}},timeZones:"Africa/Abidjan;Africa/Accra;Africa/Addis_Ababa;Africa/Algiers;Africa/Asmara;Africa/Bamako;Africa/Bangui;Africa/Banjul;Africa/Bissau;Africa/Blantyre;Africa/Brazzaville;Africa/Bujumbura;Africa/Cairo;Africa/Casablanca;Africa/Ceuta;Africa/Conakry;Africa/Dakar;Africa/Dar_es_Salaam;Africa/Djibouti;Africa/Douala;Africa/El_Aaiun;Africa/Freetown;Africa/Gaborone;Africa/Harare;Africa/Johannesburg;Africa/Kampala;Africa/Khartoum;Africa/Kigali;Africa/Kinshasa;Africa/Lagos;Africa/Libreville;Africa/Lome;Africa/Luanda;Africa/Lubumbashi;Africa/Lusaka;Africa/Malabo;Africa/Maputo;Africa/Maseru;Africa/Mbabane;Africa/Mogadishu;Africa/Monrovia;Africa/Nairobi;Africa/Ndjamena;Africa/Niamey;Africa/Nouakchott;Africa/Ouagadougou;Africa/Porto-Novo;Africa/Sao_Tome;Africa/Tripoli;Africa/Tunis;Africa/Windhoek;America/Adak;America/Anchorage;America/Anguilla;America/Antigua;America/Araguaina;America/Argentina/Buenos_Aires;America/Argentina/Catamarca;America/Argentina/Cordoba;America/Argentina/Jujuy;America/Argentina/La_Rioja;America/Argentina/Mendoza;America/Argentina/Rio_Gallegos;America/Argentina/Salta;America/Argentina/San_Juan;America/Argentina/San_Luis;America/Argentina/Tucuman;America/Argentina/Ushuaia;America/Aruba;America/Asuncion;America/Atikokan;America/Bahia;America/Bahia_Banderas;America/Barbados;America/Belem;America/Belize;America/Blanc-Sablon;America/Boa_Vista;America/Bogota;America/Boise;America/Cambridge_Bay;America/Campo_Grande;America/Cancun;America/Caracas;America/Cayenne;America/Cayman;America/Chicago;America/Chihuahua;America/Costa_Rica;America/Cuiaba;America/Curacao;America/Danmarkshavn;America/Dawson;America/Dawson_Creek;America/Denver;America/Detroit;America/Dominica;America/Edmonton;America/Eirunepe;America/El_Salvador;America/Fortaleza;America/Glace_Bay;America/Godthab;America/Goose_Bay;America/Grand_Turk;America/Grenada;America/Guadeloupe;America/Guatemala;America/Guayaquil;America/Guyana;America/Halifax;America/Havana;America/Hermosillo;America/Indiana/Indianapolis;America/Indiana/Knox;America/Indiana/Marengo;America/Indiana/Petersburg;America/Indiana/Tell_City;America/Indiana/Vevay;America/Indiana/Vincennes;America/Indiana/Winamac;America/Inuvik;America/Iqaluit;America/Jamaica;America/Juneau;America/Kentucky/Louisville;America/Kentucky/Monticello;America/La_Paz;America/Lima;America/Los_Angeles;America/Maceio;America/Managua;America/Manaus;America/Marigot;America/Martinique;America/Matamoros;America/Mazatlan;America/Menominee;America/Merida;America/Metlakatla;America/Mexico_City;America/Miquelon;America/Moncton;America/Monterrey;America/Montevideo;America/Montreal;America/Montserrat;America/Nassau;America/New_York;America/Nipigon;America/Nome;America/Noronha;America/North_Dakota/Beulah;America/North_Dakota/Center;America/North_Dakota/New_Salem;America/Ojinaga;America/Panama;America/Pangnirtung;America/Paramaribo;America/Phoenix;America/Port-au-Prince;America/Port_of_Spain;America/Porto_Velho;America/Puerto_Rico;America/Rainy_River;America/Rankin_Inlet;America/Recife;America/Regina;America/Resolute;America/Rio_Branco;America/Santa_Isabel;America/Santarem;America/Santiago;America/Santo_Domingo;America/Sao_Paulo;America/Scoresbysund;America/Shiprock;America/Sitka;America/St_Barthelemy;America/St_Johns;America/St_Kitts;America/St_Lucia;America/St_Thomas;America/St_Vincent;America/Swift_Current;America/Tegucigalpa;America/Thule;America/Thunder_Bay;America/Tijuana;America/Toronto;America/Tortola;America/Vancouver;America/Whitehorse;America/Winnipeg;America/Yakutat;America/Yellowknife;Antarctica/Casey;Antarctica/Davis;Antarctica/DumontDUrville;Antarctica/Macquarie;Antarctica/Mawson;Antarctica/McMurdo;Antarctica/Palmer;Antarctica/Rothera;Antarctica/South_Pole;Antarctica/Syowa;Antarctica/Vostok;Arctic/Longyearbyen;Asia/Aden;Asia/Almaty;Asia/Amman;Asia/Anadyr;Asia/Aqtau;Asia/Aqtobe;Asia/Ashgabat;Asia/Baghdad;Asia/Bahrain;Asia/Baku;Asia/Bangkok;Asia/Beirut;Asia/Bishkek;Asia/Brunei;Asia/Choibalsan;Asia/Chongqing;Asia/Colombo;Asia/Damascus;Asia/Dhaka;Asia/Dili;Asia/Dubai;Asia/Dushanbe;Asia/Gaza;Asia/Harbin;Asia/Ho_Chi_Minh;Asia/Hong_Kong;Asia/Hovd;Asia/Irkutsk;Asia/Jakarta;Asia/Jayapura;Asia/Jerusalem;Asia/Kabul;Asia/Kamchatka;Asia/Karachi;Asia/Kashgar;Asia/Kathmandu;Asia/Kolkata;Asia/Krasnoyarsk;Asia/Kuala_Lumpur;Asia/Kuching;Asia/Kuwait;Asia/Macau;Asia/Magadan;Asia/Makassar;Asia/Manila;Asia/Muscat;Asia/Nicosia;Asia/Novokuznetsk;Asia/Novosibirsk;Asia/Omsk;Asia/Oral;Asia/Phnom_Penh;Asia/Pontianak;Asia/Pyongyang;Asia/Qatar;Asia/Qyzylorda;Asia/Rangoon;Asia/Riyadh;Asia/Sakhalin;Asia/Samarkand;Asia/Seoul;Asia/Shanghai;Asia/Singapore;Asia/Taipei;Asia/Tashkent;Asia/Tbilisi;Asia/Tehran;Asia/Thimphu;Asia/Tokyo;Asia/Ulaanbaatar;Asia/Urumqi;Asia/Vientiane;Asia/Vladivostok;Asia/Yakutsk;Asia/Yekaterinburg;Asia/Yerevan;Atlantic/Azores;Atlantic/Bermuda;Atlantic/Canary;Atlantic/Cape_Verde;Atlantic/Faroe;Atlantic/Madeira;Atlantic/Reykjavik;Atlantic/South_Georgia;Atlantic/St_Helena;Atlantic/Stanley;Australia/Adelaide;Australia/Brisbane;Australia/Broken_Hill;Australia/Currie;Australia/Darwin;Australia/Eucla;Australia/Hobart;Australia/Lindeman;Australia/Lord_Howe;Australia/Melbourne;Australia/Perth;Australia/Sydney;Canada/Atlantic;Canada/Central;Canada/Eastern;Canada/Mountain;Canada/Newfoundland;Canada/Pacific;Europe/Amsterdam;Europe/Andorra;Europe/Athens;Europe/Belgrade;Europe/Berlin;Europe/Bratislava;Europe/Brussels;Europe/Bucharest;Europe/Budapest;Europe/Chisinau;Europe/Copenhagen;Europe/Dublin;Europe/Gibraltar;Europe/Guernsey;Europe/Helsinki;Europe/Isle_of_Man;Europe/Istanbul;Europe/Jersey;Europe/Kaliningrad;Europe/Kiev;Europe/Lisbon;Europe/Ljubljana;Europe/London;Europe/Luxembourg;Europe/Madrid;Europe/Malta;Europe/Mariehamn;Europe/Minsk;Europe/Monaco;Europe/Moscow;Europe/Oslo;Europe/Paris;Europe/Podgorica;Europe/Prague;Europe/Riga;Europe/Rome;Europe/Samara;Europe/San_Marino;Europe/Sarajevo;Europe/Simferopol;Europe/Skopje;Europe/Sofia;Europe/Stockholm;Europe/Tallinn;Europe/Tirane;Europe/Uzhgorod;Europe/Vaduz;Europe/Vatican;Europe/Vienna;Europe/Vilnius;Europe/Volgograd;Europe/Warsaw;Europe/Zagreb;Europe/Zaporozhye;Europe/Zurich;Indian/Antananarivo;Indian/Chagos;Indian/Christmas;Indian/Cocos;Indian/Comoro;Indian/Kerguelen;Indian/Mahe;Indian/Maldives;Indian/Mauritius;Indian/Mayotte;Indian/Reunion;Pacific/Apia;Pacific/Auckland;Pacific/Chatham;Pacific/Chuuk;Pacific/Easter;Pacific/Efate;Pacific/Enderbury;Pacific/Fakaofo;Pacific/Fiji;Pacific/Funafuti;Pacific/Galapagos;Pacific/Gambier;Pacific/Guadalcanal;Pacific/Guam;Pacific/Honolulu;Pacific/Johnston;Pacific/Kiritimati;Pacific/Kosrae;Pacific/Kwajalein;Pacific/Majuro;Pacific/Marquesas;Pacific/Midway;Pacific/Nauru;Pacific/Niue;Pacific/Norfolk;Pacific/Noumea;Pacific/Pago_Pago;Pacific/Palau;Pacific/Pitcairn;Pacific/Pohnpei;Pacific/Port_Moresby;Pacific/Rarotonga;Pacific/Saipan;Pacific/Tahiti;Pacific/Tarawa;Pacific/Tongatapu;Pacific/Wake;Pacific/Wallis;US/Alaska;US/Arizona;US/Central;US/Eastern;US/Hawaii;US/Mountain;US/Pacific;UTC;GMT".split(";"),constructor:function(A){this.smthngs=A;
this.preferences=this.smthngs.logic.storage.preferences();
window.on("unload",this.onExit.bind(this));
this.apply()
},state:function(){var C={},A=this.get();
for(var B in {focus:1,sidebar:1}){C[B]=A[B]
}C.list=A.list[C.focus];
return C
},get:function(){var A=Object.merge(this.defaults,this.preferences);
A.search=Object.merge(this.defaults.search,this.preferences.search);
A.list=Object.merge(this.defaults.list,this.preferences.list);
return A
},overlay:function(A){if(A){this.preferences=Object.merge(this.preferences,A)
}},apply:function(B){this.overlay(B);
B=this.get();
var A=["more","colorization"];
for(var C=A.length;
C--;
){document.body.assignClass("preferences-"+A[C],B[A[C]])
}var D=Date.format;
D.time=B.format.time;
D.date=B.format.date;
D.weekStarts=B.format.weekStarts;
document.body.assignClass("safari-mobile",navigator.userAgent.indexOf("AppleWebKit/")>=0&&navigator.userAgent.indexOf("Mobile/")>=0);
if(this.smthngs.state){this.smthngs.state.restore()
}},save:function(B,D,C){B=B||this.preferences;
var A=this.smthngs.logic;
A.request("preferences",B,null,D,C)
},onExit:function(){var A={},C=this.smthngs.state.state,B;
for(B in {sidebar:1}){this.preferences[B]=C[B]||null
}for(B in {focus:1,list:1,sidebar:1,width:1,search:1}){A[B]=this.preferences[B]
}this.save(A,null,true)
}});
var Shortcuts=Object.extend({constructor:function(B){this.smthngs=B;
var A=this.smthngs,F=A.sidebar,E=A.list,D=A.toolbar,C=A.focus;
this.shortcuts=[{keystroke:{option:1,key:219},handler:function(){C.shift(-1)
}},{keystroke:{option:1,key:221},handler:function(){C.shift(+1)
}},{keystroke:{option:1,key:"S"},handler:function(){F.toggle()
}},{keystroke:{option:1,key:"N"},handler:function(){D.sidebar("navigate")
}},{keystroke:{option:1,key:"T"},handler:function(){D.sidebar("cloud")
}},{keystroke:{option:1,key:"F"},handler:function(){D.sidebar("search")
}},{keystroke:{option:1,key:"1"},handler:function(){D.view("flat")
}},{keystroke:{option:1,key:"2"},handler:function(){D.view("fold")
}},{keystroke:{option:1,key:"3"},handler:function(){D.view("tree")
}},{keystroke:{option:1,key:"P"},handler:function(){E.transform()
}},{keystroke:{option:1,key:"G"},handler:function(){D.archive()
}},{keystroke:{option:1,key:"Q"},handler:function(){D.signOut()
}},{keystroke:[{shift:1,key:"N"},{shift:1,key:45}],handler:function(){E.create("project")
}},{keystroke:[{key:"N"},{key:45}],handler:function(){E.create("task")
}},{keystroke:{key:46},handler:function(){E.remove()
}},];
document.on("keydown",this.onKeyDown.bind(this));
document.on("keyup",this.onKeyUp.bind(this))
},onKeyDown:function(A){this.onKeyUp(A);
var J=A.target,B=A.keyCode,G=!!J.getAttribute,M=A.isTextbox();
if(G&&!M&&(B==32||B==13)&&J.hasAttribute("tabindex")){J.fire("click");
A.stop();
return 
}if(M){return 
}var I=this.shortcuts;
var N=A.keyCode,K=A.shiftKey,H=A.optionKey();
for(var F=I.length;
F--;
){var D=I[F];
var C=D.keystroke;
if(!(C instanceof Array)){C=[C]
}for(var E=C.length;
E--;
){var L=C[E];
if(typeof L.key=="string"){L.key=L.key.charCodeAt(0)
}if((!!L.shift==K)&&(!!L.option==H)&&(L.key==N)){D.handler.call(this);
return 
}}}},onKeyUp:function(A){document.body.assignClass("shortcuts",A.modifierKey())
}});
var Layout=Object.extend({constructor:function(A){this.smthngs=A;
this.node={};
this.create()
},create:function(){document.create({name:"layout",child:[{name:"toolbar left toolbar-left",child:[{name:"logo"},{name:"content",reference:{toolbarSidebar:this.node}},{name:"border"}]},{name:"sidebar",reference:{sidebar:this.node},child:[{},{name:"border"}]},{name:"toolbar left toolbar-center",reference:{toolbarCenter:this.node},child:[{name:"splitter",attribute:{touchable:1},reference:{splitter:this.node}},{name:"focus",reference:{focus:this.node}},{name:"view"},{name:"border"},{name:"content",reference:{toolbarList:this.node}}]},{name:"list",reference:{list:this.node}},{name:"toolbar right toolbar-right",child:[{name:"content",reference:{toolbar:this.node}},{name:"border"}]}],node:document.body})
}});
var Toolbar=Object.extend({constructor:function(A){this.smthngs=A;
this.node={toolbar:this.smthngs.layout.node.toolbar};
var C={},B={};
document.create({child:[B.navigate=this.button({name:"sidebar-navigate",title:"Navigate",listener:function(){this.sidebar("navigate")
}}),B.cloud=this.button({name:"sidebar-cloud",title:"Tags cloud",listener:function(){this.sidebar("cloud")
}}),B.search=this.button({name:"sidebar-search",title:"Search",listener:function(){this.sidebar("search")
}}),{name:"separator"},this.button({name:"sidebar-toggle",title:"Toggle sidebar",listener:function(){trackButton("sidebar-toggle");
this.smthngs.sidebar.toggle()
}})],node:this.smthngs.layout.node.toolbarSidebar});
document.create({child:[C.flat=this.button({name:"list-flat",title:"Flat",listener:function(){this.view("flat")
}}),C.fold=this.button({name:"list-fold",title:"Fold",listener:function(){this.view("fold")
}}),C.tree=this.button({name:"list-tree",title:"Tree",listener:function(){this.view("tree")
}})],node:this.smthngs.layout.node.toolbarList});
document.create({child:[this.button({name:"add",title:"Add task",listener:function(){trackButton("add");
this.smthngs.list.create("task")
},right:1}),this.button({name:"edit-issue",title:"Edit",listener:function(){trackButton("edit");
this.smthngs.list.edit()
},right:1}),this.button({name:"remove",title:"Remove",listener:function(){trackButton("remove");
this.smthngs.list.remove()
},right:1}),this.button({name:"transform-to-project",title:"Transform to Project",listener:function(){trackButton("transform to project");
this.smthngs.list.transform()
},right:1}),this.button({name:"transform-to-task",title:"Transform to Task",listener:function(){trackButton("transform to task");
this.smthngs.list.transform()
},right:1}),{name:"separator"},this.button({name:"archive",title:"Archive completed",listener:this.archive,right:1}),this.button({name:"empty-trash",title:"Empty trash",listener:this.emptyTrash,right:1}),this.button({name:"connection",title:"Connection",listener:this.connection,right:1}),this.button({name:"preferences",title:"Preferences",listener:this.preferences,right:1}),this.button({name:"about",title:"About Smthngs",listener:this.about,right:1}),this.button({name:"sign-out",title:"Sign out",listener:this.signOut,right:1})],node:this.node.toolbar});
this.node.sidebar=B;
this.node.list=C
},button:function(E){var C=E.context||this;
var B={};
B[E.name]=this.node;
var A={name:"shortcut",child:[{name:"key",text:"⌥"},{name:"key",text:"P"},]};
var D=document.create({name:"plate "+E.name,attribute:{tabIndex:1},child:[{name:"arrow"},{name:"select"},{name:"border",child:[{name:"left"},{name:"center",child:{child:[{text:E.title},]}},{name:"right"}]},{name:"icon"}],event:{type:"click",listener:function(F){if(D.previousSibling&&D.previousSibling.hasClass("balloon-anchor")){return 
}D.blur();
E.listener.call(C,F)
},context:E.context||this},reference:B});
return D
},restore:function(A,B){if("focus" in A){var D=A.focus=="trash",I=A.focus;
this.visible("empty-trash",D);
this.visible("add",!D);
this.visible("archive",I!="trash"&&I!="archive")
}if(!B||("select" in A)){var H=(A.select||[]).length==1,G=false;
this.visible("edit-issue",H);
if(H){var E=this.smthngs.logic.issues[A.select[0]];
if(E){G=E.type=="project"
}else{H=false
}}this.visible("transform-to-task",H&&G);
this.visible("transform-to-project",H&&!G)
}if(!B||("select" in A)||("focus" in A)){this.visible("remove",((this.smthngs.state.state.select||[]).length>0)&&(this.smthngs.state.state.focus!="trash"))
}function F(J,L){for(var K in J){J[K].assignClass("select",L==K)
}}if("sidebar" in A){F(this.node.sidebar,A.sidebar);
this.node["sidebar-toggle"].assignClass("hide",A.sidebar)
}if("list" in A){F(this.node.list,A.list)
}if("offline" in A){var C=!A.offline;
this.visible("sign-out",C);
this.visible("preferences",C)
}},select:function(B,A){this.node[B].assignClass("select",A)
},visible:function(B,A){this.node[B].style.display=(A?"":"none")
},view:function(A){trackButton("view",A);
var B={};
B[this.smthngs.focus.current.name]=A;
this.smthngs.preferences.overlay({list:B});
this.smthngs.state.restore({list:A},this)
},sidebar:function(A){trackButton("sidebar",A);
this.smthngs.state.restore({sidebar:A},this)
},emptyTrash:function(){trackButton("empty trash");
new Widget.Confirm({width:400,base:this.node["empty-trash"],caption:"Empty the Trash",context:this,message:"Are you sure you want to permanently erase the items in the Trash?",buttons:[{caption:"Empty my Trash",comment:"Remove all!",listener:function A(){this.smthngs.logic.emptyTrash();
this.smthngs.state.restore()
}},{caption:"Cancel",comment:"I’ve changed my mind",listener:null}]})
},archive:function(){trackButton("archive");
new Widget.Confirm({width:400,base:this.node.archive,caption:"Archiving",context:this,message:"Move completed items to archive? You can find them there.",buttons:[{caption:"Archive",comment:"Save all my items.",listener:function A(){var C=this.smthngs.logic.issues,E=[];
for(var D in C){var B=C[D];
if(B.visible&&(B.mark=="done"||B.mark=="cancel")){E.push(B.id)
}}this.smthngs.logic.move({issues:E,folder:"archive"});
this.smthngs.state.restore()
}},{caption:"Cancel",comment:"I've change my mind, close this window.",listener:null}]})
},signOut:function(){trackButton("sign out");
new DialogSignOut({base:this.node["sign-out"]})
},connection:function(){trackButton("connection");
this.smthngs.logic.toggle()
},about:function(){trackButton("about");
new DialogAbout({base:this.node.about})
},preferences:function(){trackButton("preferences");
new DialogPreferences({base:this.node.preferences})
}});
var Focus=Object.extend({constructor:function(A){this.smthngs=A;
this.node={};
this.state="ready";
this.current=null;
this.focuses=[{name:"inbox",folder:"inbox",test:function(B){return B.folder=="inbox"
},title:"Inbox"},{name:"today",folder:"today",test:function(B){return B.folder=="today"||B.timely()
},title:"Today"},{name:"next",folder:"next",test:function(B){return B.folder=="next"||B.folder=="today"
},title:"Next"},{name:"someday",folder:"someday",test:function(B){return B.folder=="someday"
},title:"Someday"},{name:"archive",folder:"archive",test:function(B){return B.folder=="archive"
},title:"Archive"},{name:"trash",folder:"trash",test:function(B){return B.folder=="trash"
},title:"Trash"}];
this.create();
this.node.focuses.on("click",this.onClick.bind(this))
},focus:function(A){for(var B=this.focuses.length;
B--;
){if(this.focuses[B].name==A){return this.focuses[B]
}}},create:function(){var B=[];
for(var C=0;
C<this.focuses.length;
C++){var A=this.focuses[C];
var D={name:"item "+A.name,reference:{node:this.focuses[C]},attribute:{focus:A.name,tabindex:1},service:Widget.hoverAsClick,child:[{name:"border"},{name:"content",child:[{name:"icon"},{name:"title",text:A.title.toLowerCase()}]}]};
B.push(D)
}document.create({name:"focus",node:this.smthngs.layout.node.focus,child:{name:"items",child:B},service:1});
this.node.focuses=this.smthngs.layout.node.focus
},restore:function(D,C){if(D.focus){var B=D.focus;
var A=this.focus(B);
if(A){if(this.current){this.current.node.removeClass("select")
}this.current=A;
this.current.node.addClass("select")
}}this.smthngs.list.restore(D,C);
this.smthngs.selection.restore(D,C);
this.smthngs.sidebar.restore(D,C);
this.smthngs.toolbar.restore(D,C)
},activate:function(A){if(this.current&&this.current.name==A){return 
}this.smthngs.preferences.overlay({focus:A});
this.smthngs.state.restore({focus:A,list:this.smthngs.preferences.get().list[A]},this)
},shift:function(B){var A=this.focuses;
this.activate(A[(this.focuses.indexOf(this.current)+A.length+B)%A.length].name)
},filter:function(){var D=this.smthngs.logic.issues,A=this.smthngs.state.state,I=A.search||null,G=this.smthngs.preferences.get().search,J=A.tags;
test_focus=this.current.test;
function H(L){var K=J;
if(K.length==0){return true
}if(L.tags.length<K.length){return false
}for(var M=K.length;
M--;
){if(L.tags.indexOf(K[M])==-1){return false
}}return true
}function E(K){var L=G,M=I;
return(L.title&&K.title.test(M))||(L.notes&&K.notes.test(M))||(L.tags&&K.tags.join(" ").test(M))||(L.location&&K.geolocation&&K.geolocation[3].test(M))
}function F(K){return test_focus(K)&&(!J||H(K))&&(!I||E(K))
}for(var C in D){issue=D[C];
issue.visible=false;
issue.focused=F(issue)
}for(var C in D){issue=D[C];
if(issue.visible){continue
}if(issue.focused){var B=issue;
do{issue.visible=true;
issue=D[issue.parent];
if(issue&&issue.type=="task"){issue.type="project"
}if(issue==B){issue.parent=0
}}while(issue&&!issue.visible)
}}},list:function(C){C=C||0;
var D=this.smthngs.logic.issues;
var A=[];
this.filter(this.test);
for(var E in D){var B=D[E];
if(B.visible&&((B.parent==C)||((C==0)&&!D[B.parent]))){A.push(B)
}}A.sort(this.smthngs.logic.ruleByWeight);
return A
},onClick:function(C){var B=C.target.getParent("item");
if(B){var A=B.getAttribute("focus");
trackButton("focus",A);
this.activate(A)
}}});
var ListView=Object.extend({moreLimit:5,constructor:function(A){this.smthngs=A.smthngs;
this.list=A;
this.node=A.node
},features:{task:{badges:1,notes:1,buttons:1,mode:"fold"},project:{badges:1,notes:1,buttons:1,mode:"fold"}},path:function(D){var E=(D.open||[]).slice();
var F=E.concat(D.select||[],D.edit?[D.edit]:[]);
var B=this.smthngs.logic.issues;
var A=D.root||0;
for(var C=F.length;
C--;
){var G=F[C];
while(1){G=B[G]?B[G].parent:0;
if(!G||G==A||E.exists(G)){break
}E.pushUnique(G)
}}return E
},invalidate:function(){this.node.view.clearNode();
this.node.view.className=this.name;
var A=this.smthngs.state.state;
this.create(this.node.view,A.root||null,this.path(A))
},issueNode:function(C){var A=this.node.view.getDescendants(/issue/);
for(var B=A.length;
B--;
){if(A[B].issue==C){return A[B]
}}},smoothCollapse:function(C){if(window.pageYOffset>0){var A=C.clientHeight,B=0;
C.style.minHeight=A+"px";
function D(){var F=parseInt(C.style.minHeight)-10;
C.style.minHeight=F<10?"":F+"px";
if(F<10){clearInterval(B)
}}function E(){B=setInterval(D,10)
}setTimeout(E,200)
}},moreClick:function(A){this.moreToggle(A);
this.stateOverlay("more",/^(?=.*tasks)(?=.*more)/,/fold|flat|group|issues/);
this.smthngs.selection.invalidate()
},moreApply:function(B){var A=this.moreLimit(),C=0,G=0;
if((B.length<=A)||(!this.smthngs.preferences.get().more)){return 
}for(var E=0;
E<B.length;
E++){var D=E>=A,F=B[E];
if(!B[E].hasClass("issue")){continue
}C++;
if(D){G++
}F.assignClass("more-hidden",D)
}if(G>0){B.push(Widget.more(G))
}},moreLimit:function(){return 5
},moreToggle:function(C,B){var A=C.parentNode;
A.toggleClass("more")
},stateOverlay:function(D,C,F){var A=this.node.view.getDescendants(C,F),B={};
B[D]=[];
for(var E=A.length;
E--;
){B[D].push(A[E].issue||0)
}this.smthngs.state.overlay(B)
},stateIsMore:function(A){return(this.smthngs.state.state.more||[]).indexOf(A||0)!=-1
},switchIssue:function(B,A){if(A){B.replaceNode(A)
}else{B.removeNode()
}},onClick:function(C){var B=C.target,A;
if(A=B.getParent("more-button")){return this.moreClick(A)
}},onDblClick:function(A){}});
var ListFold=ListView.extend({name:"fold",features:{task:{badges:1,notes:1,buttons:1,mode:"fold"},project:{badges:0,notes:0,buttons:1,mode:"fold"}},create:function(A,J,K){J=J||0;
K=K||null;
A.clearNode();
var B={},H=[],F=null,G=this.smthngs.focus.list(J),D=[],C=[];
for(var E=G.length;
E--;
){var I=G[E];
if(I.type=="task"){D.push(I)
}else{C.push(I)
}}for(var E=D.length;
E--;
){H.push(Widget.issue(D[E],this.features.task))
}this.moreApply(H);
B.tasks=document.create({name:"tasks"+(this.stateIsMore(J)?" more":""),property:{issue:J},child:H});
Widget.service(B.tasks);
A.appendChild(B.tasks);
H=[];
for(var E=C.length;
E--;
){var I=C[E];
var B=Widget.issue(I,this.features.project);
Widget.hoverAsClick(B);
if(!F&&K&&(K.indexOf(I.id)!=-1)){F=I.id;
B.addClass("current")
}H.push(B)
}H=H.concat([Widget.shade("shadow","top"),Widget.shade("shade","top")]);
B.projects=document.create({name:"projects",child:H});
A.appendChild(B.projects);
Widget.service(B.projects);
B.issues=document.create({name:"issues"});
A.appendChild(B.issues);
if(F){this.create(B.issues,F,K)
}},expandOrCollapse:function(F,C){var G=F.hasClass("current");
if(G&&!C){clearTimeout(this.timerCollapse);
this.timerCollapse=setTimeout(this.expandOrCollapse.bind(this,F,1),400);
return 
}var A=this.smthngs.logic.issues[F.issue];
var D=F.parentNode;
var B=D.parentNode.lastChild;
var E=D.getChildren("current")[0];
if(E){E.removeClass("current")
}this.smoothCollapse(B);
B.clearNode();
if(!G){F.addClass("current");
this.create(B,A.id)
}Widget.service(D);
this.stateOverlay("open",/^(?=.*project)(?=.*current)/,/issues|projects/);
this.smthngs.selection.stateChange();
this.smthngs.selection.invalidate()
},switchIssue:function(D,A,B){if(B.type=="project"){var C=D.parentNode;
if(D.hasClass("edit")){D.removeNode();
D=C.getChildren("modify")[0];
this.$base();
A.assignClass("current",D.hasClass("current"))
}else{clearTimeout(this.timerCollapse);
if(!D.hasClass("current")){var E=C.getChildren("current")[0];
if(E){this.expandOrCollapse(E,1)
}}D.addClass("modify");
C.getChildren("shadow")[0].insertSiblingBefore(A);
Widget.service(C)
}}else{this.$base()
}},onClick:function(C){var B=C.target,A;
if(!this.smthngs.selection.testMetaKey(C)&&(A=B.getParent("project"))){return this.expandOrCollapse(A)
}this.$base()
}});
var ListFlat=ListView.extend({name:"flat",features:{task:{badges:1,notes:1,buttons:1,mode:"flat"},project:{badges:1,notes:1,buttons:1,mode:"flat"}},onClick:function(C){var B=C.target,A;
this.$base()
},color:function(A){if(!this.cache){this.cache={}
}if(!this.cache[A]){this.cache[A]=Utils.hslToRgb(Utils.simpleHash(A),70,70)
}return this.cache[A]
},create:function(A,H,K){H=H||0;
K=K||null;
var C={},D=[],E=[],G=this.smthngs.focus.list(H),J={badges:1};
for(var F=0;
F<G.length;
F++){var I=G[F];
if(I.type=="task"){D.push(Widget.issue(I,this.features.task))
}else{E.push(document.create({name:"group",child:[Widget.issue(I,this.features.project),{name:"branch",attribute:{style:"border-left-color: "+this.color(""+I.id)},child:{name:"branch-line",reference:{container:C}},reference:{branch:C}}]}));
if(!this.create(C.container,I.id,K)){C.branch.style.display="none"
}}}this.moreApply(D);
var B=D.concat(E);
document.create({name:"tasks",service:1,property:{issue:H},child:B,append:A});
return B.length>0
},expand:function(D){var C=D.hasClass("expand");
D.assignClass("expand",!C);
var B=D.lastChild;
if(C){B.clearNode()
}else{var A=D.previousSibling;
this.create(B,parseInt(A.issue))
}}});
var ListTree=ListView.extend({name:"tree",features:{task:{badges:1,notes:1,buttons:1,mode:"tree"},project:{badges:1,notes:1,buttons:1,mode:"tree"}},create:function(A,G,J){var B={},F=[],D=null,E=this.smthngs.focus.list(G);
J=J||null;
for(var C=0;
C<E.length;
C++){var H=E[C];
F.push(Widget.issue(H,this.features.task));
if(H.type!="task"){var I=J&&(J.indexOf(H.id)!=-1);
F.push(document.create({name:"branch"+(I?" expand":""),property:{issue:H.id},child:[{name:"button button-arrow"},{name:"issues",reference:{issues:B}}]}));
if(I){this.create(B.issues,H.id,J)
}}}this.moreApply(F);
A.clearNode();
document.create({node:A,child:F});
Widget.service(A)
},onClick:function(C){var B=C.target,A;
if(B.hasClass("button-arrow")){return this.expand(B.parentNode)
}this.$base()
},expand:function(D,C){if(C==undefined){C=!D.hasClass("expand")
}D.assignClass("expand",C);
var B=D.lastChild;
if(C){var A=D.previousSibling;
this.create(B,A.issue)
}else{B.clearNode()
}this.stateOverlay("open",/^(?=.*branch)(?=.*expand)/,/branch|issues/);
this.smthngs.selection.invalidate()
}});
var Selection=Object.extend({constructor:function(A){this.smthngs=A;
this.list=A.list;
this.node=this.list.node;
var B=this.node.list;
this.fly={target:null,aim:Widget.aim()};
this.state={mouse:"up"};
this.active=null;
this.last=null;
this.list.node.view.on("mousedown",this.onMouseDown.bind(this));
this.event={mousemove:document.on("mousemove",this.onMouseMove.bind(this),{add:false}),mouseup:document.on("mouseup",this.onMouseUp.bind(this),{add:false})};
document.on("keydown",this.onKeyDown.bind(this));
document.on("keypress",this.onKeyPress.bind(this));
document.on("keyup",this.onKeyUp.bind(this));
this.stateChange.context=this;
this.stateChange.delay=500
},re:{issue:/^(?!.*filter-hide)(?!.*button)(?=.*issue +)/,select:/^(?=.*issue)(?=.*select)/,path:/fold|flat|tree|issues|tasks|projects|group|branch|branch-line/},isIssueVisible:function(A){return(A.currentStyle||A.runtimeStyle||document.defaultView.getComputedStyle(A,null)).display!="none"
},issues:function(){if(!this.collection){var B=this.node.view.getDescendants(this.re.issue,this.re.path),A=[];
for(var C=0;
C<B.length;
C++){if(this.isIssueVisible(B[C])){A.push(B[C])
}}this.collection=A
}return this.collection
},purge:function(){this.last=null;
this.single=false;
this.collection=null
},selected:function(){var A=this.issues(),C=[];
for(var B=A.length;
B--;
){if(A[B].className.indexOf("select")!=-1){C.push(A[B])
}}return C
},restore:function(B,A){if((A!=this)&&("select" in B)){this.invalidate()
}},invalidate:function(){this.purge();
var B=this.smthngs.state.state.select||[],A=[],E;
var C=this.issues();
for(var D=C.length;
D--;
){if(B.indexOf(E=C[D].issue)!=-1){this.add(C[D]);
A.push(E)
}else{this.remove(C[D])
}}if(B.length!=A.length){this.smthngs.state.restore({select:A},this,true)
}},stateChange:function(C){var A=[];
if(this.single&&this.last){A=[this.last.issue]
}else{var D=this.selected();
for(var B=D.length;
B--;
){A.push(D[B].issue)
}}this.smthngs.state.restore({select:A},this,C)
},reset:function(){var A=this.selected();
for(var B=0;
B<A.length;
B++){A[B].removeClass("select")
}},set:function(A){if(this.single){this.last.removeClass("select")
}else{this.reset()
}A.addClass("select");
this.single=true;
this.last=A
},add:function(A){this.single=false;
A.addClass("select");
this.last=A
},remove:function(A){this.single=false;
A.removeClass("select")
},assign:function(B,A){this.single=false;
B.assignClass("select",A)
},toggle:function(A){this.single=false;
A.toggleClass("select")
},current:function(A){if(this.last&&this.last.hasClass("select")){return this.last
}return this.selected()[0]||(A?this.issues()[0]:null)||null
},select:function(H){if(this.active){if(H.ctrlKey||H.altKey||H.metaKey){this.toggle(this.active)
}else{if(H.shiftKey&&this.last){var G=this.last;
var E=this.active;
if(G!=E){var D=this.issues();
var B=false;
for(var F=D.length;
F--;
){var C=D[F];
var A=(C==G)||(C==E);
if(A){B=!B
}if(B||A){this.add(C)
}}}}else{this.set(this.active)
}}this.last=this.active;
this.active=null;
this.stateChange.filter()
}},onMouseDown:function(B){this.enableGlobalEvents(true);
if(this.state.mouse=="up"){this.state.mouse="down";
this.state.startX=B.pageX;
this.state.startY=B.pageY;
var A=B.target;
this.active=(A.className=="mark")?null:A.getParent("issue")
}if(this.state.mouse=="move"){return this.onMouseUp(B)
}if(!this.testTag(B)&&!B.target.hasClass("button")){B.preventDefault()
}},onMouseMove:function(G){if(this.state.mouse=="down"&&this.active&&Math.abs(G.pageX-this.state.startX)+Math.abs(G.pageY-this.state.startY)>10){if(!this.active.hasClass("select")){this.select(G)
}if(this.flyCreate()){this.state.mouse="move"
}}if(this.state.mouse=="move"){this.flyMove(G);
var F=null,C=null,E="hr",D=G.target;
if(D.getParent&&!D.getParent(/aim|fly/)){if(!C){var B=D.getParent("issue");
if(B&&!B.hasClass("move")){if(B.mode=="navigate"||B.mode=="root"){C="inside"
}else{var H=B.offset();
if((this.list.view.name=="fold")&&B.hasClass("project")){E="vr";
H=G.pageX-H.left;
C=H<25?"before":(H>B.clientWidth-25?"after":"inside")
}else{E="hr";
H=G.pageY-H.top;
C=H<12+8?"before":(H>12+8+9?"after":"inside")
}}F=B
}}if(!C){var A=D.getParent("item");
if(A&&D.getParent("focus")){F=A;
C="focus"
}}if(!C){var D=D.getParent("tag");
if(D&&D.getParent("cloud")){F=D;
C="tag"
}}if((C!=this.fly.type)||(F!=this.fly.target)){if(this.fly.target){this.fly.target.removeClass("target")
}if(this.fly.aim){this.fly.aim.removeNode()
}this.fly.target=F;
this.fly.type=C;
if(F){switch(C){case"inside":case"focus":case"tag":F.addClass("target");
break;
case"after":case"before":this.fly.aim.className="aim "+E;
F.insertSibling(this.fly.aim,C=="before");
break
}}}}}},onMouseUp:function(H){this.enableGlobalEvents(false);
if(this.state.mouse=="move"){if(this.fly.selected){this.flyHide();
var D=this.fly.type,G=this.fly.target,A=this.fly.selected,B=[];
for(var C=A.length;
C--;
){B.push(A[C].issue)
}this.cancelDrop();
if(D){var F={issues:B};
var E=this.smthngs.focus.current.folder;
switch(D){case"inside":F.parent=G.issue;
break;
case"after":case"before":F.relative=G.issue;
F.position=D;
break;
case"focus":F.folder=this.smthngs.focus.focus(G.getAttribute("focus")).folder;
F.focus=this.fly.focus;
break;
case"tag":F.tag=G.getAttribute("title");
break
}this.smthngs.logic.move(F);
this.smthngs.invalidate()
}}}if(this.state.mouse=="down"){this.select(H)
}this.state.mouse="up"
},cancelDrop:function(){var B=this.fly;
if(B.selected){this.flyHide();
for(var A=B.selected.length;
A--;
){B.selected[A].removeClass("move")
}if(B.target){B.target.removeClass("target")
}if(B.aim){B.aim.removeNode()
}B.selected=B.target=B.type=null
}this.state.mouse="up"
},testTag:function(B,A){A=A||/textarea|input/;
return A.test(B.target.tagName.toLowerCase())
},testMetaKey:function(A){return A.shiftKey||A.altKey||A.ctrlKey||A.metaKey
},onKeyDown:function(E){var C=E.keyCode;
var D=this.smthngs.list;
if(C==13&&!D.issue&&this.last){return D.edit(this.last)
}if(C==13&&D.issue&&document.activeElement==D.issue.node.input.title){return D.save()
}if(C==32&&!D.issue&&this.last){return D.check(this.last,E)
}if(C==27&&D.issue){return D.editCancel()
}if(C==27){return this.cancelDrop(E)
}if(C==65&&(E.ctrlKey||E.metaKey)&&!this.testTag(E)&&!this.edit){E.preventDefault();
var A=this.issues();
for(var B=A.length-1;
B>=0;
B--){this.add(A[B])
}this.stateChange()
}if(navigator.isWebKit()){this.onKeyPress(E)
}},onKeyUp:function(A){},onKeyPress:function(H){if(this.testTag(H)){return 
}var A=H.keyCode;
if([97,65,1092,1060,37,38,39,40].indexOf(A)!=-1){H.preventDefault()
}if([37,38,39,40].indexOf(A)!=-1){var M=A%2,B=A==37,N=A==39,E=A==38,L=A==40,C=this.current(true),J=B||E,F,I=this.smthngs.list.view.name;
if(!C){return 
}switch(I){case"fold":if(C.hasClass("project")){if(E){F=this.near(C.parentNode.firstChild,true)
}if(L){if(!C.hasClass("current")){this.smthngs.list.view.expandOrCollapse(C),F=C
}else{F=this.near(C.parentNode.getChildren("issue").pop(),false)
}}}else{if(M){var D=C.parentNode.parentNode.previousSibling;
if(D&&D.hasClass("projects")){var G=D.getChildren("current")[0];
F=this.near(G,J)
}}else{F=this.near(C,J);
if(F.hasClass("project")){F=F.parentNode.getChildren("current")[0]||F
}}}break;
case"tree":if(M){if(C.hasClass("project")&&(N||C.nextSibling.hasClass("expand"))){var K=C.nextSibling;
this.smthngs.list.view.expand(K,N);
return 
}else{if(B){if(C.parentNode.hasClass("issues")){F=C.parentNode.parentNode.previousSibling
}else{return 
}}else{return 
}}}break
}F=F||this.near(C,J);
if(F){this[this.testMetaKey(H)?"add":"set"](F);
this.smthngs.list.scrollTo(F);
this.stateChange.filter()
}}},near:function(D,A){var C=A?D.previousSibling:D.nextSibling;
if(C&&this.re.issue.test(C.className)&&this.isIssueVisible(C)){return C
}var B=this.issues();
return B[(B.indexOf(D)+B.length+(A?-1:+1))%B.length]
},enableGlobalEvents:function(B){var A=B?"enable":"disable";
this.event.mousemove[A]();
this.event.mouseup[A]()
},flyCreate:function(){var B=this.selected();
if(B.length==0){return false
}this.node.fly.parentNode.style.display="";
Object.append(this.node.fly.style,{display:"",opacity:0.1,width:Math.min(this.node.list.clientWidth,500)+"px"});
this.fly.focus=this.smthngs.focus.current.name;
this.fly.selected=B;
for(var A=0;
A<B.length;
A++){node=B[A].cloneNode(true);
node.removeAttribute("style");
this.node.fly.appendChild(node);
B[A].removeClass("select");
B[A].addClass("move")
}this.flyTransition(0.1);
return true
},flyHide:function(){this.flyTransition(-0.1)
},flyMove:function(B){var A=this.node.fly.style;
A.top=(B.pageY+2)+"px";
A.left=(B.pageX+2)+"px"
},flyTransition:function(C){document.body.assignClass("moving",C>0);
if(navigator.isIE()){this.node.fly.style.display=C<0?"none":"";
return 
}this.delta=C;
clearInterval(this.fly.timer);
var A=this;
function B(){A.flyTransitionDo.call(A,C)
}this.fly.timer=setInterval(B,50)
},flyTransitionDo:function(B){var A=parseFloat(this.node.fly.style.opacity);
A+=B;
if(A<0.05){this.node.fly.clearNode();
this.node.fly.style.display="none";
clearInterval(this.fly.timer);
return 
}if(A>0.7){clearInterval(this.fly.timer);
return 
}this.node.fly.style.opacity=A
}});
var List=Object.extend({constructor:function(A){this.smthngs=A;
this.node={list:this.smthngs.layout.node.list,fly:document.create({name:"fly",append:document.body,style:{display:"none"}})};
document.create({name:"list",child:[{name:"filter root",reference:{root:this.node},attribute:{filter:"root"}},{name:"filter tags",reference:{tags:this.node},attribute:{filter:"tags"}},{name:"filter search",reference:{search:this.node},attribute:{filter:"search"}},{name:"view",reference:{view:this.node},attribute:{touchable:1}}],on:{click:this.onClick.bind(this)},node:this.node.list});
this.views={fold:new ListFold(this),flat:new ListFlat(this),tree:new ListTree(this)};
this.view=null;
document.on("dblclick",this.onDblClick.bind(this));
this.event={mousedown:document.on("mousedown",this.onGlobalMouseDown.bind(this),{add:false})}
},set:function(A){this.view=this.views[A]||null
},restore:function(C,B){if("list" in C){this.set(C.list)
}if(!B||("tags" in C)){this.tags(C.tags)
}if(!B||("root" in C)){this.root(C.root)
}if(!B||("search" in C)){this.search(C.search)
}if(!B||("tags" in C)||("search" in C)||("root" in C)||("focus" in C)||("list" in C)){this.invalidate()
}if((B!=this)&&("edit" in C)){if(C.edit){var A=this.view.issueNode(C.edit);
if(A){this.edit(A)
}}else{this.editCancel()
}}},filter:function(A,B){document.create({node:this.node[A],child:[{name:"content",child:[{name:"icon"},{name:"center",child:B},{name:"remove button"}]},Widget.shade("shadow","top"),Widget.shade("shade","top")]})
},tags:function(B){this.node.tags.clearNode();
if(B&&B.length>0){var A=[];
if(B.length>0){for(var C=B.length;
C--;
){A.push(Widget.tag({name:B[C]}))
}}this.filter("tags",A)
}},root:function(B){if(B){var A=this.smthngs.logic.issues[B];
this.filter("root",Widget.issue(A,{mode:"root"}))
}else{this.node.root.clearNode()
}},search:function(A){if(A){this.filter("search",{name:"text",html:"Search: &laquo;"+A+"&raquo;"})
}else{this.node.search.clearNode()
}},invalidate:function(){var B=window.pageYOffset,A=window.pageXOffset;
this.view.invalidate();
this.smthngs.selection.invalidate();
window.scrollTo(A,B)
},insert:function(D,G){if(this.issue){return this.save()
}var B=this.smthngs.logic,C=B.issues,A,E;
if(!D){D=this.smthngs.selection.issues()[0];
if(D&&D.hasClass("project")){D=null
}G=1
}if(D){var F=C[D.issue];
if(!F){return 
}A=B.createIssue(F,G);
E=Widget.issue(A,D.features);
D.parentNode.addClass("more");
D.insertSibling(E,G)
}else{A=B.createIssue();
this.view.invalidate();
var E=this.view.issueNode(A.id)
}this.newbie=true;
this.edit(E)
},create:function(B,A){this.insert()
},edit:function(C){if(!C){C=this.smthngs.selection.current()
}if(this.issue||!C){return 
}var A=this.smthngs.logic.issues[C.issue];
if(!A){return 
}this.smthngs.selection.reset();
var B=Widget.edit(A);
this.issue=A;
A.node.normal=null;
this.view.switchIssue(C,B,A);
this.smthngs.selection.purge();
this.smthngs.state.restore({edit:A.id},this);
this.scrollTo(B);
this.event.mousedown.enable()
},editDestroy:function(E){if(this.smthngs.state.state.edit){this.smthngs.state.overlay({edit:null})
}this.event.mousedown.disable();
var A=this.issue;
if(!A){return 
}this.issue=null;
var B=A.node.edit,C=null,D=B.parentNode;
if(!(E&&this.newbie)){C=Widget.issue(A,this.view.features[A.type])
}else{delete this.smthngs.logic.issues[A.id]
}delete this.newbie;
this.view.switchIssue(B,C,A);
this.smthngs.selection.purge();
delete A.node;
Widget.service(D);
if(C){this.smthngs.selection.set(C);
this.smthngs.selection.stateChange(true);
this.scrollTo(C)
}},editCancel:function(){trackButton("issue: edit cancel");
this.editDestroy(true)
},save:function(){if(!this.issue){return 
}var B=this.issue;
var C=B.node.input;
var E=B.data();
E.mark=B.node.edit.getAttribute("mark");
E.title=C.title.valueOf();
E.tags=C.tags.valueOf().SPLIT();
E.notes=C.notes.valueOf();
var D=C.dueBeforeAfter.checked?-1:1;
var A=C.startBeforeAfter.checked?-1:1;
E.start=C.startCheck.checked?C.start.data:null;
E.startRemind=C.startCheck.checked&&C.startRemindCheck.checked?C.startRemind.data*A:null;
E.due=C.dueCheck.checked?C.due.data:null;
E.dueRemind=C.dueCheck.checked&&C.dueRemindCheck.checked?C.dueRemind.data*D:null;
E.geolocation=C.geolocationCheck.checked?C.geolocation.data:null;
this.smthngs.logic.save(E);
this.editDestroy()
},check:function(F,G){var D=(G.altKey||G.ctrlKey||G.shiftKey||G.metaKey)?["cancel","note","area"]:["done","undone"];
if(F.getParent("issue")){trackButton("issue.check");
F=F.getParent("issue");
var B=this.smthngs.logic.issues[F.issue];
var D=(G.altKey||G.ctrlKey||G.shiftKey||G.metaKey)?["cancel","note","area"]:["done","undone"];
var A=B.mark;
F.removeClass(B.mark);
B.mark=D[(D.indexOf(B.mark)+1)%D.length];
F.addClass(B.mark);
this.smthngs.logic.mark(B)
}else{if(F=F.getParent("edit")){trackButton("edit.check");
var E=F.getAttribute("mark");
var C=D[(D.indexOf(E)+1)%D.length];
F.removeClass(E);
F.addClass(C);
F.setAttribute("mark",C)
}}},transform:function(){var B=this.smthngs.selection.current();
if(!B){return 
}var A=this.smthngs.logic.issues[B.issue];
if(!A){return 
}data=A.data();
data.type=data.type=="task"?"project":"task";
this.smthngs.logic.save(data);
this.smthngs.state.restore()
},remove:function(){var A=this.smthngs.selection.selected(),C=[];
if(!A.length){return 
}for(var B=A.length;
B--;
){C.push(A[B].issue)
}this.smthngs.logic.move({issues:C,folder:"trash"});
this.smthngs.invalidate()
},removeFilter:function(A){trackButton("filter.remove",A);
var B={};
B[A]=null;
this.smthngs.state.restore(B,this)
},onClick:function onClick(C){var B=C.target,A;
if(A=B.getParent("mark")){return this.check(A,C)
}if(B.hasClass("insert")){trackButton("issue.insert");
return this.insert(B.getParent("issue"),B.hasClass("before"))
}if(A=B.getParent("tag")){return this.smthngs.sidebar.views.cloud.onClick(C)
}if(B.hasClass("remove")){return this.removeFilter(B.getParent("filter").getAttribute("filter"))
}if(this.node.view.contains(C.target)){this.view.onClick(C)
}},onDblClick:function(C){var B=C.target,A;
if(A=B.getParent("mark")){return this.check(A,C)
}if(B==document.body||B==this.node.list){return this.create("task")
}if((A=B.getParent("issue"))&&this.node.view.contains(A)){return this.edit(A,C)
}this.view.onDblClick(C)
},onGlobalMouseDown:function(A){if(this.issue&&A.target&&!A.target.getParent("edit")){this.save()
}},scrollTo:function(E){var F=0,C=0;
var B=window.innerHeight;
var G=window.pageYOffset;
var A=E.offset().top;
var D=E.clientHeight;
if(A+D+C>G+B){window.scrollTo(0,A+D-B+C)
}else{if(A-F<G){window.scrollTo(0,A-F)
}}}});
var Sidebar=Object.extend({constructor:function(A){this.smthngs=A;
this.preferences=this.smthngs.preferences;
var B=this.smthngs.layout.node;
this.node={sidebar:B.sidebar,container:B.sidebar.firstChild,toolbar:B.toolbarCenter,splitter:B.splitter,list:B.list};
document.create({name:"content",child:{name:"sidebar-view",reference:{view:this.node}},node:this.node.container});
this.views={cloud:new SidebarViewCloud(this),navigate:new SidebarViewNavigate(this),search:new SidebarViewSearch(this)};
this.mouse="up";
document.on("mousewheel",this.onSplitterWheel.bind(this));
this.node.container.on("click",this.onClick.bind(this));
window.on("orientationchange",this.onOrientation.bind(this));
this.node.splitter.on("mousedown",this.onSplitterDown.bind(this));
this.event={mousemove:document.on("mousemove",this.onSplitterMove.bind(this),{add:false}),mouseup:document.on("mouseup",this.onSplitterUp.bind(this),{add:false})}
},restore:function(B,A){if("sidebar" in B){this.set(B.sidebar)
}if(this.view){this.view.restore(B,A)
}},set:function(A){this.view=this.views[A]||null;
this.visible(!!A);
this.invalidate();
if(A){this.preferences.overlay({sidebar:A})
}},invalidate:function(){if(this.view){return this.view.invalidate()
}},onOrientation:function(A){this.toggle(window.orientation%180)
},onClick:function(A){this.view.onClick(A)
},onSplitterWheel:function(C){if(C.wheelDelta){C.scrollDetail=-C.wheelDelta/400
}var B=C.scrollDetail;
var A=this;
clearInterval(this.timer_wheel);
this.timer_wheel=setTimeout(function(){A.postonSplitterWheel.call(A,B)
},1);
if(this.offset!=-1){this.postonSplitterWheel(B)
}this.offset=window.pageYOffset
},postonSplitterWheel:function(B){var C=window.pageYOffset-this.offset;
if(!this.offset_stable_delta){var A=C/B;
if(A!=0&&A==this.offset_last_delta){this.offset_stable_delta=A
}this.offset_last_delta=A
}if(C==0){C=B*(this.offset_stable_delta?this.offset_stable_delta:20)
}this.node.container.scrollTop+=C;
this.offset=-1
},toggle:function(B){console.log("toggle");
var A=this.smthngs.state;
if(B==undefined){B=!A.state.sidebar
}A.restore({sidebar:B?this.preferences.get().sidebar||this.preferences.defaults.sidebar:null},this)
},visible:function(A){if(A===undefined){return !!this.view
}var B=this.node.sidebar.style;
B.display=A?"":"none";
this.width(A?this.preferences.get().width:0)
},enableEvents:function(B){var A=B?"enable":"disable";
this.event.mousemove[A]();
this.event.mouseup[A]();
document.body.assignClass("spittered",B)
},width:function(A){this.node.sidebar.style.width=(A)+"px";
this.node.list.style.marginLeft=(A+100)+"px";
this.node.toolbar.style.left=(A+30)+"px"
},widthEx:function(C){var B=150,A=400;
if(C<B){C=B
}if(C>A){C=A
}this.width(C)
},onSplitterDown:function(A){this.enableEvents(true);
if(this.mouse=="up"){this.mouse="down"
}if(this.mouse=="move"){return this.onSplitterUp(A)
}this.mouse="down"
},onSplitterMove:function(A){if(this.mouse=="down"){this.mouse="move"
}if(this.mouse=="move"){if(!this.visible()){this.toggle()
}this.widthEx(A.pageX-30)
}},onSplitterUp:function(A){this.enableEvents(false);
if(this.mouse=="down"){this.toggle()
}else{this.preferences.overlay({width:parseInt(this.node.sidebar.style.width)||0})
}this.mouse="up"
}});
var SidebarView=Object.extend({constructor:function(A){this.sidebar=A;
this.smthngs=A.smthngs;
this.node=A.node
},invalidate:function(){return this.create()
},create:function(){this.node.view.clearNode();
this.node.view.className=this.name
}});
var SidebarViewCloud=SidebarView.extend({name:"cloud",constructor:function(){this.$base();
this.tags={}
},restore:function(F,E){if("tags" in F){var C=F.tags||[];
for(var A in this.tags){this.tags[A].assignClass("active",C.exists(A))
}}if(!E||("tags" in F)||("search" in F)||("root" in F)||("focus" in F)){var D={};
for(var A in this.tags){D[A]=0
}var B=this.smthngs.logic.issues;
for(var G in B){issue=B[G]
}}},create:function(){this.$base();
this.tags={};
var B=this.smthngs.logic.tags();
for(var C=B.length;
C--;
){var A=B[C];
var D=Widget.tag(A);
this.node.view.appendChild(D);
this.tags[A.name]=D
}},toggle:function(A){var C=this.smthngs.state;
var B=C.state.tags||[];
B.toggle(A);
C.restore({tags:B},this)
},onClick:function(C){var B;
if(B=C.target.getParent("tag")){var A=B.getAttribute("title");
this.toggle(A)
}}});
var SidebarViewNavigate=SidebarView.extend({name:"navigate",constructor:function(A){this.$base()
},restore:function(E,D){if("root" in E){var B=this.node.view.getDescendants(/^(?=.*issue)/,/level/),A=E.root;
for(var C=B.length;
C--;
){B[C].assignClass("current",B[C].issue==A)
}}},create:function(B,E){var D={0:[]},G=this.smthngs.logic.issues,F;
for(F in G){var H=G[F];
if((H.type!="task")&&(H.folder!="trash")&&(H.folder!="archive")){var I=H.parent||0;
if(!G[I]){I=0
}(D[I]||(D[I]=[])).push(G[F])
}}for(F in D){D[F].sort(this.smthngs.logic.ruleByWeight)
}var C=this;
function A(L){if(!D[L]){return null
}var O=D[L],N=O.length,K=document.create({name:"level"});
for(var J=0;
J<N;
J++){var M=Widget.issue(O[J],{mode:"navigate"});
K.appendChild(M);
if(D[O[J].id]){K.appendChild(A(O[J].id))
}}return K
}this.$base();
this.node.view.appendChild(A(0));
Widget.service(this.node.view)
},browse:function(A){var B=this.smthngs.state;
if(B.state.root==A){A=null
}B.restore({root:A},this)
},onClick:function(C){var B=C.target,A;
if(A=B.getParent("mark")){return this.smthngs.list.check(A,C)
}if(A=B.getParent("issue")){return this.browse(A.issue)
}}});
var SidebarViewSearch=SidebarView.extend({name:"search",constructor:function(){this.$base();
this.text="";
this.preferences=this.smthngs.preferences.get().search;
this.apply.context=this
},restore:function(B,A){if(A!=this){if("search" in B){this.text=B.search||"";
this.node.search.valueOf(this.text)
}}},create:function(){if(this.node.view.className==this.name){return 
}this.$base();
var B=this.smthngs.preferences.get().search;
function A(C){C.checked=B[C.name];
C.input={node:C};
return{name:"row",attribute:{name:C.name},tag:"label",child:[new Widget.Toggle(C),{name:"caption",text:C.caption}]}
}document.create({child:[new Widget.Input({hint:"Search tasks",fo__cus:1,input:{search:this.node}}),{name:"title",text:"Search in ..."},A({name:"title",caption:"titles:"}),A({name:"notes",caption:"notes:"}),A({name:"tags",caption:"tags:"}),A({name:"location",caption:"locations:"})],node:this.node.view});
this.node.search.on("keyup",this.onInput.bind(this))
},test:function(A){if(!this.text){return true
}var B=this.preferences,C=this.text;
return(B.title&&A.title.test(C))||(B.notes&&A.notes.test(C))||(B.tags&&A.tags.join(" ").test(C))||(B.location&&A.geolocation&&A.geolocation[3].test(C))
},onInput:function(A){var B=this.node.search.valueOf();
this.text=B;
this.apply.filter(this,500)
},apply:function(){this.smthngs.state.restore({search:this.text},this)
},onClick:function(D){var C=D.target;
if(C&&C.tagName.toLowerCase()=="input"&&C.type=="checkbox"){var A=C.getParent("row").getAttribute("name");
var B={};
B[A]=!!C.checked;
this.smthngs.preferences.overlay({search:B});
this.preferences=this.smthngs.preferences.get().search;
this.apply()
}}});
var Widget=Object.extend({constructor:function(){this.node={};
this.events=[];
this.visible=true
},destroy:function(){if(this.main()){this.main().removeNode()
}this.destructor()
},destructor:function(){for(var B=this.events.length;
B--;
){var C=this.events[B];
if(!(C instanceof Array)){C=[C]
}for(var A=C.length;
A--;
){C[A].disable()
}}},valueOf:function(){return this.visible?1:0
},main:function(){return this.node.main
},defer:function(B){var A=this;
setTimeout(function(){B.call(A)
},1)
},animate:function(F){var D=true;
try{D=smthngs.preferences.get().animation
}catch(E){}if(!this.fx){this.fx={timer:0,stage:F?0:1,delay:10,step:D?0.1:1}
}var B=this,C=this.fx;
function A(G){if(G){C.stage+=C.step*Math.floor(Math.abs(G/C.delay/4))
}C.stage+=C.step;
C.stage=Math.round(C.stage*1000)/1000;
if(C.stage<=0||C.stage>=1){clearInterval(C.timer)
}if(C.stage>1){C.stage=1
}if(C.stage<0){C.stage=0
}B.transition(C.stage,C.step>0)
}C.step=(F?1:-1)*Math.abs(C.step);
clearInterval(C.timer);
C.timer=setInterval(A,C.delay);
A()
},on:function(C,E,B,A){var D=B.on(C,E.bind(this),A);
this.events.push(D);
return D
}});
Widget.border=function(A){A=A||{};
return{name:A.name||"border",child:[{name:"top",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"middle",child:[{name:"left"},{name:"center",child:A.content||{}},{name:"right",child:{}}]},{name:"bottom",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]}]}
};
Widget.aim=function(){var A={name:"aim ",child:[{name:"one"},{name:"two",child:{}},{name:"three"}]};
return document.create(A)
};
Widget.shade=function(A,B){return document.create({name:(A||"shade")+" "+(B||"top"),child:[{name:"one",child:{}},{name:"two",child:{}},{name:"three",child:{}}]})
};
Widget.more=function(A){return{name:"more-button",child:[{name:"collapse"},{name:"expand",style:{width:(A*7)+"px"}}]}
};
Widget.button=function(B){var A=document.create({name:"button "+B.name,event:B.event,attribute:{title:B.title||""},child:[{name:"left"},{name:"center",child:{child:{name:"icon"}}},{name:"right"}]});
return A
};
Widget.button2=function(A){return document.create({name:"button",event:{type:"click",listener:A.listener,context:A.context},attribute:{title:A.title||""},child:[{name:"left"},{name:"center",text:A.caption},{name:"right"}]})
};
Widget.button3=function(D){var C=[{name:"icon"},{name:"content",child:[{name:"caption",text:D.caption},{name:"comment",text:D.comment}]}];
var B={};
B.main=document.create({name:"input input-button",tag:"label",child:[{name:"foreground",child:{child:C}},{tag:"input",attribute:{type:"checkbox",title:D.hint||""},property:{value:D.value||""},link:{hash:B,name:"input"}},{name:"border",child:[{name:"top",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"middle",child:[{name:"left"},{name:"center"},{name:"right"}]},{name:"bottom",child:[{name:"left"},{name:"center"},{name:"right"}]}]}]});
var A=B.input;
if(D.focus){setTimeout(function(){A.select();
A.focus()
},100)
}if(D.hint){this.hint(B.input)
}B.input.on("click",D.listener.bind(this));
return B.main
};
Widget.Balloon=Widget.extend({constructor:function(B){this.$base();
B.arrow=B.arrow||"";
this.node.main=document.create({name:"balloon-anchor",child:[{name:"balloon arrow-"+B.arrow,link:{hash:this.node,name:"balloon"},child:Widget.border({content:{name:"content",reference:{content:this.node},text:B.content}})},B.modal?{name:"shade",link:{hash:this.node,name:"shade"}}:null]});
this.node.base=B.base;
if(B.attach){B.attach(this.node.main,B.base)
}else{B.base.insertSiblingAfter(this.node.main)
}var A=this.node.balloon.style;
switch(B.arrow){case"top":A.left=(-B.width/2-6)+"px";
break;
case"bottom-left":A.bottom="0px";
A.left="-16px";
A.width="300px";
break;
case"bottom-right":A.bottom="0px";
A.right="0px";
break;
case"right-bottom":A.bottom="0px";
A.right="0px";
break
}A=this.node.content.style;
if(B.width){A.width=B.width+"px"
}if(B.height){A.height=B.height+"px"
}this.animate(1)
},insert:function(){},destroy:function(){this.visible=false;
this.animate(0)
},transition:function(A,C){var B=this.node.balloon.style;
B.opacity=A;
B.marginTop=(50*(1-A))+"px";
B.marginBottom=(50*(1-A))+"px";
if(this.node.shade){this.node.shade.style.opacity=A/4
}if(!C&&A==0){this.$super().destroy.call(this)
}}});
Widget.Dialog=Widget.Balloon.extend({constructor:function(C){var B={modal:1,attach:function(E,D){D.insertSiblingBefore(E)
},arrow:"bottom-right"};
for(var A in B){if(!(A in C)){C[A]=B[A]
}}this.$base();
document.create({name:"dialog "+(C.name||""),child:[{name:"icon"},{name:"content",child:{child:[{name:"caption",html:C.caption},{name:"body",child:C.body,reference:{body:this.node}}]}}],append:this.node.content})
}});
Widget.Confirm=Widget.Dialog.extend({constructor:function(H){var G=H.buttons||[],A=[];
var F=this;
for(var D=0,B=G.length;
D<B;
D++){var E=G[D];
if(E){E.context=E.context||H.context;
var C=E.listener;
E.listener=function I(K){I=I||arguments.callee;
var L=I.listener,J;
if(L){L.dialog=F;
J=L.call(this,K)
}if(J!==false){F.destroy()
}};
E.listener.listener=C;
A.push(new Widget.InputButtonCommand(E))
}}if(typeof I!="undefined"){I=null
}H.width=H.width||500;
H.name="confirm";
H.body=[{name:"message",html:H.message},{name:"buttons",child:A}];
this.$base()
}});
Widget.edit=function(A){if(!A.node){A.node={}
}if(!A.node.input){A.node.input={}
}var E=[{name:"\u20075 minutes",data:5*60},{name:"10 minutes",data:10*60},{name:"15 minutes",data:15*60},{name:"30 minutes",data:30*60},{name:"\u20071 hour",data:1*60*60},{name:"\u20073 hours",data:3*60*60},{name:"12 hours",data:12*60*60},{name:"\u20071 day",data:1*24*60*60},{name:"\u20073 days",data:3*24*60*60},{name:"\u20075 days",data:5*24*60*60}];
var D=new Date().allDay(true).timestamp(),C=E[0].data;
var B=A.node.input;
var F=document.create({name:"edit "+A.mark+" "+A.folder,property:{issue:A.id},link:{hash:A.node,name:"edit"},attribute:{mark:A.mark},child:[{name:"content",child:[{name:"title",child:[{name:"left mark"},{name:"right",child:new Widget.Input({value:A.title,hint:"Enter title of the task",input:{title:B},focus:true})}]},{name:"notes",child:[{name:"left"},{name:"right",child:new Widget.Input({value:A.notes,hint:"Specify your task",input:{notes:B},tag:"textarea"})}]},{name:"tags",child:[{name:"left"},{name:"right",child:new Widget.InputPickerCloud({value:A.tags.JOIN(),hint:"Choose a few keywords",input:{tags:B},picker:"cloud"})}]},{name:"due",child:[{name:"left"},{name:"right inline",child:[new Widget.Enabler({caption:"Start",checked:A.start,input:{startCheck:B},content:[new Widget.InputPickerCalendar({data:A.start||D,input:{start:B}}),new Widget.Enabler({name:"remind",on:"remind me",off:"don't remind",checked:A.startRemind,input:{startRemindCheck:B},content:[new Widget.InputPickerList({data:Math.abs(A.startRemind||C),input:{startRemind:B},values:E,type:"button"}),new Widget.Toggle({tag:"label",on:"before",off:"after",checked:(A.startRemind||-1)<0,input:{startBeforeAfter:B}})]})]})]}]},{name:"due",child:[{name:"left"},{name:"right inline",child:[new Widget.Enabler({caption:"Due",checked:A.due,input:{dueCheck:B},content:[new Widget.InputPickerCalendar({data:A.due||D,input:{due:B}}),new Widget.Enabler({name:"remind",on:"remind me",off:"don't remind",checked:A.dueRemind,input:{dueRemindCheck:B},content:[new Widget.InputPickerList({data:Math.abs(A.dueRemind||C),input:{dueRemind:B},values:E,type:"button"}),new Widget.Toggle({tag:"label",on:"before",off:"after",checked:(A.dueRemind||-1)<0,input:{dueBeforeAfter:B}})]})]})]}]},{name:"location",child:[{name:"left"},{name:"right inline",child:[new Widget.Enabler({caption:"Location",checked:A.geolocation,input:{geolocationCheck:B},content:[new Widget.InputPickerGeolocation({data:A.geolocation,input:{geolocation:B}})]})]}]}]},{name:"border",child:[{name:"top",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"middle",child:[{name:"left"},{name:"center"},{name:"right"}]},{name:"bottom",child:[{name:"left"},{name:"center"},{name:"right"}]}]}]});
function G(O){if(navigator.isOpera()){var N=window.pageYOffset
}var M=14*1;
var J=O.target;
var L=J.parentNode;
var K=(L.nodeEdit||(L.nodeEdit=L.parentNode.parentNode.parentNode.parentNode));
var I=parseInt(J.style.height);
J.style.height="";
var H=J.scrollHeight+8;
H=Math.floor(H/M+2)*M;
H=Math.max(H,M*8);
if(H!=I){L.style.height=(H)+"px";
K.style.height=(H+156)+"px"
}J.style.height=(H)+"px";
if(N){window.scrollTo(0,N)
}}B.notes.on(["keydown","keyup","keypress","onfocus","onblur"],G);
setTimeout(G.bind(null,{target:B.notes}),1);
G({target:B.notes});
return F
};
Widget.hint=function(B){function D(E){if(B.hasClass("hint")){B.value=""
}B.removeClass("hint");
if(B.password&&B.type!="password"){B.type="password";
if(document.activeElement!=B){B.focus()
}}}function C(E){var F=B.getAttribute("title");
if(B.value==""&&document.activeElement!=B){B.addClass("hint");
try{if(B.password){B.type="text"
}}catch(E){}B.value=F
}else{try{if(B.password){B.type="password"
}}catch(E){}B.removeClass("hint")
}}function A(E){if(E==undefined){return this.hasClass("hint")?"":this.value
}this.value=E;
C(null,this)
}B.on("focus",D);
B.on("blur",C);
B.valueOf=A;
B.valueEx=A;
B.password=B.type=="password";
C(null,B)
};
Widget.tag=function(C){C=C||{};
var A={};
var B={name:"tag ",attribute:{title:C.name},child:[{name:"border",child:[{name:"top",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"middle",child:[{name:"left"},{name:"center",child:{name:"content",child:[{text:C.name}],reference:{center:A}}},{name:"right"}]},{name:"bottom",child:[{name:"left"},{name:"center"},{name:"right"}]}]}]};
A.main=document.create(B);
if(C.count){A.center.style.fontSize=((C.count/3)+12)+"px"
}A.center.style.backgroundColor=Widget.tagColor(C.name);
return A.main
};
Widget.hoverAsClick=function(D){var E,C,B;
function A(){clearTimeout(E);
clearTimeout(C);
clearInterval(B)
}function F(G){E=setTimeout(function(){if(D.hasClass("target")){C=setTimeout(function(){A();
D.fire("click")
},700);
B=setInterval(function(){D.toggleClass("target")
},70)
}},1000)
}D.on("mouseover",F);
D.on(["mouseout","mouseup"],A)
};
Widget.Input=Widget.extend({constructor:function(C){this.$base();
C=C||{};
C.type=C.type||"text";
C.tag=C.tag||"input";
var B=(C.type=="button"||C.type=="submit");
this.node.main=document.create({tag:B?"label":null,name:"input input-tag-"+C.tag+" input-"+(B?"button":"text")+" "+(C.name||""),child:[(B?{name:"front",child:{reference:{front:this.node}}}:null),{tag:C.tag,attribute:{type:C.type,name:C.field||null,title:C.hint||""},property:{widget:this,data:C.data},reference:[C.input,{input:this.node}]},Widget.border()]});
this.node.content=this.node.main.lastChild.childNodes[1].childNodes[1].firstChild;
this.value(C.value);
var A=this.node.input;
if(C.focus){setTimeout(function(){try{A.select();
A.focus()
}catch(D){}},100)
}if(C.hint){Widget.hint(this.node.input)
}},value:function(B){var A=this.node.input;
if(B==undefined){return A.valueEx?A.valueEx():A.value
}else{if(A.valueEx){A.valueEx(B)
}else{A.value=B
}if(this.node.front){this.node.front.innerHTML=B
}}}});
Widget.InputButtonCommand=Widget.Input.extend({constructor:function(A){A.type="button";
this.$base();
document.create({name:"content",child:[{name:"icon"},{name:"text",child:[{name:"caption",html:A.caption},{name:"comment",html:A.comment}]}],node:this.node.content});
this.node.main.addClass("input-button-command");
if(A.listener){this.node.input.on("click",A.listener,{context:A.context})
}}});
Widget.InputTime=Widget.extend({constructor:function(A){this.$base();
this.military=Date.military();
A.hint=A.hint||"Time";
this.node.main=document.create({name:"input-time",child:[this.input=new Widget.Input(A),this.military?null:this.toggle=new Widget.Toggle({on:"AM",off:"PM",tag:"label",checked:true})]});
this.node.input=this.input.node.input;
if(!this.military){this.toggle.node.input.on("click",this.onClick.bind(this))
}},onClick:function(){this.node.input.fire("change")
},value:function(A){if(typeof A=="undefined"){A=new Date();
A.timestamp(this.encode());
return A
}this.decode(A.timestamp())
},update:function(){this.decode(this.node.input.data)
},decode:function(B){var A=new Date();
A.timestamp(B);
this.input.value(A.format(this.military?"%H:%M":"%I:%M"));
if(!this.military){this.toggle.value(A.getHours()<=12)
}},encode:function(){var A=new Date().parse(this.input.value());
if(!this.military&&!this.toggle.value()){A.setHours(A.getHours()%12+12)
}this.input.value(A.format(this.military?"%H:%M":"%I:%M"));
return this.node.input.data=A.timestamp()
}});
Widget.BalloonPicker=Widget.Balloon.extend({constructor:function(A){this.smthngs=smthngs;
this.input=A.input.widget;
this.$base();
this.node.input=A.input;
this.on(["mousedown","focus"],this.onKillFocus,window.document.body,{capture:true})
},onKillFocus:function(C){var B=C.target,A=B.localName.toLowerCase();
if(!this.node.main.contains(B)&&!this.node.input.parentNode.contains(B)&&((C.type!="focus")||(A=="input")||(A=="textarea"))){this.destroy()
}},update:function(){},change:function(A){this.node.input.data=A;
this.input.update(A)
}});
Widget.InputPicker=Widget.Input.extend({constructor:function(A){this.$base();
this.node.main.addClass("picker-"+this.name);
this.on(["focus","click"],this.onFocus,this.node.input);
this.on("change",this.onBlur,this.node.input);
this.on("click",this.onButton,this.node.main.lastChild.childNodes[1]);
this.update()
},onButton:function(A){console.debug("Input::onButton");
A.preventDefault();
A.stopPropagation();
if(+this.balloon){this.balloon.destroy()
}else{if(document.activeElement!=this.node.input){this.node.input.focus()
}else{this.onFocus()
}}},update:function(){this.decode(this.node.input.data);
this.node.input.fire("update")
},available:function(){return true
},onFocus:function(){console.debug("Input::onFocus");
if(this.available()&&!+this.balloon){var A=this.node.main;
this.balloon=new this.Balloon({input:this.node.input,width:this.node.main.clientWidth-6,arrow:"top",attach:function(B){A.appendChild(B)
}})
}},onBlur:function(A){this.encode();
if(+this.balloon){this.balloon.update()
}},encode:function(){},decode:function(){}});
Widget.BalloonPickerCalendar=Widget.BalloonPicker.extend({days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],constructor:function(A){this.$base();
this.init();
document.create({name:"calendar",append:this.node.content,child:[{name:"bar",on:{click:this.onBarClick.bind(this)},child:[{name:"backward"},{name:"today"},{name:"forward"},{name:"date",reference:{date:this.node}}]},{on:{click:this.onTableClick.bind(this)},reference:{table:this.node}},{name:"time"+(!Date.military()?" ampm":""),child:[new Widget.Enabler({on:"time",off:"all day",checked:!this.date.allDay(),input:{checkbox:this.node},content:this.time=new Widget.InputTime({input:{time:this.node}})})]}]});
this.on("change",this.onTimeBlur,this.node.time);
this.on("click",this.onCheckbox,this.node.checkbox);
this.redraw()
},table:function(){console.debug("BalloonPickerCalendar::table");
this.month.setDate(1);
var F=this.month.getDay();
var E=new Date();
var G=this.month.getDaysInMonth();
var A=0;
var J=[];
var I=[];
var K=Date.format.weekStarts;
for(var B=0;
B<7;
B++){I.push({name:"cell",text:this.days[(B+K)%7].substring(0,2)})
}J.push({name:"week title",child:I});
function H(M,L,N){return A==1&&M.getFullYear()==L.getFullYear()&&M.getMonth()==L.getMonth()&&M.getDate()==N
}var D=1;
while(1){I=[];
I.push({name:"left"});
for(var B=0;
B<7;
B++){var C=(B+K)%7;
if(A==0&&C==F){A=1
}I.push({name:"cell"+(A==1?" day":"")+(H(E,this.month,D)?" today":"")+(H(this.date,this.month,D)?" select":""),text:(A==1?""+D++:"")});
if(D>G){A=2
}}I.push({name:"right"});
J.push({name:"week",child:I});
if(A==2){break
}}return document.create({name:"table",node:this.node.table,child:J})
},onBarClick:function(B){this.grabFocus();
var A=this.month;
switch(B.target.className){case"backward":A.setMonth(A.getMonth()-1);
break;
case"forward":A.setMonth(A.getMonth()+1);
break;
case"today":this.month=new Date();
break;
default:return 
}this.redraw()
},onTableClick:function(E){this.grabFocus();
var A=E.target.getParent("day");
if(!A){return 
}var F=parseInt(A.innerHTML);
if(isNaN(F)){return 
}var B=this.node.table.getDescendants("select")[0];
if(B){B.removeClass("select")
}A.addClass("select");
var D=this.month,C=this.date;
D.setDate(F);
C.setDate(D.getDate());
C.setMonth(D.getMonth());
C.setFullYear(D.getFullYear());
this.change()
},grabFocus:function(){this.node.checkbox.focus()
},onTimeBlur:function(){console.debug("BalloonPickerCalendar::onTimeBlur");
var A=this.time.value();
this.date.setHours(A.getHours());
this.date.setMinutes(A.getMinutes());
this.change()
},onCheckbox:function(A){console.debug("BalloonPickerCalendar::onCheckbox "+A.screenX);
if(A.screenX==-1){return 
}this.date.setSeconds(this.node.checkbox.checked?0:1);
this.change()
},change:function(){console.debug("BalloonPickerCalendar::change");
this.$base(this.date.timestamp())
},init:function(){this.date=new Date();
this.date.timestamp(this.node.input.data);
this.month=this.date.clone()
},update:function(){console.debug("BalloonPickerCalendar::update");
this.init();
this.redraw()
},redraw:function(){console.debug("BalloonPickerCalendar::redraw");
this.table();
this.node.date.innerHTML=this.months[this.month.getMonth()]+" "+this.month.getFullYear();
this.time.value(this.date);
if(this.date.allDay()==this.node.checkbox.checked){this.node.checkbox.fire("click",{screenX:-1})
}}});
Widget.InputPickerCalendar=Widget.InputPicker.extend({name:"calendar",constructor:function(A){this.Balloon=Widget.BalloonPickerCalendar;
this.$base()
},decode:function(B){var A=new Date();
A.timestamp(B);
this.value(A.format())
},encode:function(){var A=this.node.input;
var B=new Date().parse(this.value());
A.data=B.timestamp();
this.value(B.format())
}});
Widget.BalloonPickerCloud=Widget.BalloonPicker.extend({constructor:function(A){this.$base();
this.node.input=A.input;
document.create({name:"cloud",reference:{cloud:this.node},append:this.node.content});
this.on("click",this.onClick,this.node.content);
this.on("keyup",this.parse,this.node.input);
this.tags={};
this.update()
},onClick:function(E){console.debug("BalloonPickerCloud::onClick");
var D;
if(D=E.target.getParent("tag")){E.stopPropagation();
var A=D.getAttribute("title");
var C=this.node.input.value.SPLIT(),B;
if((B=C.indexOf(A))==-1){C.push(A)
}else{C.splice(B,1)
}this.node.input.value=C.JOIN();
this.parse()
}},parse:function(){var B=this.node.input.value.SPLIT();
for(var A in this.tags){this.tags[A].node.assignClass("active",B.indexOf(A)!=-1)
}},update:function(){this.redraw();
this.parse()
},redraw:function(){var B=this.smthngs.logic.tags(true);
this.node.cloud.clearNode();
for(var C=B.length;
C--;
){var A=B[C];
var D=Widget.tag(A);
this.tags[A.name]={name:A.name,node:D};
this.node.cloud.appendChild(D)
}}});
Widget.InputPickerCloud=Widget.InputPicker.extend({name:"cloud",constructor:function(A){this.Balloon=Widget.BalloonPickerCloud;
this.$base()
}});
Widget.BalloonPickerGeolocation=Widget.BalloonPicker.extend({constructor:function(B){this.$base();
document.create({name:"geolocation",child:[{child:this.list=new Widget.InputPickerList({hint:"Search",values:[],input:{list:this.node}})},Widget.border({name:"frame",content:{child:{name:"map",reference:{map:this.node}}}}),{name:"buttons",child:[new Widget.Input({value:"Show my location",type:"button",input:{locate:this.node}})]}],append:this.node.content});
this.on("click",this.onLocate,this.node.locate);
this.on("update",this.onList,this.node.list);
this.on("keydown",this.onListKeyDown,this.node.list);
this.update();
if(window.google&&google.maps){this.initialize()
}else{var A=this;
window.onGoogleMapsApiLoaded=function(){A.initialize()
};
document.importScript("http://maps.google.com/maps/api/js?sensor=false&callback=onGoogleMapsApiLoaded")
}},initialize:function(){var B=this.data;
var A=new google.maps.LatLng(B[0],B[1]);
this.map=new google.maps.Map(this.node.map,{zoom:B[2],center:A,disableDefaultUI:true,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:true,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},navigationControl:true,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL},backgroundColor:"#f8f8f8"});
this.marker=new google.maps.Marker({position:A,title:"Point",map:this.map,draggable:true});
this.geocoder=new google.maps.Geocoder();
google.maps.event.addListener(this.map,"click",this.onMapClick.bind(this));
google.maps.event.addListener(this.marker,"dragend",this.onMarkerDragEnd.bind(this))
},geocode:function(){this.geocoder.geocode({latLng:this.marker.getPosition()},this.onGeocode.bind(this,false))
},position:function(A,C,B){this.map.setCenter(A);
this.marker.setPosition(A);
if(this.circle){this.circle.setMap(null);
delete this.circle
}if(C){this.map.fitBounds(C)
}if(B){this.geocode()
}this.change()
},onLocate:function(A){this.smthngs.geolocation.position(this.onPosition.bind(this))
},onPosition:function(A){var C=A.coords;
var B=new google.maps.LatLng(C.latitude,C.longitude);
var D=new google.maps.Circle({center:B,clickable:false,map:this.map,radius:C.accuracy,fillColor:"#2996cc",fillOpacity:0.3,strokeColor:"#2996cc",strokeWeight:1});
this.position(B,D.getBounds(),true);
this.circle=D
},onList:function(){var A=this.node.list.data.geometry;
this.position(A.location,A.bounds)
},onListKeyDown:function(A){if(A.keyCode==13){A.preventDefault();
A.stopPropagation();
if(+this.list.balloon){this.list.balloon.destroy()
}this.geocoder.geocode({address:this.node.list.value},this.onGeocode.bind(this,true))
}},onMapClick:function(A){this.position(A.latLng,null,true)
},onMarkerDragEnd:function(A){this.position(this.marker.getPosition(),null,true)
},onGeocode:function(B,E,A){var C=this.list.values;
C.length=0;
console.log("responses: ",E);
if(E.length>1){for(var D=0;
D<E.length;
D++){C.push({name:E[D].formatted_address,data:{address:E[D].formatted_address,geometry:E[D].geometry}})
}}if(B&&(E.length>1)){this.list.onFocus()
}else{if(E.length==1){var F=E[0].geometry;
this.position(F.location,F.bounds)
}}this.list.value(E.length>0?E[0].formatted_address:"");
this.change()
},update:function(){var A;
this.data=(this.node.input.data||((A=this.smthngs.geolocation.position())?[A.coords.latitude,A.coords.longitude,11,""]:0)||[37.7577,-122.4376,11,"Los Angeles, CA, USA"]).slice()
},change:function(){var A=this.map.getCenter();
this.data=[A.lat(),A.lng(),this.map.getZoom(),this.list.value()];
this.node.input.data=this.data.slice();
this.input.update()
}});
Widget.InputPickerGeolocation=Widget.InputPicker.extend({name:"geolocation",constructor:function(A){this.Balloon=Widget.BalloonPickerGeolocation;
this.$base()
},decode:function(A){if(A){this.value(A[3])
}},encode:function(){input.data[3]=this.value()
}});
Widget.BalloonPickerList=Widget.BalloonPicker.extend({constructor:function(E){this.$base();
var B=this.input.values;
var A=[];
for(var C=0;
C<B.length;
C++){var D=B[C];
A.push({name:"item",text:typeof D=="string"?D:D.name,property:{data:D.data}})
}document.create({name:"combo-box-list",child:A,append:this.node.content});
this.on("click",this.onClick,this.node.content)
},onClick:function(A){A.stopPropagation();
A.preventDefault();
this.change(A.target.data);
this.destroy()
}});
Widget.InputPickerList=Widget.InputPicker.extend({name:"list",constructor:function(A){this.values=A.values;
this.Balloon=Widget.BalloonPickerList;
this.$base()
},available:function(){return(this.values||[]).length>0
},decode:function(D){var A=this.values,B;
for(var C=A.length;
C--;
){if(A[C].data==D){B=A[C].name;
break
}}if(B){this.value(B)
}}});
Widget.tagColor=function(A,D){if(!this.cache){this.cache={}
}if(!this.cache[A]){var C=A.hash(360),B=20+A.hash(80);
this.cache[A]=[Utils.hslToRgb(C,B,80),Utils.hslToRgb(C,B,75)]
}return this.cache[A][D?1:0]
};
Widget.issue=function(K,B){B=B||{};
var N=B.search,H=B.mode||"";
try{if(!N){N=smthngs.state.state.search
}}catch(I){}function D(O){if(N){O=O.replace(new RegExp("("+N+")","gmi"),'<span class="marker">$1</span>')
}return O
}function J(P,O){return{name:"badge "+O,attribute:{title:P},style:O=="tag"?{background:Widget.tagColor(P,true)}:null,child:[{name:"left"},{name:"center",html:D(Utils.typograf(P))},{name:"right"}]}
}var C=K.type=="task",G,A;
if(B.badges){G=[];
if(K.tags.length>0){var M=K.tags;
for(var F=M.length-1;
F>=0;
F--){G.push(J(M[F],"tag"))
}}var L=K.badges();
A=[L.geolocation?J(L.geolocation.text,"geolocation"):null,L.due?J(L.due.text,"due"+(L.due.overdue?" overdue":"")):null,L.start?J(L.start.text,"start"):null]
}if(!K.node){K.node={}
}var E={name:"issue "+K.type+" "+K.mark+" "+K.folder+(!K.focused?" unfocused":"")+(H?" mode-"+H:""),property:{issue:K.id,features:B,mode:H},child:[B.buttons?{name:"insert before"}:null,B.buttons?{name:"insert after"}:null,{name:"border",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"content shader",child:{child:[{name:"mark"},{name:"title",child:{attribute:H=="navigate"?{title:K.title}:null,html:D(Utils.typograf(K.title)||"No title."),child:K.notes&&B.notes?{tag:"em",html:Utils.typograf(K.notes)}:null}}]}},G?{name:"badges first",child:G}:null,A?{name:"badges second",child:A}:null]};
return document.create(E)
};
Widget.service=function(F,I){if(!this.service_queue){this.service_queue=[]
}if(!this.service_timer){this.service_timer=0
}function E(M){}function B(S){var O={projects:S},Q=[],U=0,V=0,P=false;
var S=O.projects.getChildren("project");
if(S.length==0){return 
}for(var T=S.length;
T--;
){var X=S[T];
var M=X.lastChild.firstChild.lastChild.clientWidth;
M+=24;
if(X.hasClass(/current|modify/)){P=!X.hasClass("modify");
U=M+13;
M=0
}else{V+=M
}Q[T]=M
}E(S);
O.projects.assignClass("clip",P);
var R=23*(S.length-1),W=U,N=R-W;
O.projects.style.marginRight=-(R+30)+"px";
O.projects.style.paddingRight=(W+30)+"px";
O.edit=O.projects.getChildren("edit")[0];
if(O.edit){O.edit.style.marginRight=N+"px"
}O.other=O.projects.getChildren(/shadow|shade|clip/);
for(var T=O.other.length-1;
T>=0;
T--){O.other[T].style.marginRight=(N-30)+"px"
}for(var T=S.length-1;
T>=0;
T--){S[T].style.maxWidth=Q[T]?((Q[T]/V*100)+"%"):""
}O.projects.redraw()
}function J(M){E(M.getChildren("issue"))
}function L(M){E(M.firstChild.getChildren("item"))
}function K(M){E(M.getDescendants(/issue/,/navigate|level/))
}function H(M){E(M.getChildren("tag"))
}function D(M){if(M.hasClass("tasks")||M.hasClass("tree")||M.hasClass("issues")){J(M)
}if(M.hasClass("projects")){B(M)
}if(M.hasClass("navigate")){K(M)
}if(M.hasClass("tags")){H(M)
}if(M.hasClass("focus")){L(M)
}}function A(){var M=this.service_queue;
for(var N=M.length;
N--;
){D(M[N])
}M.length=0
}var C=0;
if(I){var G=this.service_queue;
if(G.indexOf(F)==-1){G.push(F)
}clearTimeout(this.service_timer);
this.service_timer=setTimeout(A,10)
}else{D(F)
}};
Widget.Toggle=Widget.extend({constructor:function(A){this.$base();
A=A||{};
A.checked=A.checked||false;
this.node.main=document.create({tag:A.tag,name:"toggle "+(A.checked?" checked":""),attribute:{title:A.title||"",touchable:1},child:[{tag:"input",attribute:{type:"checkbox"},reference:[A.input,{input:this.node}]},{name:"border",child:[{name:"left"},{name:"center",child:{}},{name:"right"}]},{name:"clip",child:[{name:"on",text:A.on||"on",reference:{slider:this.node}},{name:"slider"},{name:"off",text:A.off||"off"}]}]});
this.node.input.checked=A.checked;
this.node.slider.style.marginLeft=(A.checked?0:-100)+"%";
this.on("click",this.change,this.node.input);
this.down=0;
this.on("mousedown",this.mouseDown,this.node.slider.nextSibling);
this.on("mousemove",this.mouseMove,this.node.slider.nextSibling)
},mouseDown:function(B){this.down=1;
var A=this;
setTimeout(function(){A.down=0
},700)
},mouseMove:function(A){if(this.down){this.down=0;
this.node.input.fire("click")
}},value:function(B){var A=this.node.input;
if(typeof B=="undefined"){return A.checked
}if(B!=A.checked){A.fire("click")
}},change:function(C){this.down=0;
var A=this.node.input,B=A.checked;
console.log("toggle: change, checked: "+B);
A.focus();
this.node.main.assignClass("checked",B);
this.node.main.getParent("toggle").assignClass("checked",B);
this.animate(B?1:0)
},transition:function(A,B){console.log("toggle: transition, stage: "+A+", direction: "+B);
this.node.slider.style.marginLeft=(1-A)*-100+"%"
}});
Widget.Enabler=Widget.extend({constructor:function(B){this.$base();
this.toggle=new Widget.Toggle(B);
this.node.main=document.create({name:"enabler "+(B.name||""),child:[{tag:"label",attribute:{title:B.title||""},child:[B.caption?{name:"caption",text:B.caption}:null,this.toggle]},{name:"content",child:B.content,reference:{content:this.node}}]});
var A=this.node.content.style;
A.opacity=B.checked?1:0;
A.display=B.checked?"":"none";
this.toggle.node.input.on("click",this.onClick.bind(this))
},onClick:function(B){var A=this.toggle.node.input;
this.node.content.style.display="";
this.animate(A.checked)
},transition:function(A,B){this.node.content.style.opacity=A;
if(!B&&A==0){this.node.content.style.display="none"
}}});
var DialogAbout=Widget.Dialog.extend({constructor:function(B){B.width=400;
B.caption="About Smthngs";
this.$base();
function A(E,D){var C=D.replace(/^\w+:\/?\/?/,"");
return{child:[{tag:"a",attribute:{href:D,target:"_blank"},html:E}]}
}document.create({node:this.node.body,child:[{name:"row group",text:"Smthngs (thn.gs)"},{text:"version 3.0.4"},{html:"&copy; 2007&mdash;"+(new Date()).getFullYear()+' <a href="http://shergin.com/">shergin research</a>'},{html:"all right reserved"},A("info@thn.gs","mailto:info@thn.gs"),{name:"group",text:"Stay tuned"},A("Twitter","http://twitter.com/smthngs"),A("Facebook","http://facebook.com/smthngs"),{name:"group",text:"Share us"},{name:"like-buttons",child:[{tag:"span",html:'<fb:like href="http://facebook.com/smthngs" ref="info-balloon" layout="button_count" show_faces="false" width="100"></fb:like>'},{tag:"span",html:'<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://thn.gs/" data-text="Smthngs" data-count="horizontal" data-via="smthngs">Tweet</a>'},]},{name:"group",html:"Our team"},{text:"Valentin Shergin"},{text:"Julia Kuzina"},{name:"group",html:"Special thanks"},{text:"Rouss Valiulin, Anton Sotkov, Alexander Timofeev, Dmitry Soshnikov, Marat Potashov."},{name:"buttons",child:[new Widget.Input({value:"Close",hint:"",input:{close:this.node},event:[],type:"button",focus:1})]}]});
document.importScript("http://connect.facebook.net/en_US/all.js#xfbml=1");
document.importScript("http://platform.twitter.com/widgets.js");
this.on("click",this.destroy,this.node.close)
}});
var DialogPreferences=Widget.Dialog.extend({constructor:function(G){this.smthngs=smthngs;
this.preferences=this.smthngs.preferences;
var B=this.preferences.get();
G.width=600;
G.name="preferences";
G.caption="Preferences";
this.$base();
function E(H){return{name:"row",child:[{name:"left",text:H.title},{name:"right",child:H.content}]}
}var F=this.preferences.timeZones.map(function(H){return{name:H.replace(/_/g," "),data:H}
});
var D=this.node;
document.create({node:D.body,child:[{name:"row group",text:"Account"},{name:"row",child:[{name:"left",text:"name:"},{name:"right",child:new Widget.Input({value:B.name,hint:"Name",input:{name:D}})}]},{name:"row",child:[{name:"left",text:"Login (your email):"},{name:"right",child:new Widget.Input({value:B.mail,hint:"E-mail",input:{mail:D}})}]},{name:"row group",text:"Password"},{name:"row",child:[{name:"left",text:"Old password:"},{name:"right",child:new Widget.Input({value:"",hint:"Old password",input:{passwordOld:D},type:"password"})},{name:"error",text:"wrong password"}]},{name:"row",child:[{name:"left",text:"New password:"},{name:"right",child:new Widget.Input({value:"",hint:"New password",input:{passwordNew:D},type:"password"})},{name:"error",text:"must have at least 6 characters"}]},{name:"row group",text:"Date & Time"},E({title:"Time zone:",content:new Widget.InputPickerList({name:"time-zone",data:B.timeZone,input:{timeZone:D},values:F,type:"button"})}),E({title:"First day of week:",content:new Widget.InputPickerList({data:B.format.weekStarts,input:{formatWeekStarts:D},values:[{name:"Sunday",data:0},{name:"Monday",data:1}],type:"button"})}),E({title:"Date notation:",content:new Widget.InputPickerList({data:B.format.date,input:{formatDate:D},values:[{name:"MM/DD/YY",data:"%m/%d/%y"},{name:"DD.MM.YY",data:"%d.%m.%Y"},{name:"YY-MM-DD",data:"%Y-%m-%d"}],type:"button"})}),E({title:"Time notation:",content:new Widget.InputPickerList({data:B.format.time,input:{formatTime:D},values:[{name:"12-hour",data:"%I:%M %p"},{name:"24-hour",data:"%H:%M"}],type:"button"})}),{name:"row group",text:"Other"},this.toggle({name:"more",title:"Clip task list:"}),this.toggle({name:"offline",title:"Swich to offline mode automatically:"}),this.toggle({name:"animation",title:"Animation:"}),this.toggle({name:"colorization",title:"Color highlight:"}),{name:"row",child:[{name:"left",child:["Send notification via ",{tag:"a",attribute:{href:"http://notifo.com",target:"_blank"},text:"Notifo"},":"]},{name:"right",child:new Widget.Enabler({name:"notifo",checked:B.notifo,input:{notifoCheck:D},content:[new Widget.Input({value:B.notifo,hint:"Notifo username",input:{notifo:D}})]})}]},{name:"buttons",child:[new Widget.Input({value:"Close",hint:"",input:{close:D},event:[],type:"button"}),new Widget.Input({value:"Save",hint:"",input:{save:D},type:"button",focus:1})]}]});
var A=[D.passwordNew,D.passwordOld,D.mail,D.name];
for(var C=A.length;
C--;
){this.on(["blur","focus"],this.onInput,A[C])
}this.on("click",this.onSave,D.save);
this.on("click",this.destroy,D.close)
},toggle:function(C){var B=this.preferences.get(),A={};
A[C.name]=this.node;
return{name:"row",property:{preference:C.name},tag:"label",child:[{name:"left",text:C.title},{name:"right",child:new Widget.Toggle({checked:B[C.name],name:C.name,on:C.on,off:C.off,input:A})}]}
},onSave:function(D,C){var A={};
for(var B in {more:1,offline:1,animation:1,colorization:1}){A[B]=!!this.node[B].checked
}for(var B in {name:1,mail:1,passwordNew:1,passwordOld:1}){A[B]=this.node[B].widget.value()
}A.format={date:this.node.formatDate.data,time:this.node.formatTime.data,weekStarts:this.node.formatWeekStarts.data};
A.notifo=this.node.notifoCheck.checked?(this.node.notifo.widget.value()||null):null;
A.timeZone=this.node.timeZone.data;
if(A.passwordNew!=""){if(A.passwordOld.length<6){return this.error(this.node.passwordOld)
}if(A.passwordNew.length<6){return this.error(this.node.passwordNew)
}}else{delete A.passwordNew;
delete A.passwordOld
}delete A.passwordNewRepeat;
this.preferences.save(A,this.onResponse.bind(this,A))
},onResponse:function(A,B){if(B.status=="ok"){delete A.passwordNew;
delete A.passwordOld;
this.preferences.apply(A);
this.destroy()
}else{this.error(this.node.passwordOld)
}},row:function(A){return A.getParent("row")
},onInput:function(B,A){this.row(B.target).removeClass("invalid")
},error:function(A){this.row(A).addClass("invalid")
}});
var DialogSignOut=Widget.Confirm.extend({constructor:function(C){this.smthngs=smthngs;
var B={width:500,caption:"Sign out",message:"How do you want to sign out?",context:this,buttons:[{caption:"Sign out from current session",comment:"I want to sign out only from this browser, keep open all my other sessions.",listener:function(){this.signOut()
},focus:1},{caption:"Sign out from all session",comment:"I want to sign out from everywere: all browsers, computers and mobile devices.",listener:function(){this.signOut(true)
}},{caption:"Cancel",comment:"I’ve change my mind, close this window."}]};
for(var A in B){C[A]=B[A]
}this.$base()
},signOut:function(A){this.smthngs.logic.request("sign-out",{all:!!A},null,function(){this.smthngs.logic.auth("#sign-out")
},true);
this.destroy()
}});
if(typeof console=="undefined"){var logger=(window.opera&&opera.postError)?opera.postError:function(){};
console={log:logger}
}if(!console.debug){console.debug=console.log
}var Smthngs=Object.extend({debug:(window.mode=="debug"),constructor:function(){window.smthngs=this;
this.statistics=new Statistics(this);
this.gears=new Gears(this);
this.layout=new Layout(this);
this.toolbar=new Toolbar(this);
this.api=new API(this);
this.logic=new Logic(this);
this.preferences=new Preferences(this);
this.focus=new Focus(this);
this.list=new List(this);
this.sidebar=new Sidebar(this);
this.selection=new Selection(this);
this.geolocation=new Geolocation(this);
this.state=new State(this);
this.shortcuts=new Shortcuts(this);
this.state.init()
},invalidate:function(){this.sidebar.invalidate();
this.list.invalidate()
}});
