/*

    Remember The Milk(tm) (M12) - Copyright (c) 2006 Remember The Milk Pty Ltd
                                  All Rights Reserved. Don't steal, please.

    Non vi sed virtute, non armis sed arte paritur victoria.

*/


function is(x){return!!(x===0||x);}
function exists(x){return typeof x!=="undefined";}
function map(f,input){var out=[];for(var i=0,j=input.length;i<j;i++){out.push(f(input[i]));}
return out;}
function mapkv(f,input){var out={};for(var key in input){out[key]=f(key,input[key]);}
return out;}
String.prototype.trim=new Function("return this.replace(/^\\s+|\\s+$/g,'')");String.prototype.replaceStr=function(find,replace){return this.split(find).join(replace);};String.prototype.escapeForXML=function(){return this.replaceStr("&","&amp;").replaceStr("\"","&quot;").replaceStr("<","&lt;").replaceStr(">","&gt;");};String.prototype.escapeForField=function(){return this.replaceStr("&lt;","<").replaceStr("&","&amp;").replaceStr("\"","&quot;").replaceStr("<","&lt;").replaceStr(">","&gt;");};String.prototype.escapeForDisplay=function(){return this.replaceStr("<","&lt;");};String.prototype.escapeForAttr=function(){return this.replaceStr("'","\\'").replaceStr("<","&lt;");};function url_repl(s){var out=[];for(var i=0,j=s.length;i<j;i++){out.push(s.charAt(i));out.push("<wbr />");}
return"<a href=\""+s+"\" target=\"_blank\">"+out.join("")+"</a>";}
function email_repl(s){var out=[];for(var i=0,j=s.length;i<j;i++){out.push(s.charAt(i));out.push("<wbr />");}
return"<a href=\"mailto:"+s+"\">"+out.join("")+"</a>";}
String.prototype.autoLink=function(attach){var s=this;var email=/(([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+)/g;var url=/(http:\/\/|https:\/\/|file:\/\/|ftp:\/\/)([^\s<>\'"]+)/;s=s.replaceStr("mailto:","");s=s.replace(email,email_repl);s=s.replace(/(http:\/\/|https:\/\/|file:\/\/|ftp:\/\/)([^\s<>'"]+)/g,url_repl);if(attach){if(url.test(s)===false){var news="http://"+s;if(url.test(news)===true){s=news.replace(/(http:\/\/|https:\/\/)([^\s<>'"]+)/g,url_repl);}}}
return s;};Array.prototype.unique=function(){var seen={};for(var i=0;i<this.length;i++){seen[this[i]]=true;}
var out=[];for(var s in seen){out.push(s);}
return out;};var isBrowser=(typeof navigator!=="undefined");var is_ie=isBrowser&&(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent));var is_ie5=isBrowser&&(is_ie&&/msie 5\.0/i.test(navigator.userAgent));var is_opera=isBrowser&&(/opera/i.test(navigator.userAgent));var is_win_opera=isBrowser&&(/Windows/i.test(navigator.userAgent));var is_khtml=isBrowser&&(/Konqueror|Safari|KHTML/i.test(navigator.userAgent));var is_gecko=isBrowser&&(/Gecko/i.test(navigator.userAgent));var is_gecko18=isBrowser&&(is_gecko&&/rv:1.8/i.test(navigator.userAgent));var is_safari=isBrowser&&(/Safari/i.test(navigator.userAgent));function cloneObj(obj){var c={};for(var i in obj){c[i]=obj[i];}
return c;}
function cloneArr(inArr){var arr=[];for(var i=0;i<inArr.length;i++){arr[i]=inArr[i];}
return arr;}
Array.prototype.spliceAll=function(i){for(var x in this){if(i==this[x]){this.splice(x,1);}}
return this;};Array.prototype.toHash=function(){var keys={};for(var i=0;i<this.length;i++){keys[this[i]]=true;}
return keys;};function isHashEmpty(hash){var empty=true;for(var key in hash){if(is(hash[key])){empty=false;break;}}
return empty;}
if(isBrowser&&!window.XMLHttpRequest){window.XMLHttpRequest=function(){var xmlHttp=null;var ex;try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP.4.0");}
catch(ex){try{xmlHttp=new ActiveXObject("MSXML2.XMLHTTP");}
catch(ex){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(ex){}}}
return xmlHttp;};}
function Utility(){}
Utility.prototype.stopEvent=function(ev){ev||(ev=window.event);if(is_ie){ev.cancelBubble=true;ev.returnValue=false;}else{ev.preventDefault();ev.stopPropagation();}
return false;};Utility.stopPropagation=function(ev){ev||(ev=window.event);if(is_ie){ev.cancelBubble=true;}else{ev.stopPropagation();}
return true;};Utility.prototype.escapeText=function(t){t=t.replace(/\</g,"&lt;");t=t.replace(/\>/g,"&gt;");t=t.replace(/\&/g,"&amp;");t=t.replace(/\"/g,"&quot;");t=t.replace(/\'/g,"&39#;");t=t.replace(/\*/g,"&42#;");return t;};Utility.prototype.getEventTarget=function(ev){var targ=null;if(ev.target){targ=ev.target;}else{if(ev.srcElement){targ=ev.srcElement;}}
if(targ.nodeType==3){targ=targ.parentNode;}
return targ;};Utility.prototype.getRandomInt=function(x){return Math.floor(x*Math.random());};Utility.getRandomInt=function(x){return Math.floor(x*Math.random());};Utility.prototype.suffixize=function(iNumber){var sNumber=(""+iNumber);var iLastDigit=parseInt(sNumber[sNumber.length-1],10);if(iLastDigit==1&&iNumber!=11){return iNumber+"st";}else{if(iLastDigit==2){return iNumber+"nd";}else{if(iLastDigit==3){return iNumber+"rd";}else{return iNumber+"th";}}}};Utility.prototype.pluralize=function(n,t){if(rtmLanguage=="en_US"){if(n==1){return n+" "+t;}else{return n+" "+t+"s";}}
return n+" "+fmt(t);};function el(id){if(document.getElementById){return document.getElementById(id);}else{if(window[id]){return window[id];}}
return null;}
function quoted(t){return t?"\""+t+"\"":"\"\"";}
function padded(value){return(value<10?("0"+value):value.toString());}
function setCookie(name,value,expires,path,domain,secure){document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");}
function getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0){return null;}}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));}
function deleteCookie(name,path,domain){if(getCookie(name)){document.cookie=name+"="+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
function extendObject(me,them){for(var proto in them.prototype){me.prototype[proto]=them.prototype[proto];}}
function getfmt(s){return typeof STRING_TABLE!=="undefined"&&is(STRING_TABLE[s])?STRING_TABLE[s]:s;}
function fmt(s,args){s=typeof STRING_TABLE!=="undefined"&&is(STRING_TABLE[s])?STRING_TABLE[s]:s;if(args instanceof Array){for(var i=0;i<args.length;i++){s=s.replace("%"+(i+1),args[i]);}
return s;}else{return s.replace("%1",args);}}
function _T(s,args){s=typeof STRING_TABLE!=="undefined"&&is(STRING_TABLE[s])?STRING_TABLE[s]:s;s=s.replace(new RegExp("{RTM}","g"),"Remember The Milk");if(args){for(var arg in args){s=s.replace(new RegExp("{"+arg+"}","g"),args[arg]);}}
return s;}
function _TF(s,args){if(!args){args={};}
args["START_BOLD"]="<b>";args["END_BOLD"]="</b>";args["START_ITALIC"]="<i>";args["END_ITALIC"]="</i>";args["START_LINK"]="<a href=\" \">";args["END_LINK"]="</a>";if(s instanceof Array){var url=s[1];var newwindow=s[2];var id="";if(is(args["LINK_ID"])){id=" id="+qtd(args["LINK_ID"]);}
var onc="";if(is(args["LINK_ONCLICK"])){onc=" onclick="+qtd(args["LINK_ONCLICK"]);}
if(newwindow){args["START_LINK"]="<a "+id+" "+onc+" href="+qtd(url)+" target=\"_blank\">";}else{args["START_LINK"]="<a "+id+" "+onc+" href="+qtd(url)+">";}
if(is(args["LINK_WRAP"])){args["START_LINK"]="<span id="+qtd(args["LINK_WRAP"])+">"+args["START_LINK"];args["END_LINK"]=args["END_LINK"]+"</span>";}
s=s[0];}
return _T(s,args);}
function qtd(t){return t?"\""+t+"\"":"\"\"";}
function quoteSearchTerm(str){if(str.charAt(0)!=="\""&&str.indexOf(" ")>-1&&str.charAt(str.length-1)!=="\""){return"\""+str+"\"";}
if(str.indexOf("(")>-1||str.indexOf(")")>-1){return"\""+str+"\"";}
return str;}
function debracket(str){if(str&&str.charAt(0)==="("&&str.charAt(str.length-1)==")"){return str.substring(1,str.length-1);}
return str;}
function normalizeSearchEntry(s){var x=s.split(/[\s;,]+/);var len=x.length;var output={};var inQuote=false;var words;for(var i=0;i<len;i++){if(x[i].charAt(0)=="\""){words=[];while(i<len&&x[i].charAt(x[i].length-1)!=="\""){words.push(x[i]);i++;}
if(i<len){words.push(x[i]);}
output[words.join(" ")]=true;}else{output[x[i]]=true;}}
var out=[];for(var x in output){if(x.indexOf("(")>-1||x.indexOf(")")>-1){out.push("\""+x+"\"");}else{out.push(x);}}
return out;}
function getWindowSize(){var windowWidth,windowHeight;if(window.innerWidth){windowWidth=window.innerWidth;windowHeight=window.innerHeight;}else{if(document.documentElement&&document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else{if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}}}
return[windowWidth,windowHeight];}
function EscapeUnicode(s){var out=[],c,y;for(var i=0;i<s.length;i++){c=s.charCodeAt(i);y=(Math.floor(c/16).toString(16)+(c%16).toString(16)).toString();if(y.length==2){out.push("\\u00"+y);}else{out.push("\\u"+y);}}
return out.join("");}
(function(){var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"},s={array:function(x){var a=["["],b,f,i,l=x.length,v;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=="string"){if(b){a[a.length]=",";}
a[a.length]=v;b=true;}}}
a[a.length]="]";return a.join("");},"boolean":function(x){return String(x);},"null":function(x){return"null";},number:function(x){return isFinite(x)?String(x):"null";},object:function(x){if(x){if(x instanceof Array){return s.array(x);}
var a=["{"],b,f,i,v;for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=="string"){if(b){a[a.length]=",";}
a.push(s.string(i),":",v);b=true;}}}
a[a.length]="}";return a.join("");}
return"null";},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16);});}
return"\""+x+"\"";}};Utility.prototype.encodeJavaScript=function(arg){var f=s[typeof arg];if(f){return f(arg);}
return s.string(String(arg));};Utility.toJSON=function(arg){var f=s[typeof arg];if(f){return f(arg);}
return s.string(String(arg));};})();Utility.SortAndSign=function(params){var SID=getCookie("SID");var params_out=[];for(var key in params){params_out.push([key,params[key]]);}
params_out.sort(function(a,b){return(a[0]===b[0])?0:(a[0]<b[0]?-1:1);});var to_sign=[],param,q=[];for(var i=0,j=params_out.length;i<j;i++){param=params_out[i];to_sign.push(param[0]+param[1]);q.push(param[0]+"="+param[1]);}
if(SID){q.push("sig="+hex_sha1(SID.substring(0,40)+to_sign.join("")));}
return q.join("&");};function DateRange(from,to){this.from=from;this.to=to;this.cache={};this.fromEpoch=this.from.getTime()/1000;this.toEpoch=this.to.getTime()/1000;}
DateRange.prototype.toString=function(){return"[DateRange] from = "+this.from+", to = "+this.to;};DateRange.prototype.withinRange=function(value){return(this.from.getTime()<=value.getTime()&&value.getTime()<=this.to.getTime());};DateRange.prototype.withinRangeExc=function(value){return(this.from.getTime()<=value.getTime()&&value.getTime()<this.to.getTime());};DateRange.prototype.epochWithinRange=function(epoch){if(this.cache[epoch]){return this.cache[epoch];}
return(this.cache[epoch]=(epoch>=this.fromEpoch)&&(epoch<this.toEpoch));};DateRange.prototype.intersectsRange=function(dateRange){return((dateRange.from.getTime()<=this.to.getTime()&&this.to.getTime()<=dateRange.to.getTime())||(dateRange.from.getTime()<=this.from.getTime()&&this.from.getTime()<=dateRange.to.getTime()));};DateRange.prototype.intersectsRanges=function(dateRangeArray){for(var i=0;i<dateRangeArray.length;++i){if(this.intersectsRange(dateRangeArray[i])){return true;}}};Date.Days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.ICALDays={"SU":0,"MO":1,"TU":2,"WE":3,"TH":4,"FR":5,"SA":6};Date.Months=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.prototype.padded=function(value){return(value<10?("0"+value):value.toString());};Date.prototype.timezone=function(value){var tz=this.getTimezoneOffset();var abtz=Math.floor(Math.abs(tz/60));abtz=this.padded(abtz);var ex=Math.floor(Math.abs(tz%60));var r=ex==0?abtz:abtz+":"+ex;if(tz<0){return"+"+r;}else{return"-"+r;}};Date.prototype.getFullMonth=function(){return Date.Months[this.getMonth()];};Date.prototype.getShortMonth=function(){return Date.Months[this.getMonth()].substring(0,3);};Date.prototype.getFullDay=function(){return Date.Days[this.getDay()];};Date.prototype.getShortDay=function(){return Date.Days[this.getDay()].substring(0,3);};Date.prototype.getUTCFullMonth=function(){return Date.Months[this.getUTCMonth()];};Date.prototype.getUTCShortMonth=function(){return Date.Months[this.getUTCMonth()].substring(0,3);};Date.prototype.getUTCFullDay=function(){return Date.Days[this.getUTCDay()];};Date.prototype.getUTCShortDay=function(){return Date.Days[this.getUTCDay()].substring(0,3);};Date.prototype.formatUTC=function(formatString){var s=new String(formatString);s=s.replace("HH",this.padded(this.getUTCHours()));s=s.replace("H",this.getUTCHours().toString());s=s.replace("MM",this.padded(this.getUTCMinutes()));s=s.replace("M",this.getUTCMinutes().toString());s=s.replace("SS",this.padded(this.getUTCSeconds()));s=s.replace("S",this.getUTCSeconds().toString());s=s.replace("YYYY",this.getUTCFullYear().toString());s=s.replace("YY",this.getUTCFullYear().toString().substring(2,4));s=s.replace("DDDD",this.getUTCFullDay());s=s.replace("DDD",this.getUTCShortDay());s=s.replace("DD",this.padded(this.getUTCDate()));s=s.replace("D",this.getUTCDate().toString());s=s.replace("mmmm",this.getUTCFullMonth());s=s.replace("mmm",this.getUTCShortMonth());s=s.replace("mm",this.padded(this.getUTCMonth()+1));s=s.replace("XX",this.padded(this.getUTCHours())>11?"PM":"AM");s=s.replace("ZZ",this.padded((this.getUTCHours())>11?(this.getUTCHours()-12):this.getUTCHours()));s=s.replace("V",(this.getUTCHours())>11?(this.getUTCHours()-12):this.getUTCHours());var z=this.getUTCHours()>11?(this.getUTCHours()-12):this.getUTCHours();s=s.replace("Z",(z==0?12:z));return s;};Date.prototype.withinRange=function(dateRange){return(dateRange.from.getTime()<=this.getTime()&&this.getTime()<=dateRange.to.getTime());};Date.prototype.withinRanges=function(dateRangeArray){for(var i=0;i<dateRangeArray.length;++i){if(this.withinRange(dateRangeArray[i])){return true;}}
return false;};Date.prototype.dateWithinRange=function(dateRange){var from=new Date(dateRange.from.getTime());var to=new Date(dateRange.to.getTime());from.setHours(0,0,0,0);to.setHours(23,59,59,999);return(from.getTime()<=this.getTime()&&this.getTime()<=to.getTime());};Date.prototype.dateWithinRanges=function(dateRangeArray){for(var i=0;i<dateRangeArray.length;++i){if(this.dateWithinRange(dateRangeArray[i])){return true;}}
return false;};Date.prototype.monthWithinRange=function(dateRange){var from=new Date(dateRange.from.getTime());var to=new Date(dateRange.to.getTime());from.setDate(1);from.setHours(0,0,0,0);to.setMonth(dateRange.to.getMonth()+1,1);to.setHours(0,0,0,0);to.setTime(to.getTime()-1);return(from.getTime()<=this.getTime()&&this.getTime()<=to.getTime());};Date.prototype.monthWithinRanges=function(dateRangeArray){for(var i=0;i<dateRangeArray.length;++i){if(this.monthWithinRange(dateRangeArray[i])){return true;}}
return false;};Date.isleap=function(year){return year%4==0&&(year%100!=0||year%400==0)?1:0;};Date._days_in_month=[0,31,28,31,30,31,30,31,31,30,31,30,31];Date.days_in_month=function(year,month){return Date.isleap(year)&&month==2?29:Date._days_in_month[month];};Date.fromISO=function(iso){return new Date(iso.substring(0,4),(iso.substring(4,6)*1)-1,iso.substring(6,8),iso.substring(9,11),iso.substring(11,13),iso.substring(13,15),0);};function DateFormat(pattern,indate){var len=pattern.length;var op=0;var out=[];var c,n;var inquote=false;var date=indate||new Date();var year,month,day,hours,minutes;for(var i=0;i<len;i++){var c=pattern.charAt(i);if(i!==len){n=pattern.charAt(i+1);}else{n=null;}
if(c=="'"&&n=="'"){out.push(c);i++;}else{if(c=="'"){inquote=!inquote;}else{if(inquote){out.push(c);continue;}
switch(c){case"y":op++;if(n!="y"){year=date.getFullYear().toString();switch(op){case 1:out.push(year);break;case 2:out.push(year.length==1?("0"+year):year.substring(year.length-2,year.length));break;case 3:out.push(year.length==1?("00"+year):(year.length==2?("0"+year):(year.length==3?year:year.substring(year.length-3,year.length))));break;case 4:out.push(year.length==1?("000"+year):(year.length==2?("00"+year):(year.length==3?("0"+year):(year.length==4?year:year.substring(year.length-4,year.length)))));break;case 5:out.push(year.length==1?("0000"+year):(year.length==2?("000"+year):(year.length==3?("00"+year):(year.length==4?("0"+year):(year.length==5?year:year.substring(year.length-5,year.length))))));break;}
op=0;}
break;case"M":op++;if(n!="M"){month=date.getMonth()+1;switch(op){case 1:out.push(month);break;case 2:out.push(month<10?("0"+month):month);break;case 3:out.push(Intl.month_abbreviated[month-1]);break;case 4:out.push(Intl.month_wide[month-1]);break;case 5:out.push(Intl.month_narrow[month-1]);break;}
op=0;}
break;case"d":op++;if(n!="d"){day=date.getDate().toString();switch(op){case 1:out.push(day);break;case 2:out.push(day.length==1?("0"+day):day);break;}
op=0;}
break;case"E":op++;if(n!="E"){day=date.getDay();switch(op){case 1:out.push(day+1);break;case 2:out.push("0"+(day+1));break;case 3:out.push(Intl.day_abbreviated[day]);break;case 4:out.push(Intl.day_wide[day]);break;case 5:out.push(Intl.day_narrow[day]);break;}
op=0;}
break;case"a":out.push(date.getHours()>11?Intl.day_period["pm"]:Intl.day_period["am"]);break;case"h":op++;if(n!="h"){hours=date.getHours();hours=(hours==0?12:(hours>12?(hours-12):hours));switch(op){case 1:out.push(hours);break;case 2:out.push(hours<10?("0"+hours):hours);break;}
op=0;}
break;case"H":op++;if(n!="H"){hours=date.getHours();switch(op){case 1:out.push(hours);break;case 2:out.push(hours<10?("0"+hours):hours);break;}
op=0;}
break;case"K":op++;if(n!="K"){hours=date.getHours();hours=hours>11?(hours-12):hours;switch(op){case 1:out.push(hours);break;case 2:out.push(hours<10?("0"+hours):hours);break;}
op=0;}
break;case"k":op++;if(n!="k"){hours=date.getHours();hours=hours==0?24:hours;switch(op){case 1:out.push(hours);break;case 2:out.push(hours<10?("0"+hours):hours);break;}
op=0;}
break;case"m":op++;if(n!="m"){minutes=date.getMinutes();switch(op){case 1:out.push(minutes);break;case 2:out.push(minutes<10?("0"+minutes):minutes);break;}
op=0;}
break;case"s":op++;if(n!="s"){seconds=date.getSeconds();switch(op){case 1:out.push(seconds);break;case 2:out.push(seconds<10?("0"+seconds):seconds);break;}
op=0;}
break;default:out.push(c);break;}}}}
return out.join("");}
if(typeof Intl=="undefined"){var Intl={"month_wide":["January","February","March","April","May","June","July","August","September","October","November","December"],"month_wide_normal":["January","February","March","April","May","June","July","August","September","October","November","December"],"month_abbreviated":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month_abbreviated_normal":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month_narrow":["J","F","M","A","M","J","J","A","S","O","N","D"],"day_wide":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"day_wide_normal":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"day_abbreviated":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day_abbreviated_normal":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day_narrow":["S","M","T","W","T","F","S"],"date_formats":{"full":"EEEE, MMMM d, yyyy","long":"MMMM d, yyyy","medium":"MMM d, yyyy","short":"M/d/yy"},"time_formats":{"full":"h:mm:ss a v","long":"h:mm:ss a z","medium":"h:mm:ss a","short":"h:mm a"},"date_time_formats":{"HHmm":"HH:mm","HHmmss":"HH:mm:ss","KKmm":"KK:mm a","KKmmss":"KK:mm:ss a","MMMM":"MMMM","MMMdd":"MMM dd","MMdd":"MM-dd","mmssSS":"mm:ss.SS","ww":"ww","yyMM":"MM/yy","yyMMMEEEd":"EEE, MMM d, yy","yyMMMEEEdd":"EEE dd/MMM yy","yyMMMd":"MMM d, yy","yyMMdd":"MM/dd/yy","yyMMdd_1":"yy-MM-dd","yyMMddKKmm":"MM/dd/yy KK:mm a","yyMd":"M/d/yy","yyQQQQ":"QQQQ yy","yyyyMMMMEEEEd":"EEEE,MMMM d, yyyy","yyyyMMMMEEEEdd":"EEEE,MMMM dd, yyyy","yyyyMMMMEEEd":"EEE, MMMM d, yyyy","yyyyMMMMd":"d. MMMM yyyy","yyyyMMMMd_1":"MMMM d, yyyy","yyyyMMMd":"MMM d, yyyy","yyyyMMMd_1":"d. MMM. yyyy","yyyyMMdd":"MM/dd/yyyy","yyyyMMdd_1":"yyyy-MM-dd","yyyyMMddHHmmss":"MM/dd/yyyy HH:mm:ss"},"date_never":"never","date_transforms":[],"preferred_formats":{"current_date":"EEEE, MMMM d, yyyy' | 'h:mma","list_date":"dd MMM","due":"EEE d MMM yy","due_field":"d MMM yy","due_time":"EEE d MMM yy' at 'h:mma","due_time_field":"d MMM yy' at 'h:mma","weekly_planner":"EEEE, MMMM d yyyy","MMM_d":"MMM d","hmm_a":"h:mma","note_date":"d MMM yyyy, h:mma","mobile_day":"EEEE, d MMM","mobile_short_day":"d MMM"},"locale":"en-US","day_period":{"am":"AM","pm":"PM"}};}
var inSelect=false;function floatDiv(id,iX,iY){var dD=document,dH=dD.html,dE=document.documentElement,dB=dD.body,px=dD.layers?"":"px";var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];var B=dD.getElementById?dD.getElementById("listbox"):dD.all?dD.all["listbox"]:dD.layers["listbox"];if(!L){return null;}
this[id+"O"]=L;if(document.layers){L.style=L;}
L.B=B;L.nX=L.iX=iX;L.nY=L.iY=iY;L.stopNext=false;L.P=function(x,y){if(x==0&&y<0.01){return false;}
this.style.left=x+px;this.style.top=y+px;};L.moveDiv=function(){var pX,pY;pX=(this.iX>=0)?0:dB.clientWidth;pY=dE&&dE.scrollTop?dE.scrollTop:dB.scrollTop;if(this.iY<0){pY+=dB.clientHeight;}
var posX=this.offsetLeft+this.clientWidth;var posY=this.clientHeight;var boxY=this.B.clientHeight;var diff=(this.offsetTop-this.B.offsetTop);if(!(is_gecko&&inSelect==true)){var movingUp=(0.1*(pY+this.iY-this.nY))<0;if(!((posY+diff+98)>boxY)||movingUp){this.nX+=0.1*(pX+this.iX-this.nX);this.nY+=0.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);Autocomplete.handleWindowResize();}}
setTimeout(this.id+"O.moveDiv()",50);};return L;}
function MessageBus(){this.channels={};this.channelsOnce={};}
MessageBus.prototype.doSubscribe=function(channels,whom,channel){if(!channels[channel]){channels[channel]=[];}
channels[channel].push(whom);};MessageBus.prototype.subscribe=function(whom,channel){this.doSubscribe(this.channels,whom,channel);};MessageBus.prototype.subscribeOnce=function(whom,channel){this.doSubscribe(this.channelsOnce,whom,channel);};MessageBus.prototype.broadcast=function(whom,channel,what){var chan=this.channels[channel];var chanOnce=this.channelsOnce[channel];if(!chan&&!chanOnce){return false;}
if(chan){for(var i=0;i<chan.length;i++){chan[i](whom,what);}}
if(chanOnce){for(var i=0;i<chanOnce.length;i++){chanOnce[i](whom,what);}
chanOnce.length=0;}
return true;};function Configuration(){this.inited=false;this.dateStyle=0;this.mbn=null;this.configuration={};this.pendingDelta={};this.pendingReminderDelta={};this.overrideGeneralSave=false;}
Configuration.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();this.inited=true;};Configuration.prototype.setData=function(configuration){this.configuration=configuration;this.updateGeneralSettings();this.updateReminderSettings();this.setupGeneral();this.setupReminder();};Configuration.prototype.setup=function(){this.addField("language","language");this.addField("country","country");this.addField("timezone","timezone");this.addField("dateformat_eu","dateformat_eu");this.addField("dateformat_am","dateformat_am");this.addField("timeformat_12","timeformat_12");this.addField("timeformat_24","timeformat_24");this.addField("taskcloud","taskcloud");this.addField("taskdueoncheck","taskdueoncheck");this.addField("taskduespeccheck","taskduespeccheck");this.addField("taskduespec","taskduespec");this.addField("taskduestart","taskduestart");this.addField("timedueoncheck","timedueoncheck");this.addField("timeduespeccheck","timeduespeccheck");this.addField("timeduespec","timeduespec");this.addField("generalFirstname","firstname");this.addField("generalLastname","lastname");this.addField("generalEmail","email");this.addField("settingsSave","settingssubmit");this.addField("settingsCancel","settingscancel");this.addField("reminderSave","reminder_save");this.addField("reminderCancel","reminder_cancel");var self=this;this.settingsSave.onclick=function(){self.configurationDelta();return false;};this.settingsCancel.onclick=function(){self.settingsSave.disabled=true;self.settingsCancel.disabled=true;self.updateGeneralSettings();return false;};this.reminderSave.onclick=function(){self.reminderDelta();return false;};this.reminderCancel.onclick=function(){self.reminderSave.disabled=true;self.reminderCancel.disabled=true;self.updateReminderSettings();return false;};this.taskduespec.onfocus=function(){helpBox.showHelpText("reminders.datedue");};this.taskduespec.onblur=function(){var hideFunc=function(){helpBox.stopShowing("reminders.datedue");if(view.getViewToken("Settings","Reminders")){helpBox.showHelpText("settings.reminders");}};setTimeout(hideFunc,1000);};this.taskduestart.onfocus=function(){helpBox.showHelpText("reminders.start");};this.taskduestart.onblur=function(){var hideFunc=function(){helpBox.stopShowing("reminders.start");if(view.getViewToken("Settings","Reminders")){helpBox.showHelpText("settings.reminders");}};setTimeout(hideFunc,1000);};this.timeduespec.onfocus=function(){helpBox.showHelpText("reminders.timedue");};this.timeduespec.onblur=function(){var hideFunc=function(){helpBox.stopShowing("reminders.timedue");if(view.getViewToken("Settings","Reminders")){helpBox.showHelpText("settings.reminders");}};setTimeout(hideFunc,1000);};};Configuration.prototype.addField=function(localName,name){var self=this;eval("self."+localName+" = el('"+name+"');");};Configuration.prototype.getUniqueMessageBusName=function(){return"rtm.configuration.";};Configuration.prototype.confCountryDelta=function(){return this.country.options[this.country.selectedIndex].text.trim();};Configuration.prototype.confTimeZoneDelta=function(){var s=this.timezone.options[this.timezone.selectedIndex].value.split("_");return s[1];};Configuration.prototype.confLanguageDelta=function(){return this.language.options[this.language.selectedIndex].value.trim();};Configuration.prototype._stripEmailSecret=function(s){var filter=/^([a-zA-Z0-9_\.])+$/;if(s==null){return"";}
s=s.trim();var idx=s.indexOf("+");if(idx>-1){s=s.substring(idx+1,s.length);}
if(s.length==0){return s;}
var r=filter.exec(s);if(!r){return null;}
return r[0];};Configuration.prototype.vetEmailSecret=function(c){if((c==8||c==13||c==37||c==39)||(c>=48&&c<=57)||(c>=65&&c<=90)||(c>=97&&c<=122)){return true;}else{return false;}};Configuration.prototype.confEmailSecretDelta=function(){var s=this._stripEmailSecret(this.emailSecret.value);if(s==null){this.setError(el("emailSecretStatus"),"Letters and numbers only, please.");this.overrideGeneralSave=true;}else{if(s.length<4){this.setError(el("emailSecretStatus"),"Minimum 4 characters.");this.overrideGeneralSave=true;}else{if(s.length>30){this.setError(el("emailSecretStatus"),"Max. 30 characters.");this.overrideGeneralSave=true;}else{this.setSuccess(el("emailSecretStatus"),null);this.overrideGeneralSave=false;}}}
return s;};Configuration.prototype.confDateFormatDelta=function(){if(this.dateformat_eu.checked==true){return 0;}else{return 1;}};Configuration.prototype.confTimeFormatDelta=function(){if(this.timeformat_12.checked==true){return 0;}else{return 1;}};Configuration.prototype.confTaskCloudDelta=function(){if(this.taskcloud.checked==true){return true;}
return false;};Configuration.prototype.reminderRemindOnDelta=function(){if(this.taskdueoncheck.checked==true){return"t";}
return"f";};Configuration.formatInterval=function(s){s=s.replace(/_RTM_:/,"");s=s.replace(/year=1/,"1 year");s=s.replace(/year=(\d+)/,"$1 years");s=s.replace(/month=1/,"1 mon");s=s.replace(/month=(\d+)/,"$1 mons");s=s.replace(/date=1/,"1 day");s=s.replace(/date=(\d+)/,"$1 days");s=s.replace(/1 YEAR/,"1 year");s=s.replace(/(\d+) YEAR(?:S)?/,"$1 years");s=s.replace(/1 MONTH/,"1 mon");s=s.replace(/(\d+) MONTH(?:S)?/,"$1 mons");s=s.replace(/1 DAY/,"1 day");s=s.replace(/(\d+) DAY(?:S)?/,"$1 days");s=s.replace(/\s*\,\s*/," ");return s;};Configuration.prototype.reminderRemindIntervalDelta=function(){if(this.taskduespeccheck.checked==true){var c=dateTimeMgr.parseDueDate(this.taskduespec.value.trim());if(c[0]!==null){return Configuration.formatInterval(c[5]);}else{return null;}}else{return null;}};Configuration.prototype.reminderRemindDayStartDelta=function(){var t=dateTimeMgr.parseTime(this.taskduestart.value.trim());return dateTimeMgr.formatTime(t,true);};Configuration.prototype.reminderRemindTimeOnDelta=function(){if(this.timedueoncheck.checked==true){return"t";}
return"f";};Configuration.prototype.reminderRemindTimeIntervalDelta=function(){if(this.timeduespeccheck.checked==true){var c=dateTimeMgr.parseDueDate(this.timeduespec.value.trim());if(c[0]!==null){return dateTimeMgr.convertTimeSpec(Configuration.formatInterval(c[5]));}else{return null;}}else{return null;}};Configuration.prototype.reminderDelta=function(dontSend){var self=this;var mappings={"remindOn":function(){return self.reminderRemindOnDelta();},"remindInterval":function(){return self.reminderRemindIntervalDelta();},"remindTimeOn":function(){return self.reminderRemindTimeOnDelta();},"remindTimeInterval":function(){return self.reminderRemindTimeIntervalDelta();},"remindDayStart":function(){return self.reminderRemindDayStartDelta();}};var delta={};var modified=false;for(key in mappings){var comp=mappings[key];if(typeof comp=="function"){comp=comp();}
if(comp!=this.configuration[key]){delta[key]=comp;modified=true;}}
if(modified){if(!dontSend){transMgr.request("notifies.configuration.update",utility.encodeJavaScript(delta));for(var key in delta){this.pendingReminderDelta[key]=delta[key];}}else{this.reminderSave.disabled=false;this.reminderCancel.disabled=false;}}else{if(dontSend){this.reminderSave.disabled=true;this.reminderCancel.disabled=true;}}
return modified;};Configuration.prototype.configurationDelta=function(dontSend){var self=this;var mappings={"firstname":this.generalFirstname.value.trim(),"lastname":this.generalLastname.value.trim(),"email":this.generalEmail.value.trim(),"dateFormat":function(){return self.confDateFormatDelta();},"time24":function(){return self.confTimeFormatDelta();},"timeZone":function(){return self.confTimeZoneDelta();},"country":function(){return self.confCountryDelta();},"language":function(){return self.confLanguageDelta();},"taskcloud":function(){return self.confTaskCloudDelta();}};var delta={};var modified=false;this.configuration["language"]=rtmLanguage;for(key in mappings){var comp=mappings[key];if(typeof comp=="function"){comp=comp();}
if(comp!=this.configuration[key]){delta[key]=comp;modified=true;}}
if(modified){if(!dontSend){transMgr.request("configuration.update",utility.encodeJavaScript(delta));for(var key in delta){this.pendingDelta[key]=delta[key];}}else{if(this.overrideGeneralSave==false){this.settingsSave.disabled=false;}else{this.settingsSave.disabled=true;}
this.settingsCancel.disabled=false;}}else{if(dontSend){this.settingsSave.disabled=true;this.settingsCancel.disabled=true;}}
return modified;};Configuration.prototype.updateReminderSettings=function(){if(this.configuration["remindOn"]=="t"){this.taskdueoncheck.checked=true;}else{this.taskdueoncheck.checked=false;}
if(this.configuration["remindTimeOn"]=="t"){this.timedueoncheck.checked=true;}else{this.timedueoncheck.checked=false;}
if(this.configuration["remindInterval"]==null){this.taskduespeccheck.checked=false;this.taskduespec.disabled=true;this.taskduespec.value="";}else{this.taskduespeccheck.checked=true;this.taskduespec.disabled=false;this.taskduespec.value=dateTimeMgr.TransformDate(this.configuration["remindInterval"]);}
if(this.configuration["remindTimeInterval"]==null){this.timeduespeccheck.checked=false;this.timeduespec.disabled=true;this.timeduespec.value="";}else{this.timeduespec.disabled=false;this.timeduespeccheck.checked=true;this.timeduespec.value=dateTimeMgr.TransformDate(this.configuration["remindTimeInterval"]);}
if(this.configuration["remindDayStart"]==null){this.taskduestart.value="12am";}else{var t=dateTimeMgr.parseTime(this.configuration["remindDayStart"]);this.taskduestart.value=dateTimeMgr.formatTime(t);}
this.toggleStartDay();};Configuration.prototype.updateShowOverview=function(){if(this.configuration["showOverview"]){overviewView.continueTasksAlways.innerHTML=_T("INTERFACE_ALWAYS_SKIP_THIS_PAGE");overviewView.continueTasksAlways.title=_T("INTERFACE_ALWAYS_SKIP_THIS_PAGE");overviewView.continueTasksAlways.onclick=function(){messageBus.broadcast(configurationMgr,configurationMgr.mbn+"continueToTasks",[true,false]);return false;};}else{overviewView.continueTasksAlways.innerHTML=_T("INTERFACE_DONT_SKIP_THIS_PAGE");overviewView.continueTasksAlways.title=_T("INTERFACE_DONT_SKIP_THIS_PAGE");overviewView.continueTasksAlways.onclick=function(){messageBus.broadcast(configurationMgr,configurationMgr.mbn+"continueToTasks",[true,true]);return false;};}};Configuration.prototype.updateGeneralSettings=function(){this.updateShowOverview();this.generalFirstname.value=this.configuration["firstname"];this.generalLastname.value=this.configuration["lastname"];this.generalEmail.value=this.configuration["email"];this.taskcloud.checked=this.configuration["taskcloud"];if(this.taskcloud.checked&&view.getViewToken("Tasks")){if(taskCloud){taskCloud.showCopy();}}else{if(taskCloud){taskCloud.hideCopy();}}
for(var i=0;i<this.country.options.length;i++){if(this.country.options[i].text.trim()==this.configuration["country"]){this.country.selectedIndex=i;break;}}
for(var i=0;i<this.timezone.options.length;i++){var s=this.timezone.options[i].value.split("_");if(s[1]==this.configuration["timeZone"]){this.timezone.selectedIndex=i;break;}}
for(var i=0;i<this.language.options.length;i++){if(this.language.options[i].value.trim()==rtmLanguage){this.language.selectedIndex=i;break;}}
if(this.configuration["dateFormat"]==0){this.dateformat_eu.checked=true;}else{this.dateformat_am.checked=true;}
if(this.configuration["time24"]==0){this.timeformat_12.checked=true;}else{this.timeformat_24.checked=true;}
this.dateStyle=parseInt(this.configuration["dateFormat"],10);};Configuration.prototype.enableTaskDue=function(){this.taskduespec.disabled=!this.taskduespeccheck.checked;this.reminderDelta(true);this.toggleStartDay();};Configuration.prototype.enableTimeDue=function(){this.timeduespec.disabled=!this.timeduespeccheck.checked;this.reminderDelta(true);};Configuration.prototype.checkTimeSpec=function(){this.reminderDelta(true);};Configuration.prototype.checkTaskSpec=function(){this.reminderDelta(true);};Configuration.prototype.checkTaskStart=function(){this.reminderDelta(true);};Configuration.prototype.checkTaskOnCheck=function(){this.reminderDelta(true);this.toggleStartDay();};Configuration.prototype.toggleStartDay=function(){if(this.taskdueoncheck.checked||this.taskduespeccheck.checked){if(el("taskduestartwrap").style.display=="none"){el("taskduestartwrap").style.display="";}}else{if(!this.taskdueoncheck.checked&&!this.taskduespeccheck.checked){el("taskduestartwrap").style.display="none";}}};Configuration.prototype.checkTimeOnCheck=function(){this.reminderDelta(true);};Configuration.prototype.setupReminder=function(){var self=this;this.taskduespeccheck.onclick=function(){self.enableTaskDue();};this.timeduespeccheck.onclick=function(){self.enableTimeDue();};this.timeduespec.onkeyup=function(){self.checkTimeSpec();};this.taskduespec.onkeyup=function(){self.checkTaskSpec();};this.taskduestart.onkeyup=function(){self.checkTaskStart();};this.timeduespec.onkeypress=function(){self.checkTimeSpec();};this.taskduespec.onkeypress=function(){self.checkTaskSpec();};this.taskduestart.onkeypress=function(){self.checkTaskStart();};this.taskdueoncheck.onclick=function(){self.checkTaskOnCheck();};this.timedueoncheck.onclick=function(){self.checkTimeOnCheck();};this.enableTaskDue();this.enableTimeDue();};Configuration.prototype.setupGeneral=function(){var self=this;this.generalFirstname.onkeyup=function(){self.configurationDelta(true);};this.generalLastname.onkeyup=function(){self.configurationDelta(true);};this.generalEmail.onkeyup=function(){self.configurationDelta(true);};this.generalFirstname.onkeypress=function(){self.configurationDelta(true);};this.generalLastname.onkeypress=function(){self.configurationDelta(true);};this.generalEmail.onkeypress=function(){self.configurationDelta(true);};this.timezone.onchange=function(){self.configurationDelta(true);};this.country.onchange=function(){self.configurationDelta(true);};this.language.onchange=function(){self.configurationDelta(true);};this.dateformat_eu.onclick=function(){self.configurationDelta(true);};this.dateformat_am.onclick=function(){self.configurationDelta(true);};this.timeformat_12.onclick=function(){self.configurationDelta(true);};this.timeformat_24.onclick=function(){self.configurationDelta(true);};this.taskcloud.onclick=function(){self.configurationDelta(true);};this.settingsSave.disabled=true;this.settingsCancel.disabled=true;};Configuration.prototype.mergePendingReminderDelta=function(){for(var key in this.pendingReminderDelta){this.configuration[key]=this.pendingReminderDelta[key];}
this.pendingReminderDelta={};this.reminderSave.disabled=true;this.reminderCancel.disabled=true;this.updateReminderSettings();};Configuration.prototype.mergePendingDelta=function(){for(var key in this.pendingDelta){this.configuration[key]=this.pendingDelta[key];if(key=="language"){rtmLanguage=this.pendingDelta[key];}}
this.pendingDelta={};this.settingsSave.disabled=true;this.settingsCancel.disabled=true;this.updateGeneralSettings();this.updatePersonName();dateTimeMgr.updateDateTime(dateTimeMgr,new Date());this.overrideGeneralSave=false;};Configuration.prototype.updatePersonName=function(){var personName=el("personName");var firstName=this.generalFirstname.value;var lastName=this.generalLastname.value;personName.innerHTML=unescape(firstName+" "+lastName).escapeForDisplay();if(firstName.charAt(firstName.length-1)=="s"){firstName+="'";}else{firstName+="'s";}
document.title=fmt("Remember The Milk - %1 Tasks",firstName);};Configuration.prototype.updateEmailIn=function(){var emailAddress=el("infoEmailAddress");var emailSecret=this.emailSecret.value;var mboxAddress=rtmUsername+"+"+emailSecret+"@"+rtmMailHost;emailAddress.innerHTML=unescape(mboxAddress).escapeForDisplay();emailAddress.href="mailto:"+mboxAddress;};Configuration.prototype.setDefaultList=function(newList){this.configuration.defaultList=newList;};Configuration.prototype.setDefaultLocation=function(newLocation){this.configuration.defaultLocation=newLocation;};Configuration.prototype.setSuccess=function(o,m){o.innerHTML="<span class=\"success_msg\">"+(m==null?"&nbsp;":m)+"</span>";o.className="success";};Configuration.prototype.setError=function(o,m){o.innerHTML="<span class=\"error_msg\">"+(m==null?"&nbsp;":m)+"</span>";o.className="error";};Configuration.prototype.setClear=function(o){o.innerHTML="";o.className="";};function DateTimeManager(){this.timeEstimateCache={};this.timeEstimateFormatCache={};this.timeSpecCache={};this.serverDate=null;this.serverOffset=0;this.chimeTimeout=null;this.monthLength=new Array(31,28,31,30,31,30,31,31,30,31,30,31);this.numbers={"zero":0,"one":1,"two":2,"three":3,"four":4,"five":5,"six":6,"seven":7,"eight":8,"nine":9};this.cache={};this.rangeCache={};this.useCache=false;this.formatCache={};this.timezoneOffset=null;}
DateTimeManager.prototype.getCachedIntlFormat=function(format,time){if(!is(this.formatCache[format])){this.formatCache[format]={};}
if(this.formatCache[format][time]){return this.formatCache[format][time];}
return(this.formatCache[format][time]=DateFormat(format,new Date(time*1000)));};DateTimeManager.formatCache={};DateTimeManager.getCachedIntlFormatForDate=function(format,time){if(!is(this.formatCache[format])){this.formatCache[format]={};}
if(this.formatCache[format][time]){return this.formatCache[format][time];}
return(this.formatCache[format][time]=DateFormat(format,time));};DateTimeManager.prototype.setCache=function(b){this.useCache=!!b;this.cache={};this.rangeCache={};};DateTimeManager.prototype.setTimezoneOffset=function(tz){this.timezoneOffset=tz;};DateTimeManager.prototype.getDay=function(d){var days=Date.Days;var shortDays={};for(var i=0;i<days.length;i++){shortDays[days[i].substring(0,3).toLowerCase()]=i;}
d=d.length>3?d.substring(0,3).toLowerCase():d.toLowerCase();return shortDays[d];};DateTimeManager.prototype.calculateDate=function(target,now,next){var howMany=0;if(now>=target){target=target+7;}
if(next){howMany=7+(target-now);}else{howMany=target-now;}
return howMany;};DateTimeManager.prototype.checkDate=function(d,daysToAdd){var newDate=d;var year=parseInt(newDate.getFullYear(),10);var month=parseInt(newDate.getMonth(),10);if(daysToAdd){var day=parseInt(newDate.getDate(),10);day+=daysToAdd;}else{var day=parseInt(newDate.getDate(),10);}
if(!is(day)||!is(month)||!is(year)){return false;}
var monthLength,excess;do{if(month==12){year=parseInt(year,10)+1;month=0;}
monthLength=Date.days_in_month(year,month+1);if(!(day>monthLength)){break;}
excess=parseInt(day,10)-monthLength;month=parseInt(month,10)+1;day=excess;}while(day>monthLength);var dateToCheck=new Date(newDate);dateToCheck.setYear(year);dateToCheck.setMonth(month);dateToCheck.setDate(day);dateToCheck.setHours(newDate.getHours());dateToCheck.setMinutes(newDate.getMinutes());dateToCheck.setSeconds(newDate.getSeconds());return dateToCheck;};DateTimeManager.prototype.calculateUnit=function(newDatex,num,type,past){var daysToAdd=0;var monthsToAdd=0;var yearsToAdd=0;var newYear=newDatex.getFullYear();var newMonth=newDatex.getMonth();var newDate=newDatex.getDate();var t=type.toLowerCase().charAt(0);var numx=parseInt(num,10);if(isNaN(numx)){numx=this.numbers[num.toLowerCase()];}
switch(t){case"d":daysToAdd=numx;break;case"w":daysToAdd=numx*7;break;case"m":monthsToAdd=numx;break;case"y":yearsToAdd=numx;break;}
if(!past){newYear+=yearsToAdd;newMonth+=monthsToAdd;newDate+=daysToAdd;}else{newYear-=yearsToAdd;newMonth-=monthsToAdd;newDate-=daysToAdd;}
newDatex.setYear(newYear);newDatex.setMonth(newMonth);var checkedDate;if(typeof is_safari!=="undefined"&&is_safari){checkedDate=this.checkDate(newDatex,daysToAdd);}else{newDatex.setDate(newDate);checkedDate=this.checkDate(newDatex);}
return checkedDate;};DateTimeManager.prototype.getMonth=function(m){var months=Date.Months;var shortMonths={};for(var i=0;i<months.length;i++){shortMonths[months[i].substring(0,3).toLowerCase()]=i+1;}
m=m.length>3?m.substring(0,3).toLowerCase():m.toLowerCase();return shortMonths[m];};DateTimeManager.prototype.getYear=function(y){return y.length==1?parseInt("200"+y,10):(y.length==2?parseInt("20"+y,10):y);};DateTimeManager.prototype.updateDateTime=function(self,newTime){var dateTime=el("datetime");if(dateTime&&newTime){dateTime.innerHTML=DateFormat(Intl.preferred_formats.current_date);var hours=newTime.getHours();var mins=newTime.getMinutes();if(hours===0&&mins===0){DateTimeManager.PRE_TODAY=this.parseDueDate("today");DateTimeManager.PRE_TOMORROW=this.parseDueDate("tomorrow");}}};DateTimeManager.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();var self=this;var updateFunc=function(x,y){self.updateDateTime(x,y);};messageBus.subscribe(updateFunc,this.mbn+"chime");this.startChime();};DateTimeManager.PRE_TODAY=null;DateTimeManager.PRE_TOMORROW=null;DateTimeManager.prototype.getUniqueMessageBusName=function(){return"rtm.datetimemanager.";};DateTimeManager.prototype.startChime=function(){DateTimeManager.PRE_TODAY=this.parseDueDate("today");DateTimeManager.PRE_TOMORROW=this.parseDueDate("tomorrow");this.chime();};DateTimeManager.prototype.chime=function(){var self=this;var chimeFunc=function(){self.chime();};this.chimeTimeout=setTimeout(chimeFunc,1000*60);messageBus.broadcast(this,this.mbn+"chime",new Date());};DateTimeManager.prototype.stopChime=function(){clearTimeout(this.chimeTimeout);this.chimeTimeout=null;};DateTimeManager.prototype.setServerDate=function(date){this.serverDate=new Date(date*1000);var now=new Date();this.serverOffset=now.getTime()-this.serverDate.getTime();};DateTimeManager.prototype.setTimezone=function(dontSend){var myDate=new Date();setCookie("TZ",myDate.getTimezoneOffset(),null,"/",null,null);if(!dontSend){transMgr.request("auth.setTimezone",utility.encodeJavaScript({"tz":myDate.getTimezoneOffset()}));}};DateTimeManager.prototype.parseTimeEstimate=function(estimate){var days,hours,minutes;var valid=false;if(this.timeEstimateCache[estimate]){return this.timeEstimateCache[estimate];}
days=hours=minutes=0;var m=/([0-9.]+)\s*(days|day|d)/i.exec(estimate);if(m!=null){if(typeof m[0]!="undefined"){days+=parseInt(m[1],10);valid=true;}}
var m=/([0-9.]+)\s*(hours|hour|hrs|hr|h)/i.exec(estimate);if(m!=null){if(typeof m[0]!="undefined"){idx=m[1].indexOf(".");if(idx>-1){if(idx>0){hours=parseInt(m[1].substring(0,idx),10);}else{hours=0;}
minutes=parseFloat("0"+m[1].substring(idx,m[1].length))*60;}else{hours=parseInt(m[1],10);}
valid=true;}}
var m=/([0-9.]+)\s*(minutes|minute|mins|min|m)/i.exec(estimate);if(m!=null){if(typeof m[0]!="undefined"){minutes+=parseInt(m[1],10);valid=true;}}
if(valid===false){return null;}
minutes=(days*24*60)+(hours*60)+minutes;this.timeEstimateCache[estimate]=minutes;return minutes;};DateTimeManager.prototype.formatTimeEstimate=function(input){if(this.timeEstimateFormatCache[input]){return this.timeEstimateFormatCache[input];}
var days,hours,minutes;days=hours=minutes=0;minutes=input;days=Math.floor(minutes/(24*60));minutes=Math.floor(minutes%(24*60));hours=Math.floor(minutes/60);minutes=Math.floor(minutes%60);var est=[];if(days===1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_DAY"));}else{if(days>1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_DAYS",{"NUM":days}));}}
if(hours===1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_HOUR"));}else{if(hours>1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_HOURS",{"NUM":hours}));}}
if(minutes===1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_MINUTE"));}else{if(minutes>1){est.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_MINUTES",{"NUM":minutes}));}}
est=est.join(", ");this.timeEstimateFormatCache[input]=est;return est;};DateTimeManager.prototype.parseTimeSpec=function(spec){var valid=false;var hours,minutes,seconds;if(this.timeSpecCache[spec]){return this.timeSpecCache[spec];}
hours=minutes=seconds=0;var m=/([0-9]+)\:([0-9]+)\:([0-9]+)/i.exec(spec);if(m!=null){if(typeof m[0]!="undefined"){hours=parseInt(m[1],10);minutes=parseInt(m[2],10);seconds=parseInt(m[3],10);valid=true;}}else{var m=/([0-9.]+)\s*(hours|hour|hrs|hr|h)/i.exec(spec);if(m!=null){if(typeof m[0]!="undefined"){idx=m[1].indexOf(".");if(idx>-1){hours=parseInt(m[1].substring(0,idx),10);minutes=parseFloat("0"+m[1].substring(idx,m[1].length))*60;}else{hours=parseInt(m[1],10);}
valid=true;}}
var m=/([0-9.]+)\s*(minutes|minute|mins|min|m)/i.exec(spec);if(m!=null){if(typeof m[0]!="undefined"){minutes+=parseInt(m[1],10);valid=true;}}
var m=/([0-9.]+)\s*(seconds|second|secs|sec|s)/i.exec(spec);if(m!=null){if(typeof m[0]!="undefined"){seconds+=parseInt(m[1],10);valid=true;}}}
seconds=(hours*60*60)+(minutes*60)+seconds;if(valid){this.timeSpecCache[spec]=seconds;return seconds;}else{return null;}};DateTimeManager.prototype.splitTimeSpec=function(input){var hours,minutes,seconds;hours=minutes=seconds=0;seconds=input;hours=Math.floor(seconds/(60*60));minutes=Math.floor(seconds%(60*60));seconds=Math.floor(minutes%60);minutes=Math.floor(minutes/60);return[hours,minutes,seconds];};DateTimeManager.prototype.formatTimeSpec=function(input){var s=this.splitTimeSpec(input);var hours=s[0];var minutes=s[1];var seconds=s[2];var est="";if(hours>0){est+=utility.pluralize(hours,"hour");}
if(minutes>0){if(hours>0){est+=", "+utility.pluralize(minutes,"minute");}else{est+=utility.pluralize(minutes,"minute");}}
if(seconds>0){if(hours>0||minutes>0){est+=" and "+utility.pluralize(seconds,"second");}else{est+=utility.pluralize(seconds,"second");}}
return est;};DateTimeManager.prototype.convertTimeSpec=function(s){var hms=this.parseTimeSpec(s);if(hms==null){return null;}
hms=this.splitTimeSpec(hms);for(var i=0;i<hms.length;i++){hms[i]=padded(hms[i]);}
return hms.join(":");};DateTimeManager.prototype.normalizeAMPM=function(hour,spec){if(spec){var tx=spec.toLowerCase().charAt(0);hour=parseInt(hour,10);if(hour!=12&&(tx=="p"||tx=="\u4e0b"||spec=="\u5348\u5f8c"||spec=="\uc624\ud6c4")){hour=hour+12;}
hour=parseInt(hour,10);if(hour==12){if(tx=="a"||tx=="\u4e0a"||spec=="\u5348\u524d"||spec=="\uc624\uc804"){hour=0;}else{hour=12;}}}else{hour=parseInt(hour,10);}
return hour;};DateTimeManager.prototype.formatTime=function(t,raw){if(t[0]==null){if(raw){return"00:00";}
return"12am";}
if(raw){return padded(t[0])+":"+padded(t[1])+":00";}
var tx="am";if(t[0]>11){tx="pm";}
var h=t[0]||12;if(h>12){h=h-12;}
var m=t[1]!=0?":"+padded(t[1]):"";return h+m+tx;};DateTimeManager.prototype.parseTime=function(s){if(s.trim().length==0||s.trim().indexOf("never")>-1){return[null,null];}
s=s.replace(/midnight/i,"tomorrow 12am");s=s.replace(/midday/i,"today 12pm");s=s.replace(/noon/i,"12pm");var four=/(@|at)?\s*([0-9]+)(?::|\.)([0-9]+)\s*(am|pm)?/i;var five=/(@|at)?\s*([0-9]{3,4})\s*(am|pm)?/i;var six=/(@|at)?\s*([0-9]{1,2})\s*(am|pm)?/i;var a=four.exec(s);var b=five.exec(s);var c=six.exec(s);if(!a&&!b&&!c){return[null,null];}
var hour=null,minute=null;if(a){if(a[2]){hour=a[2];if(a[3]){minute=parseInt(a[3],10);}else{minute=0;}
hour=this.normalizeAMPM(hour,a[4]);}}
if(!a&&b){if(b[2]){if(b[2].length==3){hour=parseInt(b[2].substring(0,1),10);minute=parseInt(b[2].substring(1,3),10);}else{hour=parseInt(b[2].substring(0,2),10);minute=parseInt(b[2].substring(2,4),10);}
hour=this.normalizeAMPM(hour,b[3]);}}
if(!a&&!b&&c){if(c[2]){hour=parseInt(c[2],10);minute=0;hour=this.normalizeAMPM(hour,c[3]);}}
return[hour,minute];};DateTimeManager.prototype.parseDueRange=function(s,past){var raw=s;s=s.trim();if(this.useCache&&this.rangeCache[raw]){return this.rangeCache[raw];}
if(s.length==0){return this.useCache?(this.rangeCache[raw]=null):null;}
var split=s.split(/\bof\b/i);var range,due;if(split.length==1){range=split[0];due="today";}else{if(split.length==2){range=split[0];due=split[1];}else{range=split.shift();due=split.join("of");}}
range=range.trim();due=due.trim();var startDate=this.parseDueDate(due);if(startDate[0]===null){return this.useCache?(this.rangeCache[raw]=null):null;}
startDate=startDate[0];range=range.replace(/a /,"1").split(/\s+/);if(range.length==1){return this.useCache?(this.rangeCache[raw]=null):null;}
var numRange=range.shift();var typeRange=range.shift();var endDate=this.calculateUnit(new Date(startDate),numRange,typeRange,!!past);if(!startDate||!endDate){return this.useCache?(this.rangeCache[raw]=null):null;}
if(!!past===true){var tmp=startDate;startDate=endDate;endDate=tmp;startDate.setDate(startDate.getDate()+1);endDate.setDate(endDate.getDate()+1);}
return this.useCache?(this.rangeCache[raw]=new DateRange(startDate,endDate)):new DateRange(startDate,endDate);};DateTimeManager.reNow=/now/i;DateTimeManager.tom=/(tod|tom|ton|tmr)/i;if(typeof is_safari=="undefined"||!is_safari){DateTimeManager.zero=/([0-9]{1,4})(?:\-|\/|\.|\u5e74|\u6708|\u65e5)([0-9]{1,2})(?:\-|\/|\.|\u5e74|\u6708|\u65e5)*([0-9]{1,4})*/i;}else{DateTimeManager.zero=new RegExp("([0-9]{1,4})(?:\\-|\\/|\\.|\u5e74|\u6708|\u65e5)([0-9]{1,2})(?:\\-|\\/|\\.|\u5e74|\u6708|\u65e5)*([0-9]{1,4})*","i");}
DateTimeManager.one=/(on)?\s*(([0-9]*)(?:st|th|rd|nd)*(?:\s|of|\-|,|\.)*(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december|dec)(?:\s|\-)*([0-9]*))/i;DateTimeManager.upcomingFormat=/(on)?\s*((january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december|dec)(?:\s|,|\.|\-)*([0-9]+)(?:st|th|rd|nd)*(?:\s|,|\.|\-)*([0-9]*))/i;DateTimeManager.two=/(on)?\s*((next)?\s*(monday|mon|tuesday|tue|wednesday|wed|thursday|thu|friday|fri|saturday|sat|sunday|sun))/i;DateTimeManager.three=/(in)?\s*(one|two|three|four|five|six|seven|eight|nine|ten|[0-9]+)\s*(years|year|yrs|yr|months|month|mons|mon|weeks|week|wks|wk|days|day)/i;DateTimeManager.endofFormat=/end\s*of\s*(?:the)*\s*(w|m)/i;DateTimeManager.dateBased=/(on)?\s*([0-9]+)(?:st|th|rd|nd)/i;if(typeof is_safari=="undefined"||!is_safari){DateTimeManager.four=/(@|at|,)?\s*([0-9]+)(?::|\.|\u0020\u0068\u0020|\u6642)([0-9]+)(?:\u5206)?\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?/i;DateTimeManager.five=/(@|at)?\s*([0-9]{3,4})\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?/i;DateTimeManager.six=/(@|at)?\s*([0-9]{1,2})\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?/i;}else{DateTimeManager.four=new RegExp("(@|at|,)?\\s*([0-9]+)(?::|.| h |\u6642)([0-9]+)(?:\u5206)?\\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?","i");DateTimeManager.five=new RegExp("(@|at)?\\s*([0-9]{3,4})\\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?","i");DateTimeManager.six=new RegExp("(@|at)?\\s*([0-9]{1,2})\\s*(a|p|\u4e0a|\u4e0b|\u5348\u524d|\u5348\u5f8c|\uc624\uc804|\uc624\ud6c4)?","i");}
DateTimeManager.rtmformat=new RegExp("_RTM_:(year=(\\d+))?(?:,)?(month=(\\d+))?(?:,)?(date=(\\d+))?");DateTimeManager._r_a=/ a /i;DateTimeManager._r_midnight=/midnight/i;DateTimeManager._r_midday=/midday/i;DateTimeManager._r_noon=/noon/i;DateTimeManager.prototype.parseDueDate=function(s){var raw=s;if(this.useCache&&this.cache[raw]){return this.cache[raw];}
if(s.trim().length==0||s.trim().indexOf("never")>-1){return this.useCache?(this.cache[raw]=[null,null]):[null,null];}
var now=new Date();s=s.replace(DateTimeManager._r_a," one ");s=s.replace(DateTimeManager._r_midnight,"tomorrow 12am");s=s.replace(DateTimeManager._r_midday,"12pm");s=s.replace(DateTimeManager._r_noon,"12pm");var d=null,t=null;var d,r,t,u,v,x,y,z,o,p,q;d=r=t=u=v=x=y=z=o=p=q=null;r=DateTimeManager.rtmformat.exec(s);if(!(r&&r[0])){p=DateTimeManager.upcomingFormat.exec(s);z=DateTimeManager.three.exec(s);q=DateTimeManager.endofFormat.exec(s);if(!p){v=DateTimeManager.zero.exec(s);}
x=DateTimeManager.one.exec(s);if(!x){if(!p&&!z&&!q&&!v){y=DateTimeManager.two.exec(s);}
o=DateTimeManager.dateBased.exec(s);}
t=DateTimeManager.reNow.exec(s);u=DateTimeManager.tom.exec(s);}
var timespec=this.parseTimeSpec(s);var a=DateTimeManager.four.exec(s);var b=DateTimeManager.five.exec(s);var c=DateTimeManager.six.exec(s);var yearSpecified=false;var hourSpecified=false;if(!t&&!u&&!v&&!x&&!y&&!z&&!o&&!p&&!r&&!q&&!a&&!b&&!c&&!timespec){return this.useCache?(this.cache[raw]=[null,null]):[null,null];}
var used=null;var part=null;if(r){var start=s.indexOf(r[0])+r[0].length;var end=s.length;s=s.substring(start,end);used="r";part=r[0];}else{if(v){var start=s.indexOf(v[0])+v[0].length;var end=s.length;s=s.substring(start,end);used="v";part=v[0];}else{if(x){var start=s.indexOf(x[0])+x[0].length;var end=s.length;s=s.substring(start,end);used="x";part=x[0];}else{if(z){var start=s.indexOf(z[0])+z[0].length;var end=s.length;s=s.substring(start,end);used="z";part=z[0];}else{if(o){var start=s.indexOf(o[0])+o[0].length;var end=s.length;s=s.substring(start,end);used="o";part=o[0];}else{if(p){var start=s.indexOf(p[0])+p[0].length;var end=s.length;s=s.substring(start,end);used="p";part=p[0];}else{if(q){var start=s.indexOf(q[0])+q[0].length;var end=s.length;s=s.substring(start,end);used="q";part=q[0];}}}}}}}
timespec=this.parseTimeSpec(s);a=DateTimeManager.four.exec(s);b=DateTimeManager.five.exec(s);c=DateTimeManager.six.exec(s);var year=null;var month=null;var day=null;var hour=null;var minute=null;var dateSpecified=true;var futureSpecified=false;if(z){var comps=s.split(/\s*(?:and|\,)\s*/);var az=[];az.push(z);if(comps.length>1){for(var i=1;i<comps.length;i++){az.push(DateTimeManager.three.exec(comps[i]));}}}
if(r&&r[0]){if(r[2]){year=r[2]*1;yearSpecified=true;}else{year=now.getFullYear();}
if(r[4]){month=r[4]*1;}else{month=now.getMonth()+1;}
if(r[6]){day=r[6]*1;}else{day=1;}}else{if(v){if(v[3]){year=v[1].length==4?1:3;month=year==1?2:configurationMgr.dateStyle===1?1:2;day=year==1?3:configurationMgr.dateStyle===1?2:1;yearSpecified=true;if(v[month]>12){var tmp=month;month=day;day=tmp;}
year=this.getYear(v[year]);month=v[month];day=v[day];}else{if(v[1].length==4){year=v[1];month=v[2];day=1;}else{year=now.getFullYear();if(configurationMgr.dateStyle===1){month=1;day=2;}else{month=2;day=1;}
if(v[month]>12){var tmp=day;day=month;month=tmp;}
month=v[month];day=v[day];}}}else{if(x){month=this.getMonth(x[4]);if(!x[3]){if(!x[5]){day=1;}else{day=x[5];x[5]=null;}}else{day=x[3];}
if(x[5]){year=this.getYear(x[5]);yearSpecified=true;}else{year=now.getFullYear();}}else{if(y){var next=false;if(y[3]){next=true;}
if(y[4]){year=now.getFullYear();month=now.getMonth()+1;day=now.getDate()+this.calculateDate(this.getDay(y[4]),now.getDay(),next);}}else{if(z){var retDate=null;for(var i=0;i<az.length;i++){if(az[i][2]){retDate=this.calculateUnit(now,az[i][2],az[i][3],false);}}
if(retDate){futureSpecified=true;year=retDate.getFullYear();month=retDate.getMonth()+1;day=retDate.getDate();}else{return this.useCache?(this.cache[raw]=[null,null]):[null,null];}}else{if(u){var retDate=null;var ux=u[1].toLowerCase();if(ux=="tom"||ux=="tmr"){futureSpecified=true;retDate=this.calculateUnit(now,"1","day",false);}else{if(ux=="tod"||ux=="ton"){retDate=now;}}
if(retDate){year=retDate.getFullYear();month=retDate.getMonth()+1;day=retDate.getDate();}else{return this.useCache?(this.cache[raw]=[null,null]):[null,null];}}else{if(o){var day=parseInt(o[2],10);var retDate=new Date();month=retDate.getMonth();if(day>0&&day<=this.monthLength[month]){year=retDate.getFullYear();month=month+1;retDate.setDate(day);}else{return this.useCache?(this.cache[raw]=[null,null]):[null,null];}}else{if(p){month=this.getMonth(p[3]);if(p[4].length==4){day=1;year=this.getYear(p[4]);yearSpecified=true;}else{day=parseInt(p[4],10);if(p[5]){year=this.getYear(p[5]);yearSpecified=true;}else{year=now.getFullYear();}}}else{if(q){year=now.getFullYear();month=now.getMonth()+1;if(q[1]=="w"){day=now.getDate()+this.calculateDate(this.getDay("sun"),now.getDay(),false);}else{day=Date.days_in_month(year,month);}}else{if(t){var retDate=new Date();year=retDate.getFullYear();month=retDate.getMonth()+1;day=retDate.getDate();hour=retDate.getHours();minute=retDate.getMinutes();}else{var retDate=new Date();year=retDate.getFullYear();month=retDate.getMonth()+1;day=retDate.getDate();dateSpecified=false;}}}}}}}}}}
var positiveOffset=true;if(a){if(a[2]){hour=a[2];if(a[3]){minute=parseInt(a[3],10);}else{minute=0;}
hour=this.normalizeAMPM(hour,a[4]);hourSpecified=true;used+=",a";}}else{if(b){if(b[2]){if(b[2].length==3){hour=parseInt(b[2].substring(0,1),10);minute=parseInt(b[2].substring(1,3),10);}else{hour=parseInt(b[2].substring(0,2),10);minute=parseInt(b[2].substring(2,4),10);}
hour=this.normalizeAMPM(hour,b[3]);hourSpecified=true;used+=",b";}}else{if(timespec===null&&c){if(c[2]){hour=parseInt(c[2],10);minute=0;hour=this.normalizeAMPM(hour,c[3]);hourSpecified=true;used+=",c";}}else{c=null;}}}
var isTimeSpec=false;if((!a&&!b&&!c)&&timespec!==null){var timespecSplit=this.splitTimeSpec(timespec);hour=timespecSplit[0];minute=timespecSplit[1];seconds=timespecSplit[2];if(retDate){retDate.setHours(retDate.getHours()+hour);retDate.setMinutes(retDate.getMinutes()+minute);hour=retDate.getHours();minute=retDate.getMinutes();}
positiveOffset=false;used+=",timespec";isTimeSpec=true;}
var timeSpecified=true;if(hour===null){hour=0;timeSpecified=false;}
if(minute===null){minute=0;timeSpecified=false;}
var rightNow=new Date();var tyear=rightNow.getFullYear();var tmonth=rightNow.getMonth()+1;var tday=rightNow.getDate();var thour=rightNow.getHours();var tmins=rightNow.getMinutes();var ttime=thour*60+tmins;var myear=parseInt(year,10);var mmonth=parseInt(month,10);var mday=parseInt(day,10);var mtime=parseInt(hour,10)*60+parseInt(minute,10);var isToday=(myear===tyear&&mmonth===tmonth&&tday===mday);month=parseInt(month,10);if(futureSpecified==false&&yearSpecified==false&&month<tmonth){year=parseInt(year,10)+1;}
if(isToday===true&&dateSpecified==false&&(hourSpecified==true||isTimeSpec==true)&&(mtime<ttime)){day=parseInt(day,10)+1;}
var returnDate=new Date(year,month-1,day,hour,minute,0);var ret=[returnDate,timeSpecified,positiveOffset,used,part,raw,s];return this.useCache?(this.cache[raw]=ret):ret;};DateTimeManager.prototype.getTimeTuple=function(){var nowx=new Date();var now=new Date();now.setHours(0,0,0,0);var today=dateTimeMgr.checkDate(now);now.setDate(now.getDate()+1);var tomorrow=this.checkDate(now);now.setDate(now.getDate()+1);var clearDate=this.checkDate(now);var nt=parseInt(nowx.getTime()/1000,10);var tt=parseInt(today.getTime()/1000,10);var mt=parseInt(tomorrow.getTime()/1000,10);var ct=parseInt(clearDate.getTime()/1000,10);return[nt,tt,mt,ct];};DateTimeManager.interval_re=new RegExp("((\\d+)\\s*year(?:s)?)?\\s*((\\d+)\\s*mon(?:s)?)?\\s*((\\d+)\\s*day(?:s)?)?\\s*((\\d{2}):(\\d{2}):(\\d{2}))?");DateTimeManager.prototype.TransformDate=function(interval){var g=DateTimeManager.interval_re.exec(interval);var years=g[2];var months=g[4];var days=g[6];var hours=g[8];var minutes=g[9];var secs=g[10];var out=[];if(exists(years)){years=years*1;if(years){if(years==1){out.push(_T("INTERFACE_DF_1_YEAR"));}else{out.push(_T("INTERFACE_DF_NUM_YEARS",{"NUM":years}));}}}
if(exists(months)){months=months*1;if(months){if(months==1){out.push(_T("INTERFACE_DF_1_MONTH"));}else{out.push(_T("INTERFACE_DF_NUM_MONTHS",{"NUM":months}));}}}
if(exists(days)){days=days*1;if(days>6){var weeks=Math.floor((days/7));days=days%7;if(weeks==1){out.push(_T("INTERFACE_DF_1_WEEK"));}else{out.push(_T("INTERFACE_DF_NUM_WEEKS",{"NUM":weeks}));}}
if(days){if(days==1){out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_DAY"));}else{out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_DAYS",{"NUM":days}));}}}
if(exists(hours)){hours=hours*1;if(hours){if(hours==1){out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_HOUR"));}else{out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_HOURS",{"NUM":hours}));}}}
if(exists(minutes)){minutes=minutes*1;if(minutes){if(minutes==1){out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_MINUTE"));}else{out.push(_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_MINUTES",{"NUM":minutes}));}}}
if(exists(secs)){secs=secs*1;if(secs){if(secs==1){out.push("1 second");}else{out.push(secs+" seconds");}}}
if(rtmLanguage=="zh-CN"||rtmLanguage=="zh-TW"||rtmLanguage=="ja"){return out.join("");}
return out.join(", ");};function assert(b,s){return false;dbg(s+" = "+b);if(b==false){if(is_opera){dbg("ASSERT: "+s);this.fred=bob;}else{alert("ASSERT: "+s);}}}
function dbg(s){if(is_opera){opera.postError(s);}
if((is_safari||is_gecko)&&window.console){window.console.log(s);}}
function ied(s){if(is_ie){alert(s);}}
function dump(obj){if(typeof obj=="object"){for(var x in obj){dbg("dump: x = "+x+", obj[x] = "+obj[x]);}}else{dbg("dump: "+obj);}}
function EventManager(){this.locationTimeout=null;this.lastLocation=null;this.lastHistoryLength=null;this.mbn=null;}
EventManager.prototype.init=function(){var self=this;if(!is_ie&&false){document.onclick=function(ev){return self.bodyClickHandler(ev);};}
document.onkeypress=function(ev){return self.bodyKeyPressHandler(ev,(is_gecko&&!is_gecko18));};if(is_ie){document.onkeyup=function(ev){return self.bodyKeyEventHandler(ev,false);};}
if(is_gecko&&!is_gecko18){document.onkeydown=function(ev){return self.bodyKeyEventHandler(ev,true);};}
document.onselectstart=function(ev){return self.bodySelectStartHandler(ev);};this.mbn=this.getUniqueMessageBusName();var self=this;var checkLocationFunc=null;if(is_gecko||is_safari){checkLocationFunc=function(){self.checkLocationGecko();};this.lastLocation=window.location.toString();this.lastHistoryLength=window.history.length;}else{if(is_opera||is_ie){var hash=window.location.hash;this.lastLocation=hash||"#overview";checkLocationFunc=function(){self.checkLocationOpera();};}}
return;this.locationTimeout=setTimeout(checkLocationFunc,100);};EventManager.prototype.getUniqueMessageBusName=function(){return"rtm.eventmanager.";};EventManager.prototype.checkLocationGecko=function(){var newLocation=window.location.toString();var newHistoryLength=window.history.length;if(this.lastLocation!=newLocation){messageBus.broadcast(this,this.mbn+"locationChanged",newLocation);this.lastLocation=newLocation;}
var self=this;var checkLocationFunc=function(){self.checkLocationGecko();};this.locationTimeout=setTimeout(checkLocationFunc,100);};EventManager.prototype.checkLocationOpera=function(){var newLocation=window.location.hash;if(this.lastLocation!=newLocation){messageBus.broadcast(this,this.mbn+"locationChanged",newLocation);this.lastLocation=newLocation;}
var self=this;var checkLocationFunc=function(){self.checkLocationOpera();};this.locationTimeout=setTimeout(checkLocationFunc,200);};EventManager.prototype.bodySelectStartHandler=function(ev){ev||(ev=window.event);var target=utility.getEventTarget(ev);if(target==null){return true;}
if(target!=null&&target.type!=null&&(target.type=="textarea"||target.type=="input"||target.type.indexOf("select")==0||target.type=="text"||target.type=="password")){return true;}
if(ev.shiftKey){utility.stopEvent(ev);return false;}
return true;};EventManager.prototype.bodyKeyEventHandler=function(ev,ignoreArrow){ev||(ev=window.event);var target=utility.getEventTarget(ev);if(target==null){return true;}
if(target!=null&&target.type!=null&&(target.type=="textarea"||target.type=="input"||target.type.indexOf("select")==0||target.type=="text"||target.type=="password")){return true;}
var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);switch(pressed){case 37:if(ev.ctrlKey&&ev.shiftKey&&!ignoreArrow){var tabs=view.getViewTabs();if(tabs){tabs.selectLeft();utility.stopEvent(ev);return false;}}
return true;break;case 39:if(ev.ctrlKey&&ev.shiftKey&&!ignoreArrow){var tabs=view.getViewTabs();if(tabs){tabs.selectRight();utility.stopEvent(ev);return false;}}
return true;case 45:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Help");return false;}
return true;case 47:if(ev.ctrlKey&&ev.shiftKey){el("listFilter").focus();utility.stopEvent(ev);return false;}
return true;case 48:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Settings");utility.stopEvent(ev);return false;}
return true;case 54:case 94:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Overview");utility.stopEvent(ev);return false;}
return true;case 55:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Tasks");utility.stopEvent(ev);return false;}
return true;case 56:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Locations");utility.stopEvent(ev);return false;}
return true;case 57:if(ev.ctrlKey&&ev.shiftKey){view.selectView("Contacts");utility.stopEvent(ev);return false;}
return true;default:return true;}};EventManager.prototype.bodyClickHandler=function(ev){ev||(ev=window.event);view.setWaitingForClick(false);var target=utility.getEventTarget(ev);if(target==null){return false;}
if(target.tagName.toLowerCase()=="a"){view.setClickedLink(true);}
return true;};EventManager.prototype._ifNotesThenSwitch=function(){if(view.getViewToken("Tasks","Notes")){var tabs=view.getViewDetailTabs();if(tabs){tabs.selectLeft();}}};EventManager.prototype.bodyKeyPressHandler=function(ev,ignoreCombo){ev||(ev=window.event);var target=utility.getEventTarget(ev);if(target==null){return true;}
if(target!=null&&target.type!=null&&(target.type=="textarea"||target.type=="input"||target.type.indexOf("select")==0||target.type=="text"||target.type=="password"||(target.id!=null&&target.id=="map"))){return true;}
var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if(is_safari&&pressed>63200){if(pressed==63234){pressed=37;}else{if(pressed==63235){pressed=39;}else{if(pressed==63272){pressed=46;}}}}
if(is_gecko&&!ev.charCode&&!ev.which&&ev.keyCode==116){return true;}
if(is_opera&&is_win_opera&&pressed==0&&!ev.ctrlKey&&!ev.shiftKey&&!ev.metaKey){pressed=46;}
if(is_opera&&pressed==9){utility.stopEvent(ev);return false;}
if(ev.altKey||ev.ctrlKey&&!(ev.shiftKey&&(pressed==37||pressed==39||pressed==47||pressed==48||pressed==54||pressed==55||pressed==56||pressed==57||pressed==76||pressed==94))||ev.metaKey){return true;}
var currentView=view.getSelected();if(currentView==="Locations"){if(pressed===27){return locationMgr.handleEscape();}else{if(ev.shiftKey&&ev.ctrlKey&&pressed==76){return locationMgr.handleGoFocus();}}}
switch(pressed){case 37:if(ev.ctrlKey&&ev.shiftKey){var tabs=view.getViewTabs();if(tabs){tabs.selectLeft();utility.stopEvent(ev);return false;}}
return true;break;case 39:if(ev.ctrlKey&&ev.shiftKey){var tabs=view.getViewTabs();if(tabs){tabs.selectRight();utility.stopEvent(ev);return false;}}
return true;break;case 49:case 50:case 51:case 52:if(!tasksView.isLocked(true)){if(ev.shiftKey){}else{if(pressed!=52){var p=Math.abs(48-pressed);eval("taskList.tasksSetPriority"+p+"();");}else{taskList.tasksSetPriorityNone();}}
utility.stopEvent(ev);return false;}
return true;case 46:if(!tasksView.isLocked(false)){control.tasksDelete();utility.stopEvent(ev);return false;}
return true;case 47:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){el("listFilter").focus();utility.stopEvent(ev);return false;}
return true;case 48:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){view.selectView("Settings");utility.stopEvent(ev);return false;}
return true;case 54:case 94:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){view.selectView("Overview");utility.stopEvent(ev);return false;}
return true;case 55:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){view.selectView("Tasks");utility.stopEvent(ev);return false;}
return true;case 56:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){view.selectView("Locations");utility.stopEvent(ev);return false;}
return true;case 57:if(ev.ctrlKey&&ev.shiftKey&&!ignoreCombo){view.selectView("Contacts");utility.stopEvent(ev);return false;}
return true;case 97:case 97-32:switch(currentView){case"Tasks":taskList.taskSelectAll();break;case"Contacts":var selected=contactsView.getSelected();if(selected==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){contactList.list.selectAll();}else{if(selected==_T("INTERFACE_CONTACTS_GROUPS_TAB")){groupList.list.selectAll();}}
break;case"Settings":if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){listList.list.selectAll();}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){locationList.list.selectAll();}}
break;default:break;}
utility.stopEvent(ev);return false;case 99:case 99-32:if(!tasksView.isLocked(true)){control.tasksComplete();utility.stopEvent(ev);return false;}
return true;case 100:case 100-32:if(!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsDue.startEditing();utility.stopEvent(ev);return false;}
return true;case 102:case 102-32:if(!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsReoccur.startEditing();utility.stopEvent(ev);return false;}
return true;case 103:case 103-32:if(!view.getPublicMode()&&!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsDuration.startEditing();utility.stopEvent(ev);return false;}
return true;case 104:case 104-32:var tabs=view.getViewDetailTabs();if(tabs){tabs.selectRight();utility.stopEvent(ev);return false;}
return true;case 109:case 109-32:if(view.getPublicMode()){return false;}
if(!tasksView.isLocked(true)){view.toggleMultiEditMode();utility.stopEvent(ev);return false;}
return true;case 114:case 114-32:if(view.getPublicMode()){return false;}
if(!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.fieldsTitle.startEditing();utility.stopEvent(ev);return false;}else{if(currentView=="Settings"&&settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")&&listList.list.selected.length>0){listList.list.clearHover();settingsView.listDetails.fieldsTitle.startEditing();utility.stopEvent(ev);return false;}else{if(currentView=="Settings"&&settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")&&locationList.list.selected.length>0){locationList.list.clearHover();settingsView.locationDetails.fieldsTitle.startEditing();utility.stopEvent(ev);return false;}}}
return true;case 110:case 110-32:switch(currentView){case"Tasks":taskList.taskSelectNone();break;case"Contacts":if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){contactList.list.selectNone();}else{if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_GROUPS_TAB")){groupList.list.selectNone();}}
break;case"Settings":if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){listList.list.selectNone();}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){locationList.list.selectNone();}}
break;default:break;}
utility.stopEvent(ev);return false;case 74:case 106:this.keyboardEntryDown(ev);utility.stopEvent(ev);return false;case 75:case 107:this.keyboardEntryUp(ev);utility.stopEvent(ev);return false;case 13:case 105:case 105-32:this.keyboardEntrySelect(ev);utility.stopEvent(ev);return false;case 112:case 112-32:if(!view.getPublicMode()&&!tasksView.isLocked(true)){control.tasksPostpone();utility.stopEvent(ev);return false;}
return true;case 108:case 108-32:if(!view.getPublicMode()&&!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsLocation.startEditing();utility.stopEvent(ev);return false;}
return true;case 115:case 115-32:if(!view.getPublicMode()&&!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsTags.startEditing();utility.stopEvent(ev);return false;}
return true;case 116:case 116-32:if(view.getPublicMode()){return true;}
if(!tasksView.isLocked(true)){adder.div.onclick();utility.stopEvent(ev);return false;}else{if(currentView=="Contacts"&&(contactsView.getSelected()==_T("INTERFACE_CONTACTS_CONTACTS_TAB")||contactsView.getSelected()==_T("INTERFACE_CONTACTS_GROUPS_TAB"))){adder.div.onclick();utility.stopEvent(ev);return false;}else{if(currentView=="Settings"&&settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){adder.div.onclick();utility.stopEvent(ev);return false;}}}
return true;case 117:case 117-32:if(!tasksView.isLocked(true)&&taskList.list.selected.length>0){this._ifNotesThenSwitch();taskList.list.clearHover();tasksView.taskDetails.detailsURL.startEditing();utility.stopEvent(ev);return false;}
return true;case 121:case 121-32:if(!view.getPublicMode()&&noteMgr.enabled===true){var multiIds=false;if(view.getMultiEditMode(true)){multiIds=taskList.getViewList().getSelected();if(multiIds.length==1){multiIds=false;}else{multiIds=true;}}
if(multiIds===false){if(view.getViewToken("Tasks","Tasks")){taskList.list.clearHover();var tabs=view.getViewDetailTabs();if(tabs){tabs.selectRight();}}
if(view.getViewToken("Tasks","Notes")){noteMgr.createNewNote();utility.stopEvent(ev);return false;}}}
return true;case 122:case 122-32:if(!view.getPublicMode()&&statusBox.undoTimeout===null){if(undoMgr.transactions.length>0&&statusBox.visible===true&&statusBox.undo!==null&&statusBox.undo.innerHTML.indexOf("OK")===-1){statusBox.undoClicked();}else{control.undoLastAction();}}
return true;default:break;}};EventManager.prototype.keyboardEntryUp=function(ev){var list=view.getViewList();if(list){list.keyboardUp(ev.shiftKey);}};EventManager.prototype.keyboardEntryDown=function(ev){var list=view.getViewList();if(list){list.keyboardDown(ev.shiftKey);}};EventManager.prototype.keyboardEntrySelect=function(ev){var list=view.getViewList();if(list){list.keyboardSelect(ev.shiftKey);}};function ImageManager(){this.static_n=0;this.imageMap={"list_locked":{"src":"/img/ico/ico_lock.gif","obj":null,"alt":_T("INTERFACE_SETTINGS_LISTS_LIST_LOCKED"),"title":_T("INTERFACE_SETTINGS_LISTS_LIST_LOCKED")},"list_default":{"src":"/img/ico/ico_check_gry.gif","obj":null,"alt":_T("INTERFACE_SETTINGS_LISTS_LIST_DEFAULT"),"title":_T("INTERFACE_SETTINGS_LISTS_LIST_DEFAULT")},"list_pending":{"src":"/img/ico/ico_exclaim_blu.gif","obj":null,"alt":_T("INTERFACE_SETTINGS_LIST_PENDING"),"title":_T("INTERFACE_SETTINGS_LIST_PENDING")},"list_smart":{"src":"/img/ico/ico_search_gry.gif","obj":null,"alt":_T("INTERFACE_SETTINGS_LISTS_SMART_LIST"),"title":_T("INTERFACE_SETTINGS_LISTS_SMART_LIST")},"search":{"src":"/img/ico/ico_search_blu.gif","obj":null,"alt":"Search","title":"Search"},"busy":{"src":"/img/busy.gif","obj":null,"alt":_T("INTERFACE_TASKS_LIST_DETAILS_LOADING"),"title":_T("INTERFACE_TASKS_LIST_DETAILS_LOADING")},"calendar":{"src":"/img/ico/ico_calendar.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_DUE_DATE",{"KEY":"(d)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_DUE_DATE",{"KEY":"(d)"})},"reoccur":{"src":"/img/ico/ico_recur.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_REPEAT",{"KEY":"(f)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_REPEAT",{"KEY":"(f)"})},"duration":{"src":"/img/ico/ico_clock.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_TIME_ESTIMATE",{"KEY":"(g)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_TIME_ESTIMATE",{"KEY":"(g)"})},"tag":{"src":"/img/ico/ico_tag.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_TAGS",{"KEY":"(s)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_TAGS",{"KEY":"(s)"})},"url":{"src":"/img/ico/ico_link_gry.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_URL",{"KEY":"(u)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_URL",{"KEY":"(u)"})},"location":{"src":"/img/ico/ico_globe.gif","obj":null,"alt":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_LOCATION",{"KEY":"(l)"}),"title":_T("INTERFACE_TASKS_TASK_DETAILS_TOOLTIP_LOCATION",{"KEY":"(l)"})},"edit":{"src":"/img/ico/ico_edit.gif","obj":null,"alt":_T("INTERFACE_TOOLTIP_RENAME",{"KEY":"(r)"}),"title":_T("INTERFACE_TOOLTIP_RENAME",{"KEY":"(r)"})},"filter_edit":{"src":"/img/ico/ico_edit.gif","obj":null,"alt":_T("INTERFACE_TASKS_NOTES_EDIT"),"title":_T("INTERFACE_TASKS_NOTES_EDIT")},"atom":{"src":"/img/ico/ico_atom.gif","obj":null,"alt":"Atom Feed"},"trash":{"src":"/img/ico/ico_trash.gif","obj":null,"alt":"Delete","title":"Delete"},"add_sm":{"src":"/img/ico/ico_add_sm.gif","obj":null,"alt":"Add Note"},"add_lg":{"src":"/img/ico/ico_add.gif","obj":null,"alt":_T("INTERFACE_TASKS_ADD_TASK"),"title":_T("INTERFACE_TASKS_ADD_TASK")},"info_blue":{"src":"/img/ico/ico_info_blu.gif","obj":null,"alt":"Information"},"help_blue":{"src":"/img/ico/ico_help_blu.gif","obj":null,"alt":"Help"},"phone":{"src":"/img/ico/ico_phone.gif","obj":null,"alt":"Enter your mobile phone number"},"email":{"src":"/img/ico/ico_email.gif","obj":null,"alt":"Enter your SMS email address"},"weeklyplanner":{"src":"/img/ico/ico_weeklyplanner.gif","obj":null,"alt":"Weekly Planner"},"done_grey":{"src":"/img/done_grey.gif","obj":null,"alt":"Done - Inactive"},"done_blue":{"src":"/img/done_blue.gif","obj":null,"alt":"Done"},"done_share_grey":{"src":"/img/btn_share_gry.gif","obj":null,"alt":"Done Sharing - Inactive"},"done_share_blue":{"src":"/img/btn_share_blu.gif","obj":null,"alt":"Done Sharing"},"done_send_grey":{"src":"/img/btn_send_gry.gif","obj":null,"alt":"Done Sending - Inactive"},"done_send_blue":{"src":"/img/btn_send_blu.gif","obj":null,"alt":"Done Sending"},"done_publish_grey":{"src":"/img/btn_publish_gry.gif","obj":null,"alt":"Done Publishing - Inactive"},"done_publish_blue":{"src":"/img/btn_publish_blu.gif","obj":null,"alt":"Done Publishing"},"cancel":{"src":"/img/btn_cancel_org.gif","obj":null,"alt":"Cancel"},"tab_white_left":{"src":"/img/left_white.png","obj":null,"alt":"Tab - Left - White"},"tab_white_right":{"src":"/img/right_white.png","obj":null,"alt":"Tab - Right - White"},"tab_grey_left":{"src":"/img/left_grey.png","obj":null,"alt":"Tab - Left - Grey"},"tab_grey_right":{"src":"/img/right_grey.png","obj":null,"alt":"Tab - Right - Grey"},"tab_blue_left":{"src":"/img/left_blue.png","obj":null,"alt":"Tab - Left - Blue"},"tab_blue_right":{"src":"/img/right_blue.png","obj":null,"alt":"Tab - Right - Blue"},"whitebox_back":{"src":"/img/whitebox_back.gif","obj":null,"alt":"Whitebox - Back"},"whitebox_t":{"src":"/img/whitebox_t.gif","obj":null,"alt":"Whitebox - Back"},"whitebox_tl":{"src":"/img/whitebox_tl.gif","obj":null,"alt":"Whitebox - Top"},"whitebox_tr":{"src":"/img/whitebox_tr.gif","obj":null,"alt":"Whitebox - Top Left"},"whitebox_b":{"src":"/img/whitebox_b.gif","obj":null,"alt":"Whitebox - Top Right"},"whitebox_bl":{"src":"/img/whitebox_bl.gif","obj":null,"alt":"Whitebox - Bottom"},"whitebox_br":{"src":"/img/whitebox_br.gif","obj":null,"alt":"Whitebox - Bottom Left"},"whitebox_l":{"src":"/img/whitebox_l.gif","obj":null,"alt":"Whitebox - Left"},"whitebox_r":{"src":"/img/whitebox_r.gif","obj":null,"alt":"Whitebox - Right"},"bluebox_back":{"src":"/img/bluebox_back.gif","obj":null,"alt":"Bluebox - Back"},"bluebox_tl":{"src":"/img/bluebox_tl.gif","obj":null,"alt":"Bluebox - Top"},"bluebox_tr":{"src":"/img/bluebox_tr.gif","obj":null,"alt":"Bluebox - Top Left"},"bluebox_bl":{"src":"/img/bluebox_bl.gif","obj":null,"alt":"Bluebox - Bottom"},"bluebox_br":{"src":"/img/bluebox_br.gif","obj":null,"alt":"Bluebox - Bottom Left"},"bluetab":{"src":"/img/ico/ico_close_blu_blu.gif","obj":null,"alt":"Blue Tab"},"whitetab":{"src":"/img/ico/ico_close_gry_whi.gif","obj":null,"alt":"White Tab"},"orangetab":{"src":"/img/ico/ico_close_org_whi.gif","obj":null,"alt":"Orange Tab"},"orangebluetab":{"src":"/img/ico/ico_close_org_blu.gif","obj":null,"alt":"Orange Blue Tab"},"locations_ch":{"src":"/img/locations/ch.gif","obj":null,"alt":""},"locations_iw_bl":{"src":"/img/locations/iw_bl.png","obj":null,"alt":""},"locations_iw_br":{"src":"/img/locations/iw_br.png","obj":null,"alt":""},"locations_iw_l":{"src":"/img/locations/iw_l.png","obj":null,"alt":""},"locations_iw_r2":{"src":"/img/locations/iw_r2.png","obj":null,"alt":""},"locations_iw_r":{"src":"/img/locations/iw_r.png","obj":null,"alt":""},"locations_iw_tl":{"src":"/img/locations/iw_tl.png","obj":null,"alt":""},"locations_iw_tr":{"src":"/img/locations/iw_tr.png","obj":null,"alt":""},"locations_mkr_dblu":{"src":"/img/locations/mkr_dblu.png","obj":null,"alt":""},"locations_mkr_grn":{"src":"/img/locations/mkr_grn.png","obj":null,"alt":""},"locations_mkr_gry":{"src":"/img/locations/mkr_gry.png","obj":null,"alt":""},"locations_mkr_lblu":{"src":"/img/locations/mkr_lblu.png","obj":null,"alt":""},"locations_mkr_org":{"src":"/img/locations/mkr_org.png","obj":null,"alt":""},"locations_mkr_shadow":{"src":"/img/locations/mkr_shadow.png","obj":null,"alt":""}};}
ImageManager.prototype.init=function(){if(typeof(is_ie)!=="undefined"&&is_ie===false){this.preloadImages();}};ImageManager.prototype.getNextStatic=function(){var n=this.static_n++;if(this.static_n>2){this.static_n=0;}
return"http://"+n+".static.rememberthemilk.com";};ImageManager.prototype.preloadImages=function(){for(var i in this.imageMap){this.imageMap[i].obj=new Image();this.imageMap[i].obj.src=this.getNextStatic()+this.imageMap[i].src;}};ImageManager.prototype.getImageHTML=function(f){if(f==null){return null;}
return"<img src="+quoted(this.getNextStatic()+this.imageMap[f].src)+" alt="+quoted(this.imageMap[f].alt)+" />";};ImageManager.prototype.getImage=function(f,asFieldImage,withLink){if(f==null){return null;}
if(withLink){var a=document.createElement("a");a.href=" ";a.title=this.imageMap[f].title;}
var c=document.createElement("img");c.src=this.getNextStatic()+this.imageMap[f].src;c.alt=this.imageMap[f].alt;c.title=this.imageMap[f].title;if(asFieldImage){c.className="field_img";}
if(withLink){a.appendChild(c);return a;}
return c;};function StringManager(){this.strings={"error.contacts.add.alreadyExists":"INTERFACE_ERROR_CONTACTS_ADD_ALREADYEXISTS","error.contacts.add.failure":"INTERFACE_ERROR_CONTACTS_ADD_FAILURE","error.contacts.add.emailSpecified":["INTERFACE_ERROR_CONTACTS_ADD_EMAILSPECIFIED","",false],"error.contacts.add.noYourself":"INTERFACE_ERROR_CONTACTS_ADD_NOYOURSELF","error.contacts.add.noExist":"INTERFACE_ERROR_CONTACTS_ADD_NOEXIST","error.groups.add.failure":"INTERFACE_ERROR_GROUPS_ADD_FAILURE","error.groups.add.alreadyExists":"INTERFACE_ERROR_GROUPS_ADD_ALREADYEXISTS","help.lists.removing":"INTERFACE_HELP_LISTS_REMOVING","help.tasks.duedate":["INTERFACE_HELP_TASKS_DUEDATE","/help/answers/basics/dateformat.rtm",true],"help.tasks.reoccur":["INTERFACE_HELP_TASKS_REOCCUR","/help/answers/basics/repeatformat.rtm",true],"help.tasks.duration":["INTERFACE_HELP_TASKS_DURATION","/help/answers/basics/timeestimateformat.rtm",true],"help.tasks.tags":["INTERFACE_HELP_TASKS_TAGS","/help/answers/tags/whatare.rtm",true],"help.tasks.inbox":["INTERFACE_HELP_TASKS_INBOX","/help/answers/tasks/whatinbox.rtm",true],"help.tasks.sent":["INTERFACE_HELP_TASKS_SENT","/help/answers/tasks/whatsent.rtm",true],"help.tasks.publishing":["INTERFACE_HELP_TASKS_PUBLISHING","/help/answers/sharing/whatpublish.rtm",true],"help.tasks.sharing":["INTERFACE_HELP_TASKS_SHARING","/help/answers/sharing/whatshare.rtm",true],"help.tasks.save":["INTERFACE_HELP_TASKS_SAVE","/help/answers/smartlists/whatare.rtm",true],"help.contacts":["INTERFACE_HELP_CONTACTS","/help/answers/contacts/whatcontacts.rtm",true],"help.contacts.add":"INTERFACE_HELP_CONTACTS_ADD","help.groups":["INTERFACE_HELP_GROUPS","/help/answers/contacts/whatgroups.rtm",true],"help.invites":"INTERFACE_HELP_INVITES","help.reminders.datedue":["INTERFACE_HELP_REMINDERS_DATEDUE","/help/answers/reminders/whenreminders.rtm",true],"help.reminders.start":["INTERFACE_HELP_REMINDERS_START","/help/answers/reminders/whenreminders.rtm",true],"help.reminders.timedue":["INTERFACE_HELP_REMINDERS_TIMEDUE","/help/answers/reminders/whenreminders.rtm",true],"help.reminders.email":"INTERFACE_HELP_REMINDERS_EMAIL","help.reminders.im":"INTERFACE_HELP_REMINDERS_IM","help.reminders.phone":"INTERFACE_HELP_REMINDERS_PHONE","help.reminders.username":"INTERFACE_HELP_REMINDERS_USERNAME","help.reminders.other":["INTERFACE_HELP_REMINDERS_OTHER","/help/answers/reminders/setreminders.rtm",true],"help.reminders.network":"INTERFACE_HELP_REMINDERS_NETWORK","help.reminders.smsmax":"INTERFACE_HELP_REMINDERS_SMSMAX","help.settings.general":"INTERFACE_HELP_SETTINGS_GENERAL","help.settings.lists":"INTERFACE_HELP_SETTINGS_LISTS","help.settings.locations":"INTERFACE_HELP_LOCATIONS","help.settings.reminders":"INTERFACE_HELP_SETTINGS_REMINDERS","help.settings.services":["INTERFACE_HELP_SETTINGS_SERVICES","/services/",true],"help.settings.info":["INTERFACE_HELP_SETTINGS_INFO","/help/answers/sending/emailinbox.rtm",true]};}
StringManager.prototype.getString=function(key){if(this.strings[key]){return _TF(this.strings[key]);}else{return"STRING_NOT_FOUND";}};function Legend(boxId,closeId,mapLegend){this.boxId=boxId;this.closeId=closeId;this.boxDiv=el(boxId);this.closeButton=el(closeId);if(mapLegend){this.mapLegend=true;}else{this.mapLegend=false;}
this.visible=false;}
Legend.prototype.init=function(){var self=this;this.closeButton.onclick=function(){self.hide();if(!view.getPublicMode()&&(typeof rtmRequestedList=="undefined"||rtmRequestedList===null)){transMgr.request(self.mapLegend?"legend.setMapVisible":"legend.setVisible",utility.encodeJavaScript({"visible":false}));}else{self.setCookie();}};};Legend.prototype.show=function(){this.boxDiv.style.display="";this.visible=true;if(this.mapLegend){locationMgr.handleListResize();}};Legend.prototype.toggle=function(){if(this.visible){this.hide();}else{this.show();}
if(!view.getPublicMode()&&(typeof rtmRequestedList=="undefined"||rtmRequestedList===null)){transMgr.request(this.mapLegend?"legend.setMapVisible":"legend.setVisible",utility.encodeJavaScript({"visible":this.visible}));}};Legend.prototype.hide=function(){this.boxDiv.style.display="none";this.visible=false;if(this.mapLegend){locationMgr.handleListResize();}};Legend.prototype.setCookie=function(){setCookie("LEGEND_SHOW",0,null,"/",null,null);};function List(id,type){this.id=id;this.table=el(id);this.entries=[];this.selected=[];this.selectedMap={};this.busy=[];this.busyMap={};this.map={};this.reverseMap={};this.present={};this.type=type;this.inited=false;this.invalidated=[];this.prioState=List.LIST_PRIO_INCOMPLETE;this.inAdvise=false;this.needToBlit=true;this.dateKlass="xtd_date";this.hashMap=null;this.sortFields=null;this.sortSpec=null;this.sortSpecClean=null;this.clickable=true;this.visible=false;this.emptyMessage=null;this.showingEmpty=false;this.hoverable=true;this.multiSelectable=true;this.hoveringId=null;this.keyboardPosition=null;this.keyboardEntries=[];this.table.className="xtable";this.table.cellSpacing="0";this.table.cellPadding="0";if(!is_ie&&(is_safari||!is_khtml)){this.table.innerHTML="<tbody></tbody>";}else{var tbody=this.table.tBodies[0];if(tbody){while(tbody.childNodes.length>0){tbody.removeChild(tbody.firstChild);}}}}
List.LIST_TYPE_PLAIN=1;List.LIST_TYPE_PRIO=2;List.LIST_TYPE_CHECK=4;List.LIST_TYPE_DATE=8;List.LIST_TYPE_IMAGE=22;List.LIST_TYPE_LOADING=50;List.LIST_TYPE_ADDING=100;List.LIST_PRIO_INCOMPLETE=0;List.LIST_PRIO_COMPLETED=1;List.LIST_SORT_ASC=0;List.LIST_SORT_DESC=1;List.LIST_SORT_NULL_IS_NEGATIVE=2;List.prototype.setEmptyMessage=function(message){this.emptyMessage=message;};List.prototype.setDateKlass=function(klass){this.dateKlass=klass;};List.prototype.setMultiSelectable=function(multiSelectable){this.multiSelectable=multiSelectable;};List.prototype.show=function(){this.visible=true;this.table.style.display="";this.fireSelectionStarted();this.fireSelectionFinished();};List.prototype.hide=function(){this.visible=false;this.table.style.display="none";this.fireSelectionCleared();};List.prototype._findPosition=function(el){var top=0;if(el.offsetParent){while(el.offsetParent){top+=el.offsetTop;el=el.offsetParent;}}else{if(el.y){top+=el.y;}}
return top;};List.prototype._findInnerHeight=function(){if(window.innerHeight){return window.innerHeight;}
if(is_ie){return document.documentElement.clientHeight;}};List.prototype._findScrollTop=function(el){if(is_safari||is_gecko||is_khtml){return window.scrollY;}
if(is_ie||is_opera){if(document.compatMode&&document.compatMode=="CSS1Compat"){return document.documentElement.scrollTop;}
return document.body.scrollTop;}
if(el.parentNode){while(el.parentNode){top=el.scrollTop;if(top!==0){break;}
el=el.parentNode;}
if(!el.parentNode&&el.scrollTop===0){top=el.scrollTop;}}
return top;};List.prototype.keyboardUp=function(shift){if(this.keyboardPosition===null){this.keyboardPosition=0;this.setRowHover(this.table.rows[this.keyboardPosition],true);this.keyboardEntries.push(this.keyboardPosition);}else{this.keyboardEnsureBounds();if(!shift){this.setRowHover(this.table.rows[this.keyboardPosition],false);this.keyboardEntries.spliceAll(this.keyboardPosition);}
if(this.keyboardPosition===0){this.keyboardPosition=this.table.rows.length-1;var clientHeight=is_opera?document.documentElement.clientHeight:document.body.clientHeight;window.scrollBy(0,clientHeight);}else{this.keyboardPosition--;var elPos=this._findPosition(this.table.rows[this.keyboardPosition]);var pageTop=this._findInnerHeight()/2;if(is_safari){elPos+=(32*this.keyboardPosition)+this.keyboardPosition;}
if(elPos<this._findScrollTop(document.body)){window.scrollBy(0,-pageTop);}}
this.setRowHover(this.table.rows[this.keyboardPosition],true);this.keyboardEntries.spliceAll(this.keyboardPosition);this.keyboardEntries.push(this.keyboardPosition);}};List.prototype.keyboardDown=function(shift){if(this.keyboardPosition===null){this.keyboardPosition=0;this.setRowHover(this.table.rows[this.keyboardPosition],true);this.keyboardEntries.push(this.keyboardPosition);}else{this.keyboardEnsureBounds();if(!shift){this.setRowHover(this.table.rows[this.keyboardPosition],false);this.keyboardEntries.spliceAll(this.keyboardPosition);}
var scrollTop=this._findScrollTop(document.body);if(this.keyboardPosition+1<this.table.rows.length){this.keyboardPosition++;var elPos=this._findPosition(this.table.rows[this.keyboardPosition]);if(is_safari){elPos+=(32*this.keyboardPosition)+this.keyboardPosition;}
var innerHeight=this._findInnerHeight();var pageTop=innerHeight/2;if(elPos+32>innerHeight+scrollTop){window.scrollBy(0,pageTop);}}else{this.keyboardPosition=0;window.scrollBy(0,-scrollTop);}
this.setRowHover(this.table.rows[this.keyboardPosition],true);this.keyboardEntries.spliceAll(this.keyboardPosition);this.keyboardEntries.push(this.keyboardPosition);}};List.prototype.keyboardSelect=function(shift){if(this.keyboardEntries.length>0){this.keyboardEnsureBounds();this.selectOne(this.entries[this.keyboardPosition][0],false);var keyboardEntries={};for(var i=0;i<this.keyboardEntries.length;i++){if(this.keyboardPosition!==this.keyboardEntries[i]){keyboardEntries[this.keyboardEntries[i]]=true;}}
this.selectSome(keyboardEntries);}};List.prototype.keyboardClearHover=function(reselect){for(var i=0;i<this.keyboardEntries.length;i++){var pos=this.keyboardEntries[i];this.setRowHover(this.table.rows[pos],false);}
this.keyboardEntries=[];this.keyboardEnsureBounds();if(reselect&&this.keyboardPosition!==null){this.setRowHover(this.table.rows[this.keyboardPosition],true);this.keyboardEntries.push(this.keyboardPosition);}};List.prototype.keyboardEnsureBounds=function(){if(this.keyboardPosition!==null&&this.keyboardPosition>this.table.rows.length-1){this.keyboardPosition=this.table.rows.length-1;}};List.prototype.getLastSelected=function(){if(this.selected.length){return this.selected[this.selected.length-1];}else{return null;}};List.prototype.getLastSelectedId=function(){var pos=this.getLastSelected();if(pos!==null){return this.entries[pos][0];}
return null;};List.prototype.setSortParameters=function(hashMap,fields,spec){this.hashMap=hashMap;this.sortFields=fields;this.sortSpec=[];this.sortSpecClean=spec;for(var i=0;i<spec.length;i++){this.sortSpec[i]=1;if(spec[i]==List.LIST_SORT_DESC){this.sortSpec[i]=-1;}
if(spec[i]==List.LIST_SORT_NULL_IS_NEGATIVE){this.sortSpec[i]=-2;}}};List.prototype.doSort=function(a,b){for(var i=0;i<a.length;i++){if(a[i]===null&&b[i]!==null){return 1;}else{if(a[1]!==null&&b[i]===null){return-1;}}
if(a[i]>b[i]){return 1;}else{if(a[i]<b[i]){return-1;}}}
return 0;};List.prototype.getSelected=function(){var selectedIds=[];for(var i=0;i<this.selected.length;i++){selectedIds.push(this.reverseMap[this.selected[i]]);}
return selectedIds;};List.prototype.getBusy=function(){var busyIds=[];for(var i=0;i<this.busy.length;i++){busyIds.push(this.reverseMap[this.busy[i]]);}
return busyIds;};List.prototype.sort=function(){messageBus.broadcast(this,this.mbn+"sortStarted");if(this.hashMap==null||this.sortFields==null){return false;}
if(this.entries.length>0){this.showingEmpty=false;}
var selectedIds=this.getSelected();var busyIds=this.getBusy();var startTime=new Date();var entriesSort=[];for(var j=0;j<this.entries.length;j++){var entry=this.entries[j];var entryTuple=[];for(var i=0;i<this.sortFields.length;i++){var f=this.sortFields[i];var v=eval("this.hashMap[entry[0]]."+f);entryTuple.push(v);}
entryTuple.list=this;entryTuple.id=this.entries[j];entriesSort.push(entryTuple);}
entriesSort.sort(this.doSort);var remapList=[];for(var i=0;i<this.entries.length;i++){remapList.push([entriesSort[i].id[0],i]);}
var iters=0;var needUpdate=[];for(var i=0;i<remapList.length;i++){var oldId=this.reverseMap[remapList[i][1]];var newId=remapList[i][0];var oldPos=remapList[i][1];var newPos=this.map[newId];if(oldPos==newPos){continue;}
this.map[oldId]=newPos;this.reverseMap[newPos]=oldId;this.map[newId]=oldPos;this.reverseMap[oldPos]=newId;var tmpEntry=this.entries[oldPos];this.entries[oldPos]=this.entries[newPos];this.entries[newPos]=tmpEntry;needUpdate.push(oldPos);needUpdate.push(newPos);iters++;}
var rcuSelected=[];var rcuSelectedMap={};for(var i=0;i<selectedIds.length;i++){var pos=this.map[selectedIds[i]];rcuSelected.push(pos);rcuSelectedMap[pos]=true;this.setRowSelect(this.table.rows[pos],true);}
for(var i=0;i<this.selected.length;i++){var pos=this.selected[i];if(!rcuSelectedMap[pos]){this.setRowSelect(this.table.rows[pos],false);}}
this.selected=rcuSelected;this.selectedMap=rcuSelectedMap;var rcuBusy=[];var rcuBusyMap={};for(var i=0;i<busyIds.length;i++){var pos=this.map[busyIds[i]];rcuBusy.push(pos);rcuBusyMap[pos]=true;this.tableSetRowBusy(pos,true);}
for(var i=0;i<this.busy.length;i++){var pos=this.busy[i];if(!is(rcuBusyMap[pos])){this.tableSetRowBusy(pos,false);}}
this.busy=rcuBusy;this.busyMap=rcuBusyMap;var endTime=new Date();var startTime=new Date();var seen={};for(var i=0;i<needUpdate.length;i++){var id=needUpdate[i];if(!seen[id]){seen[id]=true;}else{continue;}
if(this.entries[id]===null){}else{this.updateEntry(this.entries[id],true);}}
var endTime=new Date();messageBus.broadcast(this,this.mbn+"sortFinished");};List.prototype.printMappings=function(){for(var i=0;i<this.entries.length;i++){}};List.prototype.getUniqueMessageBusName=function(){return"rtm.list."+this.id+".";};List.prototype.setPrioState=function(newState){this.prioState=newState;};List.prototype.setClickable=function(clickable){this.clickable=clickable;};List.prototype.setHoverable=function(hoverable){this.hoverable=hoverable;};List.prototype.init=function(){this.addRow=this.getAddFunc();this.inited=true;this.inAdvise=false;this.needToBlit=true;this.mbn=this.getUniqueMessageBusName();this.prioState=List.LIST_PRIO_INCOMPLETE;this.clickable=true;};List.prototype.clear=function(){this.entries=[];this.invalidated=[];this.selected=[];this.selectedMap={};this.busy=[];this.busyMap={};this.map={};this.reverseMap={};this.present={};this.needToBlit=true;this.inAdvise=false;this.showingEmpty=false;this.hoveringId=null;this.keyboardPosition=null;this.keyboardEntries=[];this.fireSelectionCleared();var old_visible=this.visible;this.clearTable();if(old_visible){this.show();}else{this.hide();}};List.prototype.clearTable=function(){if(!is_ie&&(is_safari||!is_khtml)){this.table.innerHTML="<tbody></tbody>";}else{var tbody=this.table.tBodies[0];while(tbody.childNodes.length>0){tbody.removeChild(tbody.firstChild);}}};List.prototype.setAdvise=function(advise){this.inAdvise=advise;this.needToBlit=false;if(advise){this.memory={};}};List.prototype.conditionalAddOrReplaceEntry=function(entry,force){if(is(this.map[entry[0]])){if(this.entries.length>this.map[entry[0]]&&is(this.entries[this.map[entry[0]]])){this.updateEntry(entry,force);}else{this.entries[this.map[entry[0]]]=entry;}
if(this.inAdvise){this.memory[entry[0]]=true;}
return false;}else{this.addEntryDelayed(entry);if(this.inAdvise){this.memory[entry[0]]=true;this.needToBlit=true;}
return true;}};List.prototype.addEntryDelayed=function(entry){if(this.inited==false){return false;}
this.entries.push(entry);this.map[entry[0]]=this.entries.length-1;this.reverseMap[this.entries.length-1]=entry[0];return true;};List.prototype.getEntry=function(id){return this.entries[this.map[id]];};List.prototype.prune=function(){if(this.memory===null){return false;}
var toDelete=[];for(var i=0;i<this.entries.length;i++){var id=this.entries[i][0];if(!this.memory[id]&&is(this.map[id])&&this.table.rows.length>this.map[id]&&this.table.rows[this.map[id]]){toDelete.push(id);}}
for(var i=0;i<toDelete.length;i++){this.removeEntry(toDelete[i]);}
this.memory=null;};List.prototype.addEntry=function(entry){var ret=this.addEntryDelayed(entry);this.addRow(entry);this.present[entry[0]]=true;return ret;};List.prototype.tableBlitRows=function(){var startTime=new Date();this.tableBlitEmpty();if(this.inAdvise&&this.needToBlit==false){return false;}
for(var i=0;i<this.entries.length;i++){var entry=this.entries[i];if(!this.present[entry[0]]){this.addRow(entry);this.present[entry[0]]=true;}}
var endTime=new Date();if(is_gecko18){this._redraw(true);}};List.prototype.tableBlitEmpty=function(){if(this.emptyMessage&&!this.showingEmpty&&this.entries.length==0){var emptyEntry=null;if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){emptyEntry=[0,"N",this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)){emptyEntry=[0,"N",this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){emptyEntry=[0,this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){emptyEntry=[0,this.emptyMessage];}}}}
var row=this.addRow(emptyEntry);if(row){row.rowText.className+=" xtr_empty";row.onmouseover=function(){};row.onmouseout=function(){};row.onclick=function(){};if(row.rowCheckBox){row.rowCheck.style.display="none";row.rowText.colSpan=2;}
row.rowText.style.fontWeight="bold";}
this.showingEmpty=true;this._redraw(false);}
this.tableClearEmpty();};List.prototype._redraw=function(severe){if(is_gecko18&&severe){if(this.visible&&!(this.type==List.LIST_TYPE_LOADING||this.type==List.LIST_TYPE_ADDING)){this.table.style.display="none";var self=this;var redrawFunc=function(){self.table.style.display="";};setTimeout(redrawFunc,0);}}
this.table.style.visibility="hidden";this.table.style.visibility="visible";};List.prototype.tableClearEmpty=function(){if(this.emptyMessage&&this.showingEmpty&&this.entries.length>0){this.clearTable();this.showingEmpty=false;}};List.prototype.tableAddRow=function(entry){var row=this.table.insertRow(-1);row.className="xtr";var col=row.insertCell(0);col.className="xtd xtd_text";col.innerHTML=entry[1];row.rowText=col;return row;};List.prototype.setRowHover=function(row,hover){if(hover){if(row.className.indexOf("xtr_select")>-1){row.className=row.className.replace(/xtr_select/g,"");}
if(row.className.indexOf("xtr_hover")==-1){row.className+=" xtr_hover";}
if(this.type&List.LIST_TYPE_PRIO&&this.prioState==List.LIST_PRIO_COMPLETED){var cell=row.rowPriority;cell.className=cell.className.replace(/(prio[123N])C/,"$1");}}else{if(is(this.selectedMap[this.map[row.entry[0]]])){row.className+=" xtr_select";}
row.className=row.className.replace("xtr_hover","");if(this.type&List.LIST_TYPE_PRIO&&this.prioState==List.LIST_PRIO_COMPLETED){var cell=row.rowPriority;cell.className=cell.className.replace(/(prio[123N])/,"$1C");}}
return false;};List.prototype.setRowSelect=function(row,select){if(select){if(row.className.indexOf("xtr_select")==-1){row.className+=" xtr_select";}
if(this.type&List.LIST_TYPE_CHECK){row.rowCheckBox.checked=true;}}else{row.className=row.className.replace(/xtr_select/g,"");if(this.type&List.LIST_TYPE_CHECK){row.rowCheckBox.checked=false;}}
return false;};List.prototype.onRowMouseOver=function(ev,row,entry){if(!this.clickable||!this.hoverable){return false;}
ev||(ev=window.event);var id=entry[0];this.setRowHover(row,true);this.hoveringId=id;messageBus.broadcast(this,this.mbn+"hoverOn",id);};List.prototype.onRowMouseOut=function(ev,row,entry){if(!this.clickable||!this.hoverable){return false;}
ev||(ev=window.event);var id=entry[0];this.setRowHover(row,false);this.hoveringId=null;messageBus.broadcast(this,this.mbn+"hoverOff",id);};List.prototype.fireSelectionStarted=function(){messageBus.broadcast(this,this.mbn+"selectStarted");};List.prototype.fireSelectionCleared=function(){messageBus.broadcast(this,this.mbn+"selectCleared");};List.prototype.selectMulti=function(id){var map=this.map[id];var already=this.selectedMap[map]?true:false;var selected=cloneArr(this.selected);selected.sort();var from=selected.length>0?selected[0]:null;if(from==null){this.fireSelectionStarted();}
var to=already?(selected.length>0?(selected[selected.length-1]>map?map:map-1):map-1):map;var deselectAll=(to==-1)||(selected.length==1&&selected[0]==map);from=(from==null)?to:from;var fromDeselect=null;var toDeselect=null;if(map<this.selected[selected.length-1]){fromDeselect=already?map:map+1;toDeselect=this.selected[selected.length-1];}
var select=[];var deselect=[];var min=from<to?from:to;var max=from<to?to:from;if(!deselectAll){for(var i=min;i<max+1;i++){select.push(i);}}
if(fromDeselect!=null&&toDeselect!=null){var demin=fromDeselect<toDeselect?fromDeselect:toDeselect;var demax=fromDeselect<toDeselect?toDeselect:fromDeselect;if(deselectAll||demin>=selected[0]){for(var i=demin;i<demax+1;i++){if(!deselectAll){select.spliceAll(i);}
deselect.push(i);}}}
if(!deselectAll&&select.length){for(var i=select[0];i<select[select.length-1]+1;i++){already=this.selectedMap[i]?true:false;if(!already){this.setRowSelect(this.table.rows[i],true);this.reflectSelected(i,true);}}}
if(deselectAll&&fromDeselect==null){deselect.push(map);}
if(deselect.length){for(var i=deselect[0];i<deselect[deselect.length-1]+1;i++){already=this.selectedMap[i]?true:false;if(already){this.setRowSelect(this.table.rows[i],false);this.reflectSelected(i,false);}}}
this.fireSelectionFinished();return false;};List.prototype.reflectBusy=function(map,busy){if(!busy){this.busyMap[map]=false;this.busy.spliceAll(map);}else{if(!this.busyMap[map]){this.busyMap[map]=true;}else{this.busy.spliceAll(map);}
this.busy.push(map);}};List.prototype.reflectSelected=function(map,select){if(!select){this.selectedMap[map]=false;this.selected.spliceAll(map);}else{if(!this.selectedMap[map]){this.selectedMap[map]=true;}else{this.selected.spliceAll(map);}
this.selected.push(map);}};List.prototype.selectAll=function(){if(this.showingEmpty){return false;}
messageBus.broadcast(this,this.mbn+"selectStarted");for(var i=0;i<this.table.rows.length;i++){this.setRowSelect(this.table.rows[i],true);this.reflectSelected(i,true);}
this.fireSelectionFinished();this.keyboardClearHover(true);};List.prototype.selectSome=function(which){messageBus.broadcast(this,this.mbn+"selectStarted");for(var i=0;i<this.table.rows.length;i++){if(which[i]!==null&&typeof which[i]!="undefined"){this.setRowSelect(this.table.rows[i],true);this.reflectSelected(i,true);}}
this.fireSelectionFinished();};List.prototype.deselectSome=function(which){messageBus.broadcast(this,this.mbn+"selectStarted");for(var i=0;i<this.table.rows.length;i++){if(is(which[i])){this.setRowSelect(this.table.rows[i],false);this.reflectSelected(i,false);}}
this.fireSelectionFinished();};List.prototype.selectNone=function(suppress){this.keyboardClearHover(true);if(this.selected.length==0){return;}
if(!suppress){this.fireSelectionStarted();}
for(var i=0;i<this.selected.length;i++){var pos=this.selected[i];this.setRowSelect(this.table.rows[pos],false);this.reflectSelected(pos,false);i--;}
if(!suppress){this.fireSelectionFinished();}};List.prototype.selectOne=function(id,force){this.fireSelectionStarted();if(this.multiSelectable===false){this.selectNone();}
var map=this.map[id];if(typeof(map)!=="undefined"){var already=!force&&this.selectedMap[map]?true:false;this.setRowSelect(this.table.rows[map],!already);if(already){this.reflectSelected(map,false);}else{this.reflectSelected(map,true);}}
this.fireSelectionFinished();};List.prototype.fireSelectionFinished=function(){messageBus.broadcast(this,this.mbn+"selectFinished",[this.selected.length,this.selected.length>0?this.selected[this.selected.length-1]:null]);if(this.selected.length==0){this.fireSelectionCleared();}};List.prototype.onRowMouseClick=function(ev,row,entry){if(!this.clickable){return false;}
ev||(ev=window.event);var id=entry[0];if(!ev.shiftKey||this.multiSelectable===false){this.selectOne(id);}else{this.selectMulti(id);}};List.prototype.tableAddRowBase=function(entry){var list=this;var row=this.table.insertRow(-1);row.entry=entry;row.onmouseover=function(ev){list.onRowMouseOver(ev,this,this.entry);return false;};row.onmouseout=function(ev){list.onRowMouseOut(ev,this,this.entry);return false;};row.onclick=function(ev){list.onRowMouseClick(ev,this,this.entry);return true;};row.onmousedown=function(ev){ev||(ev=window.event);if(ev.shiftKey){return false;}
return true;};row.className="xtr";return row;};List.prototype.tableAddRowWithCheckBase=function(entry){var row=this.tableAddRowBase(entry);var col1=row.insertCell(-1);col1.className="xtd xtd_check";col1.innerHTML="<form action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form>";row.rowCheck=col1;row.rowCheckBox=col1.getElementsByTagName("input")[0];return row;};List.prototype.tableAddRowWithCheck=function(entry){var row=this.tableAddRowWithCheckBase(entry);var col1=row.insertCell(-1);col1.className="xtd xtd_text";col1.innerHTML=entry[1];row.rowText=col1;var col2=row.insertCell(-1);col2.className="xtd xtd_image";row.rowImage=col2;return row;};List.prototype.tableConditionalImageAttach=function(entry,row){row.rowImage.innerHTML="";if(entry[2]!=null){var img=imageMgr.getImage(entry[2]);row.rowImage.appendChild(img);}else{row.rowImage.innerHTML="&nbsp;";}};List.prototype.tableAddRowWithCheckAndImage=function(entry){var row=this.tableAddRowWithCheck(entry);this.tableConditionalImageAttach(entry,row);return row;};List.prototype.tableAddRowWithPriorityBase=function(entry){var row=this.tableAddRowBase(entry);var col0=row.insertCell(-1);var prio="prio"+entry[1];if(this.prioState==List.LIST_PRIO_COMPLETED){prio=prio+"C";}
col0.className="xtd xtd_prio "+prio;row.rowPriority=col0;col0.innerHTML="&nbsp;";return row;};List.prototype.tableAddRowWithPriority=function(entry){var row=this.tableAddRowWithPriorityBase(entry);var col1=row.insertCell(-1);col1.className="xtd xtd_text";col1.innerHTML=entry[2];row.rowText=col1;return row;};List.prototype.tableAddRowWithLoading=function(entry){var stubEntry=[0,"N",entry[0]];var row=this.tableAddRowWithPriority(stubEntry);var col2=row.insertCell(-1);col2.className="xtd xtd_image";row.rowImage=col2;stubEntry=[null,null,entry[1]];this.tableConditionalImageAttach(stubEntry,row);return row;};List.prototype.tableAddRowWithAdding=function(entry){var id=hex_sha1(transMgr.getRandomInt(600673)+new Date().getTime());var stubEntry=[id,"N",""];row=null;if(adder.type==Adder.ADDER_TYPE_TASK){row=this.tableAddRowWithPriorityAndCheck(stubEntry);}else{row=this.tableAddRowWithCheck(stubEntry);}
row.rowText.innerHTML="<div id="+quoted("adder_"+id)+"></div>";var field=new Field("adder_"+id);field.init();field.setKlass("xtd_entry");field.blit();control.registerAdder(id,field);field.show();field.startEditing();row.rowField=field;this.parent.fields.push(field);var col2=row.insertCell(-1);col2.className="xtd xtd_image";row.rowImage=col2;stubEntry=[null,null,null];this.tableConditionalImageAttach(stubEntry,row);for(var i=0;i<row.cells.length;i++){row.cells[i].style.borderBottom="0px";}
return row;};List.prototype.tableAddRowWithPriorityAndCheck=function(entry){var row=this.tableAddRowWithPriorityBase(entry);var col1=row.insertCell(-1);col1.className="xtd xtd_check";col1.innerHTML="<form id="+quoted(this.id+"_row_form_"+entry[0])+" action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form>";row.rowCheck=col1;row.rowCheckBox=col1.getElementsByTagName("input")[0];var col2=row.insertCell(-1);col2.className="xtd xtd_text";col2.innerHTML=entry[2];row.rowText=col2;return row;};List.prototype.tableAddRowWithPriorityAndDate=function(entry){var row=this.tableAddRowWithPriority(entry);var col2=row.insertCell(-1);col2.className="xtd "+this.dateKlass;col2.innerHTML=entry[3]?entry[3]:"&nbsp;";row.rowDate=col2;return row;};List.prototype.tableAddRowWithPriorityAndCheckAndDate=function(entry){var row=this.tableAddRowWithPriorityAndCheck(entry);var col3=row.insertCell(-1);col3.className="xtd "+this.dateKlass;col3.innerHTML=entry[3]?entry[3]:"&nbsp;";row.rowDate=col3;return row;};List.prototype.tableSetRowBusy=function(map,busy){var row=this.table.rows[map];if(!row){return false;}
var cols=row.cells.length;if(busy){var busyCell=2;if(cols>2){if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)||this.type==List.LIST_TYPE_ADDING){busyCell=3;}
row.busyCell=busyCell;var imgs=row.cells[busyCell].getElementsByTagName("img");if(imgs.length>0){if(imgs[0].src.indexOf("busy")==-1){row.savedCellClassName=row.cells[busyCell].className;row.savedCellContent=row.cells[busyCell].innerHTML;}else{}}else{row.savedCellClassName=row.cells[busyCell].className;row.savedCellContent=row.cells[busyCell].innerHTML;}}
var col3=row.cells[busyCell];col3.className="xtd xtd_image";var img=imageMgr.getImage("busy");col3.innerHTML="";col3.appendChild(img);this.reflectBusy(map,true);}else{if(row.busyCell){var busyCell=row.cells[row.busyCell];if(row.rowDate&&row.savedCellClassName.indexOf("xtd_image")>-1){busyCell.className="xtd "+this.dateKlass;}else{busyCell.className=row.savedCellClassName;}
busyCell.innerHTML=row.savedCellContent;}
this.reflectBusy(map,false);}
this._redraw(false);return row;};List.prototype.tableSetRowBusyById=function(id,busy){return this.tableSetRowBusy(this.map[id],busy);};List.prototype.updateEntry=function(entry,force){var id=this.map[entry[0]];var row=this.table.rows[id];var oldEntry=this.entries[id];if(row==null){return false;}
row.entry=entry;if(this.showingEmpty){row.rowText.style.fontWeight="bold";return true;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){if(!force&&entry[1]==oldEntry[1]){return true;}
row.rowText.innerHTML=entry[1];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){if(!force&&entry[1]==oldEntry[1]&&entry[2]==oldEntry[2]){return true;}
row.rowText.innerHTML=entry[1];this.tableConditionalImageAttach(entry,row);}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_CHECK|List.LIST_TYPE_DATE)||this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){if(!force&&entry[1]==oldEntry[1]&&entry[2]==oldEntry[2]&&entry[3]==oldEntry[3]){return true;}
var prio="prio"+entry[1];if(this.prioState==List.LIST_PRIO_COMPLETED){prio=prio+"C";}
row.rowPriority.className="xtd xtd_prio "+prio;row.rowText.innerHTML=entry[2];row.rowDate.innerHTML=entry[3]?entry[3]:"";}else{return false;}}}
this.entries[id]=entry;this.invalidated.push(id);return true;};List.prototype.debugDump=function(){var y=[];for(var x in this.reverseMap){y.push(x);}};List.prototype.removeEntry=function(id){var row=this.map[id];if(row===null||typeof row=="undefined"||!this.table.rows[row]){return false;}
this.reflectSelected(row,false);this.reflectBusy(row,false);this.table.rows[row].onmouseover={};this.table.rows[row].onmouseout={};this.table.rows[row].onclicked={};this.entries.splice(row,1);if(this.rows){this.rows.splice(row,1);}
this.table.deleteRow(row);this.reverseMap[row]=null;this.map[id]=null;this.present[id]=null;var max=this.entries.length;for(var i=row+1;i<max+1;i++){var entry=this.reverseMap[i];this.map[entry]=i-1;if(this.selectedMap[i]){this.reflectSelected(i,false);this.reflectSelected(i-1,true);}
if(this.busyMap[i]){this.reflectBusy(i,false);this.reflectBusy(i-1,false);}
this.reverseMap[i-1]=entry;}
if(this.entries.length==0){this.tableBlitEmpty();}
return true;};List.prototype.getAddFunc=function(){if(this.type==List.LIST_TYPE_PLAIN){return this.tableAddRow;}
if(this.type==List.LIST_TYPE_LOADING){return this.tableAddRowWithLoading;}
if(this.type==List.LIST_TYPE_ADDING){return this.tableAddRowWithAdding;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){return this.tableAddRowWithCheck;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){return this.tableAddRowWithCheckAndImage;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO)){return this.tableAddRowWithPriority;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_CHECK)){return this.tableAddRowWithPriorityAndCheck;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){return this.tableAddRowWithPriorityAndDate;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)){return this.tableAddRowWithPriorityAndCheckAndDate;}
return this.tableAddRowWithPriorityAndDate;};List.prototype.clearHover=function(){if(!this.hoveringId){return null;}
this.table.rows[this.map[this.hoveringId]].onmouseout();};function ListBase(){this.list=null;}
ListBase.prototype.show=function(){this.list.show();};ListBase.prototype.hide=function(){this.list.hide();};function AddingList(id){this.id=id;this.list=new List(id,List.LIST_TYPE_ADDING);this.list.init();this.type="adding";this.list.parent=this;this.mbn=null;this.list.setClickable(false);this.fields=[];}
AddingList.prototype.clear=function(){this.list.clear();};AddingList.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();};AddingList.prototype.blit=function(){this.list.tableBlitRows();};AddingList.prototype.getUniqueMessageBusName=function(){return"rtm.addinglist.";};AddingList.prototype.addEntry=function(){var entry=[hex_sha1(transMgr.getRandomInt(600673)+new Date().getTime()),"N",""];this.list.addEntry(entry);};AddingList.prototype.show=ListBase.prototype.show;AddingList.prototype.hide=ListBase.prototype.hide;function LoadingList(id){this.id=id;this.list=new XList(id,List.LIST_TYPE_LOADING);this.list.init();this.list.setTableKlass("xtable_loading");this.type="loading";this.list.parent=this;this.list.setHoverable(false);}
LoadingList.prototype.init=function(){var entry=[_T("INTERFACE_TASKS_LIST_DETAILS_LOADING"),"busy"];this.list.clear();this.list.conditionalAddOrReplaceEntry(entry);this.list.tableBlitRows();};LoadingList.prototype.show=function(){this.list.show();this.shownAt=new Date().getTime();};LoadingList.prototype.hide=function(){this.list.hide();this.hideAt=new Date().getTime();if(this.hideAt&&this.shownAt){}};LoadingList.prototype.showLoadingMessage=function(){this.list.table.className="xtable";this.list.table.cellSpacing="0";this.list.table.cellPadding="0";this.init();};function GroupList(id){this.id=id;this.list=new List(id,List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK);this.list.init();this.list.setEmptyMessage(_T("INTERFACE_CONTACTS_GROUPS_NO_GROUPS"));this.list.setSortParameters(stateMgr.groups,["name.toLowerCase()"],[List.LIST_SORT_ASC]);this.type="group";this.list.parent=this;}
GroupList.prototype.addGroup=function(group){var groupInfo=[group.id,unescape(group.name).escapeForXML()];this.list.conditionalAddOrReplaceEntry(groupInfo);};GroupList.prototype.show=ListBase.prototype.show;GroupList.prototype.hide=ListBase.prototype.hide;function ContactList(id){this.id=id;this.list=new List(id,List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK);this.list.init();this.list.setEmptyMessage(_T("INTERFACE_CONTACTS_NO_CONTACTS"));this.list.setSortParameters(stateMgr.contacts,["firstname.toLowerCase()","lastname.toLowerCase()"],[List.LIST_SORT_ASC,List.LIST_SORT_ASC]);this.type="contact";this.list.parent=this;}
ContactList.prototype.addContact=function(contact){var contactInfo=[contact.id,unescape(contact.firstname+" "+contact.lastname).escapeForXML()];return this.list.conditionalAddOrReplaceEntry(contactInfo);};ContactList.prototype.show=ListBase.prototype.show;ContactList.prototype.hide=ListBase.prototype.hide;function ListList(id){this.id=id;this.list=new List(id,List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE);this.list.init();this.list.setEmptyMessage(_T("INTERFACE_SETTINGS_LISTS_NO_LISTS"));this.list.setSortParameters(stateMgr.lists,["position","name.toLowerCase()"],[List.LIST_SORT_ASC,List.LIST_SORT_ASC]);this.type="list";this.list.parent=this;this.mbn="rtm.listslist.";}
ListList.prototype.show=ListBase.prototype.show;ListList.prototype.hide=ListBase.prototype.hide;ListList.prototype.addList=function(list){var image=null;if(list.id===configurationMgr.configuration.defaultList){image="list_default";}else{if(list.locked){image="list_locked";}else{if(list.queued){image="list_pending";}else{if(list.filter!==null){image="list_smart";}}}}
var lc_name=list.name.toLowerCase();if(lc_name=="inbox"){list.name=_T("INTERFACE_TASKS_INBOX");}
if(lc_name=="sent"){list.name=_T("INTERFACE_TASKS_SENT");}
var listInfo=[list.id,unescape(list.name).escapeForXML(),image];this.list.conditionalAddOrReplaceEntry(listInfo);};ListList.prototype.doStyles=function(){for(var i=0;i<this.list.entries.length;i++){var list=stateMgr.lists[this.list.entries[i][0]];if(list){if(list.archived){this.setListArchived(list.id);}else{this.setListClear(list.id);}}}};ListList.prototype.setListArchived=function(id){var pos=this.list.map[id];var row=this.list.table.rows[pos];row.rowText.style.fontStyle="italic";};ListList.prototype.addListTab=function(entry,id){if(stateMgr.lists[id].filter!==null){listTabs.addEntry(entry,[TasksView.LIST_TYPE_SMART,id,stateMgr.lists[id].filter]);}else{listTabs.addEntry(entry,[TasksView.LIST_TYPE_NORMAL,id]);}
listTabs.sort();listTabs.blitDiv();};ListList.prototype.removeListTab=function(id){listTabs.removeEntryByData(id);listTabs.sort();listTabs.blitDiv();};ListList.prototype.setListClear=function(id){var pos=this.list.map[id];var row=this.list.table.rows[pos];row.rowText.style.fontStyle="normal";};ListList.prototype.listUpdateName=function(id,newname){var pos=this.list.map[id];var list=stateMgr.lists[id];list.name=newname;this.list.entries[pos][1]=unescape(newname).escapeForXML();this.list.updateEntry(this.list.entries[pos],true);this.list.sort();listTabs.renameEntry(id,newname);};ListList.prototype.listUpdateDefault=function(id,makeDefault){var pos=this.list.map[id];if(makeDefault){this.list.entries[pos][2]="list_default";}else{if(is(stateMgr.lists[id])&&stateMgr.lists[id].filter!==null){this.list.entries[pos][2]="list_smart";}else{this.list.entries[pos][2]=null;}}
this.list.updateEntry(this.list.entries[pos],true);this.list.sort();};function OverviewList(overviewId){this.overviewId=overviewId;this.list=new XList(overviewId,List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE);this.list.init();this.list.setEmptyMessage(_T("INTERFACE_OVERVIEW_NO_TASKS_DUE_TODAY"));this.list.setMultiSelectable(false);this.list.setSortParameters(stateMgr.tasks,["priority.charAt(1)","date_due","name.toLowerCase()"],[List.LIST_SORT_ASC,List.LIST_SORT_ASC,List.LIST_SORT_ASC]);this.mbn=null;this.drawn=null;this.list.parent=this;this.views=[];this.currentView=0;this.filterObj=null;}
OverviewList.prototype.update=function(){if(this.filterObj===null){return this.updateForFilter(this.views[0][1],0);}else{return this.refresh();}};OverviewList.prototype.addView=function(view){this.views.push(view);overviewTabs.addEntry(view[0],view[1]);overviewView.addState(view[0],[overviewList],null,overviewTabs);overviewTabs.blitDiv();};OverviewList.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();var self=this;var doTriage=function(x,data){self.doTriage(data);};messageBus.subscribe(doTriage,dateTimeMgr.mbn+"chime");};OverviewList.prototype.getUniqueMessageBusName=function(){return"rtm.overviewlist.";};OverviewList.prototype.doTriage=function(data){var now=new Date();var hours=now.getHours();var minutes=now.getMinutes();if(hours==0&&minutes==0){this.refresh();locationMgr.redrawWhenNeeded();}};OverviewList.prototype.clear=function(){this.list.clear();};OverviewList.prototype.show=function(){this.list.show();};OverviewList.prototype.hide=function(){this.list.hide();};OverviewList.prototype.switchView=function(newView){this.view=newView;this.show();messageBus.broadcast(this,this.mbn+"viewChanged",this.view);};OverviewList.prototype.getViewList=function(){return this.list;};OverviewList.prototype.removeTask=function(id){this.list.removeEntry(id);};OverviewList.prototype.addTask=function(task){var taskInfo;var today=true;if(this.currentView!==2){taskInfo=[task.id,task.priority.charAt(1),unescape(task.name).escapeForXML(),(task.date_due&&task.time_due?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.hmm_a,task.date_due):null)];}else{taskInfo=[task.id,task.priority.charAt(1),unescape(task.name).escapeForXML(),(task.date_due?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.list_date,task.date_due):null)];}
this.list.conditionalAddOrReplaceEntry(taskInfo);return today;};OverviewList.prototype.setAdvise=function(advise){this.list.setAdvise(advise);};OverviewList.prototype.blit=function(){this.list.tableBlitRows();};OverviewList.prototype.prune=function(){this.list.prune();};OverviewList.prototype.sortAndBlit=function(){this.list.sortAndBlit();};OverviewList.prototype.sort=function(){this.list.sort();};OverviewList.prototype.getFilteredList=function(s){var l=new Sexp(s);this.filterObj=new Filter(stateMgr.tasks,filterMap,l.sexpr,"name");this.filterObj.setImplicitFilter(_includeArchived);dateTimeMgr.setCache(true);var results=this.filterObj.reduce();dateTimeMgr.setCache(false);return results;};OverviewList.prototype.taskBelongs=function(id){return this.filterObj.isMember(id);};OverviewList.prototype.taskPresent=function(id){return is(this.list.map[id]);};OverviewList.prototype.taskUpdateDueDate=function(id,dontSort){if(this.taskPresent(id)===false){return false;}
var pos=this.list.map[id];var task=stateMgr.tasks[id];this.list.entries[pos][3]=(task.date_due&&task.time_due?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.hmm_a,task.date_due):null);this.list.updateEntry(this.list.entries[pos],true);if(!!dontSort!==true){this.list.sort();}
return true;};OverviewList.prototype.updateForFilter=function(f,id){if(this.drawn===f){return false;}
this.currentView=id;this.list.setEmptyMessage(this.views[id][2]);this.clear();this.setAdvise(true);var tasks=this.getFilteredList(f);for(var i=0;i<tasks.length;i++){this.addTask(stateMgr.tasks[tasks[i]]);}
this.setAdvise(false);this.sortAndBlit();this.prune();this.drawn=f;};OverviewList.prototype.refresh=function(){var currentFilter=this.drawn;var currentId=this.currentView;this.drawn=null;this.updateForFilter(currentFilter,currentId);};OverviewList.prototype.removeTask=function(id){if(is(this.list.map[id])){this.list.removeEntry(id);}};OverviewList.prototype.setTaskOverdue=function(row){row.rowText.style.fontWeight="bold";row.rowText.style.textDecoration="underline";};function TaskList(id,completedid){this.id=id;this.completedid=completedid;this.list=new XList(id,List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK);this.completedList=new XList(completedid,List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK);this.list.init();this.completedList.init();this.completedList.setPrioState(List.LIST_PRIO_COMPLETED);this.list.setEmptyMessage(_T("INTERFACE_TASKS_NO_INCOMPLETE"));this.completedList.setEmptyMessage(_T("INTERFACE_TASKS_NO_COMPLETED"));this.list.setSortParameters(stateMgr.tasks,["priority.charAt(1)","date_due","name.toLowerCase()","id"],[List.LIST_SORT_ASC,List.LIST_SORT_ASC,List.LIST_SORT_ASC,List.LIST_SORT_ASC]);this.completedList.setSortParameters(stateMgr.tasks,["date_completed * -1","priority.charAt(1)","name.toLowerCase()","id"],[List.LIST_SORT_ASC,List.LIST_SORT_ASC,List.LIST_SORT_ASC,List.LIST_SORT_ASC]);this.view=TaskList.TASK_LIST_VIEW_INCOMPLETE;this.mbn=null;this.type="task";this.list.parent=this;this.completedList.parent=this;this.loadTimeout=null;}
TaskList.TASK_LIST_VIEW_INCOMPLETE=0;TaskList.TASK_LIST_VIEW_COMPLETED=1;TaskList.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();this.view=TaskList.TASK_LIST_VIEW_INCOMPLETE;var self=this;var doDues=function(x,data){self.doDues(data);};messageBus.subscribe(doDues,dateTimeMgr.mbn+"chime");};TaskList.prototype.setLoadTimeout=function(timeout){this.loadTimeout=timeout;};TaskList.prototype.clearLoadTimeout=function(){clearTimeout(this.loadTimeout);};TaskList.prototype.getUniqueMessageBusName=function(){return"rtm.tasklists."+this.id+".";};TaskList.prototype.clear=function(){this.list.clear();this.completedList.clear();};TaskList.prototype.show=function(){if(view.getSelected()=="Tasks"){if(this.view==TaskList.TASK_LIST_VIEW_INCOMPLETE){this.completedList.hide();this.list.show();}else{this.list.hide();this.completedList.show();}}else{this.hide();}};TaskList.prototype.hide=function(){this.list.hide();this.completedList.hide();};TaskList.prototype.switchView=function(newView){this.view=newView;if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED&&this.completedList.rows.length!==this.completedList.entries.length){this.completedList.prune();this.completedList.sortAndBlit();}
this.show();messageBus.broadcast(this,this.mbn+"viewChanged",this.view);};TaskList.prototype.getViewList=function(){if(this.view==TaskList.TASK_LIST_VIEW_INCOMPLETE){return this.list;}else{return this.completedList;}};TaskList.prototype.getTaskList=function(id){if(is(this.list.map[id])){return this.list;}else{if(is(this.completedList.map[id])){return this.completedList;}else{return null;}}};TaskList.prototype.doDues=function(self){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){for(var i=0;i<this.completedList.table.rows.length;i++){this.setTaskClear(this.completedList.table.rows[i]);}
return;}
var tuple=dateTimeMgr.getTimeTuple();var nt=tuple[0];var tt=tuple[1];var mt=tuple[2];var ct=tuple[3];for(var i=0;i<this.list.table.rows.length;i++){this.doDueForRow(i,nt,tt,mt,ct);}};TaskList.TASK_LIST_STATUS_CLEAR=0;TaskList.TASK_LIST_STATUS_TODAY=1;TaskList.TASK_LIST_STATUS_TOMORROW=2;TaskList.TASK_LIST_STATUS_OVERDUE=3;TaskList.prototype.checkTaskStatus=function(t,tt,mt,ct){if(t.date_due==null){return TaskList.TASK_LIST_STATUS_CLEAR;}
var dt=t.date_due;if(dt<tt){return TaskList.TASK_LIST_STATUS_OVERDUE;}
if(dt>=tt&&dt<mt){return TaskList.TASK_LIST_STATUS_TODAY;}
if(dt>=mt&&dt<ct){return TaskList.TASK_LIST_STATUS_TOMORROW;}
return TaskList.TASK_LIST_STATUS_CLEAR;};TaskList.prototype.doDueForRow=function(i,now,today,tomorrow,clearDate){var t=stateMgr.tasks[this.list.reverseMap[i]];if(!t){return null;}
var tuple=this.taskTimeStatus(t,now,today,tomorrow,clearDate);var tclear=tuple[0];var ttoday=tuple[1];var ttomorrow=tuple[2];var toverdue=tuple[3];var ttimeoverdue=tuple[4];if(tclear){this.setTaskClear(this.list.table.rows[i]);}else{if(ttoday){this.setTaskDueToday(this.list.table.rows[i]);}else{if(ttomorrow){this.setTaskClear(this.list.table.rows[i]);}else{if(toverdue){this.setTaskOverdue(this.list.table.rows[i]);}}}}
if(ttimeoverdue){this.setTaskOverdue(this.list.table.rows[i]);}};TaskList.prototype.taskTimeStatus=function(t,now,today,tomorrow,clearDate){if(!t){return null;}
t.duetoday=false;t.duetomorrow=false;t.overdue=false;var retTuple=new Array(5);switch(this.checkTaskStatus(t,today,tomorrow,clearDate)){case TaskList.TASK_LIST_STATUS_CLEAR:retTuple[0]=true;break;case TaskList.TASK_LIST_STATUS_TODAY:retTuple[1]=true;t.duetoday=true;break;case TaskList.TASK_LIST_STATUS_TOMORROW:retTuple[2]=true;t.duetomorrow=true;break;case TaskList.TASK_LIST_STATUS_OVERDUE:retTuple[3]=true;t.overdue=true;break;}
if(t.time_due&&this.checkTaskStatus(t,now,tomorrow,clearDate)==TaskList.TASK_LIST_STATUS_OVERDUE){retTuple[4]=true;t.overdue=true;}
return retTuple;};TaskList.prototype.doDueForRowScratch=function(i){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){this.setTaskClear(this.list.table.rows[i]);return;}
var tuple=dateTimeMgr.getTimeTuple();var nt=tuple[0];var tt=tuple[1];var mt=tuple[2];var ct=tuple[3];this.doDueForRow(i,nt,tt,mt,ct);};TaskList.prototype.setAdvise=function(advise){this.list.setAdvise(advise);this.completedList.setAdvise(advise);};TaskList.prototype.blit=function(){this.list.tableBlitRows();this.completedList.tableBlitRows();};TaskList.prototype.prune=function(){this.list.prune();this.completedList.prune();};TaskList.prototype.sort=function(){this.list.sort();this.completedList.sort();};TaskList.prototype.addTask=function(task){var taskInfo=null;if(task.date_completed==null){taskInfo=[task.id,task.priority.charAt(1),unescape(task.name).escapeForXML(),(task.date_due?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.list_date,task.date_due):null)];this.list.conditionalAddOrReplaceEntry(taskInfo);}else{taskInfo=[task.id,task.priority.charAt(1),unescape(task.name).escapeForXML(),(task.date_completed?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.list_date,task.date_completed):null)];this.completedList.conditionalAddOrReplaceEntry(taskInfo);}};TaskList.prototype.taskUpdateDueDate=function(id,duedate,duetime,dontSort){var pos=taskList.list.map[id];var task=stateMgr.tasks[id];task.date_due=duedate;task.time_due=duetime;this.list.entries[pos][3]=duedate?dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.list_date,duedate):null;this.list.updateEntry(this.list.entries[pos],true);if(!!dontSort!==true){this.list.sort();}};TaskList.prototype.getTasksForTaskSeries=function(taskSeriesId){var ids=[];for(var id in stateMgr.tasks){if(is(stateMgr.tasks[id])&&stateMgr.tasks[id].series_id===taskSeriesId){ids.push(id);}}
return ids;};TaskList.prototype.taskUpdateName=function(taskSeriesId,newname){var ids=this.getTasksForTaskSeries(taskSeriesId);var sortOverview=false;var sortCompleted=false;for(var i=0;i<ids.length;i++){var id=ids[i];var L=taskList.getTaskList(id);var pos=L.map[id];var task=stateMgr.tasks[id];if(!is(pos)){continue;}
if(L==taskList.completedList){sortCompleted=true;}
task.name=newname;L.entries[pos][2]=unescape(newname).escapeForXML();L.updateEntry(L.entries[pos],true);if(overviewList.taskPresent(id)){var oPos=overviewList.list.map[id];sortOverview=true;overviewList.list.entries[oPos][2]=unescape(newname).escapeForXML();overviewList.list.updateEntry(overviewList.list.entries[oPos],true);}}
this.list.sort();if(sortCompleted){this.completedList.sort();}
if(sortOverview){overviewList.sort();}};TaskList.prototype.setTaskClear=function(row){row.rowText.style.fontWeight="normal";row.rowText.style.textDecoration="none";};TaskList.prototype.setTaskDueToday=function(row){row.rowText.style.fontWeight="bold";row.rowText.style.textDecoration="none";};TaskList.prototype.setTaskOverdue=function(row){row.rowText.style.fontWeight="bold";row.rowText.style.textDecoration="underline";};TaskList.prototype.taskSelectAll=function(shiftHeld){var list=this.getViewList();if(!shiftHeld){list.selectNone();}
list.selectAll();};TaskList.prototype.taskSelectDueToday=function(shiftHeld){var list=this.getViewList();if(!shiftHeld){list.selectNone();}
var toSelect={};for(var i=0;i<list.entries.length;i++){var id=list.entries[i][0];if(stateMgr.tasks[id].completed==false&&stateMgr.tasks[id].duetoday){toSelect[i]=true;}}
list.selectSome(toSelect);};TaskList.prototype.taskSelectDueTomorrow=function(shiftHeld){var list=this.getViewList();if(!shiftHeld){list.selectNone();}
var toSelect={};for(var i=0;i<list.entries.length;i++){var id=list.entries[i][0];if(stateMgr.tasks[id].completed==false&&stateMgr.tasks[id].duetomorrow){toSelect[i]=true;}}
list.selectSome(toSelect);};TaskList.prototype.taskSelectOverdue=function(shiftHeld){var list=this.getViewList();if(!shiftHeld){list.selectNone();}
var toSelect={};for(var i=0;i<list.entries.length;i++){var id=list.entries[i][0];if(stateMgr.tasks[id].completed==false&&stateMgr.tasks[id].overdue){toSelect[i]=true;}}
list.selectSome(toSelect);};TaskList.prototype.taskSelectNone=function(shiftHeld){this.getViewList().selectNone();};TaskList.prototype.taskGetPriorityDown=function(oldPrio){if(oldPrio=="N"){return oldPrio;}
if(oldPrio=="3"){return"N";}
return((oldPrio-0)+1);};TaskList.prototype.taskGetPriorityUp=function(oldPrio){if(oldPrio=="1"){return oldPrio;}
if(oldPrio=="N"){return"3";}
return((oldPrio-0)-1);};TaskList.prototype.tasksSetPriority=function(entries,newPrio){var e=entries.length;var direction=false;if(newPrio=="U"||newPrio=="D"){direction=true;}else{p=newPrio;}
var changed=[];var iters=0;var seenSeries={};for(var i=0;i<e;i++){var id=entries[i];if(is(seenSeries[stateMgr.tasks[id].series_id])){continue;}else{seenSeries[stateMgr.tasks[id].series_id]=id;}
var pos=taskList.list.map[id];var entry=taskList.list.entries[pos];iters++;var oldPrio=entry[1];if(direction){p=newPrio=="U"?this.taskGetPriorityUp(oldPrio):this.taskGetPriorityDown(oldPrio);}
if(p!=oldPrio){entry[1]=p;stateMgr.tasks[id].priority="P"+p;changed.push(entry);}}
for(var id in seenSeries){var task=seenSeries[id];var tasks=this.getTasksForTaskSeries(id);var p=stateMgr.tasks[task].priority.charAt(1);for(var i=0;i<tasks.length;i++){var id=tasks[i];var L=this.getTaskList(id);if(!L||(id==task)){continue;}
var pos=L.map[id];var entry=L.entries[pos];entry[1]=p;stateMgr.tasks[id].priority="P"+p;changed.push(entry);}}
var sortOverview=false;for(var i=0;i<changed.length;i++){var L=this.getTaskList(changed[i][0]);L.updateEntry(changed[i],true);if(is(overviewList.list.map[changed[i][0]])){var oPos=overviewList.list.map[changed[i][0]];overviewList.list.entries[oPos][1]=changed[i][1];overviewList.list.updateEntry(overviewList.list.entries[oPos],true);sortOverview=true;}}
taskList.sort();if(sortOverview){overviewList.sort();}
return changed.length;};TaskList.prototype.tasksSetPriority1=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var setPriority1Func=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(setPriority1Func,"tasks.setPriority1","1");};TaskList.prototype.tasksSetPriority2=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var setPriority2Func=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(setPriority2Func,"tasks.setPriority2","2");};TaskList.prototype.tasksSetPriority3=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var setPriority3Func=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(setPriority3Func,"tasks.setPriority3","3");};TaskList.prototype.tasksSetPriorityNone=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var setPriorityNoneFunc=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(setPriorityNoneFunc,"tasks.setPriorityNone","N");};TaskList.prototype.tasksMovePriorityUp=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var movePriorityUpFunc=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(movePriorityUpFunc,"tasks.movePriorityUp","U");};TaskList.prototype.tasksMovePriorityDown=function(){if(this.view==TaskList.TASK_LIST_VIEW_COMPLETED){return false;}
var self=this;var movePriorityDownFunc=function(rows,newPrio){return self.tasksSetPriority(rows,newPrio);};transMgr.executeTxn(movePriorityDownFunc,"tasks.movePriorityDown","D");};TaskList.prototype.removeTask=function(id){if(is(this.list.map[id])){this.list.removeEntry(id);}else{if(is(this.completedList.map[id])){this.completedList.removeEntry(id);}}
stateMgr.workingSet.spliceAll(id);};function LocationList(id){this.id=id;this.list=new List(id,List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE);this.list.init();this.list.setEmptyMessage(_T("INTERFACE_SETTINGS_LOCATIONS_NO_LOCATIONS"));this.list.setSortParameters(locationMgr.data,["name.toLowerCase()"],[List.LIST_SORT_ASC]);this.type="location";this.list.parent=this;}
LocationList.prototype.show=ListBase.prototype.show;LocationList.prototype.hide=ListBase.prototype.hide;LocationList.prototype.addLocation=function(loc){var image=null;if(is(configurationMgr.configuration.defaultLocation)&&loc.id===configurationMgr.configuration.defaultLocation){image="list_default";}
var locationInfo=[loc.id,unescape(loc.name).escapeForXML(),image];this.list.conditionalAddOrReplaceEntry(locationInfo);};LocationList.prototype.locationUpdateName=function(id,newname){var pos=this.list.map[id];var loc=locationMgr.locations_[id];loc.name=newname;this.list.entries[pos][1]=unescape(newname).escapeForXML();this.list.updateEntry(this.list.entries[pos],true);this.list.sort();};LocationList.prototype.listUpdateDefault=function(id,makeDefault){var pos=this.list.map[id];if(makeDefault){this.list.entries[pos][2]="list_default";}else{this.list.entries[pos][2]=null;}
this.list.updateEntry(this.list.entries[pos],true);this.list.sort();};function NoteManager(boxId,notesId){this.boxId=boxId;this.notesId=notesId;if(boxId){this.boxDiv=el(boxId);}
if(notesId){this.notesDiv=el(notesId);}
this.noteTimeStampCache={};this.noteMap={};this.noteHashMap={};this.noteEditRefCount=0;this.index={};this.mbn=null;this.inited=false;this.notesCount=0;this.currentTask=null;this.enabled=true;}
NoteManager.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();this.inited=true;};NoteManager.prototype.getUniqueMessageBusName=function(){return"rtm.notemanager.";};NoteManager.prototype.show=function(){this.boxDiv.style.display="";if(this.enabled&&!view.getPublicMode()){el("addnote").style.display="";el("notetoolbox").style.display="";this.fillNotePrint();}};NoteManager.prototype.fillNotePrint=function(){var task_id=taskList.getViewList().getLastSelectedId();if(!task_id){return false;}
if(!is(stateMgr.tasks[task_id])){return false;}
var list_id=stateMgr.tasks[task_id].list_id;var printnote="/print/"+rtmUsername+"/"+list_id+"/"+task_id+"/notes/";el("printnote").href=printnote;};NoteManager.prototype.hide=function(){this.boxDiv.style.display="none";taskList.list.setHoverable(true);taskList.completedList.setHoverable(true);if(!view.getPublicMode()){el("addnote").style.display="none";el("notetoolbox").style.display="none";}};NoteManager.prototype.incrRef=function(){this.noteEditRefCount++;taskList.list.setHoverable(false);taskList.completedList.setHoverable(false);};NoteManager.prototype.decrRef=function(){if(this.noteEditRefCount>0){this.noteEditRefCount--;}
if(this.noteEditRefCount===0){taskList.list.setHoverable(true);taskList.completedList.setHoverable(true);}};NoteManager.prototype.enable=function(){if(!view.getPublicMode()){el("addnote").style.display="";}
this.enabled=true;};NoteManager.prototype.disable=function(){if(!view.getPublicMode()){el("addnote").style.display="none";}
this.enabled=false;};NoteManager.prototype.splitNoteText=function(text){var title="",content="";var newline=text.indexOf("\n");var period=text.indexOf(".");var pos=newline==-1?(period==-1?null:period+1):(period==-1?newline:(period<newline?newline:(period>newline?newline:period)));var ignore=false;if(newline>-1||period>-1){if((text.charAt(pos)==="."&&text.charAt(pos+1)!==" ")||(text.charAt(pos-1)==="."&&text.charAt(pos)!==" ")&&text.length>pos){if(newline!==-1){pos=newline;}else{title=text;ignore=true;}}
if(ignore===false){title=text.substring(0,pos);content=text.substring(pos,text.length);}}else{title=text;}
if(content.trim().length==0){content=title;title="";}
if(title.length>255){var pos=title.substring(0,253).lastIndexOf(".");if(pos===-1){var excess=title.substring(254,title.length);title=title.substring(0,254);content=excess+content;}else{var excess=title.substring(pos+1,title.length);title=title.substring(0,pos+1);content=excess+content;}}
return[title.trim(),content.trim()];};NoteManager.prototype.formatNoteTimestamp=function(timestamp){return dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.note_date,timestamp);};NoteManager.prototype.formatNoteText=function(text){return text.escapeForDisplay().replaceStr("\r\n","<br />").replaceStr("\n","<br />").autoLink();};NoteManager.prototype.createNote=function(noteId,noteTitle,noteText,noteTime){var noteMgr=this;var noteDiv=document.createElement("div");noteDiv.id="noteEdit_"+noteId;noteDiv.noteId=noteId;noteDiv.className="notexedit";if(noteId!=0){this.noteMap[noteId]=noteDiv;}
var noteTitleDiv=document.createElement("div");var noteTextDiv=document.createElement("div");var noteEditLineDiv=document.createElement("div");var noteEditLineOtherSpan=document.createElement("span");var noteEditBoxDiv=document.createElement("div");var noteEditForm=document.createElement("form");var noteOtherDiv=document.createElement("div");var noteEditLineTimeSpan=document.createElement("span");var noteEditSaveButton=document.createElement("input");var noteEditCancelButton=document.createElement("input");var noteEditTextArea=document.createElement("textarea");noteTitleDiv.className="notextitle";noteTextDiv.className="notextext";noteEditLineTimeSpan.className="notextimestamp";noteTitleDiv.innerHTML=unescape(noteTitle).escapeForDisplay();noteTextDiv.innerHTML=this.formatNoteText(noteText);if(noteTime){noteEditLineTimeSpan.appendChild(document.createTextNode(this.formatNoteTimestamp(noteTime)));}
noteEditLineDiv.appendChild(noteEditLineTimeSpan);var noteEditLinePrivateSpan=document.createElement("span");noteEditLinePrivateSpan.appendChild(document.createTextNode(" | "));var noteEditLineEdit=document.createElement("a");noteEditLineEdit.onclick=function(ev){if(noteOtherDiv.style.display!="none"){noteOtherDiv.style.display="none";}else{noteOtherDiv.style.display="block";}
if(noteEditForm.style.display!="none"){noteEditForm.style.display="none";}else{noteEditForm.style.display="block";}
noteEditTextArea.focus();noteMgr.incrRef();return false;};noteDiv.editLink=noteEditLineEdit;noteEditLineEdit.href=" ";noteEditLineEdit.innerHTML=_T("INTERFACE_TASKS_NOTES_EDIT");noteEditLineEdit.className="notexeditlink";noteEditLinePrivateSpan.appendChild(noteEditLineEdit);noteEditLinePrivateSpan.appendChild(document.createTextNode(" | "));var noteEditLineDelete=document.createElement("a");noteEditLineDelete.onclick=function(ev){var noteDivOld=noteMgr.notesDiv.removeChild(noteDiv);delete noteDivOld;if(noteDiv.noteId!=0){noteMgr.deleteNote(noteDiv.noteId);}
return false;};noteEditLineDelete.href=" ";noteEditLineDelete.innerHTML="<img src=\"http://static.rememberthemilk.com/img/ico/ico_trash.gif\" class=\"deletenote\" alt=\""+_T("INTERFACE_TASKS_NOTES_DELETE")+"\" width=\"11\" height=\"11\" />";noteEditLinePrivateSpan.appendChild(noteEditLineDelete);if(view.getPublicMode()===false&&!tasksView.inSentList()&&this.enabled===true){noteEditLineOtherSpan.appendChild(noteEditLinePrivateSpan);}
noteEditLineDiv.appendChild(noteEditLineOtherSpan);noteEditTextArea.className="noteedittext";noteEditSaveButton.type="submit";noteEditCancelButton.type="submit";noteEditSaveButton.value=_T("INTERFACE_TASKS_NOTES_SAVE_BUTTON");noteEditCancelButton.value=_T("INTERFACE_TASKS_NOTES_CANCEL_BUTTON");noteEditTextArea.onkeydown=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if((pressed===13&&ev.ctrlKey)||(pressed==77&&ev.ctrlKey)){noteEditSaveButton.onclick();return false;}else{if(pressed===27){noteEditCancelButton.onclick();return false;}}
return true;};noteEditSaveButton.onclick=function(ev){if(noteEditTextArea.value.trim().length===0){return noteEditCancelButton.onclick();}
var noteContents=noteMgr.splitNoteText(noteEditTextArea.value);if(noteDiv.noteId==0){var noteHash=hex_sha1(utility.getRandomInt(376006)+noteContents[0]+noteContents[1]);noteDiv.noteHash=noteHash;noteMgr.noteHashMap[noteHash]=noteDiv;transMgr.request("notes.add",utility.encodeJavaScript({"task":control.taskSeriesMap([taskList.getViewList().getLastSelectedId()]),"title":noteContents[0],"content":noteContents[1],"hash":noteHash}));}else{transMgr.request("notes.edit",utility.encodeJavaScript({"task":control.taskSeriesMap([taskList.getViewList().getLastSelectedId()]),"note":noteDiv.noteId,"title":noteContents[0],"content":noteContents[1]}));}
noteEditLineOtherSpan.style.display="none";noteEditLineTimeSpan.innerHTML=_T("INTERFACE_TASKS_NOTES_SAVING_NOTE");noteTitleDiv.innerHTML=unescape(noteContents[0]).escapeForDisplay();noteTextDiv.innerHTML=noteMgr.formatNoteText(noteContents[1]);if(noteOtherDiv.style.display!="none"){noteOtherDiv.style.display="none";}else{noteOtherDiv.style.display="block";}
if(noteEditForm.style.display!="none"){noteEditForm.style.display="none";}else{noteEditForm.style.display="block";}
noteMgr.decrRef();return false;};noteEditCancelButton.onclick=function(ev){noteMgr.decrRef();if(noteDiv.noteId==0){noteEditLineDelete.onclick();return false;}
if(noteOtherDiv.style.display!="none"){noteOtherDiv.style.display="none";}else{noteOtherDiv.style.display="block";}
if(noteEditForm.style.display!="none"){noteEditForm.style.display="none";}else{noteEditForm.style.display="block";}
return false;};noteDiv.onaddnote=function(noteId){var note=stateMgr.notes[noteId];var noteTime=note.date_last_modified;this.id="noteEdit_"+noteId;this.noteId=noteId;noteMgr.noteMap[noteId]=this;var noteContents=noteMgr.splitNoteText(noteEditTextArea.value);noteTitleDiv.innerHTML=noteContents[0];noteTextDiv.innerHTML=noteMgr.formatNoteText(noteContents[1]);noteEditLineTimeSpan.innerHTML=noteMgr.formatNoteTimestamp(noteTime);noteEditLineOtherSpan.style.display="inline";};noteDiv.onupdatenote=function(){var note=stateMgr.notes[this.noteId];var noteTime=note.date_last_modified;var noteContents=noteMgr.splitNoteText(noteEditTextArea.value);noteTitleDiv.innerHTML=noteContents[0];noteTextDiv.innerHTML=noteMgr.formatNoteText(noteContents[1]);noteEditLineTimeSpan.innerHTML=noteMgr.formatNoteTimestamp(noteTime);noteEditLineOtherSpan.style.display="inline";};noteDiv.ondeletenote=function(noteId){};noteEditForm.id="noteeditform_"+noteId;noteEditTextArea.id="noteedittext_"+noteId;noteEditSaveButton.id="noteeditsavebutton_"+noteId;noteEditCancelButton.id="noteeditcancelbutton_"+noteId;noteEditForm.style.display="none";noteEditTextArea.value=(noteId==0||(noteTitle.trim().length==0&&noteText.trim().length==0))?"":noteTitle+"\n\n"+noteText+"\n";noteEditForm.appendChild(noteEditTextArea);var buttonDiv=document.createElement("div");buttonDiv.className="noteeditbutton";buttonDiv.style.clear="both";noteEditSaveButton.style.display="inline";noteEditSaveButton.style.marginRight="1px";noteEditCancelButton.style.display="inline";buttonDiv.appendChild(noteEditSaveButton);buttonDiv.appendChild(noteEditCancelButton);noteEditForm.appendChild(buttonDiv);noteOtherDiv.appendChild(noteTitleDiv);noteOtherDiv.appendChild(noteTextDiv);noteOtherDiv.appendChild(noteEditLineDiv);noteDiv.appendChild(noteOtherDiv);noteDiv.appendChild(noteEditForm);return noteDiv;};NoteManager.prototype.appendNote=function(noteId,noteTitle,noteText,noteDate){var noteDiv=this.createNote(noteId,noteTitle,noteText,noteDate);this.notesDiv.appendChild(noteDiv);this.notesCount++;return noteDiv;};NoteManager.prototype.prependNote=function(noteId,noteTitle,noteText,noteDate){var noteDiv=this.createNote(noteId,noteTitle,noteText,noteDate);var firstChild=this.notesDiv.getElementsByTagName("div")[0];if(firstChild==null){this.notesDiv.appendChild(noteDiv);}else{this.notesDiv.insertBefore(noteDiv,firstChild);}
this.notesCount++;return noteDiv;};NoteManager.prototype.createNewNote=function(){var noteDiv=this.prependNote(0,"","",null);noteDiv.editLink.onclick();};NoteManager.prototype.deleteNote=function(noteId){transMgr.request("notes.delete",utility.encodeJavaScript({"task":control.taskSeriesMap([taskList.getViewList().getLastSelectedId()]),"note":noteId}));stateMgr.notes[noteId].date_deleted=(new Date().getTime())/1000;messageBus.broadcast(this,this.mbn+"noteDeleted",noteId);format.formatNoteCount(this.currentTask);};NoteManager.prototype.completeNewNote=function(id,h){var note=this.noteHashMap[h];if(note){note.onaddnote(id);messageBus.broadcast(this,this.mbn+"noteAdded",id);}else{note=this.noteMap[id];note.onupdatenote();messageBus.broadcast(this,this.mbn+"noteUpdated",id);}
format.formatNoteCount(stateMgr.notes[id].task_series_id);};NoteManager.prototype.undeleteNote=function(noteId){stateMgr.notes[noteId].date_deleted=null;this.fillNotes(this.currentTask);};NoteManager.prototype.taskAddNote=function(a){this.appendNote(a.id,a.title,a.content,a.date_last_modified);};NoteManager.prototype.clearNotes=function(){this.notesDiv.innerHTML="";this.notesCount=0;this.currentTask=null;this.noteEditRefCount=0;};NoteManager.prototype.setCurrentTask=function(taskSeriesId){this.currentTask=taskSeriesId;};NoteManager.prototype.getNoteCount=function(id){var noteCount=0;for(var i in stateMgr.notes){var note=stateMgr.notes[i];if(note.task_series_id==id&&note.date_deleted===null){noteCount++;}}
return noteCount;};NoteManager.prototype.sortNotes=function(a,b){var fields=["date_last_modified","title","content"];for(var i=0;i<fields.length;i++){var af=eval("a."+fields[i]);var bf=eval("b."+fields[i]);if(af>bf){return-1;}else{(af<bf);}
return 1;continue;}
return 0;};NoteManager.prototype.fillNotes=function(taskSeriesId,force){this.clearNotes();var noteIds=[];for(var note in stateMgr.notes){if(stateMgr.notes[note].task_series_id==taskSeriesId&&stateMgr.notes[note].date_deleted==null){noteIds.push(stateMgr.notes[note]);}}
if(noteIds.length>0){noteIds.sort(this.sortNotes);for(var i=0;i<noteIds.length;i++){this.taskAddNote(noteIds[i]);}}};NoteManager.prototype.prepareIndex=function(){this.index={};for(var i in stateMgr.notes){var note=stateMgr.notes[i];if(note.date_deleted===null){if(!is(this.index[note.task_series_id])){this.index[note.task_series_id]=[];}
this.index[note.task_series_id].push(i);}}};NoteManager.prototype.showMultiEditMessage=function(){this.clearNotes();this.disable();this.notesDiv.innerHTML=_T("INTERFACE_TASKS_NOTES_MULTIEDIT");};function RadioGroup(name){this.radios=[];this.inited=false;this.names=[];this.selected=null;this.defaultRadio=null;this.name=name;this.mbn="rtm.radiogroups."+name+".";}
RadioGroup.prototype.init=function(){this.inited=true;};RadioGroup.prototype.addRadio=function(name,radio){radio=el(radio);this.radios.push(radio);this.names.push(name);eval("this."+name+" = radio");var self=this;radio.pos=this.radios.length-1;radio.onclick=function(ev){messageBus.broadcast(self,self.mbn+"radioSelected",this.pos);};var selFunc=function(x,y){self.handleRadioChecked(x,y);};messageBus.subscribe(selFunc,this.mbn+"radioSelected");};RadioGroup.prototype.select=function(pos,defaultRadio){this.radios[pos].checked=true;this.selected=pos;if(defaultRadio){this.defaultRadio=pos;}
this.radios[pos].onclick();};RadioGroup.prototype.enable=function(){for(var i=0;i<this.radios.length;i++){this.radios[i].disabled=false;}};RadioGroup.prototype.disable=function(){for(var i=0;i<this.radios.length;i++){this.radios[i].disabled=true;}};RadioGroup.prototype.handleRadioChecked=function(who,i){this.selected=i;};function Label(labelId,inputId){this.labelId=labelId;this.label=el(labelId);this.inputId=inputId;this.input=el(inputId);if(is_safari){var self=this;this.label.onclick=function(){if(self.input.type=="radio"||self.input.type=="checkbox"){self.input.checked=!self.input.checked;if(self.input.onclick){self.input.onclick();}}else{if(self.input.type=="text"||self.input.type=="password"){self.input.focus();}}};}}
function ReoccurrenceManager(){}
ReoccurrenceManager.prototype.convertReoccurrenceSpecDesc=function(values){var count=values["INTERVAL"]?values["INTERVAL"]:1;var type;switch(values["FREQ"]){case"DAILY":if(count==1){return _T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_ONE_DAY");}else{return _T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE_NUM_DAYS",{"NUM":count});}
break;case"WEEKLY":if(count==1){return _T("INTERFACE_DF_1_WEEK");}else{return _T("INTERFACE_DF_NUM_WEEKS",{"NUM":count});}
break;case"MONTHLY":if(count==1){return _T("INTERFACE_DF_1_MONTH");}else{return _T("INTERFACE_DF_NUM_MONTHS",{"NUM":count});}
break;case"YEARLY":if(count==1){return _T("INTERFACE_DF_1_YEAR");}else{return _T("INTERFACE_DF_NUM_YEARS",{"NUM":count});}
break;}};ReoccurrenceManager.prototype.convertReoccurrenceWeeklyDesc=function(values){var count=values["INTERVAL"]?values["INTERVAL"]:1;var days=values["BYDAY"].split(",");var daysOut=[];for(var i=0;i<days.length;i++){daysOut.push(Intl.day_wide[Date.ICALDays[days[i]]]);}
if(count!=1){count=utility.suffixize(count)+" ";}else{count="";if(daysOut.length==5){var seen=0;for(var i=0;i<days.length;i++){if(seen==5){break;}
switch(days[i]){case"MO":case"TU":case"WE":case"TH":case"FR":seen++;default:}}
if(seen==5){return _T("INTERFACE_DF_WEEKDAY");}}}
if(rtmLanguage=="zh-TW"||rtmLanguage=="zh-CN"||rtmLanguage=="ja"){return count+daysOut.join(this.getDayJoin());}
return count+daysOut.join(", ");};ReoccurrenceManager.prototype.convertReoccurrenceDayOfMonthDesc=function(values){var count=1;var days=values["BYDAY"].split(",");var daysOut=[];for(var i=0;i<days.length;i++){if(days[i].charAt(0)=="-"){count=days[i].substring(0,2)*1;days[i]=days[i].substring(2);}else{count=days[i].substring(0,1)*1;days[i]=days[i].substring(1);}
daysOut.push(Intl.day_wide[Date.ICALDays[days[i]]]);}
if(count<0){if(count==-1){count="last ";}else{count=utility.suffixize(count*-1)+" last ";}}else{count=utility.suffixize(count)+" ";}
if(rtmLanguage=="zh-TW"||rtmLanguage=="zh-CN"||rtmLanguage=="ja"){return count+daysOut.join(this.getDayJoin())+" of the month";}
return"month on the "+count+daysOut.join(", ");};ReoccurrenceManager.RE_DAYJOIN=new RegExp("{DAY_NAME}","g");ReoccurrenceManager.prototype.getDayJoin=function(){var j=_T("INTERFACE_DF_DAY_NAME_AND_DAY_NAME");j=j.replace(ReoccurrenceManager.RE_DAYJOIN,"").trim();return j;};ReoccurrenceManager.prototype.convertReoccurrenceMonthlyDesc=function(values){var count=values["BYMONTHDAY"];return"month on the "+utility.suffixize(count);};ReoccurrenceManager.prototype.convertReoccurrenceDesc=function(rrule,field){var s=rrule[0];var when=rrule[1];var text;var parts=s.split(";");var values={};for(var i=0;i<parts.length;i++){var kv=parts[i].split("=");values[kv[0]]=kv[1];}
if(is(values["BYDAY"])){if(values["FREQ"]=="MONTHLY"){text=this.convertReoccurrenceDayOfMonthDesc(values);}else{text=this.convertReoccurrenceWeeklyDesc(values);}}else{if(is(values["BYMONTHDAY"])){text=this.convertReoccurrenceMonthlyDesc(values);}else{text=this.convertReoccurrenceSpecDesc(values);}}
if(when){if(is(values["COUNT"])){return _T("INTERFACE_DF_EVERY_DAY_NAME_FOR_NUM_TIMES",{"DAY_NAME":text,"NUM":values["COUNT"]});}else{if(is(values["UNTIL"])){return _T("INTERFACE_DF_EVERY_DAY_NAME_UNTIL_DATE",{"DAY_NAME":text,"DATE":this.formatUntil(values["UNTIL"],!!field)});}else{return _T("INTERFACE_DF_EVERY_INTERVAL",{"INTERVAL":text});}}}else{return _T("INTERFACE_DF_AFTER_INTERVAL",{"INTERVAL":text});}};ReoccurrenceManager.prototype.formatUntil=function(until,field){var d=Date.fromISO(until);var has_time=!(d.getHours()===0&&d.getMinutes()===0);if(has_time){if(field){return dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due_time_field,(d.getTime()/1000));}else{return dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due_time,(d.getTime()/1000));}}else{if(field){return dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due_field,(d.getTime()/1000));}else{return dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due,(d.getTime()/1000));}}};ReoccurrenceManager.prototype.parseReoccurrence=function(s){var valid=null;if(s.trim().length==0||s.trim()=="never"){return null;}
s=s.toLowerCase();if(s.indexOf("daily")>-1){s="every day";}else{if(s.indexOf("weekly")>-1){s="every week";}else{if(s.indexOf("monthly")>-1){s="every month";}else{if(s.indexOf("yearly")>-1||s.indexOf("annually")>-1){s="every year";}}}}
s=s.replace(/fortnight/i,"2 weeks");s=s.replace(/week\s?day/i,"mon,tue,wed,thu,fri");s=s.replace(/week\s?end/i,"sat,sun");s=s.replace(/month\s*on\s*the\s*(\S*)$/i,"$1 of the month");s=s.replace(/month\s*on\s*the\s*(.*)/i,"$1 of the month");var yearly=/(every|after)?\s*(([0-9]+)\s*(january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sep|october|oct|november|nov|december|dec)\s*([0-9]*))/i;var monthly=/(every|after)?\s*([0-9]+)(th|st|nd|rd)/i;var weekly=/(every|after)?\s*((first|1st|second|2nd|third|3rd|fourth|4th|other|last|[1-5])?\s*(monday|mon|tuesday|tue|wednesday|wed|thursday|thu|friday|fri|saturday|sat|sunday|sun))/i;var specBased=/(every|after)?\s*((one|two|three|four|five|six|seven|eight|nine|ten|[0-9]+)\s*)?(years|year|yrs|yr|months|month|mons|mon|weeks|week|wks|wk|days|day)/i;var monthByDay=/(every|after)?\s*(first|1st|second|2nd|third|3rd|fourth|4th|fifth|5th|other|last|[1-5])(\s*last)?\s*(monday|mon|tuesday|tue|wednesday|wed|thursday|thu|friday|fri|saturday|sat|sunday|sun)/i;var until=/until\s*(.*)+\s*/;var limit=/for\s*([0-9]+).*/;var raw=s;var eUntil=until.exec(s);var eLimit=limit.exec(s);if(eUntil){s=s.substring(0,s.indexOf(eUntil[0]));eUntil=dateTimeMgr.parseDueDate(eUntil[1]);}else{if(eLimit){s=s.substring(0,s.indexOf(eLimit[0]));eLimit=eLimit[1];}}
var eYearly=yearly.exec(s);var eMonthly=monthly.exec(s);var eWeekly=weekly.exec(s);var eSpecBased=specBased.exec(s);var eDayBased=monthByDay.exec(s);var eType=(s.indexOf("each")>-1||s.indexOf("every")>-1)?true:false;if(eType===false){eLimit=null;eUntil=null;}
var monthSpecified=(s.indexOf("mont")>-1);var ofSpecified=(s.indexOf("of")>-1);if(eMonthly&&eWeekly){if(monthSpecified){eWeekly=null;if(eDayBased){eMonthly=null;}}else{eDayBased=null;eMonthly=null;}}
if(eSpecBased&&eWeekly&&!monthSpecified){eSpecBased=null;}else{if(eSpecBased&&eWeekly&&monthSpecified){eWeekly=null;}}
if(eSpecBased&&eDayBased&&ofSpecified){eSpecBased=null;}else{if(eSpecBased&&eDayBased&&!ofSpecified){eDayBased=null;}}
if(eYearly){valid=["yearly",eYearly,eUntil,eLimit,eType];}else{if(eDayBased){var comps=s.split(/\s*(?:and|\,)\s*/);var as=[];as.push(eDayBased);if(comps.length>1){for(var i=1;i<comps.length;i++){as.push(monthByDay.exec(comps[i]));}}
eDayBased=as;valid=["day_of_month",eDayBased,eUntil,eLimit,eType];}else{if(eMonthly){var comps=s.split(/\s*(?:and|\,)\s*/);var as=[];as.push(eMonthly);if(comps.length>1){for(var i=1;i<comps.length;i++){as.push(monthly.exec(comps[i]));}}
eMonthly=as;valid=["monthly",eMonthly,eUntil,eLimit,eType];}else{if(eWeekly){var comps=s.split(/\s*(?:and|\,)\s*/);var as=[];as.push(eWeekly);if(comps.length>1){for(var i=1;i<comps.length;i++){as.push(weekly.exec(comps[i]));}}
eWeekly=as;valid=["weekly",eWeekly,eUntil,eLimit,eType];}else{if(eSpecBased){var comps=s.split(/\s*(?:and|\,)\s*/);var as=[];as.push(eSpecBased);if(comps.length>1){for(var i=1;i<comps.length;i++){as.push(specBased.exec(comps[i]));}}
eSpecBased=as;valid=["spec",eSpecBased,eUntil,eLimit,eType];}}}}}
if(valid!==null){valid.push(raw);}
return valid;};function StateManager(){this.tasks={};this.groups={};this.contacts={};this.lists={};this.notes={};this.permissions=null;this.mbn="rtm.statemanager.";this.currentList=null;this.currentFilter=null;this.currentType=TasksView.LIST_TYPE_NORMAL;this.filterObj=null;this.workingSet=[];this.tick=0;this.lastLoadThreshold=0;this.reduced=0;}
StateManager.prototype.setCurrentList=function(listId){this.currentList=listId;};StateManager.prototype.setCurrentFilter=function(listFilter){this.currentFilter=listFilter;};StateManager.prototype.setCurrentType=function(listType){this.currentType=listType;};StateManager.prototype.getValidLists=function(){var pairs=[];for(var i=0;i<listTabs.entries.length;i++){var listData=listTabs.data[i];if(listData[0]!=TasksView.LIST_TYPE_NORMAL){continue;}
pairs.push([listData[1],stateMgr.lists[listData[1]].name]);}
return pairs;};function Format(id){}
Format.FORMAT_HELP_LOCATION="/help/answers/";Format.prototype.formatTaskEstimate=function(e){if(e==null){e=_T("INTERFACE_TASKS_TASK_DETAILS_TIME_ESTIMATE_NONE");}else{e=e.trim();if(e.length==0){e=_T("INTERFACE_TASKS_TASK_DETAILS_TIME_ESTIMATE_NONE");}}
tasksView.taskDetails.detailsDuration.setValue(e);};Format.prototype.formatNoteCountTemplate=function(count){var tpl;if(count==0){tpl="INTERFACE_TASKS_TASK_DETAILS_NOTES_COUNT_ZERO";}else{if(count==1){tpl="INTERFACE_TASKS_TASK_DETAILS_NOTES_COUNT_ONE";}else{tpl="INTERFACE_TASKS_TASK_DETAILS_NOTES_COUNT_NUM";}}
tasksView.taskDetails.fieldsTitle.setCount(_T(tpl,{"NUM":count}));};Format.prototype.formatNoteCount=function(id){if(view.getViewToken("Tasks","Notes")){this.formatNoteCountTemplate(noteMgr.getNoteCount(id));tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.blit();}};Format.prototype.getMultiEditFormat=function(ids,field){if(ids.length===0){return fmt("No tasks selected.");}
var initial=stateMgr.tasks[ids[0]][field];var same=true;for(var i=1,j=ids.length;i<j;i++){if(stateMgr.tasks[ids[i]][field]!==initial){same=false;break;}}
return same?initial:[null];};Format.prototype.formatTask=function(id){var r=stateMgr.tasks[id];if(!r){return false;}
helpBox.stopShowing("tasks.publishing");helpBox.stopShowing("tasks.sharing");helpBox.stopShowing("tasks.save");var tasksToken=view.getViewToken("Tasks","Tasks");var notesToken=view.getViewToken("Tasks","Notes");var multiIds=null;if(view.getMultiEditMode(true)){multiIds=taskList.getViewList().getSelected();}
if(tasksToken){if(tasksView.taskDetails.fieldsTitle.state==Field.FIELD_STATE_DISPLAY){tasksView.taskDetails.fieldsTitle.setCount(null);if(stateMgr.lists[r.list_id].position==TasksView.LIST_SENT){tasksView.taskDetails.disable();tasksView.taskDetails.fieldsTitle.setEnabled(false);}else{if(view.getPublicMode()){tasksView.taskDetails.disable();tasksView.taskDetails.fieldsTitle.setEnabled(false);}else{if(taskList.view==TaskList.TASK_LIST_VIEW_COMPLETED){tasksView.taskDetails.disable();}else{tasksView.taskDetails.enable();}
tasksView.taskDetails.fieldsTitle.setEnabled(true);}}
tasksView.taskDetails.fieldsTitle.blit();}}else{if(notesToken){if(multiIds===null){this.formatNoteCountTemplate(noteMgr.getNoteCount(r.series_id));tasksView.taskDetails.fieldsTitle.setValue(unescape(r.name).escapeForDisplay(),true);}else{var n=this.getMultiEditFormat(multiIds,"name");if(n instanceof Array&&n[0]===null){tasksView.taskDetails.fieldsTitle.setCount(null);tasksView.taskDetails.fieldsTitle.setFieldValue(unescape(fmt("<Multiple>")),true);tasksView.taskDetails.fieldsTitle.setValue(unescape(fmt("<Multiple>")).escapeForDisplay(),true);}else{if(multiIds!==null&&multiIds.length>1){tasksView.taskDetails.fieldsTitle.setCount(null);tasksView.taskDetails.fieldsTitle.fieldValue=null;tasksView.taskDetails.fieldsTitle.setValue(unescape(r.name).escapeForDisplay(),true);}else{this.formatNoteCountTemplate(noteMgr.getNoteCount(r.series_id));}}}
tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.blit();if(multiIds!==null&&multiIds.length>1){noteMgr.showMultiEditMessage();noteMgr.setCurrentTask(null);}else{if(noteMgr.notesCount!==noteMgr.getNoteCount(r.series_id)||r.series_id!==noteMgr.currentTask||view.getInUndo()){if(tasksView.inSentList()){noteMgr.disable();}else{noteMgr.enable();}
noteMgr.fillNotes(r.series_id,true);noteMgr.setCurrentTask(r.series_id);}else{noteMgr.setCurrentTask(r.series_id);}}}}
el("listtoolbox").style.display="none";if(!tasksToken){return false;}
if(control.showAdded){tasksView.taskDetails.detailsAdded.setValue(dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due,r.date_added));tasksView.taskDetails.detailsAdded.show();}else{tasksView.taskDetails.detailsAdded.hide();}
if(taskList.view==TaskList.TASK_LIST_VIEW_COMPLETED){tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.setValue(unescape(r.name).escapeForDisplay(),true);tasksView.taskDetails.detailsCompleted.setValue(dateTimeMgr.getCachedIntlFormat(Intl.preferred_formats.due,r.date_completed));var due=_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER");var fieldDue=_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER");if(r.date_due!=null){var tfmt,ffmt;if(r.time_due){tfmt=Intl.preferred_formats.due_time;ffmt=Intl.preferred_formats.due_time_field;}else{tfmt=Intl.preferred_formats.due;ffmt=Intl.preferred_formats.due_field;}
fieldDue=dateTimeMgr.getCachedIntlFormat(ffmt,r.date_due);due=dateTimeMgr.getCachedIntlFormat(tfmt,r.date_due);}
tasksView.taskDetails.detailsDue.setFieldValue(fieldDue);tasksView.taskDetails.detailsDue.setValue(due);}else{if(view.getPublicMode()||stateMgr.lists[r.list_id].position==TasksView.LIST_SENT){tasksView.taskDetails.fieldsTitle.setEnabled(false);}else{tasksView.taskDetails.fieldsTitle.setEnabled(true);}
var multiSet=false;if(view.getMultiEditMode(true)){var n=this.getMultiEditFormat(multiIds,"name");if(n instanceof Array&&n[0]===null){tasksView.taskDetails.fieldsTitle.setFieldValue(unescape(fmt("<Multiple>")),true);tasksView.taskDetails.fieldsTitle.setValue(unescape(fmt("<Multiple>")).escapeForDisplay(),true);multiSet=true;}}
if(multiSet===false){tasksView.taskDetails.fieldsTitle.fieldValue=null;tasksView.taskDetails.fieldsTitle.setValue(unescape(r.name).escapeForDisplay(),true);}
var due=_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER");var fieldDue=_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER");var multiSet=false;if(view.getMultiEditMode(true)){var same=true;for(var i=0;i<multiIds.length;i++){var task=stateMgr.tasks[multiIds[i]];if(task.date_due!==r.date_due||task.time_due!==r.time_due){same=false;break;}}
if(same===false){tasksView.taskDetails.detailsDue.setFieldValue("<Multiple>");tasksView.taskDetails.detailsDue.setValue("<Multiple>");multiSet=true;}}
if(multiSet===false){if(r.date_due!=null){var tfmt,ffmt;if(r.time_due){tfmt=Intl.preferred_formats.due_time;ffmt=Intl.preferred_formats.due_time_field;}else{tfmt=Intl.preferred_formats.due;ffmt=Intl.preferred_formats.due_field;}
fieldDue=dateTimeMgr.getCachedIntlFormat(ffmt,r.date_due);due=dateTimeMgr.getCachedIntlFormat(tfmt,r.date_due);}
tasksView.taskDetails.detailsDue.setFieldValue(fieldDue);tasksView.taskDetails.detailsDue.setValue(due);}}
var tpl="INTERFACE_TASKS_TASK_DETAILS_POSTPONED_ZERO";var count=r.postponed?r.postponed*1:0;if(count===1){tpl="INTERFACE_TASKS_TASK_DETAILS_POSTPONED_ONE";}else{if(count>1){tpl="INTERFACE_TASKS_TASK_DETAILS_POSTPONED_NUM";}}
tasksView.taskDetails.detailsPostponed.setValue(_T(tpl,{"NUM":count}));var multiSet=false;if(view.getMultiEditMode(true)){var n=this.getMultiEditFormat(multiIds,"estimate");if(n instanceof Array&&n[0]===null){this.formatTaskEstimate("<Multiple>");multiSet=true;}}
if(multiSet===false){this.formatTaskEstimate(r.estimate);}
var shared=_T("INTERFACE_TASKS_TASK_DETAILS_SHARED_WITH_NO_ONE");var memberIds=[];var seenParts={};if(r.participants!=null){shared=[];var title=_T("INTERFACE_TASKS_TASK_DETAILS_SHOW_CONTACT");for(var i=0;i<r.participants.length;i++){if(is(seenParts[r.participants[i].person_id])){continue;}
seenParts[r.participants[i].person_id]=true;var cname=_T("INTERFACE_CONTACTS_CONTACT_FORMAT",{"CONTACT_FIRST_NAME":r.participants[i].person_first_name,"CONTACT_LAST_NAME":r.participants[i].person_last_name});shared.push("<a title="+quoted(title)+" id=\"contacts.members."+r.participants[i].person_id+"\" href=\" \">"+cname+"</a>");memberIds.push(r.participants[i].person_id);}
shared=shared.join(", ");}
if(stateMgr.lists[r.list_id].position==TasksView.LIST_SENT){tasksView.taskDetails.detailsShared.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_SENT_TO"));}else{if(stateMgr.lists[r.list_id].position==TasksView.LIST_INBOX){tasksView.taskDetails.detailsShared.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_SENT_FROM"));}else{tasksView.taskDetails.detailsShared.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_SHARED_WITH"));}}
if(!r.participants&&r.source=="email"&&stateMgr.lists[r.list_id].position!=TasksView.LIST_SENT){tasksView.taskDetails.detailsShared.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_SENT_FROM"));tasksView.taskDetails.detailsShared.setValue(_T("INTERFACE_TASKS_TASK_DETAILS_SENT_FROM_EMAILED"),true);}else{tasksView.taskDetails.detailsShared.setValue(shared,true);}
if(memberIds.length>0){var links=tasksView.taskDetails.detailsShared.div.getElementsByTagName("a");for(var i=0;i<links.length;i++){var a=links[i];a.member=memberIds[i];if(a.id.indexOf("contacts.members")>-1){a.onclick=function(ev){messageBus.broadcast(contactList,contactList.mbn+"showContact",this.member);return false;};}}}
if(multiIds===null){var noteCount=noteMgr.getNoteCount(r.series_id);if(noteCount>0){tasksView.taskDetails.detailsNotes.setValue("<a title=\""+_T("INTERFACE_TASKS_TASK_DETAILS_SHOW_NOTES")+"\" href=\" \" onclick=\"taskTabs.selectTab('"+_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB")+"'); return false;\">"+noteCount+"</a>",true);}else{tasksView.taskDetails.detailsNotes.setValue("0",true);}}else{noteMgr.prepareIndex();var n=is(noteMgr.index[r.series_id])?noteMgr.index[r.series_id].length:0;if(multiIds.length===1){if(n>0){tasksView.taskDetails.detailsNotes.setValue("<a title=\""+_T("INTERFACE_TASKS_TASK_DETAILS_SHOW_NOTES")+"\" href=\" \" onclick=\"taskTabs.selectTab('"+_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB")+"'); return false;\">"+n+"</a>",true);}else{tasksView.taskDetails.detailsNotes.setValue("0",true);}}else{var multiSet=false;var same=true;var series,c;for(var i=0;i<multiIds.length;i++){series=stateMgr.tasks[multiIds[i]].series_id;if(!is(noteMgr.index[series])){c=0;}else{c=noteMgr.index[series].length;}
if(c!==n){same=false;break;}}
if(same===false){tasksView.taskDetails.detailsNotes.setValue("&lt;Multiple&gt;",true);}else{if(n>0){tasksView.taskDetails.detailsNotes.setValue("<a title=\""+_T("INTERFACE_TASKS_TASK_DETAILS_SHOW_NOTES")+"\" href=\" \" onclick=\"taskTabs.selectTab('"+_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB")+"'); return false;\">"+n+"</a>",true);}else{tasksView.taskDetails.detailsNotes.setValue("0",true);}}}}
var multiSet=false;if(view.getMultiEditMode(true)){var same=true;var mx=0;for(var i=0;i<multiIds.length;i++){var rrule=stateMgr.tasks[multiIds[i]].reoccur;if((r.reoccur===null&&rrule!==null)||(r.reoccur!==null&&rrule===null)){same=false;break;}else{if(r.reoccur!==null&&rrule!==null){if((r.reoccur[0]===null&&rrule[0]!==null)||(r.reoccur[0]!==null&&rrule[0]===null)){same=false;break;}else{if(r.reoccur[0]!==null){if(r.reoccur[0]!==rrule[0]||r.reoccur[1]!==rrule[1]){same=false;break;}}}}}}
if(same===false){tasksView.taskDetails.detailsReoccur.setValue("<Multiple>");tasksView.taskDetails.detailsReoccur.setFieldValue("<Multiple>");multiSet=true;}}
if(multiSet===false){var reoccur=r.reoccur&&r.reoccur[0]?reoccurMgr.convertReoccurrenceDesc(r.reoccur):_T("INTERFACE_TASKS_TASK_DETAILS_REPEAT_NEVER");var reoccur_field=r.reoccur&&r.reoccur[0]?reoccurMgr.convertReoccurrenceDesc(r.reoccur,true):_T("INTERFACE_TASKS_TASK_DETAILS_REPEAT_NEVER");tasksView.taskDetails.detailsReoccur.setValue(reoccur);tasksView.taskDetails.detailsReoccur.setFieldValue(reoccur_field);}
var tags=[];var multiSet=false;if(view.getMultiEditMode(true)){var series={};series[r.series_id]=true;var initial=tagMgr.getTagsForTaskSeries(r.series_id);var same=true;var bl=false;for(var i=0,j=multiIds.length;(same===true&&i<j);i++){var task=stateMgr.tasks[multiIds[i]];if(!is(series[task.series_id])){series[task.series_id]=true;var tasktags=tagMgr.getTagsForTaskSeries(task.series_id);if(tasktags.length!==initial.length){same=false;break;}
for(var x=0;x<initial.length;x++){if(initial[x]!==tasktags[x]){same=false;break;}}}}
if(same===false){tasksView.taskDetails.detailsTags.setValue(fmt("<Multiple>").escapeForDisplay(),true);tasksView.taskDetails.detailsTags.setFieldValue(fmt("<Multiple>"));multiSet=true;}else{tags=initial;}}else{tags=tagMgr.getTagsForTaskSeries(r.series_id);}
if(multiSet===false){if(tags.length==0){tasksView.taskDetails.detailsTags.setFieldValue("");tasksView.taskDetails.detailsTags.setValue(_T("INTERFACE_TASKS_TASK_DETAILS_TAGS_NONE"));}else{var tagOut=[];for(var i=0;i<tags.length;i++){var tag=tags[i];var title=_T("INTERFACE_TASKS_TASK_DETAILS_SHOW_LIST_FOR_TAG",{"TAG":tag});tagOut.push("<a onclick=\"el('listFilter').value = 'tag:"+tag+"'; control.updateListFilter(); return false;\" title="+quoted(title)+" id=\"task.tags."+tag+"\" href=\"#section.tasks\">"+tag+"</a>");}
tasksView.taskDetails.detailsTags.setFieldValue(tags.join(", "));tasksView.taskDetails.detailsTags.setValue(tagOut.join(", "));}}
var multiSet=false;if(view.getMultiEditMode(true)){var n=this.getMultiEditFormat(multiIds,"url");if(n instanceof Array&&n[0]===null){tasksView.taskDetails.detailsURL.setFieldValue(unescape(fmt("<Multiple>")),true);tasksView.taskDetails.detailsURL.setValue(unescape(fmt("<Multiple>")).escapeForDisplay(),true);multiSet=true;}}
if(multiSet===false){tasksView.taskDetails.detailsURL.setFieldValue(r.url?r.url:_T("INTERFACE_TASKS_TASK_DETAILS_URL_NONE"));tasksView.taskDetails.detailsURL.setValue(r.url?r.url.escapeForDisplay().autoLink(true):_T("INTERFACE_TASKS_TASK_DETAILS_URL_NONE"));}
if(!view.getPublicMode()){var multiSet=false;if(view.getMultiEditMode(true)){var same=true;var mx=multiIds.length>0?locationMgr.location_task_series_[stateMgr.tasks[multiIds[0]].series_id]:null;var series;for(var i=0;i<multiIds.length;i++){series=stateMgr.tasks[multiIds[i]].series_id;if(locationMgr.location_task_series_[series]!==mx){same=false;break;}}
if(same===false){tasksView.taskDetails.detailsLocation.setValue("&lt;Multiple&gt;");tasksView.taskDetails.detailsLocation.setFieldValue("<Multiple>");multiSet=true;}}
if(multiSet===false){tasksView.taskDetails.detailsLocation.setFieldValue(locationMgr.getTaskLocation(r.series_id),true);tasksView.taskDetails.detailsLocation.setValue(locationMgr.getTaskLocationLink(r.series_id),true);}}
if(stateMgr.currentType!==TasksView.LIST_TYPE_NORMAL){var multiSet=false;var value;if(view.getMultiEditMode(true)){var n=this.getMultiEditFormat(multiIds,"list_id");if(n instanceof Array&&n[0]===null){value="<Multiple>";multiSet=true;}}
if(multiSet===false){value=stateMgr.lists[r.list_id].name;}
tasksView.taskDetails.detailsList.setValue(unescape(value).escapeForDisplay(),true);}};Format.prototype.getListStatistics=function(id){var dueToday,dueTomorrow,overdue,minutes,prio;dueToday=dueTomorrow=overdue=minutes=0;prio=[0,0,0,0];var dueCounted=0,dueTotal=0;var completed,incomplete;completed=incomplete=0;var presentIncomplete=[],presentComplete=[];for(var taskId in stateMgr.tasks){if(stateMgr.tasks[taskId]==null||stateMgr.tasks[taskId].list_id!=id){continue;}
var tuple=this.getListStatisticsTuple(taskId);dueToday+=tuple[0];dueTomorrow+=tuple[1];overdue+=tuple[2];minutes+=tuple[3];if(tuple[4]){completed+=1;presentComplete.push(taskId);}else{incomplete+=1;presentIncomplete.push(taskId);var p=stateMgr.tasks[taskId].priority.charAt(1);if(p=="N"){p=4;}else{p=parseInt(p,10);}
prio[p-1]++;if(stateMgr.tasks[taskId].date_due){dueCounted++;dueTotal+=parseFloat(stateMgr.tasks[taskId].date_due);}}}
return[completed,dueToday,dueTomorrow,overdue,minutes,incomplete,[presentIncomplete,presentComplete],prio,[dueCounted,dueTotal]];};Format.prototype.getListStatisticsTuple=function(taskId){var tuple=new Array(5);var td=stateMgr.tasks[taskId];if(td.duetoday){tuple[0]=1;}else{tuple[0]=0;}
if(td.duetomorrow){tuple[1]=1;}else{tuple[1]=0;}
if(td.overdue){tuple[2]=1;}else{tuple[2]=0;}
if(td.estimate){tuple[3]=dateTimeMgr.parseTimeEstimate(td.estimate);}else{tuple[3]=0;}
if(td.date_completed!==null){tuple[4]=1;}else{tuple[4]=0;}
return tuple;};Format.prototype.getCurrentListStatistics=function(){var dueToday,dueTomorrow,overdue,minutes;dueToday=dueTomorrow=overdue=minutes=0;var completed=0;var incomplete=0;for(var i=0;i<stateMgr.workingSet.length;i++){var taskId=stateMgr.workingSet[i];if(!is(stateMgr.tasks[taskId])){continue;}
var tuple=this.getListStatisticsTuple(taskId);if(tuple[4]!==1){dueToday+=tuple[0];dueTomorrow+=tuple[1];overdue+=tuple[2];minutes+=tuple[3];}
if(tuple[4]===1){completed+=1;}else{incomplete+=1;}}
return[completed,dueToday,dueTomorrow,overdue,minutes,incomplete];};Format.prototype.getPermissionsLinks=function(perms){var objs=[];if(perms===null){return objs;}
for(var id in perms){var perm=perms[id];var m="";var pending=perm[2]?" <span class=\"notecount\">"+_T("INTERFACE_TASKS_LIST_DETAILS_SHARE_PENDING")+"</span>":"";if(perm[1]===null&&is(perm[0])&&is(stateMgr.groups[perm[0]])){var func="messageBus.broadcast(groupList, groupList.mbn + 'showGroup', "+perm[0]+"); return false;";m="<a href=\" \" onclick="+quoted(func)+">"+stateMgr.groups[perm[0]].name+"</a> <span class=\"notecount\">"+_T("INTERFACE_TASKS_LIST_DETAILS_SHARE_GROUP")+"</span>";objs.push(m);}else{if(is(perm[1])&&is(stateMgr.contacts[perm[1]])){var func="messageBus.broadcast(contactList, contactList.mbn + 'showContact', "+perm[1]+"); return false;";var cname=_T("INTERFACE_CONTACTS_CONTACT_FORMAT",{"CONTACT_FIRST_NAME":stateMgr.contacts[perm[1]].firstname,"CONTACT_LAST_NAME":stateMgr.contacts[perm[1]].lastname});m="<a href=\" \" onclick="+quoted(func)+">"+cname+"</a>"+pending;objs.push(m);}}}
return objs;};Format.prototype.formatSharedDetailsForList=function(id){var permissions=stateMgr.permissions;var perms=permissions?permissions["share"]?permissions["share"][id]?permissions["share"][id]:null:null:null;var shareprivate=el("shareprivate");var sharecontact=el("sharecontact");var sharecontacts=el("sharecontacts");var shareToken=view.getViewToken("Tasks","Share");if(shareToken){tasksView.taskDetails.fieldsTitle.setEnabled(false);}
if(perms===null||perms.length===0){shareMgr.radiogroup.select(0,true);if(shareToken){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_SHARE_NOT_SHARED"));}
sharecontacts.style.display="none";}else{shareMgr.radiogroup.select(1,true);if(shareToken){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_SHARE_SHARED_WITH_CONTACTS"));}
var objs=this.getPermissionsLinks(perms);if(objs.length>0){sharecontacts.innerHTML="<div class=\"sharingentry\">"+objs.join("</div><div class=\"sharingentry\">")+"</div>";}else{sharecontacts.innerHTML=_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_DELETED_CONTACTS");}
sharecontacts.style.display="";}
if(shareToken){tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.setValue(unescape(stateMgr.lists[id].name).escapeForDisplay(),true);}};Format.prototype.formatSaveListDetailsForList=function(id){if(view.getViewToken("Tasks","Save")){tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.setCount(null);tasksView.taskDetails.fieldsTitle.setValue(_T("INTERFACE_TASKS_LIST_DETAILS_SEARCH_RESULTS"),true);}};Format.prototype.formatPublishDetailsForList=function(id){var permissions=stateMgr.permissions;var perms=permissions?permissions["publish"]?permissions["publish"][id]?permissions["publish"][id]:null:null:null;var publishprivate=el("publishprivate");var publishcontact=el("publishcontact");var publishcontacts=el("publishcontacts");var publishpublic=el("publishpublic");var publishurl=el("publishurl");var publishToken=view.getViewToken("Tasks","Publish");if(publishToken){tasksView.taskDetails.fieldsTitle.setEnabled(false);}
if(perms===null||perms.length===0){publishMgr.radiogroup.select(0,true);if(publishToken){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_NOT_PUBLISHED"));}
publishcontacts.style.display="none";publishurl.innerHTML="";publishurl.style.display="none";}else{if(perms.length==1&&perms[0][0]==-1){publishMgr.radiogroup.select(2,true);publishpublic.checked=true;if(publishToken){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_PUBLIC_LIST"));}
publishcontacts.style.display="none";}else{publishMgr.radiogroup.select(1,true);if(publishToken){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_PUBLISHED_TO_CONTACTS"));}
var objs=this.getPermissionsLinks(perms);if(objs.length>0){publishcontacts.innerHTML="<div class=\"sharingentry\">"+objs.join("</div><div class=\"sharingentry\">")+"</div>";}else{publishcontacts.innerHTML="<div class=\"sharingentry\">"+_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_DELETED_CONTACTS")+"</div>";}
publishcontacts.style.display="";}
publishurl.innerHTML="<a href="+quoted("/home/"+rtmUsername+"/"+stateMgr.currentList+"/")+">"+_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_LINK")+"</a>";publishurl.style.display="";}
if(publishToken){tasksView.taskDetails.fieldsTitle.setValue(unescape(stateMgr.lists[id].name).escapeForDisplay(),true);}};Format.prototype.formatTaskStatisticsForList=function(id,loading){if(!view.getViewToken("Tasks")){return false;}
if(view.getViewToken("Tasks","List")){tasksView.taskDetails.fieldsTitle.setCount(null);tasksView.taskDetails.fieldsTitle.setEnabled(false);tasksView.taskDetails.fieldsTitle.blit();}
if(id===null){if(view.getViewToken("Tasks","List")){var count=taskList.getViewList().entries.length;var tpl;if(count==0){tpl="INTERFACE_TASKS_LIST_DETAILS_ZERO_TASKS";}else{if(count==1){tpl="INTERFACE_TASKS_LIST_DETAILS_ONE_TASK";}else{tpl="INTERFACE_TASKS_LIST_DETAILS_NUM_TASKS";}}
tasksView.taskDetails.fieldsTitle.setCount(_T(tpl,{"NUM":count}));tasksView.taskDetails.fieldsTitle.setValue(_T("INTERFACE_TASKS_LIST_DETAILS_SEARCH_RESULTS"),true);}}else{if(id==-1||!stateMgr.lists[id]){if(view.getViewToken("Tasks","List")){tasksView.taskDetails.fieldsTitle.setValue(_T("INTERFACE_TASKS_LIST_DETAILS_LOADING"),true);}
return false;}}
if(loading==true){if(view.getViewToken("Tasks","List")){if(id===null){tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_SEARCHING"));tasksView.taskDetails.fieldsTitle.setValue(unescape(debracket(stateMgr.currentFilter)).escapeForDisplay(),true);}else{tasksView.taskDetails.fieldsTitle.setCount(_T("INTERFACE_TASKS_LIST_DETAILS_LOADING"));tasksView.taskDetails.fieldsTitle.setValue(unescape(stateMgr.lists[id].name).escapeForDisplay(),true);}}
return false;}
if(view.getViewToken("Tasks","Share")){el("listtoolbox").style.display="none";helpBox.showHelpText("tasks.sharing");this.formatSharedDetailsForList(id);return false;}else{if(view.getViewToken("Tasks","Publish")){el("listtoolbox").style.display="none";helpBox.showHelpText("tasks.publishing");this.formatPublishDetailsForList(id);return false;}else{if(view.getViewToken("Tasks","Save")){el("listtoolbox").style.display="none";helpBox.showHelpText("tasks.save");this.formatSaveListDetailsForList(id);return false;}else{helpBox.stopShowing("tasks.save");helpBox.stopShowing("tasks.publishing");helpBox.stopShowing("tasks.sharing");}}}
if(stateMgr.currentType!==TasksView.LIST_TYPE_SEARCH){if(taskList.view===TaskList.TASK_LIST_VIEW_INCOMPLETE){el("listtoolbox").style.display="";var pla=document.getElementById("printlista");pla.href="/print/"+rtmUsername+"/"+id+"/";var ila=document.getElementById("icalendarlista");ila.href="webcal://"+rtmHostname+"/icalendar/"+rtmUsername+"/"+id+"/";var iela=document.getElementById("icalendareventslista");iela.href="webcal://"+rtmHostname+"/icalendar/"+rtmUsername+"/"+id+"/"+"events/";var ala=document.getElementById("atomlista");ala.href="/atom/"+rtmUsername+"/"+id+"/";var permalist=document.getElementById("permalist");var prla=document.getElementById("permalista");if(!(view.getPublicMode()||is(publishMgr.publicLists[id]))){permalist.style.visibility="hidden";}else{permalist.style.visibility="visible";}
el("exportlist").style.visibility="visible";el("exportlistevents").style.visibility="visible";el("atomlist").style.visibility="visible";el("permalist").style.display="";prla.href="/home/"+rtmUsername+"/"+id+"/";}else{el("listtoolbox").style.display="";el("exportlist").style.visibility="hidden";el("exportlistevents").style.visibility="hidden";el("atomlist").style.visibility="hidden";el("permalist").style.display="none";var pla=document.getElementById("printlista");pla.href="/print/"+rtmUsername+"/"+id+"/completed/";}}else{el("exportlist").style.visibility="hidden";el("exportlistevents").style.visibility="hidden";el("atomlist").style.visibility="hidden";el("permalist").style.display="none";el("listtoolbox").style.display="";var pla=document.getElementById("printlista");var print_href="/print/"+rtmUsername+"/-/?filter="+encodeURIComponent(stateMgr.currentFilter);if(taskList.view===TaskList.TASK_LIST_VIEW_COMPLETED){print_href+="&mode=completed";}
pla.href=print_href;}
if(view.getViewToken("Tasks","List")){var count=taskList.getViewList().entries.length;var tpl;if(count==0){tpl="INTERFACE_TASKS_LIST_DETAILS_ZERO_TASKS";}else{if(count==1){tpl="INTERFACE_TASKS_LIST_DETAILS_ONE_TASK";}else{tpl="INTERFACE_TASKS_LIST_DETAILS_NUM_TASKS";}}
tasksView.taskDetails.fieldsTitle.setCount(_T(tpl,{"NUM":count}));if(id!==null){tasksView.taskDetails.fieldsTitle.setValue(unescape(stateMgr.lists[id].name).escapeForDisplay(),true);}}
var listSearchedFor=el("listsearchfor");var listCompleted=el("listcompleted");var listDueToday=el("listduetoday");var listDueTomorrow=el("listduetomorrow");var listOverDue=el("listoverdue");var listEstimatedTime=el("listestimatedtime");if(stateMgr.currentType===TasksView.LIST_TYPE_NORMAL){listSearchedFor.style.display="none";}else{listSearchedFor.innerHTML=_T("INTERFACE_TASKS_LIST_DETAILS_SEARCHED_FOR",{"CRITERIA":debracket(stateMgr.currentFilter)});listSearchedFor.style.paddingBottom="8px";listSearchedFor.style.display="";}
var count,tpl;var stats=this.getCurrentListStatistics();if(stats[0]==0&&taskList.view===TaskList.TASK_LIST_VIEW_INCOMPLETE){listCompleted.innerHTML=_T("INTERFACE_TASKS_LIST_DETAILS_ZERO_COMPLETED");}else{var chtml,f;if(taskList.view==TaskList.TASK_LIST_VIEW_INCOMPLETE){count=stats[0];tpl=count==0?"INTERFACE_TASKS_LIST_DETAILS_ZERO_COMPLETED":"INTERFACE_TASKS_LIST_DETAILS_NUM_COMPLETED";f=_T(tpl,{"NUM":count});chtml="<a href=\" \" title="+quoted(_T("INTERFACE_TASKS_LIST_DETAILS_SHOW_COMPLETED"))+" onclick=\"taskList.switchView(TaskList.TASK_LIST_VIEW_COMPLETED); return false;\">"+f+"</a>";}else{count=stats[5];tpl=count==0?"INTERFACE_TASKS_LIST_DETAILS_ZERO_INCOMPLETE":"INTERFACE_TASKS_LIST_DETAILS_NUM_INCOMPLETE";f=_T(tpl,{"NUM":count});chtml="<a href=\" \" title="+quoted(_T("INTERFACE_TASKS_LIST_DETAILS_SHOW_INCOMPLETE"))+" onclick=\"taskList.switchView(TaskList.TASK_LIST_VIEW_INCOMPLETE); return false;\">"+f+"</a>";}
listCompleted.innerHTML=chtml;}
count=stats[1];tpl=stats[1]==0?"INTERFACE_TASKS_LIST_DETAILS_ZERO_DUE_TODAY":"INTERFACE_TASKS_LIST_DETAILS_NUM_DUE_TODAY";listDueToday.innerHTML=_T(tpl,{"NUM":count});count=stats[2];tpl=stats[2]==0?"INTERFACE_TASKS_LIST_DETAILS_ZERO_DUE_TOMORROW":"INTERFACE_TASKS_LIST_DETAILS_NUM_DUE_TOMORROW";listDueTomorrow.innerHTML=_T(tpl,{"NUM":count});count=stats[3];tpl=stats[3]==0?"INTERFACE_TASKS_LIST_DETAILS_ZERO_OVERDUE":"INTERFACE_TASKS_LIST_DETAILS_NUM_OVERDUE";listOverDue.innerHTML=_T(tpl,{"NUM":count});if(stats[4]){listEstimatedTime.innerHTML=_T("INTERFACE_TASKS_LIST_DETAILS_TIME_ESTIMATE",{"TIME":dateTimeMgr.formatTimeEstimate(stats[4])});}else{listEstimatedTime.innerHTML="";}};Format.prototype.formatContact=function(id){var c=stateMgr.contacts[id];if(c==null){return null;}
if(view.getViewToken("Contacts","Contacts")){contactsView.contactDetails.fieldsTitle.setEnabled(false);contactsView.contactDetails.fieldsTitle.blit();contactsView.contactDetails.fieldsTitle.setValue(this.formatContactName(id));}
var viewShared=_T("INTERFACE_CONTACTS_CONTACT_VIEW_TASKS_SHARED",{"CONTACT_FIRST_NAME":c.firstname});var userSearch="<a href=\" \" title="+quoted(viewShared)+" onclick="+quoted("control.updateListFilter('(sharedWith:"+c.username+")'); return false;")+">"+viewShared+"</a>";contactsView.contactDetails.contactUsername.setValue(c.username);el("contactsearch").innerHTML=userSearch;var gx=[];for(var g in stateMgr.groups){var gm=stateMgr.groups[g];if(gm.members!=null){for(var i=0;i<gm.members.length;i++){if(gm.members[i].contact_id==id){gx.push([gm.id,gm.name]);break;}}}}
var gp=[];var groupIds=[];for(var i=0;i<gx.length;i++){gp.push("<a id=\"contact.groups."+gx[i][0]+"\" href=\" \">"+gx[i][1]+"</a>");groupIds.push(gx[i][0]);}
if(gp.length>0){gp=gp.join(", ");}else{gp=_T("INTERFACE_CONTACTS_CONTACT_GROUPS_NONE");}
contactsView.contactDetails.contactGroups.setValue(gp,true);if(groupIds.length>0){var links=contactsView.contactDetails.contactGroups.div.getElementsByTagName("a");for(var i=0;i<links.length;i++){var a=links[i];a.group=groupIds[i];if(a.id.indexOf("contact.groups.")>-1){a.onclick=function(ev){messageBus.broadcast(groupList,groupList.mbn+"showGroup",this.group);return false;};}}}
contactsView.contactDetails.show();};Format.prototype.formatContactStatistics=function(){if(view.getViewToken("Contacts","Contacts")){var count=contactList.list.entries.length;var tpl="INTERFACE_CONTACTS_CONTACTS_ZERO";if(count===1){tpl="INTERFACE_CONTACTS_CONTACTS_ONE";}else{if(count>1){tpl="INTERFACE_CONTACTS_CONTACTS_NUM";}}
contactsView.contactDetails.fieldsTitle.setValue(_T(tpl,{"NUM":count}),true);}
contactsView.contactDetails.hide();if(view.getViewToken("Contacts","Contacts")){contactsView.contactDetails.fieldsTitle.show();}};Format.prototype.formatGroup=function(id){var g=stateMgr.groups[id];if(!g){return false;}
if(view.getViewToken("Contacts","Groups")){var count=groupList.list.entries.length;var tpl="INTERFACE_CONTACTS_GROUPS_ZERO";if(count===1){tpl="INTERFACE_CONTACTS_GROUPS_ONE";}else{if(count>1){tpl="INTERFACE_CONTACTS_GROUPS_NUM";}}
contactsView.groupDetails.fieldsTitle.setValue(_T(tpl,{"NUM":count}));}
if(!g.members){g.members=[];}
if(view.getViewToken("Contacts","Groups")){var groupCount=0;for(var i=0;i<g.members.length;i++){var contactId=g.members[i].contact_id;var contact=stateMgr.contacts[contactId];if(contact){groupCount++;}}
var tpl="INTERFACE_CONTACTS_GROUPS_MEMBERS_ZERO";if(groupCount===1){tpl="INTERFACE_CONTACTS_GROUPS_MEMBERS_ONE";}else{if(groupCount>1){tpl="INTERFACE_CONTACTS_GROUPS_MEMBERS_NUM";}}
contactsView.groupDetails.fieldsTitle.setCount(_T(tpl,{"NUM":groupCount}));contactsView.groupDetails.fieldsTitle.setValue(unescape(g.name).escapeForDisplay());}
var members=[];var memberIds=[];if(g.members.length>0){for(var i=0;i<g.members.length;i++){var contactId=g.members[i].contact_id;var contact=stateMgr.contacts[contactId];if(contact){var cname=this.formatContactName(contactId);members.push("<a id=\"contacts.members."+contactId+"\" href=\" \">"+cname+"</a>");memberIds.push(contactId);}}
members=members.join(", ");}else{members=_T("INTERFACE_CONTACTS_CONTACT_GROUPS_NONE");}
contactsView.groupDetails.groupMembers.setValue(members,true);if(memberIds.length>0){var links=contactsView.groupDetails.groupMembers.div.getElementsByTagName("a");for(var i=0;i<links.length;i++){var a=links[i];a.member=memberIds[i];if(a.id.indexOf("contacts.members")>-1){a.onclick=function(ev){messageBus.broadcast(contactList,contactList.mbn+"showContact",this.member);return false;};}}}
contactsView.groupDetails.show();};Format.prototype.formatGroupStatistics=function(id){if(view.getViewToken("Contacts","Groups")){var count=groupList.list.entries.length;var tpl="INTERFACE_CONTACTS_GROUPS_ZERO";if(count===1){tpl="INTERFACE_CONTACTS_GROUPS_ONE";}else{if(count>1){tpl="INTERFACE_CONTACTS_GROUPS_NUM";}}
contactsView.groupDetails.fieldsTitle.setCount(null);contactsView.groupDetails.fieldsTitle.setValue(_T(tpl,{"NUM":count}),true);}
contactsView.groupDetails.hide();if(view.getViewToken("Contacts","Groups")){contactsView.groupDetails.fieldsTitle.show();}};Format.prototype.formatList=function(id){var l=stateMgr.lists[id];if(l===null){l=stateMgr.pendingLists[id];}
var listsToken=view.getViewToken("Settings","Lists");if(listsToken){if(l.queued||l.locked){settingsView.listDetails.fieldsTitle.setEnabled(false);}else{settingsView.listDetails.fieldsTitle.setEnabled(true);}
settingsView.listDetails.fieldsTitle.setValue(unescape(l.name).escapeForDisplay(),true);}
var stats=this.getListStatistics(id);var tpl;if(stats[0]==0){tpl="INTERFACE_TASKS_LIST_DETAILS_ZERO_COMPLETED";}else{tpl="INTERFACE_TASKS_LIST_DETAILS_NUM_COMPLETED";}
settingsView.listDetails.listCompleted.setValue(_T(tpl,{"NUM":stats[0]}));if(stats[5]==0){tpl="INTERFACE_TASKS_LIST_DETAILS_ZERO_INCOMPLETE";}else{tpl="INTERFACE_TASKS_LIST_DETAILS_NUM_INCOMPLETE";}
settingsView.listDetails.listIncomplete.setValue(_T(tpl,{"NUM":stats[5]}));settingsView.listDetails.listFilter.setHidden(true);settingsView.listDetails.listFilter.hide();var properties=[];if(id===configurationMgr.configuration.defaultList){properties.push(_T("INTERFACE_SETTINGS_LISTS_LIST_DEFAULT"));}
if(l.queued){var text=[];text.push(_T("INTERFACE_SETTINGS_LIST_PENDING"));var tpl;if(stateMgr.contacts[l.from]==null){tpl="INTERFACE_SETTINGS_LIST_SENT_BY_NOT_CONTACT";}else{tpl="INTERFACE_SETTINGS_LIST_SENT_BY_CONTACT";}
text.push(_T(tpl,{"CONTACT_FIRST_NAME":l.from_first_name,"CONTACT_LAST_NAME":l.from_last_name}));text.push("<span style=\"text-align: center;\"><input type=\"submit\" value=\""+_T("INTERFACE_SETTINGS_LIST_ACCEPT")+"\" /> <input type=\"submit\" value=\""+_T("INTERFACE_SETTINGS_LIST_REJECT")+"\" /></span>");settingsView.listDetails.listPending.setHidden(false);settingsView.listDetails.listPending.setEscape(false);settingsView.listDetails.listPending.setValue(text.join("<br /><br />"));settingsView.listDetails.listPending.show();var inputs=settingsView.listDetails.listPending.div.getElementsByTagName("input");inputs[0].onclick=function(ev){messageBus.broadcast(listList,listList.mbn+"acceptList",id);return false;};inputs[1].onclick=function(ev){messageBus.broadcast(listList,listList.mbn+"rejectList",id);return false;};}else{if(l.locked){properties.push(_T("INTERFACE_SETTINGS_LISTS_LIST_LOCKED"));}
settingsView.listDetails.listPending.setHidden(true);settingsView.listDetails.listPending.hide();settingsView.listDetails.listDescription.setHidden(true);settingsView.listDetails.listDescription.hide();}
if(l.filter!==null){properties.push(_T("INTERFACE_SETTINGS_LISTS_SMART_LIST"));settingsView.listDetails.listCompleted.setHidden(true);settingsView.listDetails.listCompleted.hide();settingsView.listDetails.listIncomplete.setHidden(true);settingsView.listDetails.listIncomplete.hide();settingsView.listDetails.listFilter.setHidden(false);settingsView.listDetails.listFilter.setValue(debracket(l.filter),true);settingsView.listDetails.listFilter.show();el("settingslistbreak").style.display="none";}else{settingsView.listDetails.listCompleted.setHidden(false);settingsView.listDetails.listCompleted.show();settingsView.listDetails.listIncomplete.setHidden(false);settingsView.listDetails.listIncomplete.show();el("settingslistbreak").style.display="";}
if(l.archived){properties.push(_TF(["INTERFACE_SETTINGS_LISTS_ARCHIVED"," ",false],{"LINK_ID":"lists.unarchive."+id}));}
if(properties.length>0){settingsView.listDetails.listPending.hide();settingsView.listDetails.listDescription.setEscape(false);settingsView.listDetails.listDescription.setHidden(false);settingsView.listDetails.listDescription.setValue(properties.join("<br />"),true);settingsView.listDetails.listDescription.show();var links=settingsView.listDetails.listDescription.div.getElementsByTagName("a");for(var i=0;i<links.length;i++){var a=links[i];if(a.id.indexOf("lists.unarchive")>-1){a.onclick=function(ev){messageBus.broadcast(listList,listList.mbn+"unarchiveList",id);return false;};}}}else{el("settingslistbreak").style.display="none";settingsView.listDetails.listDescription.setHidden(true);settingsView.listDetails.listDescription.hide();}
if(listsToken){settingsView.listDetails.show();}else{settingsView.listDetails.hide();}};Format.prototype.formatListStatistics=function(id){if(view.getViewToken("Settings","Lists")){settingsView.listDetails.fieldsTitle.setEnabled(false);settingsView.listDetails.fieldsTitle.setValue(_T("INTERFACE_SETTINGS_LISTS_NUM_LISTS",{"NUM":listList.list.entries.length}),true);}
settingsView.listDetails.hide();if(view.getViewToken("Settings","Lists")){settingsView.listDetails.fieldsTitle.show();}};Format.prototype.formatContactName=function(id){var contact=stateMgr.contacts[id];if(!contact){return null;}
return unescape(_T("INTERFACE_CONTACTS_CONTACT_FORMAT",{"CONTACT_FIRST_NAME":contact.firstname,"CONTACT_LAST_NAME":contact.lastname})).escapeForDisplay();};Format.prototype.formatLearnMore=function(section,entry,text){var t=text||"Learn more";return"<a href="+quoted(Format.FORMAT_HELP_LOCATION+section+"/"+entry+".rtm")+" target=\"_blank\">"+t+"</a>";};Format.prototype.getListCount=function(list){var selected=list.getSelected();var first=selected[0];selected=selected.length;var text=null;if(selected==1){if(list.parent.type=="task"){text="\""+unescape(stateMgr.tasks[first].name).escapeForDisplay()+"\"";}else{if(list.parent.type=="list"){text="\""+unescape(stateMgr.lists[first].name).escapeForDisplay()+"\"";}else{if(list.parent.type=="contact"){var contact=stateMgr.contacts[first];text="\""+unescape(contact.firstname+" "+contact.lastname).escapeForDisplay()+"\"";}else{if(list.parent.type=="group"){text="\""+unescape(stateMgr.groups[first].name).escapeForDisplay()+"\"";}}}}}else{text=utility.pluralize(selected,list.parent.type);}
return text;};Format.prototype.formatInvites=function(){if(view.getViewToken("Contacts","Invites")){contactsView.contactDetails.hide();contactsView.contactDetails.fieldsTitle.setEnabled(false);contactsView.contactDetails.fieldsTitle.setCount(null);contactsView.contactDetails.fieldsTitle.setValue(_T("INTERFACE_CONTACTS_INVITES_TAB"),true);contactsView.contactDetails.fieldsTitle.show();}};Format.prototype.formatGeneralSettings=function(){if(view.getViewToken("Settings","General")){settingsView.listDetails.hide();settingsView.listDetails.fieldsTitle.setEnabled(false);settingsView.listDetails.fieldsTitle.setCount(null);settingsView.listDetails.fieldsTitle.setValue(_T("INTERFACE_SETTINGS_GENERAL_DESCRIPTION"),true);settingsView.listDetails.fieldsTitle.show();}};Format.prototype.formatReminderSettings=function(){if(view.getViewToken("Settings","Reminders")){settingsView.listDetails.hide();settingsView.listDetails.fieldsTitle.setEnabled(false);settingsView.listDetails.fieldsTitle.setCount(null);settingsView.listDetails.fieldsTitle.setValue(_T("INTERFACE_SETTINGS_REMINDERS_DESCRIPTION"),true);settingsView.listDetails.fieldsTitle.show();}};Format.prototype.formatServicesSettings=function(){if(view.getViewToken("Settings","Services")){settingsView.listDetails.hide();settingsView.listDetails.fieldsTitle.setEnabled(false);settingsView.listDetails.fieldsTitle.setCount(null);settingsView.listDetails.fieldsTitle.setValue(_T("INTERFACE_SETTINGS_SERVICES_TAB"),true);settingsView.listDetails.fieldsTitle.show();}};Format.prototype.formatInfoSettings=function(){if(view.getViewToken("Settings","Info")){settingsView.listDetails.hide();settingsView.listDetails.fieldsTitle.setEnabled(false);settingsView.listDetails.fieldsTitle.setCount(null);settingsView.listDetails.fieldsTitle.setValue(_T("INTERFACE_SETTINGS_INFO_DESCRIPTION"),true);settingsView.listDetails.fieldsTitle.show();}};Format.prototype.formatContactList=function(contacts){var formatted=[];for(var i=0;i<contacts.length;i++){var n=this.formatContactName(contacts[i]);if(n===null){continue;}
formatted.push(n);}
return formatted;};Format.prototype.formatContactString=function(contacts){var contactsText;if(contacts.length===0){return"";}
if(contacts.length==1){contactsText=this.formatContactName(contacts[0]);}else{var formatted=this.formatContactList(contacts);contactsText=formatted.join(", ");}
return contactsText;};Format.prototype.formatParticipantsString=function(participants){var seenParts={};var ids=[];for(var i=0;i<participants.length;i++){if(is(seenParts[participants[i].person_id])){continue;}
seenParts[participants[i].person_id]=true;ids.push(participants[i].person_id);}
return ids.length>0?this.formatContactString(ids):"";};Format.prototype.formatLocationStatistics=function(id){if(view.getViewToken("Settings","Locations")){settingsView.locationDetails.fieldsTitle.setEnabled(false);var tpl="INTERFACE_SETTINGS_LOCATIONS_ZERO_LOCATIONS";var num=locationList.list.entries.length;if(num===1){tpl="INTERFACE_SETTINGS_LOCATIONS_ONE_LOCATION";}else{if(num>1){tpl="INTERFACE_SETTINGS_LOCATIONS_NUM_LOCATIONS";}}
settingsView.locationDetails.fieldsTitle.setValue(_T(tpl,{"NUM":locationList.list.entries.length}),true);}
settingsView.locationDetails.hide();if(view.getViewToken("Settings","Locations")){settingsView.locationDetails.fieldsTitle.show();}};Format.prototype.formatLocation=function(id){var l=locationMgr.locations_[id];if(l===null){return false;}
if(view.getViewToken("Settings","Locations")){settingsView.locationDetails.fieldsTitle.setEnabled(true);settingsView.locationDetails.fieldsTitle.setValue(unescape(l.name).escapeForDisplay(),true);var properties=[];if(id===configurationMgr.configuration.defaultLocation){properties.push(_T("INTERFACE_SETTINGS_LOCATIONS_LOCATION_DEFAULT"));}
if(l.address){properties.push(_T("INTERFACE_SETTINGS_LOCATIONS_ADDRESS",{"LOCATION_ADDRESS":l.address}));}
if(properties.length>0){settingsView.locationDetails.locationDescription.setEscape(false);settingsView.locationDetails.locationDescription.setHidden(false);settingsView.locationDetails.locationDescription.setValue(properties.join("<br />"),true);settingsView.locationDetails.locationDescription.show();settingsView.locationDetails.show();}else{settingsView.locationDetails.hide();}}
return true;};function StatusBox(boxId,textId,buttonsId){this.boxId=boxId;this.textId=textId;this.buttonsId=buttonsId;this.box=el(boxId);this.text=el(textId);this.buttons=el(buttonsId);this.timeout=null;this.currentText=null;this.undoId=this.boxId+"Undo";this.undo=null;this.undoTimeout=null;this.sharing=false;this.locating=false;this.inited=false;this.visible=false;}
StatusBox.prototype.init=function(){this.inited=true;this.mbn=this.getUniqueMessageBusName();messageBus.subscribe(this.setText,this.mbn+"setText");};StatusBox.prototype.getUniqueMessageBusName=function(){return"rtm.statusbox."+this.boxId+".";};StatusBox.prototype.setText=function(text,undo,withTimeout){var t=[];this.clearStatusTimeout();this.currentText=text;t.push("<span>"+text+"</span>");if(undo){t.push("<span id=\""+this.undoId+"\">"+_TF(["INTERFACE_STATUS_UNDO","",false],{"LINK_ONCLICK":"statusBox.undoClicked(); return false;"})+"</span>");}
if(this.sharing){this.buttons.style.display="";withTimeout=false;}else{this.buttons.style.display="none";}
this.text.innerHTML=t.join(" ");if(withTimeout){this.setStatusTimeout(undo);}
if(undo){this.undo=el(this.undoId);}
this.show();};StatusBox.prototype.show=function(){this.box.style.visibility="visible";this.visible=true;};StatusBox.prototype.hide=function(){this.box.style.visibility="hidden";this.visible=false;this.clearStatusTimeout();this.undo=null;};StatusBox.prototype.setStatusTimeout=function(undo){var self=this;var hideFunc=function(){self.hide();};var timeout=!undo?(10*1000):(30*1000);this.timeoutSetAt=new Date().getTime();this.timeout=setTimeout(hideFunc,timeout);};StatusBox.prototype.clearStatusTimeout=function(){if(this.timeout){clearTimeout(this.timeout);if(this.timeoutSetAt){var end=(new Date().getTime()-this.timeoutSetAt)/1000;this.timeoutSetAt=null;}else{}
this.timeout=null;}};StatusBox.prototype.undoSetText=function(text){if(!this.undo){this.setText(this.currentText,true,true);}
this.undo.innerHTML=text;};StatusBox.prototype.undoFailed=function(){this.undoClearTimeout();this.clearStatusTimeout();this.undoSetText(_TF(["INTERFACE_STATUS_UNDO_FAILED_TRY_AGAIN","",false],{"LINK_ONCLICK":"statusBox.undoClicked(); return false;"}));this.setStatusTimeout(true);};StatusBox.prototype.undoSuccess=function(){this.undoClearTimeout();this.undoSetText(_T("INTERFACE_STATUS_UNDO_OK"));this.setStatusTimeout(false);};StatusBox.prototype.undoSetTimeout=function(){var self=this;var undoFunc=function(){self.undoFailed();};this.undoTimeout=setTimeout(undoFunc,10*1000);};StatusBox.prototype.undoClearTimeout=function(){if(this.undoTimeout){clearTimeout(this.undoTimeout);this.undoTimeout=null;}};StatusBox.prototype.undoClicked=function(){var id=this.undo.id||0;var undoing=undoMgr.undoTransaction(id);if(undoing==true){this.undoSetTimeout();this.undoSetText(_T("INTERFACE_STATUS_UNDOING"));}else{this.undoSetText(_T("INTERFACE_STATUS_UNDO_FAILED"));}};StatusBox.prototype.sharingSetText=function(done,extraInfo){var text;if(view.shareMode!==null){if(view.shareMode==Control.SHARE_TASK_SHARE){var selected=taskList.getViewList().getSelected();if(selected===null||selected.length==0){return false;}
var tpl;tpl=done?"INTERFACE_SHARING_TASK_WITH_DONE":"INTERFACE_SHARING_TASK_WITH";if(selected.length>1){tpl=done?"INTERFACE_SHARING_NUM_TASKS_WITH_DONE":"INTERFACE_SHARING_NUM_TASKS_WITH";}
if(extraInfo&&extraInfo[1].length>0){var total=extraInfo[0];var notInList=extraInfo[1];var participants=extraInfo[2];var failed_contacts=format.formatContactString(notInList);var success_contacts=null;if(participants&&participants.length>0){success_contacts=format.formatContactString(participants);}
if(!(notInList.length===0||notInList.length===participants.length)){done=false;}
var tpl;if(selected.length===1){if(done===true){tpl="INTERFACE_SHARING_TASK_WITH_SUCCESS";}else{tpl="INTERFACE_SHARING_TASK_WITH_FAILED";}}else{if(done===true){tpl="INTERFACE_SHARING_NUM_TASKS_WITH_SUCCESS";}else{tpl="INTERFACE_SHARING_NUM_TASKS_WITH_FAILED";}}
text=_T(tpl,{"TASK_NAME":unescape(stateMgr.tasks[selected[0]].name).escapeForDisplay(),"TASK_NUM":selected.length,"SUCCESS_CONTACTS":success_contacts,"FAILED_CONTACTS":failed_contacts});}else{text=_T(tpl,{"TASK_NAME":unescape(stateMgr.tasks[selected[0]].name).escapeForDisplay(),"TASK_NUM":selected.length});}}else{if(view.shareMode==Control.SHARE_TASK_SEND){var selected=taskList.getViewList().getSelected();if(selected===null||selected.length==0){return false;}
var tpl;tpl=done?"INTERFACE_SENDING_TASK_TO_DONE":"INTERFACE_SENDING_TASK_TO";if(selected.length>1){tpl=done?"INTERFACE_SENDING_NUM_TASK_TO_DONE":"INTERFACE_SENDING_NUM_TASK_TO";}
if(extraInfo&&extraInfo[1].length>0){var total=extraInfo[0];var notInList=extraInfo[1];var participants=extraInfo[2];var failed_contacts=format.formatContactString(notInList);var success_contacts=null;if(participants&&participants.length>0){success_contacts=format.formatContactString(participants);}
if(!(notInList.length===0||notInList.length===participants.length)){failed_contacts=format.formatContactString(notInList);done=false;}
var tpl;if(selected.length===1){if(done===true){tpl="INTERFACE_SENDING_TASK_TO_DONE_WITH_SUCCESS";}else{tpl="INTERFACE_SENDING_TASK_TO_DONE_WITH_FAILED";}}else{if(done===true){tpl="INTERFACE_SENDING_NUM_TASK_TO_DONE_SUCCESS";}else{tpl="INTERFACE_SENDING_NUM_TASK_TO_DONE_FAILED";}}
text=_T(tpl,{"TASK_NAME":unescape(stateMgr.tasks[selected[0]].name).escapeForDisplay(),"TASK_NUM":selected.length,"SUCCESS_CONTACTS":success_contacts,"FAILED_CONTACTS":failed_contacts});}else{text=_T(tpl,{"TASK_NAME":unescape(stateMgr.tasks[selected[0]].name).escapeForDisplay(),"TASK_NUM":selected.length});}}else{if(view.shareMode==Control.SHARE_LIST_SHARE){text=_T("INTERFACE_SHARING_X_WITH",{"LIST_NAME":unescape(stateMgr.lists[stateMgr.currentList].name).escapeForDisplay()});}else{if(view.shareMode==Control.PUBLISH_LIST_PUBLISH){text=_T("INTERFACE_PUBLISHING_X_TO",{"LIST_NAME":unescape(stateMgr.lists[stateMgr.currentList].name).escapeForDisplay()});}}}}
this.setText(text,false,true);return true;}};StatusBox.prototype.sharingEnableDone=function(enable){var self=this;switch(view.shareMode){case Control.SHARE_TASK_SHARE:case Control.SHARE_LIST_SHARE:tasksView.statusDoneButton.setText(_T("INTERFACE_TASKS_LIST_DETAILS_SHARE"));break;case Control.SHARE_TASK_SEND:tasksView.statusDoneButton.setText(_T("INTERFACE_BUTTON_SEND"));break;case Control.PUBLISH_LIST_PUBLISH:tasksView.statusDoneButton.setText(_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH_PUBLISH_BUTTON"));break;default:tasksView.statusDoneButton.setText("Done");break;}
if(!enable){tasksView.statusDoneButton.setColor("grey");tasksView.statusDoneButton.setClickFunction(function(){},false);}else{tasksView.statusDoneButton.setColor("blue");var clickFunc=function(ev){messageBus.broadcast(self,self.mbn+"buttonClicked","Done");};tasksView.statusDoneButton.setClickFunction(clickFunc,true);}};StatusBox.prototype.sharingEnableCancel=function(){var self=this;tasksView.statusCancelButton.setText(_T("INTERFACE_TASKS_NOTES_CANCEL_BUTTON"));tasksView.statusCancelButton.setColor("orange");var clickFunc=function(ev){messageBus.broadcast(self,self.mbn+"buttonClicked","Cancel");};tasksView.statusCancelButton.setClickFunction(clickFunc,true);};StatusBox.prototype.sharingStart=function(){this.sharing=true;this.sharingEnableDone(false);this.sharingEnableCancel();};StatusBox.prototype.sharingStop=function(){this.sharing=false;this.hide();};StatusBox.prototype.retryClicked=function(which){var a=el("requestTryAgain");a.innerHTML=_T("INTERFACE_TRYING");transMgr.retryRequest(which);this.setStatusTimeout(false);};StatusBox.prototype.locationStart=function(){this.locating=true;this.setText(_TF(["INTERFACE_LOCATIONS_CLICK_DESIRED","",false],{"LINK_ONCLICK":"locationMgr.handleEscape(); return false;"}),false,true);};StatusBox.prototype.locationStop=function(){this.locating=false;this.hide();};function Button(buttonId){this.buttonId=buttonId;this.button=el(this.buttonId);this.text=null;this.color=null;}
Button.COLORS={"grey":[null,null,null,null,null],"orange":["roundbtn_org","roundbtn1_org","roundbtn2_org","roundbtnwrap_org","roundbtn_content_org"],"blue":["roundbtn_blu","roundbtn1_blu","roundbtn2_blu","roundbtnwrap_blu","roundbtn_content_blu"]};Button.prototype.setText=function(text){if(this.text!=text){this.text=text;this.blit();}};Button.prototype.setColor=function(color){if(!color||!Button.COLORS[color]){color="grey";}
if(this.color!=color){this.color=color;this.blit();}};Button.prototype.setClickFunction=function(func,makeTarget){if(!this.button){return false;}
this.button.onclick=function(ev){return func(ev);};if(makeTarget){this.button.className="xtarget";}else{this.button.className="";}};Button.prototype.blit=function(){if(!this.button){return false;}
var cls=this.color?Button.COLORS[this.color]:Button.COLORS["grey"];var html=[];html.push(cls[0]?("<div class=\"roundbtn "+cls[0]+"\">"):"<div class=\"roundbtn\">");html.push(cls[3]?("<b class=\"roundbtnwrap "+cls[3]+"\">"):"<b class=\"roundbtnwrap\">");html.push(cls[1]?("<b class=\"roundbtn1 "+cls[1]+"\"></b>"):"<b class=\"roundbtn1\"></b>");html.push(cls[2]?("<b class=\"roundbtn2 "+cls[2]+"\"></b>"):"<b class=\"roundbtn2\"></b>");html.push("</b>");html.push(cls[4]?("<div class=\"roundbtn_content "+cls[4]+"\">"+this.text+"</div>"):"<div class=\"roundbtn_content\">"+this.text+"</div>");html.push(cls[3]?("<b class=\"roundbtnwrap "+cls[3]+"\">"):"<b class=\"roundbtnwrap\">");html.push(cls[2]?("<b class=\"roundbtn2 "+cls[2]+"\"></b>"):"<b class=\"roundbtn2\"></b>");html.push(cls[1]?("<b class=\"roundbtn1 "+cls[1]+"\"></b>"):"<b class=\"roundbtn1\"></b>");html.push("</div>");this.button.innerHTML=html.join("");return true;};function TransactionManager(){this.inTxn=false;this.rtmPath="/rtm.rtm";this.r=null;this.inRpc=false;this.SSO=null;this.DM=1;this.timeline=null;this.loadSpec=null;this.queue=[];this.timeoutQueue=[];this.getMap={"lists.load":true,"rtm.preload":true,"rtm.public.preload":true,"lists.public.load":true};this.noneMap={"tasks.complete":true,"tasks.uncomplete":true,"tasks.postpone":true,"lists.delete":true,"lists.archive":true,"lists.unarchive":true};this.noneChangedMap={"tasks.setPriority":false};this.completedMap={"tasks.uncomplete":false,"tasks.delete":false};}
TransactionManager.REQUEST_TIMEOUT=20;TransactionManager.prototype.setSingleSignOn=function(username){this.SSO=hex_sha1(username);};TransactionManager.prototype.setTimeline=function(timeline){setCookie("TIMELINE",timeline,null,"/",null,null);};TransactionManager.prototype.setLoadInformation=function(loadSpec){this.loadSpec=loadSpec;if(parseFloat(this.loadSpec[1])>10){messageBus.broadcast(this,this.mbn+"loadThreshold");}};TransactionManager.prototype.setDistributionMultiplier=function(DM){this.DM=DM;return this.DM;};TransactionManager.prototype.getDistributionMultiplier=function(){return this.DM;};TransactionManager.prototype.createXMLHTTPRequest=function(){return new XMLHttpRequest();};TransactionManager.prototype.getRandomInt=function(x){return Math.floor(x*Math.random());};TransactionManager.prototype.requestFailed=function(which){var request=this.queue[which];if(!request){return true;}
if(statusBox){var msg=_TF(["INTERFACE_STATUS_FAILED_AGAIN","",false],{"REQUEST_NAME":request[0],"LINK_ONCLICK":"statusBox.retryClicked("+which+"); return false;","LINK_WRAP":"requestTryAgain"});statusBox.setText(msg);}
clearTimeout(this.timeoutQueue[which]);this.timeoutQueue[which]=null;};TransactionManager.prototype.retryRequest=function(which){var request=this.queue[which];this.request(request[0],request[1]);};TransactionManager.prototype.requestSuccess=function(which){var request=this.queue[which];clearTimeout(this.timeoutQueue[which]);this.timeoutQueue[which]=null;this.shortenQueue(which);if(statusBox&&statusBox.text.innerHTML.indexOf("TryAgain")>-1){statusBox.hide();}
if(rtmUsername==="okilani_demo"){statusBox.setText(request[0]+" success. Took "+(new Date()-request[2])+" ms");}};TransactionManager.prototype.shortenQueue=function(which){for(var i=0;i<which;i++){if(this.timeoutQueue[i]!==null){clearTimeout(this.timeoutQueue[i]);}}
this.queue=[];this.timeoutQueue=[];};TransactionManager.prototype.request=function(ac,ar){var self=this;var current_request=this.createXMLHTTPRequest();if(current_request){this.queue.push([ac,ar,new Date()]);var which=this.queue.length-1;var failCallback=function(){self.requestFailed(which);};this.timeoutQueue.push(setTimeout(failCallback,TransactionManager.REQUEST_TIMEOUT*1000));var count=5000;while(this.inRpc&&count--){}
var req_params={"v":version,"format":"js","ac":ac,"ar":encodeURIComponent(ar),"sso":this.SSO,"rid":which,"zx":Math.random()};var q=Utility.SortAndSign(req_params);if(is(this.getMap[ac])){q=this.rtmPath+"?"+q;current_request.open("GET",q,true);}else{current_request.open("POST",this.rtmPath,true);current_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
current_request.onreadystatechange=function(){if(current_request&&current_request.readyState==4){if(current_request.responseText){if(current_request.responseText.charAt(0)=="<"){self.requestFailed(which,true);}else{eval(current_request.responseText.substring("while(1);".length));}}
if(self.r===current_request){self.inRpc=false;self.r=null;}
current_request=null;}};this.inRpc=true;this.r=current_request;if(is(this.getMap[ac])){current_request.send(null);}else{current_request.send(q);}}};TransactionManager.prototype.checkNoneSelected=function(ac,n){if(n==false){return false;}
if(ac.indexOf("tasks.setPriority")==0){return true;}
if(ac.indexOf("applyLabel")==0){return true;}
if(this.noneMap[ac]==null){return false;}
return this.noneMap[ac];};TransactionManager.prototype.checkNoneChanged=function(ac,n){if(!(!n)){return true;}
if(ac.indexOf("tasks.setPriority")==0){return false;}
if(this.noneChangedMap[ac]===null){return true;}
return this.noneChangedMap[ac];};TransactionManager.prototype.checkCompletedView=function(ac){if(ac.indexOf("tasks.setPriority")==0){return true;}
if(ac.indexOf("applyLabel")==0){return false;}
if(this.completedMap[ac]==null){return true;}
return this.completedMap[ac];};TransactionManager.prototype.executeTxn=function(fc,ac,fa){var ids=[];var args={};var currentView=view.getSelected().toString();switch(currentView){case"Tasks":var L=taskList.getViewList();var selected=L.selected;var entries=L.entries;for(var i=0;i<selected.length;i++){ids.push(entries[selected[i]][0]);}
args={"list":stateMgr.currentList,"tasks":control.taskSeriesMap(L.getSelected())};break;default:break;}
if(this.checkNoneSelected(ac,ids.length==0)==true){statusBox.setText(_T("INTERFACE_STATUS_HAVE_TO_SELECT"));return false;}
if(currentView=="Tasks"&&taskList.view==TaskList.TASK_LIST_VIEW_COMPLETED&&this.checkCompletedView(ac)==true){statusBox.setText(_T("INTERFACE_STATUS_CANT_DO_TO_COMPLETED"));return false;}
this.beginTxn();var changed=null;if(!!fc){if(fa){changed=fc(ids,fa);}else{changed=fc(ids);}}
if(this.checkNoneChanged(ac,changed)==true){this.request(ac,utility.encodeJavaScript(args));}else{messageBus.broadcast(this,this.mbn+"noneChanged",ac);}
this.endTxn();return false;};TransactionManager.prototype.beginTxn=function(){this.inTxn=true;};TransactionManager.prototype.endTxn=function(){this.inTxn=false;};function Tabs(id,style){this.id=id;this.div=el(id);if(style=="grey"){this.div.className="xtabs xtabs_grey";}else{this.div.className="xtabs";}
this.entries=[];this.data=[];this.html=null;this.map={};this.reverseMap={};this.blitted=false;this.special={};this.mbn=null;this.selected=null;this.defaultEntry=null;this.inited=false;this.hidden=false;this.sortSpec=null;this.sortSpecClean=null;this.hashMap=null;}
Tabs.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();this.blitted=false;this.defaultEntry=null;this.inited=true;this.hidden=false;};Tabs.prototype.setSortParameters=function(hashMap,fields){this.hashMap=hashMap;this.sortFields=fields;};Tabs.prototype.doSort=function(a,b){for(var i=0;i<a.length;i++){if(a[i]===null&&b[i]!==null){return 1;}else{if(a[1]!==null&&b[i]===null){return-1;}}
if(a[i]>b[i]){return 1;}else{if(a[i]<b[i]){return-1;}}}
return 0;};Tabs.prototype.sort=function(){var entriesSort=[];for(var j=0;j<this.entries.length;j++){var data=this.data[j];var entryTuple=[];if(data instanceof Array){if(data[0]!=TasksView.LIST_TYPE_NORMAL){continue;}
data=data[1];}
for(var i=0;i<this.sortFields.length;i++){var f=this.sortFields[i];var v=eval("this.hashMap[data]."+f);entryTuple.push(v);}
entryTuple.list=this;entryTuple.id=data;entriesSort.push(entryTuple);}
entriesSort.sort(this.doSort);var remapList=[];for(var i=0;i<entriesSort.length;i++){remapList.push([entriesSort[i].id,i]);}
var iters=0;var needUpdate=[];var selectedData=this.data[this.selected];var rcuEntries=cloneArr(this.entries);var rcuMap=cloneObj(this.map);var rcuReverseMap=cloneObj(this.reverseMap);var rcuData=cloneArr(this.data);for(var i=0;i<remapList.length;i++){var oldId=rcuData[remapList[i][1]];if(oldId instanceof Array){oldId=oldId[1];}
var newId=remapList[i][0];var oldPos=remapList[i][1];var newPos=rcuReverseMap[newId];if(oldPos==newPos){continue;}
rcuMap[rcuEntries[oldPos]]=newPos;rcuMap[rcuEntries[newPos]]=oldPos;rcuReverseMap[oldId]=newPos;rcuReverseMap[newId]=oldPos;var tmpEntry=rcuEntries[oldPos];rcuEntries[oldPos]=rcuEntries[newPos];rcuEntries[newPos]=tmpEntry;var tmpData=rcuData[oldPos];rcuData[oldPos]=rcuData[newPos];rcuData[newPos]=tmpData;needUpdate.push(oldPos);needUpdate.push(newPos);iters++;}
this.map=rcuMap;this.reverseMap=rcuReverseMap;this.data=rcuData;this.entries=rcuEntries;this.blitted=false;if(is(selectedData)){if(selectedData instanceof Array){selectedData=selectedData[1];}
this.selected=this.reverseMap[selectedData];}else{this.selected=0;}
this.blitDiv();};Tabs.prototype.printMappings=function(){for(var i=0;i<this.entries.length;i++){}};Tabs.prototype.removeEntryByData=function(data){if(data instanceof Array){data=data[1];}
var pos=this.reverseMap[data];this.removeEntry(pos);};Tabs.prototype.removeEntry=function(pos,dontBlit){var data=this.data[pos];if(data instanceof Array){data=data[1];}
this.data[pos]=null;this.reverseMap[data]=null;assert(this.entries[pos]!=="Inbox","Tried to delete inbox!");this.entries.splice(pos,1);var max=this.entries.length;for(var i=pos+1;i<max+1;i++){var entry=this.data[i];if(entry instanceof Array){this.reverseMap[entry[1]]=i-1;}else{this.reverseMap[entry]=i-1;}
this.data[i-1]=entry;}
if(this.selected===pos){this.selected=0;this.blitDiv();this.selectDefault();}else{if(this.selected>pos){this.selected=this.selected-1;if(!dontBlit){this.blitDiv();}}else{if(!dontBlit){this.blitDiv();}}}};Tabs.prototype.setDefaultEntry=function(defaultEntry){this.defaultEntry=defaultEntry;};Tabs.prototype.show=function(){var self=this.div;if(false&&is_gecko&&!is_safari){var show=function(){self.style.display="";};setTimeout(show,1);}else{self.style.display="";}
this.hidden=false;};Tabs.prototype.hide=function(){var self=this.div;if(false&&is_gecko&&!is_safari){var hide=function(){self.style.display="none";};setTimeout(hide,1);}else{this.div.style.display="none";}
this.hidden=true;};Tabs.prototype.getUniqueMessageBusName=function(){return"rtm.tabs."+this.id+".";};Tabs.prototype.addEntry=function(entry,data,isSpecial,name){this.map[entry]=this.entries.length;this.entries.push(entry);if(data===0||data){this.data[this.entries.length-1]=data;if(data instanceof Array){if(isSpecial){this.special[data[1]]=1;}
this.reverseMap[data[1]]=this.entries.length-1;}else{if(isSpecial){this.special[data]=1;}
this.reverseMap[data]=this.entries.length-1;}}
return this.entries.length-1;};Tabs.prototype.entryExists=function(entry){return(is(this.map[entry]));};Tabs.prototype.setDataForEntry=function(entry,data){if(is(this.map[entry])){this.data[this.map[entry]]=data;if(data instanceof Array){this.reverseMap[data[1]]=this.map[entry];}else{this.reverseMap[data]=this.map[entry];}}};Tabs.prototype.getSelected=function(){if(this.selected!==null){return this.entries[this.selected];}
return null;};Tabs.prototype.selectDefault=function(suppress){if(this.inited){if(this.defaultEntry!==null){this.selectTabByPosition(this.defaultEntry,suppress);}else{this.selectTabByPosition(0,suppress);}}};Tabs.prototype.selectTab=function(newTab,suppress){var newPos=this.map[newTab];this.selectTabByPosition(newPos,suppress);};Tabs.prototype.selectTabByData=function(data){var pos=null;for(var i=0;i<this.data.length;i++){if(this.data[i]instanceof Array&&this.data[i][1]==data){pos=i;break;}else{if(!(this.data[i]instanceof Array)&&this.data[i]==data){pos=i;break;}}}
this.selectTabByPosition(pos);};Tabs.prototype.selectTabByPosition=function(newPos,suppress){var old=this.selected;if(newPos!==null&&newPos<this.entries.length){this.selected=newPos;}else{return false;}
if(!this.blitted){this.blitDiv();}else{var tabs=this.div.getElementsByTagName("li");var otherFound=false;var reassigned=false;for(var i=0;i<tabs.length;i++){var tab=tabs[i];if(tab.className.indexOf("selected")>-1&&i!=this.selected){if(this.id=="listtabs"&&this.data[i][0]!=TasksView.LIST_TYPE_NORMAL){tab.className="xtab_smartlist";}else{tab.className="";}
otherFound=true;}
if(i==this.selected){if(tab.className.indexOf("selected")==-1){tab.className="xtab_selected";reassigned=true;}
if(otherFound){break;}}}
if(!reassigned&&old!=newPos){this.blitDiv();}}
if(messageBus&&!suppress){var data=this.data[newPos];if(!is(data)){data=null;}
messageBus.broadcast(this,this.mbn+"tabChanged",[[old,(old!==null?this.entries[old]:"")],[this.selected,this.entries[newPos]],data]);}};Tabs.prototype.sortOld=function(){this.entries.sort();for(var i=0;i<this.entries.length;i++){this.map[this.entries[i]]=i;}};Tabs.prototype.renameEntry=function(from,to){for(var i=0;i<this.entries.length;i++){if(this.entries[i]==from){this.map[to]=i;delete this.map[from];this.entries[i]=to;return;}}};Tabs.prototype.renameEntryByData=function(id,newName){for(var i=0;i<this.entries.length;i++){if(is(this.entries[i])&&((this.data[i]instanceof Array&&this.data[i][1]==id)||(!(this.data[i]instanceof Array)&&this.data[i]==id))){this.entries[i]=newName;this.div.getElementsByTagName("a")[i].innerHTML=newName;return;}}};Tabs.prototype.blitDiv=function(){var htmlOut=[];htmlOut.push("<ul>");for(var i=0;i<this.entries.length;i++){var prop=[];if(this.selected===i){prop.push("xtab_selected");}
if(this.id=="listtabs"&&this.data[i]instanceof Array&&this.data[i][0]!=TasksView.LIST_TYPE_NORMAL){prop.push("xtab_smartlist");}
var cls=prop.length==0?"":" class=\""+prop.join(" ")+"\"";var special="";if(this.data[i]instanceof Array&&is(this.special[this.data[i][1]])){special=" <img src=\"http://static.rememberthemilk.com/img/tabclose.gif\" onclick=\"listTabs.removeEntryByData("+this.data[i][1]+"); return false;\" />";}
htmlOut.push("<li"+cls+"><a href=\" \">"+this.entries[i]+special+"</a></li>");}
htmlOut.push("</ul>");this.html=htmlOut.join("");this.div.innerHTML=this.html;var links=this.div.getElementsByTagName("li");for(var i=0;i<this.entries.length;i++){var link=links[i];var self=this;var entry=this.entries[i];var pos=i;link.pos=i;link.entry=entry;link.onclick=function(ev){try{this.blur();}
catch(e){}
self.selectTabByPosition(this.pos);return false;};}
this.blitted=true;};Tabs.prototype.selectLeft=function(){if(this.selected!==0){this.selectTabByPosition(this.selected-1);}else{this.selectTabByPosition(this.entries.length-1);}};Tabs.prototype.selectRight=function(){if(this.selected+1!==this.entries.length){this.selectTabByPosition(this.selected+1);}else{this.selectTabByPosition(0);}};function Field(id,image){this.id=id;if(image){this.image=imageMgr.getImage(image,true);}else{this.image=null;}
this.div=el(id);this.mbn=null;this.inited=false;this.title=null;this.value=null;this.fieldValue=null;this.klass=null;this.defaultValue=null;this.state=Field.FIELD_STATE_DISPLAY;this.enabled=true;this.hidden=false;this.escape=true;this.count=null;this.lockable=false;this.neverEmpty=false;this.newLine=false;this.delayHide=false;this.table=false;this.input=null;this.highlightable=false;this.autocompleteStore=null;this.autocomplete=null;this.autocomplete_autocommit=false;this.blitted=0;this.nextField=null;this.previousField=null;}
Field.FIELD_STATE_DISPLAY=0;Field.FIELD_STATE_EDIT=1;Field.prototype.init=function(){this.inited=true;this.mbn=this.getUniqueMessageBusName();this.title=null;this.value=null;this.fieldValue=null;this.defaultValue=null;this.state=Field.FIELD_STATE_DISPLAY;this.enabled=true;this.hidden=false;this.escape=true;this.count=null;this.delayHide=false;this.table=false;this.input=null;};Field.prototype.getUniqueMessageBusName=function(){return"rtm.fields."+this.id+".";};Field.prototype.show=function(){if(this.hidden){this.hide();}else{this.div.style.display="";}};Field.prototype.hide=function(){this.div.style.display="none";};Field.prototype.setHidden=function(hidden){this.hidden=hidden;};Field.prototype.setDelayedHide=function(delayHide){this.delayHide=delayHide;};Field.prototype.setLockable=function(lockable){this.lockable=lockable;};Field.prototype.setHighlightable=function(highlightable){this.highlightable=highlightable;};Field.prototype.setNeverEmpty=function(neverEmpty){this.neverEmpty=neverEmpty;};Field.prototype.setNewLineAfterTitle=function(nl){this.newLine=nl;};Field.prototype.setTitle=function(newTitle){this.title=newTitle;};Field.prototype.setAutocompleteStore=function(store){this.autocompleteStore=store;};Field.prototype.setAutocompleteAutocommit=function(autocommit){this.autocomplete_autocommit=autocommit;};Field.prototype.setCount=function(newCount){this.count=newCount;if(this.id&&view){assert(!(this.id=="detailstitle"&&view.getSelected()==="Settings"&&this.count!==null),"Setting count in settings mode");}};Field.prototype.setKlass=function(klass){this.klass=klass;};Field.prototype.setEscape=function(newEscape){this.escape=newEscape;};Field.prototype.setTable=function(newTable){this.table=newTable;};Field.prototype.setValue=function(newValue,force){if(force||(this.value!==newValue&&newValue!==null)){this.value=newValue;if(this.state==Field.FIELD_STATE_DISPLAY){this.blit();}
return true;}
return false;};Field.prototype.setFieldValue=function(newValue,force){if(force||(this.fieldValue!==newValue&&newValue!==null)){this.fieldValue=newValue;if(this.state==Field.FIELD_STATE_DISPLAY){this.blit();}
return true;}
return false;};Field.prototype.setDefaultValue=function(newValue){assert(!(this.id=="detailstitle"&&tasksView.getHovering()===true),"Field title set whilst hovering");this.defaultValue=newValue;};Field.prototype.setEnabled=function(enabled){this.enabled=enabled;};Field.prototype.setNextField=function(field){this.nextField=field;};Field.prototype.setPreviousField=function(field){this.previousField=field;};Field.handleTabPress=function(self,ev,value){if(is_safari){self.fieldKeyPressed=true;}
view.inTab=true;var oldDelay=self.delayHide;self.delayHide=false;self.stopEditing(value);self.delayHide=oldDelay;if(self.id=="detailstitle"&&view.getViewToken("Tasks","Tasks")){if(!ev.shiftKey){tasksView.taskDetails.detailsDue.startEditing();}else{tasksView.taskDetails.detailsURL.startEditing();}}else{if(ev.shiftKey&&self.id=="detailsdue"&&view.getViewToken("Tasks","Tasks")){tasksView.taskDetails.fieldsTitle.startEditing();}else{if(!ev.shiftKey&&self.id=="detailsurl"&&view.getViewToken("Tasks","Tasks")){tasksView.taskDetails.fieldsTitle.startEditing();}}}
if(ev.shiftKey===false&&self.nextField!==null){self.nextField.startEditing();}else{if(ev.shiftKey===true&&self.previousField!==null){self.previousField.startEditing();}}
if(!is_safari){utility.stopEvent(ev);}
view.inTab=false;return false;};Field.prototype.startEditing=function(){if(!this.enabled){return false;}
messageBus.broadcast(this,this.mbn+"editStarted");this.state=Field.FIELD_STATE_EDIT;if(this.lockable){view.setViewLocked(true);}
var span=document.getElementById(this.id+"_span");if(!span){this.blit();}
var klass=this.klass?" class=\""+this.klass+"\"":"";var value=this.fieldValue||this.value||this.defaultValue||"";var field="<form style=\"display: inline;\" autocomplete=\"off\" "+klass+"><div style=\"display: inline;\" "+klass+"><input id="+quoted(this.id+"_editfield")+" style=\"display: inline;\" type=\"text\" value=\""+value.escapeForField()+"\" "+klass+"></input></div></form>";span.innerHTML=field;var input=span.getElementsByTagName("input")[0];this.input=input;var self=this;if(this.autocompleteStore){if(this.autocomplete){delete this.autocomplete;}
this.autocomplete=new Autocomplete(this.id+"_editfield",this.autocompleteStore);this.autocomplete.setAutocommit(this.autocomplete_autocommit);this.autocomplete.setField(this);}
input.focus();input.select();input.focus();var onblur=function(ev){if(self.state!==Field.FIELD_STATE_EDIT){return true;}
if(is_safari&&(self.fieldKeyPressed||self.blurring)){self.blurring=false;return true;}
if(is_safari){self.blurring=true;}
self.stopEditing(input.value);return false;};if(is_ie){var onkeydown=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if(pressed==9){Field.handleTabPress(self,ev,input.value);return false;}};}
var onkeypress=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if(!(is_ie||is_opera)&&((is_safari&&pressed==25&&ev.shiftKey)||pressed==9)){Field.handleTabPress(self,ev,input.value);return false;}else{if(pressed==13||(is_safari&&pressed==3)){if(is_safari){self.fieldKeyPressed=true;}
self.stopEditing(input.value);if(true||!is_safari){utility.stopEvent(ev);}
return false;}else{if(pressed==27){if(is_safari){self.fieldKeyPressed=true;}
self.stopEditing(null);if(!is_safari){utility.stopEvent(ev);}
return false;}}}};if(!this.autocompleteStore){GEvent.addDomListener(input,"blur",onblur);if(is_ie){GEvent.addDomListener(input,"keydown",onkeydown);}
GEvent.addDomListener(input,"keypress",onkeypress);}else{this._handle_blur=onblur;if(is_ie){this._handle_keydown=onkeydown;}else{this._handle_keydown=null;}
this._handle_keypress=onkeypress;}};Field.prototype.stopEditing=function(newValue){if(this.autocomplete){Autocomplete.removeInstance(this.autocomplete);}
if(this.input&&is_safari){this.input.blur();}
var trimmed_value=newValue?newValue.trim():"";this.state=Field.FIELD_STATE_DISPLAY;if(!(this.neverEmpty&&trimmed_value.length===0)&&(((this.fieldValue&&this.setFieldValue(newValue)==true)||(!this.fieldValue&&this.setValue(newValue)==true))&&!(this.lockable&&newValue.trim().toLowerCase()=="<multiple>"))){messageBus.broadcast(this,this.mbn+"editFinished",newValue);}else{messageBus.broadcast(this,this.mbn+"editCancelled",newValue);if(this.delayHide&&false){var self=this;self.waited=0;view.setWaitingForClick(true);var blitFunc=function(){if(self.waited++>11||view.getWaitingForClick()===false){self.blit();clearInterval(self.blitInterval);}else{if(view.getClickedLink()){self.blit();clearInterval(self.blitInterval);}}};view.setClickedLink(false);this.blitInterval=setInterval(blitFunc,100);}else{if(this.delayHide){var self=this;var blitFunc=function(){self.blit();};setTimeout(blitFunc,500);}else{this.blit();}}}
if(this.lockable){view.setViewLocked(false);}
this.fieldKeyPressed=false;};Field.prototype.safeBlit=function(){if(this.state==Field.FIELD_STATE_DISPLAY){this.blit();return true;}
return false;};Field.prototype.blit=function(){var htmlOut=[];var title=this.title?(this.title+": "+(this.newLine?"<br />":"")):null;var value=this.value||this.defaultValue||null;value=value?unescape(value):null;value=value&&this.escape?value.escapeForDisplay():value;var count=this.count?"<br /><span class=\"fieldcount\">("+this.count+")</span>":null;if(this.id&&view){assert(!(this.id=="detailstitle"&&view.getSelected()==="Settings"&&this.count!==null),"Setting count in settings mode "+this.count);}
if(this.table===false){var span=(title||"")+"<span class=\"field\" id="+quoted(this.id+"_span")+">"+(value||"")+"</span>"+(count||"");htmlOut.push(span);if(this.image&&this.enabled){assert(!(this.id=="detailstitle"&&view.getPublicMode()===true),"Enabled title in public mode");assert(!(this.id=="detailstitle"&&view.getViewToken("Tasks","Publish")===true&&!tasksView.getHovering()),"Enabled title in publish mode");var i="<a href=\" \" title="+quoted(this.image.title)+"><img class=\"field_img\" src="+quoted(this.image.src)+" alt="+quoted(this.image.alt)+" /></a>";htmlOut.push(i);}}else{var span="<div id="+quoted(this.id+"_span")+">"+(value||"")+"</div>"+(count||"");var i="<a href=\" \" title="+quoted(this.image.title)+"><img class=\"field_img\" src="+quoted(this.image.src)+" alt="+quoted(this.image.alt)+" /></a>";htmlOut.push("<table><tbody><tr><td>"+(title||"&nbsp;")+"</td><td>"+span+"</td><td style=\"vertical-align: bottom;\">"+i+"</td></tr></tbody></table>");}
this.html="<span id="+quoted(this.id+"_highlight")+">"+htmlOut.join("")+"</span>";this.div.innerHTML=this.html;if(this.image&&this.enabled){var img=this.div.getElementsByTagName("img");img=img.length>0?img[0]:null;if(img){var self=this;img.onclick=function(ev){self.startEditing();return false;};}}
if(this.highlightable&&this.enabled){var span=el(this.id+"_highlight");span.onmouseover=function(){this.style.backgroundColor="#FFFFCC";this.style.cursor="pointer";this.style.paddingTop="2px";this.style.paddingBottom="2px";};span.onmouseout=function(){this.style.backgroundColor="";this.style.cursor="";};if(this.image){span.onclick=function(ev){ev||(ev=window.event);var target=utility.getEventTarget(ev);if(target==null){return true;}
var target_lc=target.tagName.toLowerCase();if(target_lc=="a"||target_lc=="input"){return true;}
this.onmouseover=function(){};this.onmouseout();self.startEditing();return false;};}
if(this.image.title){span.setAttribute("title",this.image.title);}}
return this.html;};function FieldGroup(id,fieldsTitleId){this.id=id;this.div=el(id);if(fieldsTitleId){this.fieldsTitleId=fieldsTitleId;this.fieldsTitle=new Field(fieldsTitleId,"edit");this.fieldsTitle.init();this.fieldsTitle.setEnabled(false);this.fieldsTitle.setLockable(true);this.fieldsTitle.setNeverEmpty(true);this.fieldsTitle.setHighlightable(true);this.fieldsTitle.safeBlit();}
this.inited=false;this.fields=[];}
FieldGroup.prototype.init=function(){this.inited=true;};FieldGroup.prototype.addField=function(name,field){this.fields.push(field);eval("this."+name+" = field");};FieldGroup.prototype.show=function(){for(var i=0;i<this.fields.length;i++){this.fields[i].show();}
this.div.style.display="";};FieldGroup.prototype.hide=function(){for(var i=0;i<this.fields.length;i++){this.fields[i].hide();}
this.div.style.display="none";};FieldGroup.prototype.enable=function(){for(var i=0;i<this.fields.length;i++){this.fields[i].setEnabled(true);this.fields[i].safeBlit();}
if(this.fieldsTitle){this.fieldsTitle.setEnabled(true);this.fieldsTitle.safeBlit();}
assert(!(this.id=="taskdetails"&&taskList.view==TaskList.TASK_LIST_VIEW_COMPLETED),"Enable called in completed view");assert(!(this.id=="taskdetails"&&view.getPublicMode()===true),"Enable called in public mode");};FieldGroup.prototype.disable=function(){for(var i=0;i<this.fields.length;i++){this.fields[i].setEnabled(false);this.fields[i].safeBlit();}
if(this.fieldsTitle){this.fieldsTitle.setEnabled(false);this.fieldsTitle.safeBlit();}};function View(id){this.id=id;this.span=el(id);this.entries=[];this.map={};this.html=null;this.objs={};this.names={};this.mbn=null;this.selected=null;this.shareMode=null;this.publicMode=false;this.multiEditMode=false;this.viewLocked=false;this.inUndo=false;this.clickedLink=false;this.waitingForClick=false;this.bulk=View.BULK_RESET;this.inTab=false;}
View.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();var self=this;var selectedFunc=function(x,y){self.viewChanged(y);};messageBus.subscribe(selectedFunc,this.mbn+"viewChanged");};View.prototype.setShareMode=function(mode){this.shareMode=mode;};View.prototype.setPublicMode=function(mode){this.publicMode=mode;};View.prototype.getPublicMode=function(){return this.publicMode;};View.prototype.setInUndo=function(undo){this.inUndo=undo;};View.prototype.getInUndo=function(){return this.inUndo;};View.prototype.setViewLocked=function(locked){this.viewLocked=locked;messageBus.broadcast(this,this.mbn+"viewLocked",locked);};View.prototype.getViewLocked=function(){return this.viewLocked;};View.BULK_START=0;View.BULK_MODIFIED=1;View.BULK_END=2;View.BULK_IGNORE=3;View.BULK_REFRESH=4;View.BULK_RESET=5;View.BULK_MODIFIED_END=6;View.prototype.setBulk=function(bulk){this.bulk=bulk;};View.prototype.getBulk=function(){return this.bulk;};View.prototype.setMultiEditMode=function(mm){this.multiEditMode=mm;};View.prototype.getMultiEditMode=function(withoutHover){return this.multiEditMode&&(!withoutHover||(withoutHover&&!tasksView.getHovering()));};View.prototype.toggleMultiEditMode=function(){var current=!this.getMultiEditMode();this.setMultiEditMode(current);messageBus.broadcast(this,this.mbn+"modeChanged",["multiEditMode",current]);};View.prototype.setClickedLink=function(clicked){this.clickedLink=clicked;};View.prototype.getClickedLink=function(){return this.clickedLink;};View.prototype.setWaitingForClick=function(wait){this.waitingForClick=wait;};View.prototype.getWaitingForClick=function(){return this.waitingForClick;};View.prototype.getSelected=function(){var selectedObj=this.entries[this.selected];if(selectedObj){return selectedObj.toString();}else{return null;}};View.prototype.viewChanged=function(data){var fromId=data[0][0];var fromName=data[0][1];var toId=data[1][0];var toName=data[1][1];if(fromName!==null&&this.objs[fromName]!==null){this.objs[fromName].hide();}
if(toName!==null&&this.objs[toName]!==null){this.objs[toName].show();}};View.prototype.getUniqueMessageBusName=function(){return"rtm.view.";};View.prototype.addEntry=function(entry,obj,name){this.map[entry[0]]=this.entries.length;this.objs[entry[0]]=obj;this.names[entry[0]]=name||entry[0];this.entries.push(entry);};View.prototype.selectView=function(newView,suppressURL){var old=this.selected;this.selected=this.map[newView];if(this.selected===null||this.selected===old){return false;}
this.blitSpan();messageBus.broadcast(this,this.mbn+"viewChanged",[[old,(old!==null?this.entries[old][0]:null)],[this.selected,newView]]);if(!suppressURL){if(!is_safari){window.location.href="#section."+newView.toLowerCase();}}};View.prototype.blitSpan=function(){var htmlOut=[];for(var i=0;i<this.entries.length;i++){var withLink=this.entries[i].length>1;var link=withLink?this.entries[i][1][0]:"#section."+this.entries[i][0].toLowerCase();var target=null;if(withLink){target=this.entries[i][1][1]?"_blank":null;}
if(this.selected!==i){htmlOut.push("<a href="+quoted(link)+" "+(target?"target="+quoted(target):"")+">"+this.names[this.entries[i][0]]+"</a>");}else{htmlOut.push("<span style=\"font-weight: bold;\">"+this.names[this.entries[i][0]]+"</span>");}}
this.html=htmlOut.join(" | ");this.span.innerHTML=this.html;var links=this.span.getElementsByTagName("a");for(var i=0;i<this.entries.length;i++){var linkIdx=i;if(this.selected===i){continue;}
if(this.selected!==null&&i>this.selected){linkIdx--;}
var link=links[linkIdx];var self=this;var entry=this.entries[i][0];var pos=i;link.pos=i;link.entry=entry;link.onclick=function(ev){if(self.entries[this.pos].length>1){return true;}else{view.selectView(this.entry,true);return true;}};}};View.prototype.getViewTabs=function(){switch(this.getSelected()){case"Overview":return overviewTabs;case"Tasks":return listTabs;case"Contacts":return contactsTabs;case"Settings":return settingsTabs;default:break;}
return null;};View.prototype.getViewDetailTabs=function(){switch(this.getSelected()){case"Tasks":if(taskList.getViewList().selected.length>0){return taskTabs;}else{return detailstab;}
case"Contacts":return contactsdetailstab;case"Settings":return settingsdetailstab;default:break;}
return null;};View.prototype.getViewList=function(){switch(this.getSelected()){case"Tasks":return taskList.getViewList();case"Contacts":var selected=contactsView.getSelected();if(selected==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){return contactList.list;}else{if(selected==_T("INTERFACE_CONTACTS_GROUPS_TAB")){return groupList.list;}}
break;case"Settings":var selected=settingsView.getSelected();if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){return listList.list;}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){return locationList.list;}}
break;default:break;}
return null;};View.prototype.getViewToken=function(view,subView){var viewSelected=this.getSelected();if(viewSelected===view&&!is(subView)){return true;}
switch(this.getSelected()){case"Tasks":if(view=="Tasks"){var selected=taskList.getViewList().selected.length;var state=tasksView.getSelected();var taskState=taskTabs.getSelected();var listState=detailstab.getSelected();if((selected>0&&subView=="Tasks"&&taskState==_T("INTERFACE_TASKS_TASK_DETAILS_TASK_TAB"))||(tasksView.getHovering()&&subView=="Tasks"&&taskState==_T("INTERFACE_TASKS_TASK_DETAILS_TASK_TAB"))){return true;}else{if(selected>0&&subView=="Notes"&&taskState==_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB")||(tasksView.getHovering()&&subView=="Notes"&&taskState==_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB"))){return true;}else{if(selected===0&&subView=="List"&&(listState==_T("INTERFACE_TASKS_LIST_DETAILS_LIST"))){return true;}else{if(selected===0&&subView=="Share"&&listState==_T("INTERFACE_TASKS_LIST_DETAILS_SHARE")){return true;}else{if(selected===0&&subView=="Publish"&&listState==_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH")){return true;}else{if(selected===0&&subView=="Save"&&listState==_T("INTERFACE_TASKS_SAVE_TAB")){return true;}}}}}}
return false;}
return false;case"Contacts":if(view=="Contacts"){var selected=contactsView.getSelected();if(subView=="Contacts"&&selected==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){return true;}else{if(subView=="Groups"&&selected==_T("INTERFACE_CONTACTS_GROUPS_TAB")){return true;}else{if(subView=="Invites"&&selected==_T("INTERFACE_CONTACTS_INVITES_TAB")){return true;}}}
return selected===subView;}
return false;case"Settings":if(view=="Settings"){var selected=settingsView.getSelected();if(subView=="General"&&selected==_T("INTERFACE_SETTINGS_GENERAL_TAB")){return true;}else{if(subView=="Lists"&&selected==_T("INTERFACE_SETTINGS_LISTS_TAB")){return true;}else{if(subView=="Locations"&&selected==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){return true;}else{if(subView=="Reminders"&&selected==_T("INTERFACE_SETTINGS_REMINDERS_TAB")){return true;}else{if(subView=="Services"&&selected==_T("INTERFACE_SETTINGS_SERVICES_TAB")){return true;}else{if(subView=="Info"&&selected==_T("INTERFACE_SETTINGS_INFO_TAB")){return true;}}}}}}
return selected===subView;}
return false;default:break;}
return null;};View.prototype.adjustWidths=function(){var width=getWindowSize()[0];if(width<850){el("content").style.width="765px";el("listbox").style.width="505px";el("list").style.width="505px";el("overviewleft").style.width="505px";el("overviewnewsbox").style.width="505px";el("statusbox").style.display="none";el("statusbox").style.width="417px";el("statusbox").style.display="";el("listFilter").style.width="105px";el("searchtogglewrap").style.width="127px";if(is_opera){el("searchboxwrap").style.display="none";el("searchboxwrap").style.display="";}
el("mapbox").style.width="605px";el("mapwrap").style.width="603px";el("map").style.width="603px";}else{el("content").style.width="830px";el("listbox").style.width="570px";el("list").style.width="570px";el("overviewleft").style.width="570px";el("overviewnewsbox").style.width="570px";el("statusbox").style.display="none";el("statusbox").style.width="467px";el("statusbox").style.display="";el("listFilter").style.width="120px";el("searchtogglewrap").style.width="142px";el("mapbox").style.width="670px";el("mapwrap").style.width="668px";el("map").style.width="668px";}
if(!view.getPublicMode()&&locationMgr&&locationMgr.isInitialized()){locationMgr.checkResize();}};function ViewBase(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn=null;}
ViewBase.prototype.init=function(){this.inited=true;};ViewBase.prototype.addObject=function(objId){if(typeof objId=="string"){this.objs.push(el(objId));}else{this.objs.push(objId);}};ViewBase.prototype.addState=function(state,showIds,hideIds,tabs){var show=[];var hide=[];if(showIds!==null){for(var i=0;i<showIds.length;i++){if(typeof showIds[i]=="string"){show.push(el(showIds[i]));}else{show.push(showIds[i]);}}}
if(hideIds!==null){for(var i=0;i<hideIds.length;i++){if(typeof hideIds[i]=="string"){hide.push(el(hideIds[i]));}else{hide.push(hideIds[i]);}}}
this.states.push([state,show,hide]);var self=this;var switchStateFunc=function(x,newState){self.switchState(newState[1][1]);};messageBus.subscribe(switchStateFunc,tabs.mbn+"tabChanged");};ViewBase.prototype.switchState=function(newState){var stateObj=null;for(var i=0;i<this.states.length;i++){var state=this.states[i];if(state[0]!=newState){var show=state[1];for(var j=0;j<show.length;j++){if(show[j].hide){show[j].hide();}else{show[j].style.display="none";}}}else{this.selected=state[0];stateObj=[state[1],state[2]];}}
if(stateObj!==null){var show=stateObj[0];for(var i=0;i<show.length;i++){if(show[i].show){show[i].show();}else{show[i].style.display="";}}
this.currentStateObjs=stateObj;}};ViewBase.prototype.show=function(){for(var i=0;i<this.objs.length;i++){if(this.objs[i].show){this.objs[i].show();}else{this.objs[i].style.display="";}}
if(this.currentStateObjs!==null){var show=this.currentStateObjs[0];var hide=this.currentStateObjs[1];for(var i=0;i<hide.length;i++){if(hide[i].hide){hide[i].hide();}else{hide[i].style.display="none";}}
for(var i=0;i<show.length;i++){if(show[i].show){show[i].show();}else{show[i].style.display="";}}}else{if(this.states.length>0){this.switchState(this.states[0][0]);}}};ViewBase.prototype.hide=function(){for(var i=0;i<this.objs.length;i++){if(this.objs[i].hide){this.objs[i].hide();}else{this.objs[i].style.display="none";}}
if(this.currentStateObjs!==null){var show=this.currentStateObjs[0];for(var i=0;i<show.length;i++){if(show[i].hide){show[i].hide();}else{show[i].style.display="none";}}}};ViewBase.prototype.getSelected=function(){return this.selected;};ViewBase.prototype.getUniqueMessageBusName=function(){return this.mbn;};function Overview(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn="rtm.views.overview";this.continueTasks=el("continue_tasks");this.continueTasksAlways=el("continue_tasks_always");this.continueTasks.onclick=function(ev){messageBus.broadcast(configurationMgr,configurationMgr.mbn+"continueToTasks",[false,false]);return false;};this.continueTasksAlways.onclick=function(ev){messageBus.broadcast(configurationMgr,configurationMgr.mbn+"continueToTasks",[true,false]);return false;};}
extendObject(Overview,ViewBase);Overview.prototype.createWeeklyPlanner=function(){this.weeklyPlanner=document.createElement("span");this.weeklyPlanner.id="weeklyplanner";var link=document.createElement("a");link.href="/printplanner/"+rtmUsername+"/";link.title=_T("INTERFACE_PRINT_WEEKLY_PLANNER");link.target="_blank";link.innerHTML="<img src=\"http://static.rememberthemilk.com/img/ico/ico_weeklyplanner.gif\" alt=\""+_T("INTERFACE_PRINT_WEEKLY_PLANNER")+"\" />";link.style.display="inline";this.weeklyPlanner.appendChild(link);link=document.createElement("a");link.href="/printplanner/"+rtmUsername+"/";link.title=_T("INTERFACE_PRINT_WEEKLY_PLANNER");link.target="_blank";link.innerHTML=_T("INTERFACE_WEEKLY_PLANNER");link.style.display="inline";this.weeklyPlanner.appendChild(link);el("overviewtabs").appendChild(this.weeklyPlanner);};function TasksView(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn="rtm.views.tasks";this.hovering=false;this.statusDoneButton=new Button("statusbutton_done");this.statusCancelButton=new Button("statusbutton_cancel");this.listDetails=new FieldGroup("listdetailsbox","detailstitle");this.taskDetails=new FieldGroup("taskdetails","detailstitle");var field=new Field("detailslist");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_LIST"));field.setDefaultValue("none");field.blit();this.taskDetails.addField("detailsList",field);var field=new Field("detailsadded");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_ADDED"));field.blit();this.taskDetails.addField("detailsAdded",field);var field=new Field("detailscompleted");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_COMPLETED"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER"));field.blit();this.taskDetails.addField("detailsCompleted",field);var field=new Field("detailsdue","calendar");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_DUE"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_DUE_NEVER"));field.setDelayedHide(true);field.setLockable(true);field.setHighlightable(true);field.blit();this.taskDetails.addField("detailsDue",field);var field=new Field("detailsreoccur","reoccur");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_REPEAT"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_REPEAT_NEVER"));field.setDelayedHide(true);field.setLockable(true);field.setHighlightable(true);field.blit();this.taskDetails.addField("detailsReoccur",field);this.taskDetails.detailsDue.setNextField(this.taskDetails.detailsReoccur);this.taskDetails.detailsReoccur.setPreviousField(this.taskDetails.detailsDue);var field=new Field("detailsduration","duration");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_TIME_ESTIMATE"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_TIME_ESTIMATE_NONE"));field.setDelayedHide(true);field.setLockable(true);field.setHighlightable(true);field.blit();this.taskDetails.addField("detailsDuration",field);this.taskDetails.detailsReoccur.setNextField(this.taskDetails.detailsDuration);this.taskDetails.detailsDuration.setPreviousField(this.taskDetails.detailsReoccur);var field=new Field("detailspostponed");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_POSTPONED"));field.setDefaultValue("never");field.blit();this.taskDetails.addField("detailsPostponed",field);var field=new Field("detailsshared");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_SHARED_WITH"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_SHARED_WITH_NO_ONE"));field.setEscape(false);field.blit();this.taskDetails.addField("detailsShared",field);var field=new Field("detailstags","tag");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_TAGS"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_TAGS_NONE"));field.setDelayedHide(true);field.setEscape(false);field.setLockable(true);field.setHighlightable(true);if(!view.getPublicMode()){field.setAutocompleteStore(new TagAutocompleteStore());}
field.blit();this.taskDetails.addField("detailsTags",field);this.taskDetails.detailsDuration.setNextField(this.taskDetails.detailsTags);this.taskDetails.detailsTags.setPreviousField(this.taskDetails.detailsDuration);if(!view.getPublicMode()){var field=new Field("detailslocation","location");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_LOCATION"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_TAGS_NONE"));field.setDelayedHide(true);field.setEscape(false);field.setLockable(true);field.setHighlightable(true);field.setAutocompleteStore(new LocationAutocompleteStore());field.setAutocompleteAutocommit(true);field.blit();this.taskDetails.addField("detailsLocation",field);this.taskDetails.detailsTags.setNextField(this.taskDetails.detailsLocation);this.taskDetails.detailsLocation.setPreviousField(this.taskDetails.detailsTags);}
var field=new Field("detailsurl","url");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_URL"));field.setDefaultValue(_T("INTERFACE_TASKS_TASK_DETAILS_TAGS_NONE"));field.setDelayedHide(true);field.setEscape(false);field.setLockable(true);field.setHighlightable(true);field.blit();this.taskDetails.addField("detailsURL",field);if(!view.getPublicMode()){this.taskDetails.detailsLocation.setNextField(this.taskDetails.detailsURL);this.taskDetails.detailsURL.setPreviousField(this.taskDetails.detailsLocation);}
var field=new Field("detailsnotes");field.init();field.setTitle(_T("INTERFACE_TASKS_TASK_DETAILS_NOTES"));field.setDefaultValue("0");field.setEscape(false);field.blit();this.taskDetails.addField("detailsNotes",field);this.currentDetails=this.taskDetails;}
extendObject(TasksView,ViewBase);TasksView.LIST_INBOX=-1;TasksView.LIST_NORMAL=0;TasksView.LIST_SENT=1;TasksView.LIST_TYPE_NORMAL=0;TasksView.LIST_TYPE_SMART=1;TasksView.LIST_TYPE_SEARCH=2;TasksView.prototype.setHovering=function(hovering){this.hovering=hovering;};TasksView.prototype.getHovering=function(){return this.hovering;};TasksView.prototype.inSentList=function(){return stateMgr.currentList&&is(stateMgr.lists[stateMgr.currentList])&&stateMgr.lists[stateMgr.currentList].position==TasksView.LIST_SENT;};TasksView.prototype.inInboxList=function(){return stateMgr.currentList&&is(stateMgr.lists[stateMgr.currentList])&&stateMgr.lists[stateMgr.currentList].position==TasksView.LIST_INBOX;};TasksView.prototype.showVisibleTaskMode=function(){if(view.getViewToken("Tasks","Tasks")){this.taskDetails.show();}else{if(view.getViewToken("Tasks","Notes")){noteMgr.show();}}};TasksView.prototype.hideVisibleTaskMode=function(){if(view.getViewToken("Tasks","Tasks")){this.taskDetails.hide();}else{if(view.getViewToken("Tasks","Notes")){noteMgr.hide();}}};function ContactsView(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn="rtm.views.contacts";this.contactDetails=new FieldGroup("contactdetails","detailstitle");var field=new Field("contactusername");field.init();field.setTitle(_T("INTERFACE_CONTACTS_CONTACT_USERNAME"));field.setEscape(false);field.blit();this.contactDetails.addField("contactUsername",field);var field=new Field("contactgroups");field.init();field.setTitle(_T("INTERFACE_CONTACTS_CONTACT_GROUPS"));field.setDefaultValue(_T("INTERFACE_CONTACTS_CONTACT_GROUPS_NONE"));field.setEscape(false);field.blit();this.contactDetails.addField("contactGroups",field);this.groupDetails=new FieldGroup("groupdetails","detailstitle");var field=new Field("groupmembers");field.init();field.setTitle(_T("INTERFACE_CONTACTS_GROUPS_MEMBERS"));field.setDefaultValue(_T("INTERFACE_CONTACTS_GROUPS_MEMBERS_NONE"));field.setEscape(false);field.blit();this.groupDetails.addField("groupMembers",field);}
extendObject(ContactsView,ViewBase);TasksView.prototype.isSpecialList=function(listId){if(is(stateMgr.lists[listId])){if(stateMgr.lists[listId].position==TasksView.LIST_INBOX||stateMgr.lists[listId].position==TasksView.LIST_SENT){return true;}
return false;}
return false;};TasksView.prototype.reflectListsInListTabs=function(){var selected=listTabs.data[listTabs.selected][1];listTabs.init();for(var i=0;i<listList.list.entries.length;i++){var entry=listList.list.entries[i];var listId=entry[0];var list=stateMgr.lists[listId];if(!list.archived&&!list.deleted){if(!is(listTabs.reverseMap[listId])){if(list.filter!==null){listTabs.addEntry(stateMgr.lists[listId].name,[TasksView.LIST_TYPE_SMART,listId,list.filter]);}else{listTabs.addEntry(stateMgr.lists[listId].name,[TasksView.LIST_TYPE_NORMAL,listId]);}}}}
listTabs.sort();listTabs.selected=listTabs.reverseMap[selected];listTabs.blitDiv();};TasksView.prototype.reflectListsInTasksToolbox=function(){this.reflectListsInToolbox(tasksToolBox);this.reflectListsInToolbox(tasksSentToolBox);this.reflectListsInToolbox(tasksCompletedToolBox);};TasksView.prototype.reflectUndoSelector=function(){this.reflectUndoSelectorForToolbox(tasksToolBox);this.reflectUndoSelectorForToolbox(tasksSentToolBox);this.reflectUndoSelectorForToolbox(tasksCompletedToolBox);};TasksView.prototype.reflectUndoSelectorForToolbox=function(toolbox){var enable=undoMgr.transactions.length>0?true:false;var select=toolbox.div.getElementsByTagName("select")[0];for(var i=0;i<toolbox.listactions.length;i++){var entry=toolbox.listactions[i];var action=entry!==null?entry[0]:null;if(action==_T("INTERFACE_TASKS_TOOLBOX_UNDO_LAST_ACTION")){select.options[i].disabled=!enable;}}};TasksView.prototype.isLocked=function(exCompleted){return!(view.getSelected()=="Tasks"&&(exCompleted?taskList.view===TaskList.TASK_LIST_VIEW_INCOMPLETE:true)&&!tasksView.inSentList()&&!view.getPublicMode());};TasksView.prototype.isNormal=function(){return stateMgr.currentType==TasksView.LIST_TYPE_NORMAL;};TasksView.prototype.toggleSearchOptions=function(){var b=el("searchboxwrap");var o=el("searchoptions");var a=el("searchtoggle");var brk=el("break");var brk2=el("break2");if(b.style.visibility!="hidden"){searchMgr.updateFields();o.style.display="";b.style.visibility="hidden";a.innerHTML=_T("INTERFACE_HIDE_SEARCH_OPTIONS");if(!is_ie){brk.style.paddingTop="0.5em";brk.style.paddingBottom="0.5em";}else{brk.style.paddingTop="0.3em";brk.style.paddingBottom="0.3em";}
brk2.style.display="";}else{b.style.visibility="visible";o.style.display="none";a.innerHTML=_T("INTERFACE_SHOW_SEARCH_OPTIONS");if(!is_ie){brk.style.paddingTop="0.75em";brk.style.paddingBottom="0.75em";}else{brk.style.paddingTop="0em";brk.style.paddingBottom="0em";}
brk2.style.display="none";}};TasksView.prototype.reflectListsInToolbox=function(toolbox){var startAt=null;var startEnd=null;for(var i=0;i<toolbox.listactions.length;i++){var entry=toolbox.listactions[i];var action=entry!==null?entry[0]:null;if(action==_T("INTERFACE_TASKS_TOOLBOX_MOVE_TO")){startAt=i;}
if(action==null&&startAt!==null&&i>startAt){startEnd=i-1;break;}}
toolbox.listactions.splice(startAt+1,startEnd-startAt);var lists=stateMgr.getValidLists();for(var i=0;i<lists.length;i++){var pos=toolbox.addListAction(startAt+1+i,_T("INTERFACE_TASKS_TOOLBOX_MOVE_TO_LIST",{"LIST_NAME":lists[i][1]}),false,true);toolbox.setListActionData(pos+1,"tasks.moveTo."+lists[i][0]);}
if(lists.length>0){toolbox.blitDiv();}};ContactsView.prototype.reflectGroupsInContactsToolbox=function(){var startAt=null;var startEnd=null;var removeAt=null;var removeEnd=contactsToolbox.listactions.length;for(var i=0;i<contactsToolbox.listactions.length;i++){var entry=contactsToolbox.listactions[i];var action=entry!==null?entry[0]:null;if(action==_T("INTERFACE_CONTACTS_CONTACTS_TOOLBOX_ADD_TO")){startAt=i;}
if(action==_T("INTERFACE_CONTACTS_CONTACTS_TOOLBOX_REMOVE_FROM")){removeAt=i;}
if(action==null&&startAt!==null&&i>startAt&&i<removeEnd){startEnd=i-1;}}
groupNames=[];for(var id in stateMgr.groups){groupNames.push([id,stateMgr.groups[id].name]);}
groupNames.sort();contactsToolbox.listactions.splice(removeAt+1,removeEnd-removeAt);contactsToolbox.listactions.splice(startAt+1,startEnd-startAt);for(var i=0;i<groupNames.length;i++){var id=groupNames[i][0];var name=groupNames[i][1];var gname=_T("INTERFACE_CONTACTS_CONTACTS_TOOLBOX_GROUP",{"GROUP_NAME":name});var pos=contactsToolbox.addListAction(startAt+1+i,gname,false,true);contactsToolbox.setListActionData(pos+1,"contacts.attachToGroup."+id);removeAt++;pos=contactsToolbox.addListAction(removeAt+1+i,gname,false,true);if(pos+1>=contactsToolbox.listactions.length){pos=contactsToolbox.listactions.length-2;}
contactsToolbox.setListActionData(pos+1,"contacts.detachFromGroup."+id);}
if(groupNames.length){contactsToolbox.blitDiv();}};function SettingsView(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn="rtm.views.settings";this.listDetails=new FieldGroup("settingslistdetails","detailstitle");var field=new Field("settingslistcompleted");field.init();field.setDefaultValue(_T("INTERFACE_TASKS_LIST_DETAILS_ZERO_COMPLETED"));field.blit();this.listDetails.addField("listCompleted",field);var field=new Field("settingslistincomplete");field.init();field.setDefaultValue(_T("INTERFACE_TASKS_LIST_DETAILS_ZERO_INCOMPLETE"));field.blit();this.listDetails.addField("listIncomplete",field);var field=new Field("settingslistdescription");field.init();field.setEscape(false);field.setHidden(true);field.blit();this.listDetails.addField("listDescription",field);var field=new Field("settingslistfilter","filter_edit");field.init();field.setEscape(false);field.setHidden(true);var filter_title=_T("INTERFACE_SETTINGS_LISTS_CRITERIA",{"CRITERIA":""}).trim();filter_title=filter_title.replace(":","");field.setNewLineAfterTitle(true);field.setTitle(filter_title);field.setHighlightable(true);field.blit();this.listDetails.addField("listFilter",field);var field=new Field("settingslistpending");field.init();field.setEscape(false);field.setHidden(true);field.blit();this.listDetails.addField("listPending",field);this.locationDetails=new FieldGroup("settingslocationdetails","detailstitle");var field=new Field("settingslocationdescription");field.init();field.setEscape(false);field.setHidden(true);field.blit();this.locationDetails.addField("locationDescription",field);}
extendObject(SettingsView,ViewBase);function LocationsView(){this.inited=false;this.objs=[];this.states=[];this.selected=null;this.currentStateObjs=null;this.mbn="rtm.views.locations";}
extendObject(LocationsView,ViewBase);function Toolbox(id){this.id=id;this.div=el(id);this.inited=false;this.buttons=[];this.listactions=[];this.selectors=[];this.mbn=null;this.html=null;}
Toolbox.prototype.init=function(){this.inited=true;this.mbn=this.getUniqueMessageBusName();};Toolbox.prototype.show=function(){this.div.style.display="";this.div.style.visibility="hidden";this.div.style.visibility="visible";};Toolbox.prototype.hide=function(){this.div.style.visibility="hidden";this.div.style.visibility="visible";this.div.style.display="none";};Toolbox.prototype.getUniqueMessageBusName=function(){return"rtm.toolbox."+this.id+".";};Toolbox.prototype.addButton=function(text){this.buttons.push(text);};Toolbox.prototype.addListAction=function(action,disabled,padded){if(arguments.length==3){this.listactions.push([action,disabled,padded]);return this.listactions.length-1;}else{if(arguments.length==4){var pos=arguments[0];action=arguments[1];disabled=arguments[2];padded=arguments[3];this.listactions.splice(pos,0,[action,disabled,padded]);return pos-1;}}
return null;};Toolbox.prototype.setListActionData=function(pos,data){if(this.listactions&&this.listactions[pos]){this.listactions[pos].data=data;}};Toolbox.prototype.addListSeperator=function(){if(arguments.length==0){this.listactions.push(null);}else{if(arguments.length==1){var pos=arguments[0];this.listactions.splice(pos,0,null);}}};Toolbox.prototype.addSelector=function(text){this.selectors.push(text);};Toolbox.prototype.blitDiv=function(){var self=this;var parentDiv=document.createElement("div");var form=document.createElement("form");var div=document.createElement("div");form.appendChild(div);parentDiv.className="xtoolbox_actions";parentDiv.appendChild(form);for(var i=0;i<this.buttons.length;i++){var button=this.buttons[i];var buttonHTML="<input type=\"submit\" class=\"xtoolbox_button\" value=\""+button+"\"></input>";div.innerHTML=div.innerHTML+buttonHTML;}
var inputs=div.getElementsByTagName("input");for(var i=0;i<inputs.length;i++){var input=inputs[i];input.onclick=function(){messageBus.broadcast(self,self.mbn+"buttonClicked",this.value);return false;};}
if(this.listactions.length){var sel=document.createElement("select");for(var i=0;i<this.listactions.length;i++){var listaction=this.listactions[i];var elem=document.createElement("option");if(listaction===null){elem.disabled=true;elem.innerHTML="---";elem.rtmValue=null;elem.rtmData=null;}else{var text=listaction[0];var disabled=listaction[1];var pad=listaction[2];elem.innerHTML=pad?".."+text:text;elem.disabled=disabled;elem.rtmValue=text;elem.rtmData=listaction.data;}
sel.appendChild(elem);}
sel.onchange=function(ev){ev||(ev=window.event);var value=this.options[this.selectedIndex].rtmValue;var data=this.options[this.selectedIndex].rtmData;if(value!==null){messageBus.broadcast(self,self.mbn+"selectionChanged",[value,data]);}
utility.stopEvent(ev);this.selectedIndex=0;this.blur();if(is_opera){self.div.focus();}
return false;};sel.selectedIndex=0;div.appendChild(sel);}
var selectorDiv=document.createElement("div");var selectorHTML=[];for(var i=0;i<this.selectors.length;i++){var html="<a href=\" \">"+this.selectors[i]+"</a>";selectorHTML.push(html);}
var selectorInner=selectorHTML.join(", ");selectorDiv.innerHTML=_T("INTERFACE_TASKS_SELECT")+" "+selectorInner;selectorDiv.className="xtoolbox_selector";var links=selectorDiv.getElementsByTagName("a");for(var i=0;i<links.length;i++){var link=links[i];link.onclick=function(ev){ev||(ev=window.event);messageBus.broadcast(self,self.mbn+"selectorClicked",[this.innerHTML,ev.shiftKey]);utility.stopEvent(ev);return false;};}
this.div.innerHTML="";this.div.appendChild(parentDiv);this.div.appendChild(selectorDiv);this.html=this.div.innerHTML;};function Infobox(boxId,textId){this.boxId=boxId;this.textId=textId;this.boxDiv=el(boxId);this.text=el(textId);this.inited=false;this.mbn=null;this.owner=null;this.visible=false;}
Infobox.prototype.init=function(){this.inited=true;this.mbn=this.getUniqueMessageBusName();this.owner=null;this.visible=false;};Infobox.prototype.getUniqueMessageBusName=function(){return"rtm.infobox.";};Infobox.prototype.show=function(){this.boxDiv.style.display="";this.visible=true;};Infobox.prototype.hide=function(){this.boxDiv.style.display="none";this.visible=false;};Infobox.prototype.setOwner=function(owner){this.owner=owner;};Infobox.prototype.setText=function(text){this.text.innerHTML=text;};function Helpbox(boxId,textId){this.boxId=boxId;this.textId=textId;this.boxDiv=el(boxId);this.text=el(textId);this.inited=false;this.mbn=null;this.owner=null;}
Helpbox.prototype.init=function(){this.inited=true;this.mbn=this.getUniqueMessageBusName();this.owner=null;};Helpbox.prototype.getUniqueMessageBusName=function(){return"rtm.infobox.";};Helpbox.prototype.show=function(){this.boxDiv.style.display="";};Helpbox.prototype.hide=function(){this.boxDiv.style.display="none";};Helpbox.prototype.setOwner=function(owner){this.owner=owner;};Helpbox.prototype.setText=function(text){this.text.innerHTML=text;};Helpbox.prototype.showHelpText=function(what){this.show();this.setText(stringMgr.getString("help."+what));this.showing=what;};Helpbox.prototype.stopShowing=function(what,delay){if(is(this.showing)&&this.showing==what){if(delay&&!view.inTab){var self=this;var hideFunc=function(){self.hide();};setTimeout(hideFunc,1000);}else{this.hide();}}};Helpbox.prototype.stopShowingAll=function(what){if(is(this.showing)&&this.showing.indexOf(what)===0){this.stopShowing(this.showing);}};function XList(id,type){this.id=id;this.div=el(id);this.table=null;this.entries=[];this.rows=[];this.selected=[];this.selectedMap={};this.busy=[];this.busyMap={};this.map={};this.reverseMap={};this.present={};this.type=type;this.inited=false;this.invalidated=[];this.prioState=List.LIST_PRIO_INCOMPLETE;this.inAdvise=false;this.needToBlit=true;this.dateKlass="xtd_date";this.tableKlass=null;this.hashMap=null;this.sortFields=null;this.sortSpec=null;this.sortSpecClean=null;this.clickable=true;this.visible=false;this.emptyMessage=null;this.showingEmpty=false;this.hoverable=true;this.multiSelectable=true;this.hoveringId=null;this.keyboardPosition=null;this.keyboardEntries=[];this.clearTable();}
extendObject(XList,List);XList.prototype.setTableKlass=function(klass){this.tableKlass=klass;};XList.prototype.show=function(){this.visible=true;this.div.style.display="";this.fireSelectionStarted();this.fireSelectionFinished();};XList.prototype.hide=function(){this.visible=false;this.div.style.display="none";this.fireSelectionCleared();};XList.prototype.sortAndBlit=function(update){if(this.hashMap==null||this.sortFields==null){return false;}
if(this.entries.length>0){this.showingEmpty=false;}
messageBus.broadcast(this,this.mbn+"sortStarted");var entriesSort=[];for(var i=0;i<this.entries.length;i++){if(!is(this.hashMap[this.entries[i][0]])){this.removeEntry(this.entries[i][0]);}}
for(var j=0;j<this.entries.length;j++){var entry=this.entries[j];var entryTuple=[];for(var i=0;i<this.sortFields.length;i++){var f=this.sortFields[i];var v=eval("this.hashMap[entry[0]]."+f);entryTuple.push(v);}
entryTuple.entry=entry;entriesSort.push(entryTuple);}
entriesSort.sort(this.doSort);var selectedIds=this.getSelected();var busyIds=this.getBusy();var need={};for(var i=0;i<entriesSort.length;i++){if(this.entries[i][0]!==entriesSort[i].entry[0]){this.entries[i]=entriesSort[i].entry;need[i]=true;}}
var toAdd=this.entries.length-this.rows.length;for(var i=this.rows.length;i<this.entries.length;i++){this.rows.push("");need[i]=true;}
for(var i=0;i<this.invalidated.length;i++){need[this.invalidated[i]]=true;}
var needUpdate=[];for(var pos in need){needUpdate.push(pos);}
this.invalidated=[];this.reflectMaps();this.tableReblit(needUpdate);if(needUpdate.length>0||(selectedIds.length>0||busyIds.length>0)){this.selected=[];this.selectedMap={};this.busy=[];this.busyMap={};var pos;for(var i=0;i<selectedIds.length;i++){pos=this.map[selectedIds[i]];this.selected.push(pos);this.selectedMap[pos]=true;this.setRowSelect(this.table.rows[pos],true);}
for(var i=0;i<busyIds.length;i++){pos=this.map[busyIds[i]];this.busy.push(pos);this.busyMap[pos]=true;this.tableSetRowBusy(pos,true);}}
messageBus.broadcast(this,this.mbn+"sortFinished");return needUpdate.length;};XList.prototype.clear=function(){this.entries=[];this.rows=[];this.invalidated=[];this.map={};this.reverseMap={};this.present={};this.selected=[];this.selectedMap={};this.busy=[];this.busyMap={};this.needToBlit=true;this.inAdvise=false;this.showingEmpty=false;this.hoveringId=null;this.keyboardPosition=null;this.keyboardEntries=[];this.fireSelectionCleared();this.clearTable();};XList.prototype.clearTable=function(){if(this.tableKlass){this.div.innerHTML="<table class=\"xtable "+this.tableKlass+"\"><tbody></tbody></table>";}else{this.div.innerHTML="<table class=\"xtable\"><tbody></tbody></table>";}
this.table=this.div.getElementsByTagName("table")[0];};XList.prototype.reflectMaps=function(){var map={};var reverseMap={};for(var i=0;i<this.entries.length;i++){reverseMap[i]=this.entries[i][0];map[this.entries[i][0]]=i;}
this.map=map;this.reverseMap=reverseMap;};XList.prototype.tableReblit=function(needUpdate){if(this.entries.length==0){this.tableBlitEmpty();return false;}
if(this.rows.length==0){return this.tableBlitRows();}
for(var i=0;i<needUpdate.length;i++){this.rows[needUpdate[i]]=this.getRowHtml(this.entries[needUpdate[i]]);}
var rows;if(this.tableKlass){rows="<table class=\"xtable "+this.tableKlass+"\"><tbody>"+this.rows.join("")+"</tbody></table>";}else{rows="<table class=\"xtable\"><tbody>"+this.rows.join("")+"</tbody></table>";}
this.div.innerHTML=rows;this.table=this.div.getElementsByTagName("table")[0];this.assignRowProperties();};XList.prototype.tableBlitRows=function(){var startTime=new Date().getTime();if(this.inAdvise&&this.needToBlit==false){return false;}
if(this.entries.length==0){this.tableBlitEmpty();return false;}
this.rows=[];for(var i=0;i<this.entries.length;i++){var entry=this.entries[i];if(!this.present[entry[0]]){this.rows.push(this.getRowHtml(entry));this.present[entry[0]]=true;}}
var rows;if(this.tableKlass){rows="<table class=\"xtable "+this.tableKlass+"\"><tbody>"+this.rows.join("")+"</tbody></table>";}else{rows="<table class=\"xtable\"><tbody>"+this.rows.join("")+"</tbody></table>";}
this.div.innerHTML=rows;this.table=this.div.getElementsByTagName("table")[0];this.assignRowProperties();var endTime=new Date().getTime();var assignTime=new Date().getTime();if(false){this._redraw(true);if(true||(rtmUsername=="test51"&&this.prioState==List.LIST_PRIO_INCOMPLETE)){el("debug").innerHTML="<br />List draw: "+((endTime-startTime)/1000)+"secs, ";el("debug").innerHTML+=((assignTime-endTime)/1000)+"secs";}}};XList.prototype.assignRowPropertiesForPlainCheck=function(){var row;for(var i=0;i<this.table.rows.length;i++){row=this.table.rows[i];row.rowCheck=row.cells[0];row.rowCheckBox=row.cells[0].getElementsByTagName("input")[0];row.rowText=row.cells[1];this.assignRowActions(row,this.entries[i]);}};XList.prototype.assignRowPropertiesForPlainCheckImage=function(){var row;for(var i=0;i<this.table.rows.length;i++){row=this.table.rows[i];row.rowCheck=row.cells[0];row.rowCheckBox=row.cells[0].getElementsByTagName("input")[0];row.rowText=row.cells[1];row.rowImage=row.cells[2];this.assignRowActions(row,this.entries[i]);}};XList.prototype.assignRowPropertiesForPlainPrioDate=function(){var row;for(var i=0;i<this.table.rows.length;i++){row=this.table.rows[i];row.rowPriority=row.cells[0];row.rowText=row.cells[1];row.rowDate=row.cells[2];this.assignRowActions(row,this.entries[i]);}};XList.prototype.assignRowPropertiesForPlainPrioDateCheck=function(){var row;for(var i=0;i<this.table.rows.length;i++){row=this.table.rows[i];row.rowPriority=row.cells[0];row.rowCheck=row.cells[1];row.rowCheckBox=row.cells[1].getElementsByTagName("input")[0];row.rowText=row.cells[2];row.rowDate=row.cells[3];this.assignRowActions(row,this.entries[i]);}};XList.prototype.assignRowProperties=function(){if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){this.assignRowPropertiesForPlainCheck();}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){this.assignRowPropertiesForPlainCheckImage();}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){this.assignRowPropertiesForPlainPrioDate();}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)){this.assignRowPropertiesForPlainPrioDateCheck();}}}}};XList.prototype.tableBlitEmpty=function(){if(this.emptyMessage&&!this.showingEmpty&&this.entries.length==0){var emptyEntry=null;if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){emptyEntry=[0,"N",this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)){emptyEntry=[0,"N",this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){emptyEntry=[0,this.emptyMessage,null];}else{if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){emptyEntry=[0,this.emptyMessage];}}}}
this.rows=[];var row=this.getRowHtml(emptyEntry);if(this.tableKlass){this.div.innerHTML="<table style=\"visibility: hidden;\" class=\"xtable "+this.tableKlass+"\"><tbody>"+row+"</tbody></table>";}else{this.div.innerHTML="<table style=\"visibility: hidden;\" class=\"xtable\"><tbody>"+row+"</tbody></table>";}
this.table=this.div.getElementsByTagName("table")[0];var row=this.table.rows[0];this.assignRowProperties();if(row){row.rowText.className+=" xtr_empty";row.onmouseover=function(){};row.onmouseout=function(){};row.onclick=function(){};if(row.rowCheckBox){row.rowCheck.style.display="none";row.rowText.colSpan=2;}
row.rowText.style.fontWeight="bold";}
this.table.style.visibility="visible";this.showingEmpty=true;}
this.tableClearEmpty();};XList.prototype._redraw=function(severe){this.table.style.visibility="hidden";this.table.style.visibility="visible";};XList.prototype.assignRowActions=function(row,entry){var self=this;row.entry=entry;row.onmouseover=function(ev){if(tasksView.getHovering()){return false;}
self.onRowMouseOver(ev,this,this.entry);return false;};row.onmouseout=function(ev){self.onRowMouseOut(ev,this,this.entry);return false;};row.onclick=function(ev){self.onRowMouseClick(ev,this,this.entry);return true;};row.onmousedown=function(ev){ev||(ev=window.event);if(ev.shiftKey){return false;}
return true;};};XList.prototype.getRowHtml=function(entry){var row=[];if(!is(entry)){return"";}
if(this.type==List.LIST_TYPE_PLAIN){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_text\">");row.push(entry[1]);row.push("</td></tr>");return row.join("");}
if(this.type==List.LIST_TYPE_LOADING){return"<tr class=\"xtr\"><td class=\"xtd xtd_prio prioN\">&nbsp;</td><td class=\"xtd xtd_text\">"+_T("INTERFACE_TASKS_LIST_DETAILS_LOADING")+"</td><td class=\"xtd xtd_image\">"+imageMgr.getImageHTML("busy")+"</td></tr>";}
if(this.type==List.LIST_TYPE_ADDING){return this.tableAddRowWithAdding;}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_check\"><form id=\"");row.push(this.id);row.push("_row_form_");row.push(entry[0]);row.push("\" action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form></td><td class=\"xtd xtd_text\">");row.push(entry[1]);row.push("</td></tr>");return row.join("");}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_CHECK|List.LIST_TYPE_IMAGE)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_check\"><form id=\"");row.push(this.id);row.push("_row_form_");row.push(entry[0]);row.push("\" action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form></td><td class=\"xtd xtd_text\">");row.push(entry[1]);if(entry[2]){row.push("</td><td class=\"xtd xtd_image\">");row.push(imageMgr.getImageHTML(entry[2]));}else{row.push("</td><td class=\"xtd xtd_image\">&nbsp;");}
row.push("</td></tr>");return row.join("");}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_prio prio");row.push(entry[1]);row.push("\">&nbsp;</td><td class=\"xtd xtd_text\">");row.push(entry[2]);row.push("</td></tr>");return row.join("");}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_CHECK)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_prio prio");row.push(entry[1]);row.push("\">&nbsp;</td><td class=\"xtd xtd_check\"><form id=\"");row.push(this.id);row.push("_row_form_");row.push(entry[0]);row.push("\" action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form></td><td class=\"xtd xtd_text\">");row.push(entry[2]);row.push("</td></tr>");return row.join("");}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_prio prio");row.push(entry[1]);row.push("\">&nbsp;</td><td class=\"xtd xtd_text\">");row.push(entry[2]);row.push("</td><td class=\"xtd xtd_date\">");row.push((entry[3]?entry[3]:"&nbsp;"));row.push("</td></tr>");return row.join("");}
if(this.type==(List.LIST_TYPE_PLAIN|List.LIST_TYPE_PRIO|List.LIST_TYPE_DATE|List.LIST_TYPE_CHECK)){row.push("<tr class=\"xtr\"><td class=\"xtd xtd_prio prio");row.push(entry[1]);if(this.prioState==List.LIST_PRIO_COMPLETED){row.push("C");}
row.push("\">&nbsp;</td><td class=\"xtd xtd_check\"><form id=\"");row.push(this.id);row.push("_row_form_");row.push(entry[0]);row.push("\" action=\"#\"><div style=\"display: inline;\"><input type=\"checkbox\"></input></div></form></td><td class=\"xtd xtd_text\">");row.push(entry[2]);row.push("</td><td class=\"xtd xtd_date\">");row.push((entry[3]?entry[3]:"&nbsp;"));row.push("</td></tr>");return row.join("");}
return"<tr class=\"xtr\"><td class=\"xtd xtd_text\">Something went wrong</td></tr>";};function XTabs(id,style){this.id=id;this.div=el(id);if(style=="grey"){this.div.className="xtabs xtabs_grey";}else{this.div.className="xtabs";}
this.entries=[];this.data=[];this.html=null;this.reverseMap={};this.blitted=false;this.special={};this.mbn=null;this.selected=null;this.defaultEntry=null;this.inited=false;this.hidden=false;this.sortSpec=null;this.sortSpecClean=null;this.hashMap=null;}
XTabs.prototype.init=function(){this.mbn=this.getUniqueMessageBusName();this.blitted=false;this.defaultEntry=null;this.inited=true;this.hidden=false;this.entries=[];this.data=[];this.html=null;this.reverseMap={};this.special={};};XTabs.prototype.setSortParameters=function(hashMap,fields){this.hashMap=hashMap;this.sortFields=fields;};XTabs.prototype.doSort=function(a,b){for(var i=0;i<a.length;i++){if(a[i]===null&&b[i]!==null){return 1;}else{if(a[i]!==null&&b[i]===null){return-1;}}
if(a[i]>b[i]){return 1;}else{if(a[i]<b[i]){return-1;}}}
return 0;};XTabs.prototype.sort=function(){var entriesSort=[];for(var j=0;j<this.entries.length;j++){var data=this.data[j];var entryTuple=[];if(data instanceof Array){data=data[1];}
if(data===null){continue;}
for(var i=0;i<this.sortFields.length;i++){var f=this.sortFields[i];var v=eval("this.hashMap[data]."+f);entryTuple.push(v);}
entryTuple.list=this;entryTuple.id=data;entriesSort.push(entryTuple);}
entriesSort.sort(this.doSort);var remapList=[];for(var i=0;i<entriesSort.length;i++){remapList.push([entriesSort[i].id,i]);}
var iters=0;var needUpdate=[];var selectedData=this.data[this.selected];for(var i=0;i<remapList.length;i++){var oldId=this.data[remapList[i][1]];if(oldId instanceof Array){oldId=oldId[1];}
var newId=remapList[i][0];var oldPos=remapList[i][1];var newPos=this.reverseMap[newId];if(oldPos==newPos){continue;}
this.reverseMap[oldId]=newPos;this.reverseMap[newId]=oldPos;var tmpEntry=this.entries[oldPos];this.entries[oldPos]=this.entries[newPos];this.entries[newPos]=tmpEntry;var tmpData=this.data[oldPos];this.data[oldPos]=this.data[newPos];this.data[newPos]=tmpData;needUpdate.push(oldPos);needUpdate.push(newPos);iters++;}
this.blitted=false;if(is(selectedData)){if(selectedData instanceof Array){selectedData=selectedData[1];}
this.selected=this.reverseMap[selectedData];}else{this.selected=0;}
this.blitDiv();};XTabs.prototype.printMappings=function(){for(var i=0;i<this.entries.length;i++){}};XTabs.prototype.removeEntryByData=function(data){this.printMappings();if(data instanceof Array){data=data[1];}
var pos=this.reverseMap[data];this.removeEntry(pos);this.printMappings();};XTabs.prototype.removeEntry=function(pos,dontBlit){var data=this.data[pos];if(data instanceof Array){data=data[1];}
this.data[pos]=null;this.reverseMap[data]=null;assert(this.entries[pos]!=="Inbox","Tried to delete inbox!");this.entries.splice(pos,1);var max=this.entries.length;for(var i=pos+1;i<max+1;i++){var entry=this.data[i];if(entry instanceof Array){this.reverseMap[entry[1]]=i-1;}else{this.reverseMap[entry]=i-1;}
this.data[i-1]=entry;}
if(this.selected===pos){this.selected=0;this.blitDiv();this.selectDefault();}else{if(this.selected>pos){this.selected=this.selected-1;if(!dontBlit){this.blitDiv();}}else{if(!dontBlit){this.blitDiv();}}}};XTabs.prototype.setDefaultEntry=function(defaultEntry){this.defaultEntry=defaultEntry;};XTabs.prototype.show=function(){var self=this.div;if(false&&is_gecko&&!is_safari){var show=function(){self.style.display="";};setTimeout(show,1);}else{self.style.display="";}
this.hidden=false;};XTabs.prototype.hide=function(){var self=this.div;if(false&&is_gecko&&!is_safari){var hide=function(){self.style.display="none";};setTimeout(hide,1);}else{this.div.style.display="none";}
this.hidden=true;};XTabs.prototype.getUniqueMessageBusName=function(){return"rtm.tabs."+this.id+".";};XTabs.prototype.addEntry=function(entry,data,isSpecial){this.entries.push(entry);if(data===0||data){this.data[this.entries.length-1]=data;if(data instanceof Array){if(isSpecial){this.special[data[1]]=1;}
this.reverseMap[data[1]]=this.entries.length-1;}else{if(isSpecial){this.special[data]=1;}
this.reverseMap[data]=this.entries.length-1;}}
return this.entries.length-1;};XTabs.prototype.entryExists=function(data){if(data instanceof Array){return(is(this.reverseMap[data[1]]));}else{return(is(this.reverseMap[data]));}};XTabs.prototype.setDataForEntry=function(key,data){if(is(this.reverseMap[key])){this.data[this.reverseMap[key]]=data;if(data instanceof Array){this.reverseMap[data[1]]=this.reverseMap[key];}else{this.reverseMap[data]=this.reverseMap[key];}}};XTabs.prototype.getSelected=function(){if(this.selected!==null){return this.entries[this.selected];}
return null;};XTabs.prototype.selectDefault=function(suppress){if(this.inited){if(this.defaultEntry!==null){this.selectTabByPosition(this.defaultEntry,suppress);}else{this.selectTabByPosition(0,suppress);}}};XTabs.prototype.selectTab=function(newTab,suppress){var newPos=this.reverseMap[newTab];this.selectTabByPosition(newPos,suppress);};XTabs.prototype.selectTabByData=function(data){var pos=null;for(var i=0;i<this.data.length;i++){if(this.data[i]instanceof Array&&this.data[i][1]==data){pos=i;break;}else{if(!(this.data[i]instanceof Array)&&this.data[i]==data){pos=i;break;}}}
this.selectTabByPosition(pos);};XTabs.prototype.selectTabByPosition=function(newPos,suppress){var old=this.selected;if(newPos!==null&&newPos<this.entries.length){this.selected=newPos;}else{return false;}
if(!this.blitted){this.blitDiv();}else{var tabs=this.div.getElementsByTagName("li");var otherFound=false;var reassigned=false;for(var i=0;i<tabs.length;i++){var tab=tabs[i];if(tab.className.indexOf("selected")>-1&&i!=this.selected){if(this.id=="listtabs"&&this.data[i][0]!=TasksView.LIST_TYPE_NORMAL){tab.className="xtab_smartlist";var img=tab.getElementsByTagName("img");if(img&&img.length>0){img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_blu_blu.gif";}}else{tab.className="";}
otherFound=true;}
if(i==this.selected){if(tab.className.indexOf("selected")==-1){tab.className="xtab_selected";reassigned=true;if(this.id=="listtabs"&&this.data[i][0]!=TasksView.LIST_TYPE_NORMAL){var img=tab.getElementsByTagName("img");if(img&&img.length>0){img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_gry_whi.gif";}}}
if(otherFound){break;}}}
if(!reassigned&&old!=newPos){this.blitDiv();}}
if(messageBus&&!suppress){var data=this.data[newPos];if(!is(data)){data=null;}
messageBus.broadcast(this,this.mbn+"tabChanged",[[old,(old!==null?this.entries[old]:"")],[this.selected,this.entries[newPos]],data]);}};XTabs.prototype.renameEntry=function(key,to){var pos=this.reverseMap[key];if(!is(pos)){return false;}
this.entries[pos]=to;this.div.getElementsByTagName("a")[pos].innerHTML=to;};XTabs.prototype.blitDiv=function(){var htmlOut=[];htmlOut.push("<ul>");for(var i=0;i<this.entries.length;i++){var prop=[];if(this.selected===i){prop.push("xtab_selected");}
if(this.id=="listtabs"&&this.data[i]instanceof Array&&this.data[i][0]!=TasksView.LIST_TYPE_NORMAL){prop.push("xtab_smartlist");}
var special="";var astyle="";if(this.data[i]instanceof Array&&is(this.special[this.data[i][1]])){if(is_ie){var img="ico_close_org_blu.gif";if(this.selected===i){img="ico_close_gry_whi.gif";}
special=" <img style=\"vertical-align: top; padding: 0;\" src=\"http://static.rememberthemilk.com/img/ico/"+img+"\" onclick=\"listTabs.removeEntryByData("+this.data[i][1]+"); return false;\" />";astyle=" style=\"vertical-align: top; padding-top: 6px; padding-bottom: 3px;\"";}else{special=" <img style=\"padding-top: 2px; padding-left: 1px;\" src=\"http://static.rememberthemilk.com/img/ico/ico_close_gry_whi.gif\" onclick=\"listTabs.removeEntryByData("+this.data[i][1]+"); return false;\" />";}}
var cls=prop.length==0?"":" class=\""+prop.join(" ")+"\"";htmlOut.push("<li"+cls+"><a "+astyle+" href=\" \">"+this.entries[i].escapeForDisplay()+special+"</a></li>");}
htmlOut.push("</ul>");this.html=htmlOut.join("");this.div.innerHTML=this.html;var links=this.div.getElementsByTagName("li");for(var i=0;i<this.entries.length;i++){var link=links[i];var self=this;var entry=this.entries[i];var pos=i;link.pos=i;link.entry=entry;link.onclick=function(ev){try{this.blur();}
catch(e){}
self.selectTabByPosition(this.pos);return false;};link.onmouseover=function(ev){ev||(ev=window.event);var target=utility.getEventTarget(ev);var img=this.getElementsByTagName("img");if(img&&img.length>0&&img[0]){if(target==img[0]){if(is_ie&&self.selected!=this.pos){img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_org_blu.gif";}else{img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_org_whi.gif";}}else{if(is_ie&&self.selected!=this.pos){img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_blu_blu.gif";}else{img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_gry_whi.gif";}}
img[0].onmouseover=function(){if(is_ie&&self.selected!=this.pos){this.src="http://static.rememberthemilk.com/img/ico/ico_close_org_blu.gif";}else{this.src="http://static.rememberthemilk.com/img/ico/ico_close_org_whi.gif";}};img[0].onmouseout=function(){if(is_ie&&self.selected!=this.pos){this.src="http://static.rememberthemilk.com/img/ico/ico_close_blu_blu.gif";}else{this.src="http://static.rememberthemilk.com/img/ico/ico_close_gry_whi.gif";}};}};link.onmouseout=function(){if(self.selected!=this.pos){var img=this.getElementsByTagName("img");if(img&&img.length>0){img[0].src="http://static.rememberthemilk.com/img/ico/ico_close_blu_blu.gif";img[0].onmouseover=function(){};img[0].onmouseout=function(){};}}};}
this.blitted=true;};XTabs.prototype.selectLeft=function(){if(this.selected!==0){this.selectTabByPosition(this.selected-1);}else{this.selectTabByPosition(this.entries.length-1);}};XTabs.prototype.selectRight=function(){if(this.selected+1!==this.entries.length){this.selectTabByPosition(this.selected+1);}else{this.selectTabByPosition(0);}};function Autocomplete(id,store){this.id=id?id:null;this.store=store?store:null;this.bound=false;this.input=null;this.completing=null;this.callback=null;this.autoselect=true;this.autocommit=false;this.field=null;if(this.id){this.bind();}
Autocomplete.AC_INSTANCES.push(this);}
Autocomplete.AC_INSTANCES=[];Autocomplete.AC_TIMEOUT=0;if(is_khtml){Autocomplete.AC_LIST_OFFSET_LEFT=0;Autocomplete.AC_LIST_OFFSET_TOP=0;Autocomplete.AC_LIST_SIZE_LEFT=0;Autocomplete.AC_LIST_SIZE_TOP=0;}else{if(is_gecko){Autocomplete.AC_LIST_OFFSET_LEFT=-2;Autocomplete.AC_LIST_OFFSET_TOP=4;Autocomplete.AC_LIST_SIZE_LEFT=2;Autocomplete.AC_LIST_SIZE_TOP=-16;}else{if(is_ie){Autocomplete.AC_LIST_OFFSET_LEFT=0;Autocomplete.AC_LIST_OFFSET_TOP=0;Autocomplete.AC_LIST_SIZE_LEFT=0;Autocomplete.AC_LIST_SIZE_TOP=0;}else{Autocomplete.AC_LIST_OFFSET_LEFT=0;Autocomplete.AC_LIST_OFFSET_TOP=0;Autocomplete.AC_LIST_SIZE_LEFT=0;Autocomplete.AC_LIST_SIZE_TOP=0;}}}
Autocomplete.findPosition=function(el){var top=0,left=0;if(el.offsetParent){while(el.offsetParent){top+=el.offsetTop;left+=el.offsetLeft;el=el.offsetParent;}}else{if(el.y){top+=el.y;}
if(el.x){left+=el.x;}}
return[left,top];};Autocomplete.handleWindowResize=function(){if(Autocomplete.AC_INSTANCES.length===0){return;}
for(var i=0,j=Autocomplete.AC_INSTANCES.length;i<j;i++){Autocomplete.AC_INSTANCES[i].handleWindowResize();}};Autocomplete.removeInstance=function(instance){for(var i=0,j=Autocomplete.AC_INSTANCES.length;i<j;i++){if(Autocomplete.AC_INSTANCES[i]===instance){Autocomplete.AC_INSTANCES.splice(i,1);}}};Autocomplete.prototype.bind=function(){var self=this;this.input=el(this.id);this.input.ignore_keyup=false;this.input.setAttribute("autocomplete","off");var onkeyup=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if(pressed==13){self.input.last_enter=true;self.input.ignore_keyup=false;return true;}
if(!self.input.ignore_keyup){self.setTimeoutWithValue(this.value);}else{self.input.ignore_keyup=false;utility.stopEvent(ev);return false;}};GEvent.addDomListener(this.input,"keyup",onkeyup);this.input.iscommitable=function(){var ret=!self.list.isVisible()&&(this.value.length===0)||!this.visible_during_reflect||this.last_enter||self.autocommit;var s="[Commit] visible = "+self.list.isVisible()+", value = "+this.value+", visible_during_reflect = "+this.visible_during_reflect+", last_enter = "+this.last_enter+", ret = "+ret;return ret;};var onkeydown=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);var tab_pressed=((is_safari&&pressed==25&&ev.shiftKey)||pressed==9);if(pressed==38||pressed==63232){self.list.handleArrowUp();self.input.last_enter=false;self.input.ignore_keyup=true;utility.stopEvent(ev);return false;}else{if(pressed==40||pressed==63233){self.list.handleArrowDown();self.input.last_enter=false;self.input.ignore_keyup=true;utility.stopEvent(ev);return false;}else{if(pressed==27){self.list.handleEscape();self.input.last_enter=false;self.input.ignore_keyup=true;}else{if(tab_pressed||pressed==13){self.clearTimeout(true);self.list.handleEnter();if(tab_pressed){self.input.last_enter=true;}
self.input.ignore_keyup=true;if(!tab_pressed&&!self.autocommit){if(is_ie){if(self.field&&self.field._handle_keydown){return self.field._handle_keydown(ev);}}
utility.stopEvent(ev);return false;}else{if(self.field&&self.field._handle_keydown){return self.field._handle_keydown(ev);}
return true;}}else{self.input.last_enter=false;}}}}
if(self.field&&self.field._handle_keydown){return self.field._handle_keydown(ev);}};GEvent.addDomListener(this.input,"keydown",onkeydown);var onkeypress=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);var tab_pressed=(!(is_ie||is_opera)&&((is_safari&&pressed==25&&ev.shiftKey)||pressed==9));if(pressed==38||pressed==63232){utility.stopEvent(ev);return false;}else{if(pressed==40||pressed==63233){utility.stopEvent(ev);return false;}else{if((tab_pressed||pressed==13)&&!this.iscommitable()){utility.stopEvent(ev);return false;}}}
if(self.field&&self.field._handle_keypress){return self.field._handle_keypress(ev);}};GEvent.addDomListener(this.input,"keypress",onkeypress);var onblur=function(ev){ev||(ev=window.event);if(self.list.mouseoveritem!==null){self.list.blur_it=true;return false;}
self.list.blur_timeout=setTimeout(function(){self.list.display(false);},100);if(self.field&&self.field._handle_blur){return self.field._handle_blur(ev);}};GEvent.addDomListener(this.input,"blur",onblur);this.input.visible_during_reflect=false;this.input.last_enter=true;this.list=new AutocompleteList(this,this.input);this.input.list=this.list;};Autocomplete.prototype.setReflectCallback=function(func){this.callback=func;};Autocomplete.prototype.setAutoselect=function(autoselect){this.autoselect=autoselect;};Autocomplete.prototype.setAutocommit=function(autocommit){this.autocommit=autocommit;};Autocomplete.prototype.setField=function(field){this.field=field;};Autocomplete.prototype.isCompleting=function(){return!!this.completing;};Autocomplete.prototype.clearTimeout=function(force){if(force||this.isCompleting()){clearTimeout(this.completing);}};Autocomplete.prototype.setTimeoutWithValue=function(value){var self=this;self.clearTimeout();this.completing=setTimeout((function(){self.complete(value);}),Autocomplete.AC_TIMEOUT);};Autocomplete.prototype.complete=function(value){var completions=this.store.getCompletions(value);this.list.updateCompletions(completions);};Autocomplete.prototype.getStore=function(){return this.store;};function AutocompleteList(parent,input){this.parent=parent;this.input=input;this.position=null;this.is_complete=false;this.just_completed=false;this.blur_timeout=null;this.mouseoveritem=null;this.blur_it=false;this.create();}
AutocompleteList.prototype.highlightRow=function(row){var li=this.list.getElementsByTagName("li");for(var i=0,j=li.length;i<j;i++){if(row==i){li[i].className="highlight";}else{li[i].className="";}}};AutocompleteList.prototype.handleEscape=function(){this.list.style.display="none";};AutocompleteList.prototype.isVisible=function(){return this.list.style.display!=="none";};AutocompleteList.prototype.handleArrowUp=function(){if(!this.isVisible()){this.position=1;this.display(true);}
if(this.position!==null&&this.position!==0){this.position--;this.highlightRow(this.position);}};AutocompleteList.prototype.handleEnter=function(){if(this.position===null){this.reflectValue(null);}else{this.reflectValue(this.completions[this.position]);}
this.display(false);};AutocompleteList.prototype.handleArrowDown=function(){if(!this.isVisible()){this.position=null;this.display(true);if(!this.parent.autoselect){return false;}}
if(this.completions&&(this.position!==null&&this.position+1!==this.completions.length)){this.position++;}else{if(this.position===null){this.position=0;}}
this.highlightRow(this.position);};AutocompleteList.prototype.reflectValue=function(value){if(value===null){if(this.parent.callback){this.parent.callback(this.input.value,false);}
return false;}
var extending=this.parent.store.isExtending();var input_value=value;if(value instanceof Array){value=value[0];}
this.input.visible_during_reflect=this.isVisible();if(extending){var last_stem=this.parent.store.getLastStem();if(last_stem.length>0){var last_position=this.input.value.lastIndexOf(last_stem);var start=this.input.value.substring(0,last_position);if(value){if(this.isVisible()){this.parent.store.last_stem=value;}
value=start+value;}else{value=start+last_stem;}
if(this.isVisible()&&exists(this.parent.store.extraChar)){value+=this.parent.store.extraChar;}}else{value=this.input.value;}}
var callback_value=value;if(input_value instanceof Array){if(typeof input_value[0]==="object"){value=input_value[1];}}
this.input.focus();this.input.value=value;this.goToEnd();if(this.parent.callback){this.parent.callback(callback_value,true);}};AutocompleteList.prototype.goToEnd=function(){var len=this.input.value.length;try{if(this.input.setSelectionRange){this.input.setSelectionRange(len,len);}else{if(this.input.createTextRange){var range=this.input.createTextRange();range.moveStart("character",len);range.moveEnd("character",0);range.select();}else{this.input.select();}}}
catch(e){return false;}};AutocompleteList.prototype.resizeContainer=function(){var pos=Autocomplete.findPosition(this.input);this.input_left=pos[0];this.input_top=pos[1];this.input_width=this.input.clientWidth;this.input_height=this.input.clientHeight;this.list.style.top=(this.input_top+this.input_height+Autocomplete.AC_LIST_OFFSET_TOP)+"px";this.list.style.left=(this.input_left+Autocomplete.AC_LIST_OFFSET_LEFT)+"px";};AutocompleteList.prototype.create=function(){this.list_extra_width=0;this.list_extra_height=0;this.list=document.createElement("div");this.list.className="autocomplete_list";this.list.style.position="absolute";this.list.style.top="0px";this.list.style.left="0px";this.mouseoveritem=null;this.resizeContainer();this.display(false);document.body.appendChild(this.list);};AutocompleteList.prototype.display=function(show){if(show){this.list.style.display="";}else{this.list.style.display="none";this.mouseoveritem=null;}};AutocompleteList.prototype.updateCompletions=function(completions){var html=["<ul>"];for(var i=0,j=completions.length;i<j;i++){if(completions[i]instanceof Array){html.push("<li>"+completions[i][1]+"</li>");}else{html.push("<li>"+completions[i]+"</li>");}}
html.push("</ul>");this.list.innerHTML=html.join("");this.display(true);var ul=this.list.getElementsByTagName("ul");ul=ul[0];this.list_extra_height=ul.clientHeight;this.list.style.display="none";this.resizeContainer();this.bindMouseEvents();this.completions=completions;this.position=null;this.mouseoveritem=null;if(completions&&completions.length>0){this.handleArrowDown();}};AutocompleteList.prototype.bindMouseEventsForItem=function(li,position){var self=this;li.onmouseover=function(){self.highlightRow(position);self.mouseoveritem=position;};li.onmouseout=function(){self.mouseoveritem=null;};li.onclick=function(ev){self.reflectValue(self.completions[position]);if(self.blur_timeout){clearTimeout(self.blur_timeout);}
self.display(false);self.input.focus();if(self.blur_it&&self.parent.field&&self.parent.field._handle_blur){return self.parent.field._handle_blur(ev);}
self.blur_it=false;};};AutocompleteList.prototype.bindMouseEvents=function(){var li=this.list.getElementsByTagName("li");if(!li){return false;}
for(var i=0,j=li.length;i<j;i++){this.bindMouseEventsForItem(li[i],i);}};function AutocompleteStore(){}
AutocompleteStore.prototype.getCompletions=function(stem){return[stem+"1",stem+"2",stem+"3",stem+"4"];};AutocompleteStore.prototype.isExtending=function(){return false;};function TagAutocompleteStore(){this.extraChar=", ";}
TagAutocompleteStore.prototype.isExtending=function(){return true;};TagAutocompleteStore.sortTags=function(a,b){if(a[0]<b[0]){return-1;}else{if(a[0]>b[0]){return 1;}}
if(a[1]<b[1]){return-1;}else{if(a[1]>b[1]){return 1;}}
return 0;};TagAutocompleteStore.prototype.formatFound=function(found,stem){var out=[];for(var i=0,j=found.length;i<j;i++){out.push([found[i][0],"<b>"+found[i][0].substring(0,stem.length)+"</b>"+found[i][0].substring(stem.length)]);}
if(out.length>11){out.length=11;}
return out;};TagAutocompleteStore.prototype.splitStem=function(stem){var split=[];var exploded=stem.split(/[\s;,]+/);var len=exploded.length;for(var i=0;i<len;i++){if(exploded[i].charAt(0)=="\""){if(i<len&&exploded[i+1].charAt(exploded[i+1].length-1)=="\""){split.push(exploded[i]+exploded[i+1]);i++;}else{split.push(exploded[i]);}}else{split.push(exploded[i]);}}
return split;};TagAutocompleteStore.prototype.getLastStem=function(){return this.last_stem;};TagAutocompleteStore.prototype.getCompletions=function(stem){var stem_cells=this.splitStem(stem);stem=stem_cells[stem_cells.length-1];this.last_stem=stem;if(!stem||stem.length===0){return[];}
var found=[],pos;var lc_stem=stem.toLowerCase(),lc_tag;for(var tag in tagMgr.index){lc_tag=tag.toLowerCase();if((pos=lc_tag.indexOf(lc_stem))==0){found.push([tag,pos]);}}
found.sort(TagAutocompleteStore.sortTags);return this.formatFound(found,stem);};Autocomplete.prototype.handleWindowResize=function(){this.list.resizeContainer();};function LocationAutocompleteStore(){this.extraChar=", ";this.geocoding=false;this.geocoding_data=null;}
LocationAutocompleteStore.prototype.setGeocoding=function(geocoding_data){this.geocoding=!!geocoding_data;this.geocoding_data=geocoding_data;};LocationAutocompleteStore.prototype.isGeocoding=function(){return this.geocoding;};LocationAutocompleteStore.prototype.isExtending=function(){return false;};LocationAutocompleteStore.sortLocations=function(a,b){if(a[0]<b[0]){return-1;}else{if(a[0]>b[0]){return 1;}}
if(a[1]<b[1]){return-1;}else{if(a[1]>b[1]){return 1;}}
return 0;};LocationAutocompleteStore.prototype.formatFound=function(found,stem){var out=[];for(var i=0,j=found.length;i<j;i++){out.push([found[i][0],"<b>"+found[i][0].substring(0,stem.length)+"</b>"+found[i][0].substring(stem.length)]);}
if(out.length>11){out.length=11;}
return out;};LocationAutocompleteStore.prototype.splitStem=function(stem){var split=[];var exploded=stem.split(/,+/);return exploded;};LocationAutocompleteStore.prototype.getLastStem=function(){return this.last_stem;};LocationAutocompleteStore.prototype.getNonGeocodingCompletions=function(stem){var stem_cells=this.splitStem(stem);stem=stem_cells[0];this.last_stem=stem;if(!stem||stem.length===0){return[];}
var lc_stem=stem.toLowerCase();var found=[],pos,name,lc_name;for(var loc_id in locationMgr.locations_){name=locationMgr.locations_[loc_id].name;lc_name=name.toLowerCase();if((pos=lc_name.indexOf(lc_stem))==0){found.push([name,pos]);}}
found.sort(LocationAutocompleteStore.sortLocations);return this.formatFound(found,stem);};LocationAutocompleteStore.prototype.getGeocodingCompletions=function(stem){var out=[];for(var i=0,j=this.geocoding_data.length;i<j;i++){if(this.geocoding_data[i]["address"]){out.push([this.geocoding_data[i],this.geocoding_data[i]["address"]]);}}
if(out.length>11){out.length=11;}
return out;};LocationAutocompleteStore.prototype.getCompletions=function(stem){if(!this.isGeocoding()||this.geocoding_data===null){return this.getNonGeocodingCompletions(stem);}else{var result=this.getGeocodingCompletions(stem);this.setGeocoding(null);return result;}};function TagManager(){this.index={};this.invertedIndex={};}
TagManager.prototype.setIndex=function(idx){this.index=idx;};TagManager.prototype.updateInvertedIndex=function(){for(var tag in this.index){for(var i=0;i<this.index[tag].length;i++){var ts=this.index[tag][i];if(!is(this.invertedIndex[ts])){this.invertedIndex[ts]={};}
this.invertedIndex[ts][tag]=true;}}};TagManager.prototype.getTagsForTaskSeries=function(taskSeries){if(!is(this.invertedIndex[taskSeries])){return[];}
var tags=[];for(var tag in this.invertedIndex[taskSeries]){if(is(this.invertedIndex[taskSeries][tag])){tags.push(tag);}}
tags.sort();return tags;};TagManager.prototype.updateTaskSeries=function(taskSeries,descTuple){var e=descTuple[0];var a=descTuple[1];var d=descTuple[2];for(var i=0;i<taskSeries.length;i++){var ts=taskSeries[i];for(var j=0;j<d.length;j++){if(!is(this.invertedIndex[ts])){this.invertedIndex[ts]={};}
if(is(this.invertedIndex[ts][d[j]])){this.invertedIndex[ts][d[j]]=null;}
if(is(this.index[d[j]])){this.index[d[j]].spliceAll(ts);if(this.index[d[j]].length==0){this.index[d[j]]=null;}}}
for(var k=0;k<a.length;k++){if(!is(this.invertedIndex[ts])){this.invertedIndex[ts]={};}
this.invertedIndex[ts][a[k]]=true;if(!is(this.index[a[k]])){this.index[a[k]]=[];}else{this.index[a[k]].spliceAll(ts);}
this.index[a[k]].push(ts);}}};TagManager.prototype.clearTagsForTaskSeries=function(taskSeries){var self=this;map(function(ts){if(!is(self.invertedIndex[ts])){return false;}
for(var tag in self.invertedIndex[ts]){if(is(self.index[tag])){self.index[tag].spliceAll(ts);if(self.index[tag].length==0){self.index[tag]=null;}}}
self.invertedIndex[ts]=null;},taskSeries instanceof Array?taskSeries:[taskSeries]);};TagManager.prototype.updateTags=function(taskSeries){var self=this;mapkv(function(ts,tags){self.clearTagsForTaskSeries(ts);self.invertedIndex[ts]={};map(function(tag){self.invertedIndex[ts][tag]=true;if(!is(self.index[tag])){self.index[tag]=[];}
self.index[tag].push(ts);},tags);},taskSeries);};function Sexp(str){if(str){str=this._encaseIfNeeded(this._balanceIfNeeded(str));}
this.str=str;this.len=0;this.i=0;this.sexpr=[];if(str){this.len=this.str.length;this.sexpr=this.getSexpr();}}
Sexp.prototype._balanceIfNeeded=function(str){var i=0;var len=str.length;var l=0,r=0;while(i<len){if(str.charAt(i)=="("){l++;}else{if(str.charAt(i)==")"){r++;}}
i++;}
if(l!==r){if(l>r){var d=l-r;for(var i=0;i<d;i++){str+=")";}}else{if(r>l){var d=r-l;for(var i=0;i<d;i++){str="("+str;}}}}
return str;};Sexp.prototype._encaseIfNeeded=function(str){var i=0;var len=str.length;var encase=false;var l=[],r=[];var stack=0;var zero=0;while(i<len){if(str.charAt(i)=="("){l.push([stack++,i]);}else{if(str.charAt(i)==")"){r.push([--stack,i]);}}
if(stack==0){zero++;}
i++;}
encase=!(l.length==r.length&&(zero==1&&(l.length>0&&l[0][1]==0&&(r[r.length-1][1]==(len-1)))));if(encase){return"("+str+")";}
return str;};Sexp.prototype.getSexpr=function(str){if(str){this.i=0;this.str=str;this.len=this.str.length;}
var expr=null;var tok=this.getToken();if(tok==")"){return null;}else{if(tok=="("){expr=[];tok=this.getToken();while(tok!=")"){if(tok=="("){this.i--;expr.push(this.getSexpr());}else{if(tok==null){return expr;}else{expr.push(tok);}}
tok=this.getToken();}
return expr;}else{return tok;}}};Sexp.HT=String.fromCharCode(9);Sexp.LF=String.fromCharCode(10);Sexp.VT=String.fromCharCode(11);Sexp.FF=String.fromCharCode(12);Sexp.CR=String.fromCharCode(13);Sexp.SQ=String.fromCharCode(39);Sexp.SB=String.fromCharCode(92);Sexp.prototype._isWhiteSpace=function(c){if(c==Sexp.HT||c==Sexp.LF||c==Sexp.VT||c==Sexp.FF||c==Sexp.CR||c==" "){return true;}else{return false;}};Sexp.prototype._isSpecial=function(c){if(c=="("||c==")"||c==Sexp.SQ||c==","){return true;}else{return false;}};Sexp.prototype.getToken=function(){if(this.i>=this.len){return null;}
while(this.i<this.len&&this._isWhiteSpace(this.str.charAt(this.i))){this.i++;}
if(this.i==this.len){return null;}
if(this._isSpecial(this.str.charAt(this.i))){this.i++;return this.str.charAt(this.i-1);}else{if(this.str.charAt(this.i)=="\""){var str="";this.i++;while(this.str.charAt(this.i)!="\""&&this.i<this.len){if(this.str.charAt(this.i)==Sexp.SB){this.i++;var c=this.str.charAt(this.i);if(c=="n"){str+=Sexp.LF;}else{if(c=="t"){str+=Sexp.HT;}}}else{str+=this.str.charAt(this.i);this.i++;}}
this.i++;return str;}else{var tok="";while(this.i<this.len-1){if(this._isWhiteSpace(this.str.charAt(this.i))||this._isSpecial(this.str.charAt(this.i))){break;}else{tok+=this.str.charAt(this.i);this.i++;if(this.str.charAt(this.i-1)==":"){tok+=this.getToken();}}}
if(!(this._isWhiteSpace(this.str.charAt(this.i))||this._isSpecial(this.str.charAt(this.i)))){tok+=this.str.charAt(this.i);this.i++;}
return tok;}}};function Filter(list,fieldMap,sexp,defaultField){this.list=list;this.fieldMap=fieldMap;this.defaultField=defaultField;this.sexp=this._rewriteQuery(sexp);this.resultCache={};this.implicitFilter=null;this.debug=false;}
Filter.LOGIC_AND=0;Filter.LOGIC_OR=1;Filter.LOGIC_NOT=2;Filter.prototype._rewriteQuery=function(query){var dicts={"lists":{}},list,list_name;for(var list_id in stateMgr.lists){list=stateMgr.lists[list_id];list_name="_"+list.name.toLowerCase();if(!list.archived&&!list.deleted&&list.filter===null&&!(list_name in dicts.lists)){dicts.lists[list_name]=list_id;}}
return this._recursiveRewriteQuery(dicts,query);};Filter.prototype._recursiveRewriteQuery=function(dicts,query){var logical;if(!(query instanceof Array)){return[3,this._rewriteFieldQuery(dicts,query)];}else{for(var i=0,j=query.length;i<j;i++){if((logical=this._isLogical(query[i]))==3){query[i]=this._recursiveRewriteQuery(dicts,query[i]);}else{if(logical===Filter.LOGIC_AND&&i+1<j&&this._isLogical(query[i+1])===Filter.LOGIC_NOT){query.splice(i,1);j--;i--;}else{query[i]=[logical,query[i]];}}}
return[4,query];}};Filter.prototype._rewriteFieldQuery=function(dicts,q){var type,cond;if(q.indexOf(":")==-1){cond=q;q=this.defaultField+":"+q;type=this.defaultField;}else{var tc=q.split(":");type=tc.shift();cond=tc.join(":");}
cond=cond.toLowerCase();if(type==="list"){if(("_"+cond)in dicts.lists){type="listId";cond=dicts.lists["_"+cond];}}
return[type,cond,type+":"+cond];};Filter.prototype._isLogical=function(tok){if(tok instanceof Array){return 3;}
tok=tok.toLowerCase();return(tok=="and"?Filter.LOGIC_AND:(tok=="or"?Filter.LOGIC_OR:(tok=="not"?Filter.LOGIC_NOT:3)));};Filter.prototype.dbg=function(s){if(this.debug){dbg(s);}};Filter.prototype.apply=function(entry,sexp){if(sexp.length==2&&sexp[0]===3){var type=sexp[1][0];var cond=sexp[1][1];var comb=sexp[1][2];return(type in this.fieldMap)?(this.resultCache[comb]=this.fieldMap[type](cond,entry,this.list[entry])):false;}else{if(sexp[0]===4){var outcome,p=null,l=null,r;var logical=3;var members=sexp[1];for(var i=0;i<members.length;i++){outcome=true;if((logical=members[i][0])===3){l=(members[i][1][2]in this.resultCache)?this.resultCache[members[i][1][2]]:this.apply(entry,members[i]);if(p!==null&&!(l&&p)&&((i+1)%2==0)){outcome=false;break;}}else{if(logical===4){l=this.apply(entry,members[i]);if(p!==null&&!(l&&p)&&((i+1)%2==0)){outcome=false;break;}}else{if(i>=members.length-1){break;}
if(logical===Filter.LOGIC_AND&&!l){return false;}
if(logical===Filter.LOGIC_OR&&l){return true;}
r=(members[i+1][1][2]in this.resultCache)?this.resultCache[members[i+1][1][2]]:this.apply(entry,members[i+1]);if(logical===Filter.LOGIC_AND){if(!(l&&r)){outcome=false;break;}}else{if(logical===Filter.LOGIC_OR){if(!(l||r)){outcome=false;}}else{if(logical===Filter.LOGIC_NOT){outcome=false;if((l&&!r)||(l===null&&!r)){outcome=true;break;}}}}
l=outcome;i++;}}
p=l;}
return members.length==1?l:outcome;}}};Filter.prototype.isMember=function(entry){this.resultCache={};var ret=this.list[entry]!==null&&((this.sexp[1].length==0)||this.apply(entry,this.sexp));this.resultCache={};return ret;};Filter.prototype.setImplicitFilter=function(f){this.implicitFilter=f;};Filter.prototype.reduce=function(){var matches=[];for(var entry in this.list){this.resultCache={};if(this.list[entry]!==null&&(!this.implicitFilter||(this.implicitFilter&&this.implicitFilter(false,entry,this.list[entry])))&&((this.sexp[1].length==0)||this.apply(entry,this.sexp))){matches.push(entry);}}
this.resultCache={};return matches;};Filter.prototype._normalizeSexpR=function(sexp){if(typeof sexp=="string"){var type,cond;if(sexp.indexOf(":")==-1){cond=sexp;sexp=this.defaultField+":"+sexp;type=this.defaultField;}else{type=sexp.split(":");cond=type[1];type=type[0];}
return is(this.fieldMap[type])?[true,cond,type]:false;}else{var logical=3,p,l,r,outcome;var result=[];for(var i=0;i<sexp.length;i++){if((logical=this._isLogical(sexp[i]))==3){l=this._normalizeSexpR(sexp[i]);if(p!==null&&((i+1)%2==0)){outcome=false;break;}}else{if(i>=sexp.length-1){break;}
if(logical==Filter.LOGIC_AND&&!l){return false;}
r=this._normalizeSexpR(sexp[i+1]);if(logical==Filter.LOGIC_OR){if((r||l)&&(!r||!l)){if(r){return r;}
if(l){return l;}}}
if(r!==false){outcome=[l,this._normalizeLogical(logical),r];if(l instanceof Array&&l[0]!==true){return outcome;}
result.push(outcome);}
l=outcome;i++;}
p=l;}
return sexp.length==1?l:result;}};Filter.prototype._quote=function(str){if(str.charAt(0)!=="\""&&str.indexOf(" ")>-1&&str.charAt(str.length-1)!=="\""){return"\""+str+"\"";}
return str;};Filter.prototype._combineSexp=function(type,cond){return type+":"+this._quote(cond);};Filter.prototype._sexpToString=function(normalized){if(normalized===false){return"";}
if(typeof normalized=="string"){return normalized;}
if(normalized instanceof Array){if(normalized.length==1&&normalized instanceof Array&&normalized[0]instanceof Array){return this._sexpToString(normalized[0]);}
if(normalized.length==3){if(normalized[0]===true){return this._combineSexp(normalized[2],normalized[1]);}}
var res="(";var lastLogical=false,ret;for(var i=0;i<normalized.length;i++){ret=this._sexpToString(normalized[i]);if(lastLogical&&ret==""&&i==normalized.length-1){res=res.trim();break;}else{if(lastLogical){res+=normalized[i-1]+" ";}
lastLogical=false;}
if(typeof normalized[i]=="string"){lastLogical=true;continue;}
res+=ret;if(i!==normalized.length-1){res+=" ";}}
if(res.length==1){return"";}
return res+")";}};Filter.prototype.normalizeSexp=function(){var normalized=this._normalizeSexpR(this.sexp);return this._sexpToString(normalized);};Filter.prototype._normalizeLogical=function(logical){if(logical==Filter.LOGIC_AND){return"and";}
if(logical==Filter.LOGIC_OR){return"or";}
if(logical==Filter.LOGIC_NOT){return"not";}
return null;};function Virtual(expr,data,callbacks){this.expr=expr;if(expr){this.sexpr=new Sexp(expr);}else{this.expr=null;this.sexpr=null;}
if(data){this.data=data;}else{this.data=null;}
if(callbacks){this.filterCallbacks=callbacks;}else{this.filterCallbacks={};}
this.cache=null;this.resultSet=[];if(this.sexpr&&this.data){this.filter=new Filter(this.data,this.filterCallbacks,this.sexpr,"name");}else{this.filter=null;}}
Virtual.prototype.updateFilter=function(expr){if(expr){this.expr=expr;}
this.sexpr=new Sexp(this.expr);if(this.sexpr&&this.data){this.filter=new Filter(this.data,this.filterCallbacks,this.sexpr,"name");}else{this.filter=null;}};Virtual.prototype.update=function(){this.resultSet=this.filter.reduce();this.cache=new Date().getTime();};Virtual.prototype.add=function(entry){if(this.filter&&this.filter.apply(entry,this.sexpr)){return true;}
return false;};function _tagFilter(f,k,v){if(!is(tagMgr.index[f])){return false;}
var ts=tagMgr.index[f];for(var i=0;i<ts.length;i++){if(ts[i]==v.series_id){return true;}}
return false;}
function _isRepeatingFilter(f,k,v){if(f=="false"&&!v.reoccur){return true;}
if(f=="true"&&v.reoccur&&v.reoccur[0]){return true;}
return false;}
function _locationFilter(f,k,v){if(!is(locationMgr.location_task_series_[v.series_id])){return false;}
if(!is(locationMgr.locations_[locationMgr.location_task_series_[v.series_id]])){return false;}
if(locationMgr.locations_[locationMgr.location_task_series_[v.series_id]].name.toLowerCase()===f){return true;}
return false;}
function _locationIdFilter(f,k,v){if(!is(locationMgr.location_task_series_[v.series_id])||(locationMgr.location_task_series_[v.series_id]!=f)){return false;}
return true;}
function _isTaggedFilter(f,k,v){if(f=="false"&&(!is(tagMgr.invertedIndex[v.series_id])||isHashEmpty(tagMgr.invertedIndex[v.series_id]))){return true;}
if(f=="true"&&(is(tagMgr.invertedIndex[v.series_id])&&!isHashEmpty(tagMgr.invertedIndex[v.series_id]))){return true;}
return false;}
function _hasLocation(f,k,v){if(f=="false"&&(!is(locationMgr.location_task_series_[v.series_id]))){return true;}
if(f=="true"&&(is(locationMgr.location_task_series_[v.series_id]))){return true;}
return false;}
function _hasDueDate(f,k,v){if(v.date_due===null&&f=="false"){return true;}
if(v.date_due===null){return false;}
return true;}
function _prioFilter(f,k,v){return v.priority.charAt(1)==f||(v.priority.charAt(1)=="N"&&f.charAt(0)=="n");}
function _includeArchived(f,k,v){return stateMgr.lists[v.list_id].archived==f;}
function _listIdFilter(f,k,v){return v.list_id==f;}
function _listFilter(f,k,v){return stateMgr.lists[v.list_id].name.toLowerCase()==f;}
function _nameFilter(f,k,v){return v.name.toLowerCase().indexOf(f)>-1;}
function _dueBeforeFilter(f,k,v){if(v.date_due===null&&f=="never"){return true;}
if(v.date_due===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
return v.date_due<(d[0].getTime()/1000);}
function _dueFilter(f,k,v){if(v.date_due===null&&f=="never"){return true;}
if(v.date_due===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
var t=d[0].getTime()/1000;return v.date_due>=t&&v.date_due<(t+(60*60*24));}
function _dueWithinFilter(f,k,v){if(v.date_due===null){return false;}
var range=dateTimeMgr.parseDueRange(f,false);if(range==null){return false;}
return range.epochWithinRange(v.date_due);}
function _dueAfterFilter(f,k,v){if(v.date_due===null&&f=="never"){return true;}
if(v.date_due===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
return v.date_due>(d[0].getTime()/1000);}
function _sharedWithFilter(f,k,v){if(!v.participants){return false;}
for(var i=0;i<v.participants.length;i++){if(v.participants[i].person_username==f){return true;}}
return false;}
function _isSharedFilter(f,k,v){if(!v.participants&&f=="false"){return true;}
if(v.participants&&f=="true"){return true;}
return false;}
function _statusFilter(f,k,v){if((f.indexOf("in")>-1)&&v.date_completed===null){return true;}
if((f.indexOf("ed")>-1)&&v.date_completed!==null){return true;}
return false;}
function _noteContainsFilter(f,k,v){if(!is(noteMgr.index[v.series_id])){return false;}
for(var i=0;i<noteMgr.index[v.series_id].length;i++){if(stateMgr.notes[noteMgr.index[v.series_id][i]].title.toLowerCase().indexOf(f)>-1||stateMgr.notes[noteMgr.index[v.series_id][i]].content.toLowerCase().indexOf(f)>-1){return true;}}
return false;}
function _completedBeforeFilter(f,k,v){if(v.date_completed===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return true;}
return v.date_completed<(d[0].getTime()/1000);}
function _completedFilter(f,k,v){if(v.date_completed===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return true;}
var t=d[0].getTime()/1000;return v.date_completed>=t&&v.date_completed<(t+(60*60*24));}
function _completedWithinFilter(f,k,v){if(v.date_completed===null){return false;}
var range=dateTimeMgr.parseDueRange(f,true);if(range==null){return true;}
return range.epochWithinRange(v.date_completed);}
function _completedAfterFilter(f,k,v){if(v.date_completed===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return true;}
return v.date_completed>(d[0].getTime()/1000);}
function _addedFilter(f,k,v){if(v.date_added===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
var t=d[0].getTime()/1000;return v.date_added>=t&&v.date_added<(t+(60*60*24));}
function _addedWithinFilter(f,k,v){if(v.date_added===null){return false;}
var range=dateTimeMgr.parseDueRange(f,true);if(range==null){return false;}
return range.epochWithinRange(v.date_added);}
function _addedBeforeFilter(f,k,v){if(v.date_added===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
return v.date_added<(d[0].getTime()/1000);}
function _addedAfterFilter(f,k,v){if(v.date_added===null){return false;}
var d=dateTimeMgr.parseDueDate(f);if(d[0]==null){return false;}
return v.date_added>(d[0].getTime()/1000);}
function _postponedFilter(f,k,v){var o=f.charAt(0);if(o=="<"||o==">"){f=f.substring(1);}else{o=null;}
var val=parseInt(f,10);if(o=="<"&&v.postponed<val){return true;}
if(o==">"&&v.postponed>val){return true;}
if(!o&&v.postponed==val){return true;}
return false;}
function _timeEstimateFilter(f,k,v){if(v.estimate===null){return false;}
var o=f.charAt(0);if(!(o=="<"||o==">")){o=null;}
var p1=dateTimeMgr.parseTimeEstimate(f);var p2=dateTimeMgr.parseTimeEstimate(v.estimate);if(o=="<"&&p2<p1){return true;}
if(o==">"&&p2>p1){return true;}
if(!o&&p2==p1){return true;}
return false;}
var filterMap={"tag":_tagFilter,"priority":_prioFilter,"listId":_listIdFilter,"list":_listFilter,"name":_nameFilter,"due":_dueFilter,"dueBefore":_dueBeforeFilter,"dueAfter":_dueAfterFilter,"sharedWith":_sharedWithFilter,"completed":_completedFilter,"noteContains":_noteContainsFilter,"dueWithin":_dueWithinFilter,"status":_statusFilter,"completedBefore":_completedBeforeFilter,"completedAfter":_completedAfterFilter,"isShared":_isSharedFilter,"postponed":_postponedFilter,"timeEstimate":_timeEstimateFilter,"completedWithin":_completedWithinFilter,"isTagged":_isTaggedFilter,"isRepeating":_isRepeatingFilter,"hasLocation":_hasLocation,"hasDueDate":_hasDueDate,"location":_locationFilter,"locationId":_locationIdFilter,"isLocated":_hasLocation,"added":_addedFilter,"addedBefore":_addedBeforeFilter,"addedAfter":_addedAfterFilter,"addedWithin":_addedWithinFilter};function SearchManager(buttonId,cancelId){this.inited=false;this.mbn="rtm.searchmanager.";this.buttonId=buttonId;this.button=el(buttonId);this.cancelId=cancelId;this.cancel=el(cancelId);var self=this;this.button.onclick=function(ev){view.selectView("Tasks");messageBus.broadcast(self,self.mbn+"buttonClicked");self.doSearch();return false;};this.cancel.onclick=function(ev){tasksView.toggleSearchOptions();return false;};this.fieldMap={"list":[SearchManager.FIELD_TYPE_SELECT,"search_lists"],"priority":[SearchManager.FIELD_TYPE_SELECT,"search_priority"],"status":[SearchManager.FIELD_TYPE_SELECT,"search_status"],"sharedWith":[SearchManager.FIELD_TYPE_SELECT,"search_shared",function(field,desc){return self.doSharedWith(field,desc);}],"tag":[SearchManager.FIELD_TYPE_TEXT,"search_tags"],"name":[SearchManager.FIELD_TYPE_TEXT,"search_words"],"not name":[SearchManager.FIELD_TYPE_TEXT,"search_words_not"],"noteContains":[SearchManager.FIELD_TYPE_CHECKBOX,"search_notes",function(field,desc){return self.doNoteContains(field,desc);}],"dueWithin":[SearchManager.FIELD_TYPE_TEXT,"search_due_range",function(field,desc){return self.doDueWithin(field,desc);}],"includeArchived":[SearchManager.FIELD_TYPE_CHECKBOX,"search_archived"]};}
SearchManager.FIELD_TYPE_SELECT=0;SearchManager.FIELD_TYPE_TEXT=1;SearchManager.FIELD_TYPE_CHECKBOX=2;SearchManager.prototype.init=function(){this.inited=true;};SearchManager.prototype.doSharedWith=function(field,desc){if(view.getPublicMode()){return null;}
var select=document.getElementById(desc[1]);var val=select[select.selectedIndex].value;if(val==-1){return null;}
if(val==-2){return"isShared:false";}
if(val==-3){return"isShared:true";}
return field+":"+quoteSearchTerm(val);};SearchManager.prototype.doDueWithin=function(field,desc){var range=el(desc[1]).value.trim();var start=el("search_due_start").value.trim();if(range.length==0&&start.length==0){return null;}
if(range.length==0){return"due:"+quoteSearchTerm(start);}else{if(start.length==0){start="today";}
return field+":"+quoteSearchTerm(fmt("%1 of %2",[range,start]));}};SearchManager.prototype.doNoteContains=function(field,desc){var check=document.getElementById(desc[1]);if(check.checked){var contains=el(this.fieldMap["name"][1]).value.trim();var ncontains=el(this.fieldMap["not name"][1]).value.trim();var q=[];if(contains.length>0){var iq=map(function(tok){return field+":"+tok;},normalizeSearchEntry(contains));q.push(iq.length==1?iq[0]:"("+iq.join(" and ")+")");}
if(ncontains.length>0){var iq=map(function(tok){return"not "+field+":"+tok;},normalizeSearchEntry(ncontains));q.push(iq.length==1?iq[0]:"("+iq.join(" and ")+")");}
if(ncontains.length==0&&contains.length==0){return null;}
return q.length==1?q[0]:"("+q.join(" ")+")";}
return null;};SearchManager.prototype.fieldQuery=function(field,desc){if(desc.length==3&&typeof desc[2]=="function"){return desc[2](field,desc);}
if(desc[0]==SearchManager.FIELD_TYPE_SELECT){var select=document.getElementById(desc[1]);var val=select[select.selectedIndex].value;if(val==0||val==-1){return null;}
return field+":"+quoteSearchTerm(val);}else{if(desc[0]==SearchManager.FIELD_TYPE_TEXT){var text=document.getElementById(desc[1]);var val=text.value.trim();if(val.length==0){return null;}
var q=map(function(tok){return field+":"+tok;},normalizeSearchEntry(val));return q.length==1?q[0]:"("+q.join(" and ")+")";}else{if(desc[0]==SearchManager.FIELD_TYPE_CHECKBOX){var check=document.getElementById(desc[1]);if(check.checked===true){return field+":true";}}}}
return null;};SearchManager.prototype.joinQuery=function(query){var out=[];var lastNot=false;for(var i=query.length-1;i>=0;i--){out.push(query[i]);if(i==0){break;}
if(query[i].indexOf("not ")>-1){lastNot=true;}
if(query[i].indexOf("noteContains")>-1){out.push("or");}else{if(lastNot==false){out.push("and");}
lastNot=false;}}
out.reverse();return out.join(" ");};SearchManager.prototype.constructQuery=function(){var query=[];var res;for(var field in this.fieldMap){if(view.getPublicMode()&&field=="includeArchived"){continue;}
res=this.fieldQuery(field,this.fieldMap[field]);if(res!==null){query.push(res);}}
if(query.length==0){return"";}
return query.length==1?query[0]:this.joinQuery(query);};SearchManager.prototype.doSearch=function(){el("listFilter").value=this.constructQuery();control.updateListFilter();tasksView.toggleSearchOptions();};SearchManager.prototype.updateLists=function(){var lists=stateMgr.getValidLists();var searchLists=document.getElementById("search_lists");searchLists.options.length=0;var option=document.createElement("option");option.value="-1";option.innerHTML=_T("INTERFACE_SEARCH_ALL_LISTS");searchLists.appendChild(option);option=document.createElement("option");option.value="-1";option.innerHTML="---";option.disabled=true;searchLists.appendChild(option);map(function(list){var option=document.createElement("option");option.value=list[1];option.innerHTML=list[1];searchLists.appendChild(option);},lists);};SearchManager.prototype.updateContacts=function(){var searchShared=document.getElementById("search_shared");searchShared.options.length=0;var option=document.createElement("option");option.value="-1";option.innerHTML=_T("INTERFACE_SEARCH_SHARED_WITH_DOESNT_MATTER");searchShared.appendChild(option);option=document.createElement("option");option.value="-2";option.innerHTML=_T("INTERFACE_SEARCH_SHARED_WITH_NO_ONE");searchShared.appendChild(option);option=document.createElement("option");option.value="-3";option.innerHTML=_T("INTERFACE_SEARCH_SHARED_WITH_SOMEONE");searchShared.appendChild(option);option=document.createElement("option");option.value="-1";option.innerHTML="---";option.disabled=true;searchShared.appendChild(option);map(function(list){var option=document.createElement("option");option.value=stateMgr.contacts[list[0]].username;option.innerHTML=list[1];searchShared.appendChild(option);},contactList.list.entries);};SearchManager.prototype.updatePriority=function(){var prioritySelect=document.getElementById("search_priority");prioritySelect.options.length=0;var option=document.createElement("option");option.value="-1";option.innerHTML=_T("INTERFACE_SEARCH_PRIORITY_ANY");prioritySelect.appendChild(option);option=document.createElement("option");option.value="-1";option.innerHTML="---";option.disabled=true;prioritySelect.appendChild(option);map(function(prio){var option=document.createElement("option");option.value=prio[0];option.innerHTML=prio[1];prioritySelect.appendChild(option);},[[1,_T("INTERFACE_SEARCH_PRIORITY_1")],[2,_T("INTERFACE_SEARCH_PRIORITY_2")],[3,_T("INTERFACE_SEARCH_PRIORITY_3")],["N",_T("INTERFACE_SEARCH_PRIORITY_NONE")]]);};SearchManager.prototype.updateStatus=function(){var statusSelect=document.getElementById("search_status");statusSelect.options.length=0;var option=document.createElement("option");option.value="-1";option.innerHTML=_T("INTERFACE_SEARCH_STATUS_ANY");statusSelect.appendChild(option);option=document.createElement("option");option.value="-1";option.innerHTML="---";option.disabled=true;statusSelect.appendChild(option);map(function(status){var option=document.createElement("option");option.value=status[0];option.innerHTML=status[1];statusSelect.appendChild(option);},[["incomplete",_T("INTERFACE_SEARCH_STATUS_INCOMPLETE")],["completed",_T("INTERFACE_SEARCH_STATUS_COMPLETED")]]);};SearchManager.prototype._armField=function(field){field.onkeypress=function(ev){ev||(ev=window.event);var pressed=(ev.charCode)?ev.charCode:((ev.which)?ev.which:ev.keyCode);if(pressed==27){searchMgr.cancel.onclick();}};return field;};SearchManager.prototype.clearOtherFields=function(){for(var field in this.fieldMap){if(view.getPublicMode()&&field=="includeArchived"){continue;}
var f=this.fieldMap[field];if(f[0]==SearchManager.FIELD_TYPE_SELECT){continue;}
var val=el(f[1]);if(f[0]==SearchManager.FIELD_TYPE_TEXT){val.value="";this._armField(val);}else{if(f[0]==SearchManager.FIELD_TYPE_CHECKBOX){val.checked=false;}}}
this._armField(el("search_due_start")).value="";};SearchManager.prototype.updateFields=function(){this.updateLists();if(!view.getPublicMode()){this.updateContacts();}
this.updatePriority();this.updateStatus();this.clearOtherFields();};function Control(){this.inited=false;this.filterTime=null;this.filterTimeout=null;this.lastFilter=null;this.lastType=null;this.showAdded=false;}
Control.prototype.init=function(){var self=this;var loadThreshold=function(x,y){if(!statusBox.visible){statusBox.setText(_T("INTERFACE_STATUS_BUSY"));}};messageBus.subscribe(loadThreshold,transMgr.mbn+"loadThreshold");var listReloadTimer=function(x,y){if(stateMgr.currentList!==null&&stateMgr.tick++%2==0&&!tasksView.getHovering()&&!(!view.getPublicMode()&&addingList&&addingList.list.visible===true)&&taskList.getViewList().selected.length==0){if(is(stateMgr.lists[stateMgr.currentList].list_last_sync)&&((new Date().getTime()-stateMgr.lists[stateMgr.currentList].list_last_sync)/1000)<60){stateMgr.tick=0;return false;}
if(stateMgr.currentType==TasksView.LIST_TYPE_NORMAL){self.tasksListReload();}}};messageBus.subscribe(listReloadTimer,dateTimeMgr.mbn+"chime");var tasksListDetailsTabChanged=function(x,y){self.tasksListDetailsTabChanged(y);};messageBus.subscribe(tasksListDetailsTabChanged,detailstab.mbn+"tabChanged");var tasksListTabChanged=function(x,y){self.tasksListTabChanged(y);};messageBus.subscribe(tasksListTabChanged,listTabs.mbn+"tabChanged");var tasksTaskTabChanged=function(x,y){self.tasksTaskTabChanged(x,y);};messageBus.subscribe(tasksTaskTabChanged,taskTabs.mbn+"tabChanged");var tasksTaskSelected=function(x,data){self.tasksTaskSelected(data);};messageBus.subscribe(tasksTaskSelected,taskList.list.getUniqueMessageBusName()+"selectFinished");messageBus.subscribe(tasksTaskSelected,taskList.completedList.getUniqueMessageBusName()+"selectFinished");var tasksSorted=function(x,data){self.tasksSorted(data);};messageBus.subscribe(tasksSorted,taskList.list.getUniqueMessageBusName()+"sortFinished");var tasksTaskHoverOn=function(x,data){self.tasksTaskHoverOn(data);};messageBus.subscribe(tasksTaskHoverOn,taskList.list.getUniqueMessageBusName()+"hoverOn");messageBus.subscribe(tasksTaskHoverOn,taskList.completedList.getUniqueMessageBusName()+"hoverOn");var tasksTaskHoverOff=function(x,data){self.tasksTaskHoverOff(data);};messageBus.subscribe(tasksTaskHoverOff,taskList.list.getUniqueMessageBusName()+"hoverOff");messageBus.subscribe(tasksTaskHoverOff,taskList.completedList.getUniqueMessageBusName()+"hoverOff");var tasksSelectorClicked=function(x,data){self.tasksSelectorClicked(data);};messageBus.subscribe(tasksSelectorClicked,tasksToolBox.getUniqueMessageBusName()+"selectorClicked");var tasksCompletedSelectorClicked=function(x,data){self.tasksCompletedSelectorClicked(data);};messageBus.subscribe(tasksCompletedSelectorClicked,tasksCompletedToolBox.getUniqueMessageBusName()+"selectorClicked");var tasksSentSelectorClicked=function(x,data){self.tasksCompletedSelectorClicked(data);};messageBus.subscribe(tasksSentSelectorClicked,tasksSentToolBox.getUniqueMessageBusName()+"selectorClicked");var tasksSelectionChanged=function(x,data){self.tasksSelectionChanged(x,data);};messageBus.subscribe(tasksSelectionChanged,tasksToolBox.getUniqueMessageBusName()+"selectionChanged");messageBus.subscribe(tasksSelectionChanged,tasksCompletedToolBox.getUniqueMessageBusName()+"selectionChanged");messageBus.subscribe(tasksSelectionChanged,tasksSentToolBox.getUniqueMessageBusName()+"selectionChanged");var tasksViewChanged=function(x,data){self.tasksViewChanged(data);};messageBus.subscribe(tasksViewChanged,taskList.getUniqueMessageBusName()+"viewChanged");var viewViewChanged=function(x,data){self.viewViewChanged(data);};messageBus.subscribe(viewViewChanged,view.getUniqueMessageBusName()+"viewChanged");var listCountSelected=function(who,data){self.listCountSelected(who,data);};messageBus.subscribe(listCountSelected,taskList.list.getUniqueMessageBusName()+"selectFinished");messageBus.subscribe(listCountSelected,taskList.completedList.getUniqueMessageBusName()+"selectFinished");var listSelectedCleared=function(who,data){self.listSelectedCleared(who,data);};messageBus.subscribe(listSelectedCleared,taskList.list.getUniqueMessageBusName()+"selectCleared");messageBus.subscribe(listSelectedCleared,taskList.completedList.getUniqueMessageBusName()+"selectCleared");var loadingListShowFunc=function(who,show){if(view.getSelected()=="Tasks"&&show){loadingList.show();}
format.formatTaskStatisticsForList(stateMgr.currentList,true);};messageBus.subscribe(loadingListShowFunc,taskList.getUniqueMessageBusName()+"loadStarted");var loadBlittedFunc=function(){loadingList.hide();};messageBus.subscribe(loadBlittedFunc,taskList.getUniqueMessageBusName()+"loadBlitted");var loadingListHideFunc=function(){taskList.clearLoadTimeout();if(view.getSelected()=="Tasks"){self.tasksFormat();}
if(false&&is_opera){taskList.getViewList().table.style.visibility="hidden";taskList.getViewList().table.style.visibility="visible";}};messageBus.subscribe(loadingListHideFunc,taskList.getUniqueMessageBusName()+"loadFinished");this.inited=true;};Control.prototype.doListTabChanged=function(){if(tasksView.inInboxList()){helpBox.showHelpText("tasks.inbox");if(!view.getPublicMode()){whatsNew.setCount("shared_tasks",0);whatsNew.setCount("emailed_tasks",0);if(view.getSelected()==="Tasks"){adder.show();}}}else{if(!view.getPublicMode()){adder.show();}
helpBox.stopShowing("tasks.inbox");}
taskList.switchView(TaskList.TASK_LIST_VIEW_INCOMPLETE);if(tasksView.inSentList()){taskList.list.setPrioState(List.LIST_PRIO_COMPLETED);tasksView.taskDetails.disable();helpBox.showHelpText("tasks.sent");noteMgr.disable();}else{noteMgr.enable();taskList.list.setPrioState(List.LIST_PRIO_INCOMPLETE);if(view.getPublicMode()||(view.getViewToken("Tasks","Share")||view.getViewToken("Tasks","Publish"))){tasksView.taskDetails.disable();}else{if(view.getViewToken("Tasks")){tasksView.taskDetails.enable();}}
helpBox.stopShowing("tasks.sent");}};Control.prototype.tasksListTabChanged=function(data){var fromId=data[0][0];var fromName=data[0][1];var toId=data[1][0];var toName=data[1][1];var tabData=data[2];if(fromId!==null){if(tabData[0]==TasksView.LIST_TYPE_SMART||tabData[0]==TasksView.LIST_TYPE_SEARCH){stateMgr.setCurrentType(tabData[0]);if(tabData[0]==TasksView.LIST_TYPE_SMART){stateMgr.setCurrentList(tabData[1]);}else{stateMgr.setCurrentList(null);}
stateMgr.setCurrentFilter(tabData[2]);var seenLists={};for(var taskId in stateMgr.tasks){if(is(stateMgr.tasks[taskId])&&noteMgr.index&&is(noteMgr.index[stateMgr.tasks[taskId].series_id])){seenLists[stateMgr.tasks[taskId].list_id]=true;}}
var toLoad=[];var includeArchived=stateMgr.currentFilter.indexOf("includeArchived:true")>-1;var noteContains=stateMgr.currentFilter.indexOf("noteContains")>-1;for(var listId in stateMgr.lists){var archived=includeArchived||stateMgr.lists[listId].archived===false;if(!stateMgr.lists[listId].deleted&&archived&&stateMgr.lists[listId].filter===null){if(!is(seenLists[listId])||(includeArchived&&stateMgr.lists[listId].archived)||noteContains){toLoad.push(listId);}}}
if(toLoad.length>0){this.doListsLoad(toLoad);}}else{stateMgr.setCurrentType(tabData[0]);stateMgr.setCurrentList(tabData[1]);stateMgr.setCurrentFilter("(listId:"+tabData[1]+")");}
this.doListTabChanged();if(fromId!=toId){taskTabs.selectDefault(false);taskTabs.hide();detailstab.show();taskList.clear();detailstab.selectDefault(true);if(!view.getPublicMode()){control.addingListAddSuccess();}
this.lastFilter=null;}
this.tasksListReload(fromId!=toId);}else{this.doListTabChanged();}};Control.prototype.doListsLoad=function(ids){var lastSynced=[];for(var i=0;i<ids.length;i++){var id=ids[i];var lastSync=is(stateMgr.lists[id].list_last_sync)?(stateMgr.lists[id].list_last_sync/1000):0;lastSynced.push(lastSync);}
if(view.getPublicMode()){transMgr.request("lists.public.load",utility.encodeJavaScript({"user":rtmUsername,"list":ids,"lastSync":lastSynced}));}else{transMgr.request("lists.load",utility.encodeJavaScript({"list":ids,"lastSync":lastSynced}));}};Control.prototype.tasksListReload=function(sw){if(sw){loadingList.showLoadingMessage();}
if(stateMgr.currentType==TasksView.LIST_TYPE_NORMAL){var lastSync=is(stateMgr.lists[stateMgr.currentList].list_last_sync)?(stateMgr.lists[stateMgr.currentList].list_last_sync/1000):0;taskList.list.setEmptyMessage(_T("INTERFACE_TASKS_NO_INCOMPLETE"));taskList.completedList.setEmptyMessage(_T("INTERFACE_TASKS_NO_COMPLETED"));if(view.getPublicMode()){transMgr.request("lists.public.load",utility.encodeJavaScript({"user":rtmUsername,"list":stateMgr.currentList,"lastSync":lastSync}));}else{transMgr.request("lists.load",utility.encodeJavaScript({"list":stateMgr.currentList,"lastSync":lastSync}));}
var listLoadTimeoutFunc=function(){messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadTimeout");};taskList.setLoadTimeout(setTimeout(listLoadTimeoutFunc,TransactionManager.REQUEST_TIMEOUT*1000*transMgr.getDistributionMultiplier()));messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadStarted",sw);}else{messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadStarted",sw);taskList.list.setEmptyMessage(_T("INTERFACE_TASKS_NO_RESULTS"));taskList.completedList.setEmptyMessage(_T("INTERFACE_TASKS_NO_RESULTS"));this.doVirtualListLoad(stateMgr.currentFilter);}};Control.prototype.doVirtualListLoad=function(s,notModified){if(this.lastFilter!==null&&this.lastFilter===s&&this.lastType!==null&&this.lastType===stateMgr.currentType&&notModified==true){messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadBlitted");messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadFinished");return false;}
var includeArchived=false;if(s.indexOf("includeArchived:true")>-1){includeArchived=true;}
s=s.replace(/\s*(and|or)?\s*includeArchived:(true|false)/,"");this.lastFilter=s;this.lastType=stateMgr.currentType;var l=new Sexp(s);stateMgr.filterObj=new Filter(stateMgr.tasks,filterMap,l.sexpr,"name");if(includeArchived===true){stateMgr.filterObj.setImplicitFilter(null);}else{stateMgr.filterObj.setImplicitFilter(_includeArchived);}
noteMgr.prepareIndex();dateTimeMgr.setCache(true);var s=new Date().getTime();stateMgr.workingSet=stateMgr.filterObj.reduce();s=(new Date().getTime()-s)/1000;dateTimeMgr.setCache(false);messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadBlitted");taskList.setAdvise(true);for(var i=0;i<stateMgr.workingSet.length;i++){taskList.addTask(stateMgr.tasks[stateMgr.workingSet[i]]);}
taskList.setAdvise(false);taskList.list.sortAndBlit();taskList.list.prune();if(this.lastFilter.indexOf("completed")>-1&&taskList.list.entries.length===0){taskList.completedList.prune();taskList.completedList.sortAndBlit();taskList.switchView(TaskList.TASK_LIST_VIEW_COMPLETED);}
if(this.lastFilter.indexOf("added")>-1){this.showAdded=true;}else{this.showAdded=false;}
taskList.doDues();messageBus.broadcast(taskList,taskList.getUniqueMessageBusName()+"loadFinished");};Control.prototype.updateListFilter=function(value){var self=this;var filterFunc=function(){view.selectView("Tasks");var filterText=value||el("listFilter").value.trim();var ft;var sx=new Sexp(filterText);ft=sx.str;stateMgr.currentFilter=filterText;stateMgr.currentList=null;stateMgr.currentType=TasksView.LIST_TYPE_SEARCH;if(listTabs.entryExists(null)){listTabs.setDataForEntry(null,[TasksView.LIST_TYPE_SEARCH,null,ft]);}else{listTabs.addEntry(_T("INTERFACE_TASKS_SEARCH_TAB"),[TasksView.LIST_TYPE_SEARCH,null,ft],true);}
listTabs.blitDiv();listTabs.selectTabByData(null);clearTimeout(self.filterTimeout);self.filterTimeout=null;};if(this.filterTimeout!==null){clearTimeout(this.filterTimeout);this.filterTimeout=null;}
this.filterTimeout=setTimeout(filterFunc,0);};Control.prototype.tasksTaskSelected=function(data){if(view.getSelected()=="Tasks"){var selected=data[0];var pos=data[1];if(selected){tasksView.setHovering(false);var id=taskList.getViewList().entries[pos][0];this.tasksViewReflectDisplay();format.formatTask(id);}else{tasksView.setHovering(false);taskTabs.selectDefault(false);this.tasksViewReflectDisplay();format.formatTaskStatisticsForList(stateMgr.currentList,false);}}};Control.prototype.tasksTaskHoverOn=function(data){var id=data;if(!tasksView.getHovering()){tasksView.setHovering(true);this.tasksViewReflectDisplay();format.formatTask(id);}};Control.prototype.tasksTaskHoverOff=function(data){tasksView.setHovering(false);this.tasksViewReflectDisplay();this.tasksFormat();};Control.prototype.tasksViewReflectDisplay=function(hideAll){if(hideAll){shareMgr.hide();publishMgr.hide();saveMgr.hide();noteMgr.hide();el("listdetailsbox").style.display="none";tasksView.taskDetails.hide();taskTabs.hide();detailstab.hide();if(!view.getPublicMode()&&taskCloud){taskCloud.hideCopy();}
return false;}
var tasksToken=view.getViewToken("Tasks","Tasks");var notesToken=view.getViewToken("Tasks","Notes");if(tasksToken||notesToken){if(!view.getPublicMode()){shareMgr.hide();publishMgr.hide();saveMgr.hide();if(taskCloud){taskCloud.hideCopy();}}
el("listdetailsbox").style.display="none";detailstab.hide();if(tasksToken){noteMgr.hide();tasksView.taskDetails.show();}else{tasksView.taskDetails.hide();noteMgr.show();}
taskTabs.show();}else{if(view.getViewToken("Tasks")){taskTabs.hide();tasksView.taskDetails.hide();noteMgr.hide();if(!view.getPublicMode()){if(taskCloud){taskCloud.hideCopy();}
if(stateMgr.currentType==TasksView.LIST_TYPE_NORMAL){if(detailstab.entries.length==2){detailstab.removeEntry(1,true);}
if(detailstab.entries.length!==3){detailstab.addEntry(_T("INTERFACE_TASKS_LIST_DETAILS_SHARE"));detailstab.addEntry(_T("INTERFACE_TASKS_LIST_DETAILS_PUBLISH"));detailstab.blitDiv();}}else{if(stateMgr.currentType==TasksView.LIST_TYPE_SMART){if(detailstab.entries.length>1){while(detailstab.entries.length>1){detailstab.removeEntry(1,true);}}
detailstab.blitDiv();}else{if(detailstab.entries.length==1||detailstab.entries.length>2){while(detailstab.entries.length>1){detailstab.removeEntry(1,true);}
detailstab.addEntry(_T("INTERFACE_TASKS_SAVE_TAB"));}
detailstab.blitDiv();}}}
detailstab.show();if(!view.getPublicMode()&&view.getViewToken("Tasks","Share")){el("listdetailsbox").style.display="none";publishMgr.hide();saveMgr.hide();shareMgr.show();}else{if(!view.getPublicMode()&&view.getViewToken("Tasks","Publish")){el("listdetailsbox").style.display="none";shareMgr.hide();saveMgr.hide();publishMgr.show();}else{if(!view.getPublicMode()&&view.getViewToken("Tasks","Save")){el("listdetailsbox").style.display="none";shareMgr.hide();publishMgr.hide();saveMgr.show();}else{if(view.getViewToken("Tasks","List")){if(!view.getPublicMode()){shareMgr.hide();publishMgr.hide();saveMgr.hide();if(taskCloud){taskCloud.showCopy();}}
el("listdetailsbox").style.display="";}}}}}else{taskTabs.hide();tasksView.taskDetails.hide();noteMgr.hide();detailstab.hide();if(view.getPublicMode()){shareMgr.hide();publishMgr.hide();saveMgr.hide();}
el("listdetailsbox").style.display="none";}}};Control.prototype.tasksSelectorClicked=function(data){var which=data[0];var shiftHeld=data[1];switch(which){case _T("INTERFACE_TASKS_SELECT_ALL"):taskList.taskSelectAll(shiftHeld);return;case _T("INTERFACE_TASKS_SELECT_NONE"):taskList.taskSelectNone(shiftHeld);return;case _T("INTERFACE_TASKS_SELECT_DUE_TODAY"):taskList.taskSelectDueToday(shiftHeld);return;case _T("INTERFACE_TASKS_SELECT_DUE_TOMORROW"):taskList.taskSelectDueTomorrow(shiftHeld);return;case _T("INTERFACE_TASKS_SELECT_OVERDUE"):taskList.taskSelectOverdue(shiftHeld);return;default:return;}};Control.prototype.tasksCompletedSelectorClicked=function(data){var which=data[0];var shiftHeld=data[1];switch(which){case _T("INTERFACE_TASKS_SELECT_ALL"):taskList.taskSelectAll(shiftHeld);return;case _T("INTERFACE_TASKS_SELECT_NONE"):taskList.taskSelectNone(shiftHeld);return;default:return;}};Control.prototype.tasksViewChanged=function(data){var newView=data;if(view.getSelected()=="Tasks"){if(!view.getPublicMode()){this.showTasksAdder();}
this.showTasksToolbox(newView);}else{this.hideTasksToolbox();}
this.tasksFormat();};Control.prototype.showTasksToolbox=function(taskListView){if(taskListView==TaskList.TASK_LIST_VIEW_INCOMPLETE){tasksCompletedToolBox.hide();tasksView.taskDetails.detailsCompleted.setHidden(true);tasksView.taskDetails.detailsCompleted.hide();if(tasksView.inSentList()){tasksToolBox.hide();tasksSentToolBox.show();tasksView.taskDetails.disable();}else{tasksSentToolBox.hide();tasksToolBox.show();if(view.getPublicMode()){tasksView.taskDetails.disable();}else{if(!(view.getViewToken("Tasks","Share")||view.getViewToken("Tasks","Publish")||view.getViewToken("Tasks","Save"))){tasksView.taskDetails.enable();}}}}else{tasksToolBox.hide();if(tasksView.inSentList()){tasksCompletedToolBox.hide();tasksSentToolBox.show();}else{tasksSentToolBox.hide();tasksCompletedToolBox.show();}
tasksView.taskDetails.detailsCompleted.setHidden(false);tasksView.taskDetails.detailsCompleted.show();if(stateMgr.currentList!==TasksView.LIST_TYPE_NORMAL){tasksView.taskDetails.detailsList.setHidden(false);tasksView.taskDetails.detailsList.show();}else{tasksView.taskDetails.detailsList.setHidden(true);tasksView.taskDetails.detailsList.hide();}
tasksView.taskDetails.disable();}
if(stateMgr.currentType!==TasksView.LIST_TYPE_NORMAL){tasksView.taskDetails.detailsList.setHidden(false);tasksView.taskDetails.detailsList.show();}else{tasksView.taskDetails.detailsList.setHidden(true);tasksView.taskDetails.detailsList.hide();}};Control.prototype.hideTasksToolbox=function(){tasksToolBox.hide();tasksSentToolBox.hide();tasksCompletedToolBox.hide();};Control.prototype.tasksFormat=function(){var id=taskList.getViewList().getLastSelectedId();this.tasksViewReflectDisplay();if(id===null){format.formatTaskStatisticsForList(stateMgr.currentList,false);}else{format.formatTask(id);}};Control.prototype.listCountSelected=function(who,data){var count=data[0];if(!view.getPublicMode()&&view.shareMode!==null){var text;var contact_num=contactList.list.getSelected().length;var group_num=groupList.list.getSelected().length;if(!(contact_num||group_num)){text=_T("INTERFACE_CONTACTS_SELECT_SOME_CONTACTS_OR_GROUPS");statusBox.sharingEnableDone(false);}else{var tpl;if(contact_num==0){tpl=group_num==1?"INTERFACE_CONTACTS_GROUPS_SELECTED_ONE":"INTERFACE_CONTACTS_GROUPS_SELECTED_NUM";text=_T(tpl,{"NUM":group_num});}else{if(contact_num==1){tpl="INTERFACE_CONTACTS_SELECTED_ONE";if(group_num==1){tpl="INTERFACE_CONTACTS_SEL_ONE_ONE";}else{if(group_num>1){tpl="INTERFACE_CONTACTS_SEL_ONE_NUM";}}
text=_T(tpl,{"GROUP_NUM":group_num});}else{if(group_num==0){tpl="INTERFACE_CONTACTS_SELECTED_NUM";text=_T(tpl,{"NUM":contact_num});}else{tpl=group_num==1?"INTERFACE_CONTACTS_SEL_NUM_ONE":"INTERFACE_CONTACTS_SEL_NUM_NUM";text=_T(tpl,{"CONTACT_NUM":contact_num,"GROUP_NUM":group_num});}}}
statusBox.sharingEnableDone(true);}
infoBox.setText(text);infoBox.show();}else{if(who.visible){if(count!=0){var text;switch(who.parent.type){case"task":if(count==1){if(view.getMultiEditMode()){text="INTERFACE_TASKS_SELECTED_ONE_TASK_MULTIEDIT";}else{text="INTERFACE_TASKS_SELECTED_ONE_TASK";}}else{if(view.getMultiEditMode()){text="INTERFACE_TASKS_SELECTED_NUM_TASKS_MULTIEDIT";}else{text="INTERFACE_TASKS_SELECTED_NUM_TASKS";}}
break;case"contact":if(count==1){text="INTERFACE_CONTACTS_SELECTED_ONE";}else{text="INTERFACE_CONTACTS_SELECTED_NUM";}
break;case"group":if(count==1){text="INTERFACE_CONTACTS_GROUPS_SELECTED_ONE";}else{text="INTERFACE_CONTACTS_GROUPS_SELECTED_NUM";}
break;case"list":if(count==1){text="INTERFACE_SETTINGS_LISTS_SELECTED_ONE";}else{text="INTERFACE_SETTINGS_LISTS_SELECTED_NUM";}
break;case"location":if(count==1){text="INTERFACE_SETTINGS_LOCATIONS_SELECTED_ONE";}else{text="INTERFACE_SETTINGS_LOCATIONS_SELECTED_NUM";}
break;default:break;}
infoBox.setText(_T(text,{"NUM":count}));infoBox.show();}else{infoBox.hide();}}}};Control.prototype.listSelectedCleared=function(who,data){if(infoBox){if(!view.getPublicMode()&&(view.shareMode===null&&!(who==groupList.list||who==contactList.list||who==locationList.list))){infoBox.hide();}}};Control.prototype.tasksSorted=function(who,data){taskList.doDues();};Control.prototype.viewViewChanged=function(data){var fromId=data[0][0];var fromName=data[0][1];var toId=data[1][0];var toName=data[1][1];var overview=el("overview");var appview=el("appview");var mapview=el("mapview");if(toName!="Overview"){if(!view.getPublicMode()){overview.style.display="none";}
if(toName!="Locations"){mapview.style.display="none";appview.style.display="";}else{appview.style.display="none";mapview.style.display="";locationMgr.display();}}else{mapview.style.display="none";appview.style.display="none";if(!view.getPublicMode()){overview.style.display="";}}
if(fromName=="Tasks"){loadingList.hide();this.tasksViewReflectDisplay(true);if(is_gecko){el("tools_spacer").style.display="none";el("tools_spacer").style.display="";}}
if(toName!="Tasks"){el("listtoolbox").style.display="none";helpBox.stopShowingAll("tasks");this.hideTasksToolbox();}
if(fromName=="Contacts"){if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){contactsView.contactDetails.hide();contactList.list.table.style.visibility="hidden";contactList.list.table.style.visibility="visible";helpBox.stopShowing("contacts");}else{if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_GROUPS_TAB")){contactsView.groupDetails.hide();helpBox.stopShowing("groups");}else{if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_INVITES_TAB")){helpBox.stopShowing("invites");}}}}
if(fromName=="Settings"){if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){settingsView.listDetails.hide();helpBox.stopShowing("settings.lists");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){settingsView.locationDetails.hide();helpBox.stopShowing("settings.locations");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_GENERAL_TAB")){helpBox.stopShowing("settings.general");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_REMINDERS_TAB")){helpBox.stopShowing("settings.reminders");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_SERVICES_TAB")){helpBox.stopShowing("settings.services");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_INFO_TAB")){helpBox.stopShowing("settings.info");}}}}}}}
if(toName=="Tasks"){if(!view.getPublicMode()){this.showTasksAdder();}
if(tasksView.inSentList()){noteMgr.disable();helpBox.showHelpText("tasks.sent");}else{if(tasksView.inInboxList()){helpBox.showHelpText("tasks.inbox");}
noteMgr.enable();}
this.showTasksToolbox(taskList.view);this.tasksViewReflectDisplay();this.tasksFormat();}else{if(toName=="Contacts"){contactsView.contactDetails.disable();contactsView.groupDetails.disable();if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_CONTACTS_TAB")){contactsdetailstabs.renameEntry(contactsdetailstabs.entries[0],_T("INTERFACE_CONTACTS_CONTACT_TAB"));contactsdetailstabs.blitDiv();this.showContactsAdder();this.contactsFormat();helpBox.showHelpText("contacts");}else{if(contactsView.getSelected()==_T("INTERFACE_CONTACTS_GROUPS_TAB")){contactsdetailstabs.renameEntry(contactsdetailstabs.entries[0],_T("INTERFACE_CONTACTS_GROUPS_GROUP_TAB"));contactsdetailstabs.blitDiv();this.showGroupsAdder();this.groupsFormat();helpBox.showHelpText("groups");}else{contactsdetailstabs.renameEntry(contactsdetailstabs.entries[0],_T("INTERFACE_CONTACTS_INVITES_TAB"));helpBox.showHelpText("invites");this.invitesFormat();contactsdetailstabs.blitDiv();if(!view.getPublicMode()){adder.hide();}}}}else{if(toName=="Settings"){if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LISTS_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_LISTS_TAB"));settingsdetailstabs.blitDiv();this.showListsAdder();this.listsFormat();helpBox.showHelpText("settings.lists");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_LOCATIONS_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_LOCATIONS_TAB"));settingsdetailstabs.blitDiv();adder.hide();this.locationsFormat();helpBox.showHelpText("settings.locations");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_GENERAL_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_GENERAL_TAB"));settingsdetailstabs.blitDiv();this.generalSettingsFormat();helpBox.showHelpText("settings.general");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_REMINDERS_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_REMINDERS_TAB"));settingsdetailstabs.blitDiv();this.reminderSettingsFormat();helpBox.showHelpText("settings.reminders");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_SERVICES_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_SERVICES_TAB"));settingsdetailstabs.blitDiv();this.servicesSettingsFormat();helpBox.showHelpText("settings.services");}else{if(settingsView.getSelected()==_T("INTERFACE_SETTINGS_INFO_TAB")){settingsdetailstabs.renameEntry(settingsdetailstabs.entries[0],_T("INTERFACE_SETTINGS_INFO_TAB"));settingsdetailstabs.blitDiv();this.infoSettingsFormat();helpBox.showHelpText("settings.info");}}}}}}}}}};Control.prototype.taskSeriesMap=function(taskIds){var taskSeries={};for(var i=0;i<taskIds.length;i++){var ts=stateMgr.tasks[taskIds[i]].series_id;if(!is(taskSeries[ts])){taskSeries[ts]=[];}
taskSeries[ts].push([stateMgr.tasks[taskIds[i]].list_id,taskIds[i]]);}
return taskSeries;};Control.prototype.getTasksForTaskSeries=function(taskSeries){var tasks=[];for(var i in stateMgr.tasks){if(is(stateMgr.tasks[i])&&stateMgr.tasks[i].series_id==taskSeries){tasks.push(i);}}
return tasks;};Control.prototype.taskSeriesFlatten=function(tsMap,pairs){var tasks=[];if(tsMap===null||tsMap instanceof Array){return tasks;}
for(var ts in tsMap){var tsTasks=tsMap[ts];for(var i=0;i<tsTasks.length;i++){if(tsTasks[i]instanceof Array&&!pairs){tasks.push(tsTasks[i][1]);}else{tasks.push(tsTasks[i]);}}}
return tasks;};Control.prototype.getTaskSeries=function(tsMap){var taskSeries=[];if(tsMap===null||tsMap instanceof Array){return taskSeries;}
for(var ts in tsMap){taskSeries.push(ts);}
return taskSeries;};Control.prototype.tasksTaskTabChanged=function(who,data){var fromId=data[0][0];var fromName=data[0][1];var toId=data[1][0];var toName=data[1][1];this.tasksViewReflectDisplay();if(who.hidden==false&&fromId!==null){this.tasksFormat();}};Control.prototype.taskSeriesExtract=function(tsMap){for(var ts in tsMap){return ts;}};Control.prototype.tasksListDetailsTabChanged=function(){this.tasksViewReflectDisplay();this.tasksFormat();};var rtm=null;var version=18;var debug=null;var messageBus=null;var statusBox=null;var infoBox=null;var helpBox=null;var transMgr=null;var stringMgr=null;var eventMgr=null;var reoccurMgr=null;var dateTimeMgr=null;var stateMgr=null;var imageMgr=null;var tagMgr=null;var searchMgr=null;var utility=null;var view=null;var control=null;var format=null;var legend=null;var taskList=null;var loadingList=null;var tasksView=null;var taskTabs=null;var detailstab=null;var noteMgr=null;var listTabs=null;var tasksToolBox=null;var tasksCompletedToolBox=null;var tasksSentToolBox=null;var rtmUsername=null;var rtmHostname=null;var rtmMailHost=null;var rtmAPIEnabled=false;var rtmTime24=false;function l(a){if(!a.deleted){if(a.id==stateMgr.currentList){if(stateMgr.currentType===TasksView.LIST_TYPE_SMART&&a.filter!==stateMgr.currentFilter){listTabs.setDataForEntry(a.id,[TasksView.LIST_TYPE_SMART,a.id,a.filter]);}
listTabs.selectTabByData(a.id);}
if(!view.getPublicMode()){listList.addList(a);if(listList.list.getLastSelectedId()===a.id){control.listsFormat();}}}
return null;}
function t(a){if(a.list_id==stateMgr.currentList){taskList.addTask(a);}
if(!view.getPublicMode()){overviewList.addTask(a);}
return null;}
function n(a){if(noteMgr.currentTask===a.task_series_id&&noteMgr.noteEditRefCount==0){control.tasksFormat();}}
function L(f,a){if(rtm.init){if(!view.getPublicMode()){listList.list.setAdvise(true);}
if(f!=null&&a!=null){for(var x=0,y=a.length;x<y;x++){stateMgr.lists[a[x].id]=a[x];z=a[x];f(z);}}
if(!view.getPublicMode()){listList.list.tableBlitRows();listList.list.setAdvise(false);listList.list.sort();listList.doStyles();tasksView.reflectListsInTasksToolbox();}
listTabs.sort();}
return!view.getPublicMode()?listList:null;}
function T(f,a,remove){if(rtm.init){var startTime=new Date().getTime();var modified=false;if(is(f)&&is(a)){for(var x=0,y=a.length;x<y;x++){var last=stateMgr.lists[a[x].list_id].list_last_sync;stateMgr.lists[a[x].list_id].list_last_sync=(new Date().getTime()-dateTimeMgr.serverOffset);stateMgr.tasks[a[x].id]=a[x];modified=true;}
for(var taskId in remove){if(typeof stateMgr.tasks[taskId]=="undefined"||stateMgr.tasks[taskId]===null){continue;}
stateMgr.tasks[taskId]=null;modified=true;}}
if(modified&&view.getBulk()===View.BULK_START){view.setBulk(View.BULK_MODIFIED);}
if(view.getBulk()!==View.BULK_MODIFIED_END){if(view.getBulk()!==View.BULK_RESET&&view.getBulk()!==View.BULK_END){return taskList;}}else{modified=true;}
view.setBulk(View.BULK_RESET);view.setInUndo(false);control.doVirtualListLoad(stateMgr.currentFilter,!modified);if(!view.getPublicMode()){var overviewUpdate=function(){if(modified||(a!==null&&a.length>0)){overviewList.update();taskCloud.update();}
messageBus.broadcast(overviewList,overviewList.getUniqueMessageBusName()+"loadFinished");};if(view.getSelected()=="Overview"){overviewUpdate();}else{setTimeout(overviewUpdate,0);}}
var endTime=new Date().getTime();if(!view.getPublicMode()){}}
return taskList;}
function N(f,a){if(rtm.init&&is(a)){for(var x=0,y=a.length;x<y;x++){stateMgr.notes[a[x].id]=a[x];z=a[x];f(z);}
if(a.length>0&&view.getBulk()===View.BULK_START){view.setBulk(View.BULK_MODIFIED);}}}
function UT(a){if(rtm.init&&is(a)){tagMgr.setIndex(a);tagMgr.updateInvertedIndex();if(!view.getPublicMode()){taskCloud.update();}}}
function UTC(a){if(rtm.init&&is(a)){tagMgr.clearTagsForTaskSeries(a);if(!view.getPublicMode()){taskCloud.update();}
if(view.getViewToken("Tasks")){control.tasksFormat();}}}
function UTI(a){if(rtm.init&&is(a)){tagMgr.updateTags(a);if(!view.getPublicMode()){taskCloud.update();}
if(view.getViewToken("Tasks")){control.tasksFormat();}}}
function LOC(a){if(rtm.init&&is(a)&&!view.getPublicMode()){locationMgr.updateLocations(a);}}
function LOCU(a){if(rtm.init&&is(a)&&!view.getPublicMode()){locationMgr.updateTaskSeries(a);}}
var rtmRequestedList=null;var rtmRequestedTask=null;var rtmLanguage=null;function RememberTheMilk(){}
RememberTheMilk.prototype.init=function(){utility=new Utility();messageBus=new MessageBus();messageBus.broadcast(this,"rtm.initStarted");stateMgr=new StateManager();format=new Format();stringMgr=new StringManager();eventMgr=new EventManager();eventMgr.init();reoccurMgr=new ReoccurrenceManager();imageMgr=new ImageManager();imageMgr.init();transMgr=new TransactionManager();transMgr.setSingleSignOn(rtmUsername);dateTimeMgr=new DateTimeManager();dateTimeMgr.init();dateTimeMgr.setTimezone(true);statusBox=new StatusBox("statusbox","statusboxtext","statusboxbuttons");statusBox.init();statusBox.setText(_T("INTERFACE_STATUS_LOADING"),false,true);statusBox.show();loadingList=new LoadingList("loading");loadingList.init();taskList=new TaskList("tasks","taskscompleted");taskList.init();view=new View("viewSelector");view.init();view.setPublicMode(true);tasksView=new TasksView();tasksView.init();tasksView.addObject(listTabs);tasksView.addObject("detailstabs");tasksView.addObject("listtoolbox");tasksView.addObject("taskdetails");tasksView.addObject("listdetails");tasksView.addObject("tools");tasksView.addObject(taskList);view.addEntry(["Tasks"],tasksView,_T("INTERFACE_TOP_NAV_TASKS"));view.addEntry(["About",["/about/",true]],null,_T("HOMEPAGE_TOP_NAV_ABOUT"));view.addEntry(["Signup",["/signup/",false]],null,_T("HOMEPAGE_TOP_NAV_SIGNUP"));view.addEntry(["Login",["/login/",false]],null,_T("HOMEPAGE_TOP_NAV_LOGIN"));view.addEntry(["Help",["/help/",true]],null,_T("INTERFACE_TOP_NAV_HELP"));noteMgr=new NoteManager("notesbox","notes");noteMgr.init();taskTabs=new Tabs("tasktabs","grey");taskTabs.init();taskTabs.addEntry(_T("INTERFACE_TASKS_TASK_DETAILS_TASK_TAB"));taskTabs.addEntry(_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB"));tasksView.addState(_T("INTERFACE_TASKS_TASK_DETAILS_TASK_TAB"),[],[],taskTabs);tasksView.addState(_T("INTERFACE_TASKS_TASK_DETAILS_NOTES_TAB"),[],[],taskTabs);tasksView.addState(_T("INTERFACE_TASKS_LIST_DETAILS_LIST"),[],[],detailstab);control=new Control();control.init();infoBox=new Infobox("detailsstatuswrap","detailsstatustext");infoBox.init();infoBox.hide();helpBox=new Helpbox("onlinehelpwrap","onlinehelptext");helpBox.init();helpBox.hide();listTabs.setSortParameters(stateMgr.lists,["position","name.toLowerCase()"]);view.selectView("Tasks");taskTabs.selectDefault(true);detailstab.selectDefault(true);legend=new Legend("keywrap","keyclose");legend.init();if(getCookie("LEGEND_SHOW")===null){legend.show();}
var self=this;var reloadFunc=function(){self.reload();};tagMgr=new TagManager();searchMgr=new SearchManager("search_begin","search_cancel");searchMgr.init();stateMgr.setCurrentList(rtmRequestedList);stateMgr.setCurrentFilter("(listId:"+rtmRequestedList+")");stateMgr.setCurrentType(TasksView.LIST_TYPE_NORMAL);control.showTasksToolbox(TaskList.TASK_LIST_VIEW_INCOMPLETE);messageBus.subscribe(reloadFunc,"rtm.initFinished");messageBus.broadcast(this,"rtm.initFinished");window.onresize=view.adjustWidths;window.onresize();if(rtmRequestedTask!==null){var loadFinishedFunc=function(x,y){if(is(taskList.getViewList().map[rtmRequestedTask])){taskList.getViewList().selectOne(rtmRequestedTask,true);}};messageBus.subscribeOnce(loadFinishedFunc,taskList.getUniqueMessageBusName()+"loadFinished");}};RememberTheMilk.prototype.reload=function(){transMgr.request("rtm.public.preload",utility.encodeJavaScript({"user":rtmUsername,"list":rtmRequestedList}));};function rtmLoad(){if(arguments.callee.done){return;}
arguments.callee.done=true;if(rtm===null){rtm=new RememberTheMilk();rtm.init();}}
// Build 64 -- Generated Tue Apr 24 11:56:47 2007 UTC
