var nativeSplit=nativeSplit||String.prototype.split;String.prototype.split=function(I,D){if(!(I instanceof RegExp)){return nativeSplit.apply(this,arguments)}if(D===undefined||+D<0){D=false}else{D=Math.floor(+D);if(!D){return[]}}var C=(I.global?"g":"")+(I.ignoreCase?"i":"")+(I.multiline?"m":""),G=new RegExp("^"+I.source+"$",C),B=[],A=0,E=0,F;if(!I.global){I=new RegExp(I.source,"g"+C)}while((!D||E++<=D)&&(F=I.exec(this))){var H=!F[0].length;if(H&&I.lastIndex>F.index){I.lastIndex=F.index}if(I.lastIndex>A){if(F.length>1){F[0].replace(G,function(){for(var J=1;J<arguments.length-2;J++){if(arguments[J]===undefined){F[J]=undefined}}})}B=B.concat(this.slice(A,F.index),(F.index===this.length?[]:F.slice(1)));A=I.lastIndex}if(H){I.lastIndex++}}return(A===this.length)?(I.test("")?B:B.concat("")):(D?B:B.concat(this.slice(A)))};Element.addMethods({removeAllChildren:function(A){while(A.lastChild){A.removeChild(A.lastChild)}},update2:function(A,B){if(B.nodeType){A.removeAllChildren();A.appendChild(B)}else{A.innerHTML=B}},$$:function(A,B){var C=A.select("."+B);return C.length!=0?C[0]:null},$$$:function(A,C){var B=A.select(C);return B.length!=0?B[0]:null},getBounds:function(B){var C=B.cumulativeOffset();var A=B.getDimensions();return new Rectangle(C.left,C.top,A.width,A.height)}});Object.extend(Event,{wheel:function(A){var B=0;if(!A){A=window.event}if(A.wheelDelta){B=A.wheelDelta/120;if(window.opera){B=-B}}else{if(A.detail){B=-A.detail/3}}return Math.round(B)}});var g_today=getToday();function parseDateTime(A){var B=A.match("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})");return new Date(Date.UTC(B[1],parseInt(B[2],10)-1,B[3],B[4],B[5],B[6]))}function parseDate(A){var B=A.match("([0-9]{4})-([0-9]{2})-([0-9]{2})");return new Date(B[1],parseInt(B[2],10)-1,B[3])}function formatDate(A){return A.getFullYear()+"-"+show2(A.getMonth()+1)+"-"+show2(A.getDate())}function show2(A){return("0"+A).slice(-2)}function isSameDay(A,B){if(A==null||B==null){return false}else{return A.getDate()==B.getDate()&&A.getMonth()==B.getMonth()&&A.getFullYear()==B.getFullYear()}}function getTodayDate(){return g_today}function getToday(){var A=new Date();return new Date(A.getFullYear(),A.getMonth(),A.getDate())}function formatDueDate(B){var A=getTodayDate();var C=null;if(isSameDay(B,A)){C="today"}else{if(isSameDay(B,new Date(A.getTime()+24*60*60*1000))){C="tomorrow"}else{if(isSameDay(B,new Date(A.getTime()-24*60*60*1000))){C="yesterday"}}}if(C){return new Template(MESSAGES["due."+C]).evaluate({"day":formatDay(B.getDay())})}else{return formatMonthDateDay(B.getMonth(),B.getDate(),B.getDay())}}function getCookie(B){var C=document.cookie.split(";");for(var E=0;E<C.length;++E){var D=C[E];var A=D.indexOf("=");if(A!=-1){if(D.substring(0,A).strip()==B){return decodeURIComponent(D.substring(A+1).strip())}}}return null}function setCookie(D,E,A){var B=null;if(A){var C=new Date();C.setTime(C.getTime()+A*24*60*60*1000);B=C.toGMTString()}else{B="Tue, 1-Jan-2030 00:00:00 GMT"}document.cookie=D+"="+encodeURIComponent(E)+";expires="+B+";path=/"}function deleteCookie(A){document.cookie=A+"=;expires=Tue, 1-Jan-1990 00:00:00 GMT;path=/"}AjaxUtil=Class.create({initialize:function(){},get:function(D,C,B,A){this.request(D,"GET",C,B,A)},post:function(D,C,B,A){this.request(D,"POST",C,B,A)},request:function(D,E,C,B,A){this.requestParams(D,E,C?Form.serialize(C,true):{},B,A)},requestParams:function(C,E,D,B,A){if(!A){A=typeof error!="undefined"&&error?error:alert}new Ajax.Request(C,{"method":E,"parameters":D||{},"evalJSON":false,"onSuccess":function(F){if(F.getResponseHeader("Content-Type").match(/^application\/json/)){if(F.responseText.length!=0){try{var H=this.evalJSON(F.responseText);if(B){B(H)}}catch(G){A([G.toString()])}}}else{B(F.responseText)}}.bind(this),"onFailure":function(F){if(F.getResponseHeader("Content-Type").match(/^application\/json/)){A(this.evalJSON(F.responseText))}else{if(F.getResponseHeader("Content-Type").match(/^text\/plain/)){A([F.responseText])}else{A([F.status+" "+F.statusText])}}}.bind(this)})},evalJSON:function(A){if(Prototype.Browser.WebKit&&A.startsWith("/*-secure-")){return A.slice(11,-3).evalJSON(false)}else{return A.evalJSON()}}});var Point=Class.create({initialize:function(A,B){this.x=A;this.y=B},clone:function(){return new Point(this.x,this.y)}});var Line=Class.create({initialize:function(B,A){this.p1=B;this.p2=A}});function ccw(G,E,C){var F=E.x-G.x;var B=E.y-G.y;var D=C.x-G.x;var A=C.y-G.y;if(F*A>B*D){return 1}else{if(F*A<B*D){return -1}else{if(F*D<0||B*A<0){return -1}else{if(F*F+B*B<D*D+A*A){return 1}else{return 0}}}}}function intersect(B,A){return ccw(B.p1,B.p2,A.p1)*ccw(B.p1,B.p2,A.p2)<=0&&ccw(A.p1,A.p2,B.p1)*ccw(A.p1,A.p2,B.p2)<=0}function inside(G,E){var H=E.length;E[-1]=E[H-1];E[H]=E[0];var A=new Line(G.clone(),G.clone());A.p2.x=10000;var F=0;var B=-1;for(var D=0;D<H;++D){var C=new Line(E[D],E[D]);if(!intersect(C,A)){if(D==B+1){C.p2=E[B];if(intersect(C,A)){++F}}else{if(ccw(A.p1,A.p2,E[D])*ccw(A.p1,A.p2,E[B])<0){++F}}B=D}}return(F&1)!=0}var Size=Class.create({initialize:function(A,B){this.width=A;this.height=B}});var Rectangle=Class.create({initialize:function(B,C,A,D){this.left=B;this.top=C;this.width=A;this.height=D},equals:function(A){return this.left==A.left&&this.top==A.top&&this.width==A.width&&this.height==A.height},clone:function(){return new Rectangle(this.left,this.top,this.width,this.height)}});function showErrorDialog(A){alert(getErrorString(A))}function getErrorString(A){if(A==null||A.length==0){return MESSAGES["error.unspecified"]}else{return MESSAGES[A[0]]||A[0]}}function getWindowWidth(){return Prototype.Browser.IE?document.documentElement.clientWidth:window.innerWidth}function getWindowHeight(){return Prototype.Browser.IE?document.documentElement.clientHeight:window.innerHeight}function getScrollHeight(){return Prototype.Browser.WebKit?document.body.scrollHeight:document.documentElement.scrollHeight}function observeInitialization(A){Event.observe(document,"dom:loaded",A)}Prototype.Browser.IE6=navigator.userAgent.indexOf("MSIE 6.0")>-1;var IE6={addClassName:function(B,A,D,C){if(Prototype.Browser.IE6){B.addClassName(D);B.removeClassName(C)}else{B.addClassName(A)}},removeClassName:function(B,A,D,C){if(Prototype.Browser.IE6){B.addClassName(C);B.removeClassName(D)}else{B.removeClassName(A)}}};var Menu=Class.create();Object.extend(Menu.prototype,{initialize:function(A){this.elem=A},layout:function(){var B=this.elem.getDimensions();var A=this.elem.$$("menuBg");A.setStyle({"width":B.width+"px","height":B.height+"px"});A.$$("menuBgLeft").setStyle({"height":(B.height-9)+"px"});A.$$("menuBgCenter").setStyle({"width":(B.width-18)+"px","height":(B.height-9)+"px"});A.$$("menuBgRight").setStyle({"height":(B.height-9)+"px"});A.$$("menuBgBottom").setStyle({"width":(B.width-18)+"px"});if(Prototype.Browser.IE){this.elem.select(".menuSeparator").each(function(C){C.setStyle({"width":(B.width-14)+"px"})})}}});if(typeof IEPNGFIX=="undefined"){var IEPNGFIX={blank:"/image/iepngfix.gif",filter:"DXImageTransform.Microsoft.AlphaImageLoader",fixit:function(B,C,D){if(B.filters[this.filter]){var A=B.filters[this.filter];A.enabled=true;A.src=C;A.sizingMethod=D}else{B.style.filter="progid:"+this.filter+'(src="'+C+'",sizingMethod="'+D+'")'}},fixwidth:function(A){if(A.currentStyle.width=="auto"&&A.currentStyle.height=="auto"){A.style.width=A.offsetWidth+"px"}},fixchild:function(D,A){if(!/MSIE (5\.5|6\.)/.test(navigator.userAgent)){return }for(var C=0,E=D.childNodes.length;C<E;C++){var B=D.childNodes[C];if(B.style){if(B.style.position){B.style.position=B.style.position}else{B.style.position="relative"}}if(A&&B.hasChildNodes()){this.fixchild(B,A)}}},fix:function(C){if(!/MSIE (5\.5|6\.)/.test(navigator.userAgent)){return }var A=C.currentStyle.backgroundImage||C.style.backgroundImage;if(C.tagName=="IMG"){this.fixwidth(C);this.fixit(C,C.src,"scale");C.src=this.blank;C.runtimeStyle.behavior="none"}else{if(A&&A!="none"){if(A.match(/^url[("']+(.*\.png)[)"']+$/i)){var B=RegExp.$1;this.fixwidth(C);C.style.backgroundImage="none";this.fixit(C,B,"scale");if(C.tagName=="A"&&C.style){if(!C.style.cursor){C.style.cursor="pointer"}}this.fixchild(C);C.runtimeStyle.behavior="none"}}}},hover:function(C,B){var A=C.style.backgroundImage;if(!A&&C.currentStyle){A=C.currentStyle.backgroundImage}if(C.tagName=="IMG"&&B){var D=C.src;C.onmouseover=function(){C.src=B;IEPNGFIX.fix(C)};C.onmouseout=function(){C.src=D;IEPNGFIX.fix(C)}}else{if(A&&A!="none"&&B){C.onmouseover=function(){C.style.backgroundImage="url("+B+")";IEPNGFIX.fix(C)};C.onmouseout=function(){C.style.backgroundImage=A;IEPNGFIX.fix(C)}}}IEPNGFIX.fix(C)}}}var g_canvasPreferences=null;var g_globalPreferences=null;var g_savePreferenceTimer=null;function restoreLocalPreferences(){if(g_canvasPreferences){var J=g_canvasPreferences.find(function(L){return L.canvasId==g_canvasId});if(J){if(PrefUtil.valid(J.originX)&&PrefUtil.valid(J.originY)){setOrigin(J.originX,J.originY)}if(PrefUtil.valid(J.showPrivate)&&g_canvasTypeFlags&CanvasType.FLAG_PRIVATE){setShowPrivate(J.showPrivate)}}}var D=!g_inner;var K=!g_inner;var B=null;var I=!g_inner;var G=null;var H=null;var E=!g_inner;var C=!g_inner;var A=null;var F=!g_inner;if(g_globalPreferences){var J=g_globalPreferences;K=PrefUtil.maybe(J.palettePinned,true);D=K&&PrefUtil.maybe(J.paletteVisible,true);B=PrefUtil.maybe(J.paletteColors,null);E=PrefUtil.maybe(J.dockPinned,true);I=E&&PrefUtil.maybe(J.dockVisible,true);G=PrefUtil.maybe(J.dockWidth,null);H=PrefUtil.maybe(J.dockScrollPos,null);F=PrefUtil.maybe(J.panelPinned,true);C=F&&PrefUtil.maybe(J.panelVisible,true);A=PrefUtil.maybe(J.panelWidth,null);g_fontSize=PrefUtil.maybe(J.fontSize,100)}g_panel.restore(A,C,F);g_dock.restore(G,H,I,E);g_palette.restore(K,D,B)}function loadLocalPreferences(){var C=getCookie("cp");if(C){try{g_canvasPreferences=C.evalJSON()}catch(B){}}if(!g_inner){var A=getCookie("gp");if(A){try{g_globalPreferences=A.evalJSON()}catch(B){}}}}function saveLocalPreferences(){if(g_savePreferenceTimer){clearTimeout(g_savePreferenceTimer)}g_savePreferenceTimer=setTimeout(_saveLocalPreferences,500)}function _saveLocalPreferences(){var B=!g_canvasPreferences?new Array():g_canvasPreferences.select(function(C){return C.canvasId!=g_canvasId});B.push({"canvasId":g_canvasId,"originX":g_origin.x,"originY":g_origin.y,"zoom":g_zoom,"showPrivate":g_canvasTypeFlags&CanvasType.FLAG_PRIVATE?g_showPrivate:false});while(B.length>10){B.shift()}setCookie("cp",B.toJSON());if(!g_inner){var A={"paletteVisible":false,"palettePinned":g_palette.isPinned(),"paletteColors":g_palette.getColors(),"dockVisible":g_dock.isVisible(),"dockWidth":g_dock.getWidth(),"dockScrollPos":g_dock.getMyScrollPos(),"dockPinned":g_dock.isPinned(),"panelVisible":g_panel.isVisible(),"panelWidth":g_panel.getWidth(),"panelPinned":g_panel.isPinned(),"fontSize":g_fontSize};if(g_palette.isExpandable()){A.paletteVisible=g_palette.isExpanded()}else{if(g_globalPreferences){A.paletteVisible=g_globalPreferences.paletteExpanded||false}}setCookie("gp",Object.toJSON(A))}}var PrefUtil={valid:function(A){return !Object.isUndefined(A)},maybe:function(A,B){return PrefUtil.valid(A)?A:B}};var CANVAS_SIZE=new Size(2560,1920);var MIN_ENTRY_SIZE=new Size(150,60);var ENTRY_SIZE_MARGIN=new Size(20,35);var MAX_AUTO_ENTRY_SIZE=new Size(300,800);var DOCK_ENTRY_DRAG_OFFSET=new Point(5,5);var FIRST_LOAD_LIMIT=25;var LOAD_STEP=5;var MIN_RELOAD_DURATION=60*1000;var MAX_RELOAD_DURATION=3*60*1000;var DEFAULT_RELOAD_DURATION=60*1000;var INITIAL_RELOAD_DURATION=60*1000;var MIN_GROUP_RELOAD_DURATION=10*1000;var INITIAL_GROUP_RELOAD_DURATION=15*1000;var NEW_ENTRY_MODE_ZINDEX=10300;var ANYWHERE_ID="VwM4HWgw";var CanvasType={MY:0,REFERENCE:1,INBOX:2,GROUP:3,FLAG_NEW:1,FLAG_DUE:2,FLAG_TAG:4,FLAG_SEND:8,FLAG_PRIVATE:16,FLAG_DOCK:32,FLAG_CALENDAR:64,FLAG_ZINDEX:128};var g_userId=null;var g_canvasId=null;var g_canvasType=null;var g_canvasTypeFlags=false;var g_groupId=null;var g_groupName=null;var g_groupOwnerId=null;var g_groups=[];var g_hasFriends=false;var g_entries=new Array();var g_embedded=false;var g_inner=false;var g_origin=new Point(0,0);var g_zoom=1;var g_loadEntriesTimer=null;var g_hilightedTags=new Array();var g_reloadDuration=INITIAL_RELOAD_DURATION;var g_reloadDurationCount=3;var g_reloadTimer=null;var g_reloading=null;var g_showPrivate=false;var g_fontSize=100;var g_hideMovie=0;var g_movieEntry=null;var g_newEntryMode=false;var g_newEntryElems=[];var g_currentNewEntryElem=null;var g_currentNewEntryHilight=false;var g_init=false;var g_palette=null;var g_dock=null;var g_panel=null;var g_popup=null;var g_search=null;var g_notification=null;var g_movieNotification=null;var g_board=null;observeInitialization(function(){if(g_groupId){MIN_RELOAD_DURATION=MIN_GROUP_RELOAD_DURATION;INITIAL_RELOAD_DURATION=INITIAL_GROUP_RELOAD_DURATION}g_reloadDuration=INITIAL_RELOAD_DURATION;initBackground();loadLocalPreferences();g_palette=new Palette(newEntryStartDrag);g_dock=new Dock();g_panel=new Panel($("canvasView"),g_canvasTypeFlags&CanvasType.FLAG_CALENDAR);g_notification=new Notification($("notification"));g_movieNotification=new MovieNotification($("movieNotification"));g_board=new Board($("board"));if(g_embedded){initializeEntries()}else{loadEntries()}$("canvas").observe("mousedown",originStartDrag);function A(){return !g_dialogsStub.isDialogVisible()}if(g_canvasTypeFlags&CanvasType.FLAG_NEW){Event.observe(document,"keydown",function(F){if(49<=F.keyCode&&F.keyCode<49+g_palette.PALETTE_ENTRIES.length&&A()){var E=g_palette.PALETTE_ENTRIES[F.keyCode-49];var G=new NewEntry(E.color,E.type,E.width,E.height,E.index);g_dialogsStub.bind(function(H){switch(E.type){case NewEntry.TYPE_NORMAL:H.showNewEntryDialog(G);break;case NewEntry.TYPE_IMAGE:H.showImageEntryDialog(G);break;case NewEntry.TYPE_MOVIE:H.showMovieEntryDialog(G);break;case NewEntry.TYPE_ATTACHMENT:H.showAttachmentEntryDialog(G);break}});F.stop()}},true)}Event.observe(document,"keydown",function(E){if(E.keyCode==77&&A()){toggleNewEntryMode()}else{if(g_newEntryMode&&(E.keyCode==37||E.keyCode==80||E.keyCode==75)&&A()){previousNewEntry()}else{if(g_newEntryMode&&(E.keyCode==39||E.keyCode==78||E.keyCode==74)&&A()){nextNewEntry()}else{if(g_newEntryMode&&(E.keyCode==27)&&A()){leaveNewEntryMode()}else{if(E.keyCode==81&&A()){toggleShowPrivate()}}}}}},true);Event.observe(document,"keypress",function(E){if(E.charCode==60&&A()){g_dock.selector.previous()}else{if(E.charCode==62&&A()){g_dock.selector.next()}else{if(E.charCode==63&&A()){g_dock.selector.my()}}}},true);g_dock.load.bind(g_dock).defer();layoutCanvasView();$("main").setStyle({visibility:"visible"});restoreLocalPreferences();g_dock.adjustWidth();saveLocalPreferences();var B=$("ad");if(B){var D=$("getAdPositionForm");D.windowWidth.value=getWindowWidth();D.windowHeight.value=getWindowHeight();new AjaxUtil().get("/api/canvas/adPosition",D,function(E){B.setStyle({"left":E.left+"px","top":E.top+"px","display":"block"})},function(){})}var C=$("recommendation");if(Prototype.Browser.IE&&!$("trialBanner")&&!getCookie("ieRec")){C.show();C.remove.bind(C).delay(30);setCookie("ieRec","1",7)}else{C.remove()}g_init=true});Event.observe(window,"resize",function(){if(!g_init){return }layoutCanvasView();updateEntriesVisibility();g_dock.adjustWidth();setOrigin(g_origin.x,g_origin.y)});function initBackground(){if(window!=window.top&&window.name==ANYWHERE_ID){$(document.body).setStyle({"background":"transparent url(/image/anywherebg.png)"});$("canvas").setStyle({"background":"transparent none"})}}function showBackground(){if(window!=window.top&&window.id==ANYWHERE_ID){$(document.body).setStyle({"background":"transparent url(/image/anywherebg.png)"})}}function hideBackground(){if(window!=window.top&&window.id==ANYWHERE_ID){$(document.body).setStyle({"background":"transparent none"})}}function initializeEntries(){var A=!(g_canvasTypeFlags&CanvasType.FLAG_PRIVATE)||!g_showPrivate;g_entries.each(function(B){var C=getEntryElemFromId(B.id);B.maskStatus=0;Entry.bind(B,C);updateContentSize(C,C.getWidth(),C.getHeight());if(B.isFlag(Entry.FLAG_AUTOHIDE)){setupAutoHide(B,C)}g_panel.initializeEntry(B);if(A&&B.intimate){B.maskPrivate()}C.observe("mouseover",installHandlers)});updateEntriesVisibility();if(g_entries.length>=120){info("canvas.info.tooManyEntries")}}var MovingOrigin=Class.create({initialize:function(C,B,A,D){this.originX=C;this.originY=B;this.offsetX=A;this.offsetY=D}});var movingOrigin=null;function originStartDrag(C){if(!C.isLeftClick()){return }if(movingOrigin!=null){originEndDrag(C)}var B=C.pointerX();var E=C.pointerY();var A=$("canvas").select(".entry");for(var D=0;D<A.length;++D){if(Position.within(A[D],B,E)){return }}movingOrigin=new MovingOrigin(g_origin.x,g_origin.y,B,E);Event.observe(document,"mousemove",originDrag);Event.observe(document,"mouseup",originEndDrag);C.stop()}function originEndDrag(A){originDrag(A);Event.stopObserving(document,"mousemove",originDrag);Event.stopObserving(document,"mouseup",originEndDrag);movingOrigin=null}function originDrag(A){setOrigin(movingOrigin.originX+(movingOrigin.offsetX-A.pointerX()),movingOrigin.originY+(movingOrigin.offsetY-A.pointerY()));A.stop()}function setOrigin(A,C){var B=$("canvasView").getDimensions();g_origin.x=Math.max(0,Math.min(A,CANVAS_SIZE.width-Math.floor(B.width/g_zoom)));g_origin.y=Math.max(0,Math.min(C,CANVAS_SIZE.height-Math.floor(B.height/g_zoom)));$("canvas").setStyle({"left":-Math.floor(g_origin.x*g_zoom)+"px","top":-Math.floor(g_origin.y*g_zoom)+"px"});updateEntriesVisibility();g_panel.layout();saveLocalPreferences()}function ensureEntryElemVisible(D){var B=D.visible();if(!B){D.show()}var G=D.positionedOffset();var C=D.getDimensions();if(!B){D.hide()}var F=$("canvasView").getDimensions();var A=G.left-Math.floor((F.width-C.width)/2);var E=G.top-Math.floor((F.height-C.height)/3);if(A!=g_origin.x||E!=g_origin.y){setOrigin(A,E)}flushEntryElem(D)}function flushEntryElem(C){var B=C.getBounds();var A=new Rectangle(B.left-200,B.top-200,B.width+400,B.height+400);showEffect(A,B,Entry.getSolidColor(C.entry.color))}function showEffect(A,E,B,D){var C=new Element("div");document.body.appendChild(C);C.setStyle({"position":"absolute","left":A.left+"px","top":A.top+"px","width":A.width+"px","height":A.height+"px","zIndex":20000,"backgroundColor":B,"opacity":0.5});var G=0;var F=function(){if(G<10){C.setStyle({"left":Math.floor((A.left*(10-G)+E.left*G)/10)+"px","top":Math.floor((A.top*(10-G)+E.top*G)/10)+"px","width":Math.floor((A.width*(10-G)+E.width*G)/10)+"px","height":Math.floor((A.height*(10-G)+E.height*G)/10)+"px"});++G;F.delay(0.03)}else{C.remove();if(D){D()}}};F.defer()}function updateCanvasDragPosition(){var A=$("canvas").cumulativeOffset();["canvasDrag","canvasCopy"].each(function(B){$(B).setStyle({"left":A.left+"px","top":A.top+"px"})})}var NewEntry=Class.create({initialize:function(B,E,D,A,C){this.color=B;this.type=E;this.fontSize=100;this.left=0;this.top=0;this.width=D||280;this.height=A||200;this.index=Object.isUndefined(C)?null:C}});NewEntry.TYPE_NORMAL=0;NewEntry.TYPE_IMAGE=1;NewEntry.TYPE_MOVIE=2;NewEntry.TYPE_ATTACHMENT=3;var newEntry=null;function newEntryStartDrag(D,A){if(newEntry!=null){newEntryEndDrag(D)}newEntry=new NewEntry(A.color,A.type,A.width,A.height,A.index);updateCanvasDragPosition();var B=$("canvas").cumulativeOffset();var E=new Point(D.pointerX()-B.left-20,D.pointerY()-B.top-20);var C=$("newEntryDrag");C.setStyle({"left":E.x+"px","top":E.y+"px","width":ls2ps(A.width)+"px","height":ls2ps(A.height)+"px"});C.show();updateEntryBackgroundColor(C,TYPE_NORMAL,newEntry.color);updateEntryBackgroundSize(C,null);Event.observe(document,"mousemove",newEntryDrag);Event.observe(document,"mouseup",newEntryEndDrag)}function newEntryEndDrag(A){var C=$("newEntryDrag");var H=A.pointerX();var F=A.pointerY();if(Position.within($("canvasView"),H,F)&&Position.within($("canvas"),H,F)){if(newEntry.type==NewEntry.TYPE_ATTACHMENT&&g_userId==0){if(confirm(MESSAGES["confirm.uploadAttachment"])){openAtTop("/session/top?redirect="+encodeURIComponent(document.URL))}C.hide()}else{var E=$("canvas").cumulativeOffset();var G=new Point(H-E.left-20,F-E.top-20);var I=C.getDimensions();var B=Position.within(g_palette.element(),H,F);newEntry.left=B?0:px2lx(G.x);newEntry.top=B?0:py2ly(G.y);newEntry.width=ps2ls(I.width);newEntry.height=ps2ls(I.height);var D=newEntry;g_dialogsStub.bind(function(J){switch(D.type){case NewEntry.TYPE_NORMAL:J.showNewEntryDialog(D,C);break;case NewEntry.TYPE_IMAGE:J.showImageEntryDialog(D,C);break;case NewEntry.TYPE_MOVIE:J.showMovieEntryDialog(D,C);break;case NewEntry.TYPE_ATTACHMENT:J.showAttachmentEntryDialog(D,C);break}if(B){C.hide()}})}}else{C.hide()}if(!g_palette.isPinned()){g_palette.collapse()}newEntry=null;Event.stopObserving(document,"mousemove",newEntryDrag);Event.stopObserving(document,"mouseup",newEntryEndDrag);A.stop()}function newEntryDrag(C){var B=$("canvas").cumulativeOffset();var A=C.pointerX()-B.left-20;var D=C.pointerY()-B.top-20;$("newEntryDrag").setStyle({"left":A+"px","top":D+"px"});C.stop()}function loadEntries(){cancelReloading();var A=$("getEntriesForm");new AjaxUtil().get("/api/entry/gets",A,updateEntries,error)}function updateEntries(C){var H=parseDate(C.today);var F=H.getTime()!=g_today.getTime();g_today=H;var D=C.entries;if(g_loadEntriesTimer){clearTimeout(g_loadEntriesTimer);g_loadEntriesTimer=null}clearEntries();if(D.length>=120){info("canvas.info.tooManyEntries")}D.each(function(K){Entry.prebind(K);g_entries.push(K)});var J=FIRST_LOAD_LIMIT;if(D.length>FIRST_LOAD_LIMIT){var B=new Array();var G=new Array();var I=$("canvasView").getDimensions();D.each(function(K){(isEntryInCanvasView(I,K)?B:G).push(K)});B.sort(function(L,K){return K.getUpdated().getTime()-L.getUpdated().getTime()});J=Math.min(J,B.length);D=B.concat(G)}for(var A=0;A<Math.min(J,D.length);++A){insertEntryElem(D[A],false,false)}if(A<D.length){var E=function(){if(A<D.length){var K=Math.min(A+LOAD_STEP,D.length);for(;A<K;++A){insertEntryElem(D[A],false,false)}g_loadEntriesTimer=setTimeout(E,0)}else{handleFragment();g_loadEntriesTimer=null;scheduleReloading()}};g_loadEntriesTimer=setTimeout(E,0)}else{handleFragment();scheduleReloading()}if(F){g_panel.getCalendar().rebuild()}}function handleFragment(){if(document.URL.match(/#e([0-9]+)$/)){var A=getEntryElemFromId(RegExp.$1);if(A){ensureEntryElemVisible(A);flushEntryElem(A)}}}function clearEntries(){$("canvas").select(".entry").each(Element.remove);g_entries.clear()}var Reloading=Class.create({initialize:function(){this.canceled=false},cancel:function(){this.canceled=true},process:function(A){g_reloading=null;if(!this.canceled){reupdateEntries(A)}}});function scheduleReloading(){if(g_reloadTimer){clearTimeout(g_reloadTimer)}g_reloadTimer=setTimeout(reloadEntries,g_reloadDuration)}function cancelReloading(){if(g_reloading){g_reloading.cancel();g_reloading=null}if(g_reloadTimer){clearTimeout(g_reloadTimer);g_reloadTimer=null}}function reloadEntries(){g_reloadTimer=null;if(g_newEntryMode){scheduleReloading()}else{g_reloading=new Reloading();var A=$("getEntriesForm");new AjaxUtil().get("/api/entry/gets",A,g_reloading.process.bind(g_reloading),function(){g_reloading=null;g_reloadDuration=Math.min(MAX_RELOAD_DURATION,Math.max(g_reloadDuration*2,DEFAULT_RELOAD_DURATION));g_reloadDurationCount=0;scheduleReloading()})}}function reupdateEntries(D){if(g_newEntryMode){scheduleReloading();return }if(shouldPostpondReupdate()){return postpondReupdate(0)}if(parseDate(D.today).getTime()!=g_today.getTime()){updateEntries(D);return }var F=D.entries;var K=false;var H=false;var E=false;var G=g_entries.clone();for(var B=0;B<F.length;++B){var M=F[B];var N=getEntryElemFromId(M.id);if(N){var A=N.entry;var C=G.indexOf(A);G[C]=null;if(!A.equals(M)){var J=N.getBounds();var L=replaceEntryElem(M,true);var I=L.getBounds();if(!J.equals(I)){showEffect(J,I,Entry.getSolidColor(M.color))}E=true}}else{insertEntryElem(M,true,true);K=true}}G.each(function(O){if(O){var Q=getEntryElemFromId(O.id);var P=function(){removeEntryElem(O.id)};dimEntryElemFunc(Q,P)();H=true}});if(H||E){ensureAllEntriesNotHidden()}if(K||H||E){g_dock.loadEntries(g_canvasId);g_panel.getCalendar().refresh()}if(K){info("canvas.info.added")}else{if(E){info("canvas.info.updated")}}if(K||H||E){g_reloadDuration=Math.max(MIN_RELOAD_DURATION,Math.min(Math.floor(g_reloadDuration/2),INITIAL_RELOAD_DURATION));g_reloadDurationCount=0}else{++g_reloadDurationCount;if(g_reloadDurationCount>5){g_reloadDuration=Math.min(g_reloadDuration*2,MAX_RELOAD_DURATION);g_reloadDurationCount=0}}scheduleReloading()}function shouldPostpondReupdate(){return Request.requestOngoing()||isMoving()||isResizing()||g_dialogsStub.isDialogVisible()}function postpondReupdate(A){if(shouldPostpondReupdate()){if(A>3){scheduleReloading()}else{postpondReupdate.curry(A+1).delay(1)}}else{reloadEntries()}}function layoutCanvasView(){var A=$("canvasView");A.setStyle({"height":calcCanvasViewHeight()+"px"});g_panel.layout()}function calcCanvasViewHeight(){return getWindowHeight()-g_board.getHeight()}function installZIndexHandler(C){var B=getHandleFromDraggable(C);var A=B||(Prototype.Browser.IE?C.$$("bg"):C);A.observe("mousedown",zIndexHandler);if(Prototype.Browser.IE){C.$$("base").observe("mousedown",zIndexHandler)}}function uninstallZIndexHandler(C){var B=getHandleFromDraggable(C);var A=B||(Prototype.Browser.IE?C.$$("bg"):C);A.stopObserving("mousedown",zIndexHandler);if(Prototype.Browser.IE){C.$$("base").stopObserving("mousedown",zIndexHandler)}}function zIndexHandler(A){if(!A.isLeftClick()||A.shiftKey){return }if(A.altKey){bringEntryToBottom(getEntryElemFromChild(A.element()).entry)}else{bringEntryToTop(getEntryElemFromChild(A.element()).entry)}}function bringEntryToTop(B){stopHilightCurrentNewEntryElem();var A=g_entries.clone();A.sort(Entry.compareZIndex);if(A.last()==B){return }var C=100;A.each(function(D){if(D!=B){D.setZIndex(C);++C}});B.setZIndex(C);if(g_canvasTypeFlags&CanvasType.FLAG_ZINDEX){updateEntryZIndices(A)}}function bringEntriesToTop(A){var C=g_entries.clone();C.sort(Entry.compareZIndex);var D=100;C.each(function(E){if(A.indexOf(E)==-1){E.setZIndex(D);++D}});var B=A.clone();B.sort(Entry.compareZIndex);B.each(function(E){E.setZIndex(D);++D});if(g_canvasTypeFlags&CanvasType.FLAG_ZINDEX){updateEntryZIndices(C)}}function bringEntryToBottom(B){stopHilightCurrentNewEntryElem();var A=g_entries.clone();A.sort(Entry.compareZIndex);if(A.first()==B){return }B.setZIndex(100);var C=101;A.each(function(D){if(D!=B){D.setZIndex(C);++C}});if(g_canvasTypeFlags&CanvasType.FLAG_ZINDEX){updateEntryZIndices(A)}}function getTopZIndex(){var A=100;g_entries.each(function(B){A=Math.max(A,B.zIndex)});return A}var Dragging=Class.create({initialize:function(B,A,D,C){this.draggable=B;this.offsetX=A;this.offsetY=D;this.others=C},elems:function(){var A=this.others?this.others.clone():[];A.sort(function(B,C){return B.entry.zIndex-C.entry.zIndex});A.push(this.draggable);return A}});var dragging=null;function installDragHandler(A){var B=getHandleFromDraggable(A);B.observe("mousedown",moveStartDrag)}function uninstallDragHandler(A){var B=getHandleFromDraggable(A);B.stopObserving("mousedown",moveStartDrag)}function moveStartDrag(C){if(!C.isLeftClick()){return }if(dragging!=null){moveEndDrag(C)}if(C.altKey){return }var G=C.element();if(G.hasClassName("nodrag")||G.up(".nodrag")){return }var K=getDraggableFromHandle(G);var I=K.hasClassName("entry");var J=null;if(I&&C.shiftKey){var D=getMovableIntersectedEntries(K);if(D.length!=0){D.each(Element.show);var F=D.map(function(L){return L.entry});F.push(K.entry);bringEntriesToTop(F);J=D}}var H=K.cumulativeOffset();dragging=new Dragging(K,C.pointerX()-H.left,C.pointerY()-H.top,J);Event.observe(document,"mousemove",moveDrag);Event.observe(document,"mouseup",moveEndDrag);Event.observe(document,"keydown",moveKeyChange);Event.observe(document,"keyup",moveKeyChange);if(I){updateCanvasDragPosition();var E=$("canvasDrag");var B=$("canvasCopy");var A=dragging.elems();A.each(function(M){E.appendChild(M);var L=M.cloneNode(true);L.removeAttribute("id");B.appendChild(L)});if(C.ctrlKey||C.metaKey){B.show()}}C.stop()}function moveEndDrag(Q){moveDrag(Q);var J=Q.pointerX();var I=Q.pointerY();var P=Q.ctrlKey||Q.metaKey;var D=dragging.draggable;var E=D.hasClassName("entry");var T=J-DOCK_ENTRY_DRAG_OFFSET.x;var R=I-DOCK_ENTRY_DRAG_OFFSET.y;var K=g_dock.getDockItemFromPosition(T,R);var A=g_panel.isInside(T,R);Event.stopObserving(document,"mousemove",moveDrag);Event.stopObserving(document,"mouseup",moveEndDrag);Event.stopObserving(document,"keydown",moveKeyChange);Event.stopObserving(document,"keyup",moveKeyChange);if(E){var F=D;var U=dragging.elems();function N(Z,a,Y){if(Z!=g_canvasId&&Y){var X=U.find(function(b){return b.entry.intimate});var V=P?"confirm.copyPrivateEntry":"confirm.transferPrivateEntry";if(X&&!confirm(MESSAGES[V])){U.each(function(b){b.entry.updatePosition();b.show()});return }}if(dragging.others){if(P||Z!=g_canvasId){var W=U.map(function(b){if(P){b.entry.updatePosition();b.show()}return new Point(a.x-F.entry.left+b.entry.left,a.y-F.entry.top+b.entry.top)});if(P){copyEntries(U,Z,W)}else{transferEntries(U,Z,W)}}else{U.each(function(b){b.setStyle({"left":lx2px(a.x-F.entry.left+b.entry.left)+"px","top":ly2py(a.y-F.entry.top+b.entry.top)+"px"});b.show()});moveEntries(U)}}else{if(P){F.show();F.entry.updatePosition();copyEntry(F.entry,Z,a)}else{if(Z!=g_canvasId){transferEntry(F,Z,a)}else{F.setStyle({"left":lx2px(a.x)+"px","top":ly2py(a.y)+"px"});moveEntry(F,a)}}}}var C=$("canvas");U.each(function(V){C.appendChild(V)});if(K!=null){var B=F.entry;F.setStyle({"left":lx2px(B.left)+"px","top":ly2py(B.top)+"px"});var L=K.hasClassName("dockMyItem");if(L||K.hasClassName("dockWritableItem")){var S=g_dock.getCanvasIdFromDockItem(K);var G=g_dock.mapScreenDockPosToCanvasPos(K,T,R);N(S,G,!L)}$("dockEntryDrag").hide()}else{if(A){N(g_canvasId,g_panel.mapScreenPanelPosToCanvasPos(T,R),false);$("dockEntryDrag").hide()}else{if(dragging.others){if(P){var H=U.map(function(V){var W=V.positionedOffset();V.entry.updatePosition();return new Point(W.left,W.top)});copyEntries(U,g_canvasId,H)}else{moveEntries(U)}}else{if(P){var M=F.positionedOffset();F.entry.updatePosition();copyEntry(F.entry,g_canvasId,new Point(px2lx(M.left),py2ly(M.top)))}else{moveEntry(F)}}}}}var O=$("canvasCopy");O.removeAllChildren();O.hide();dragging=null}function moveDrag(Q){var J=Q.pointerX();var I=Q.pointerY();var G=dragging.draggable;var H=G.hasClassName("entry");var T=J-DOCK_ENTRY_DRAG_OFFSET.x;var R=I-DOCK_ENTRY_DRAG_OFFSET.y;var K=g_dock.getDockItemFromPosition(T,R);var A=g_panel.isInside(T,R);var E=$("canvas");var M=E.cumulativeOffset();if(H&&(A||(K&&(K.hasClassName("dockMyItem")||K.hasClassName("dockWritableItem"))))){var S=$("dockEntryDrag");var L=$("dockEntryDragMain");S.setStyle({"left":(T-M.left)+"px","top":(R-M.top)+"px"});if(G.visible()){G.hide();if(dragging.others){dragging.others.each(Element.hide)}var B=G.entry;var O=A?g_panel:g_dock;var D=A?g_panel.mapCanvasToPanelX:g_dock.mapCanvasToDockX;var C=A?g_panel.mapCanvasToPanelY:g_dock.mapCanvasToDockY;L.setStyle({"width":D.call(O,B.width)+"px","height":C.call(O,B.height)+"px","backgroundColor":Entry.getSolidColor(B.color)});S.select(".dockEntryDragOther").each(Element.remove);if(dragging.others){dragging.others.each(function(U){var V=U.entry;var W=new Element("div");W.addClassName("dockEntryDrag");W.addClassName("dockEntryDragOther");W.setStyle({"left":D.call(O,V.left-B.left)+"px","top":D.call(O,V.top-B.top)+"px","width":D.call(O,V.width)+"px","height":C.call(O,V.height)+"px","backgroundColor":Entry.getSolidColor(V.color)});S.appendChild(W)})}S.show()}}else{var F=0;var N=0;if(H){F=J-M.left-dragging.offsetX;N=I-M.top-dragging.offsetY}else{F=J-dragging.offsetX;N=I-dragging.offsetY}G.setStyle({"left":F+"px","top":N+"px"});if(H&&dragging.others){dragging.others.each(function(U){U.setStyle({"left":(F-G.entry.left+U.entry.left)+"px","top":(N-G.entry.top+U.entry.top)+"px"})})}if(!G.visible()){G.show();if(dragging.others){dragging.others.each(Element.show)}$("dockEntryDrag").hide()}}function P(W){if(!W.isPinned()){var V=W.isVisible();var U=W.within(J,I);if(!V&&U){W.showAuto(Q)}else{if(V&&!U){W.hideAuto(Q)}}}}P(g_dock);P(g_panel);Q.stop()}function moveKeyChange(A){var B=$("canvasCopy");if(A.ctrlKey||A.metaKey){B.show()}else{B.hide()}}function getHandleFromDraggable(A){return A.$$("handle")}function getDraggableFromHandle(A){return A.up(".draggable")}function isMoving(){return dragging!=null}var Resizing=Class.create({initialize:function(B,A,C){this.resizable=B;this.offsetX=A;this.offsetY=C}});var resizing=null;function installResizeHandler(B){var A=getGripFromResizable(B);A.observe("mousedown",resizeStartDrag)}function uninstallResizeHandler(B){var A=getGripFromResizable(B);A.stopObserving("mousedown",resizeStartDrag)}function resizeStartDrag(D){if(!D.isLeftClick()){return }if(resizing!=null){resizeEndDrag(D)}var A=D.element();var C=getResizableFromGrip(A);var E=C.cumulativeOffset();var B=C.getDimensions();resizing=new Resizing(C,D.pointerX()-(E.left+B.width),D.pointerY()-(E.top+B.height));Event.observe(document,"mousemove",resizeDrag);Event.observe(document,"mouseup",resizeEndDrag);if(C.hasClassName("entry")&&C.entry.isFlag(Entry.FLAG_AUTOHIDE)){C.entry.resizing=true;C.$$("action").hide()}D.stop()}function resizeEndDrag(B){var A=resizing.resizable;var D=A.hasClassName("entry");var C=Prototype.Browser.IE&&D&&A.entry.intimate&&!g_showPrivate;if(C){A.entry.unmaskPrivate()}resizeDrag(B);if(C){A.entry.maskPrivate()}Event.stopObserving(document,"mousemove",resizeDrag);Event.stopObserving(document,"mouseup",resizeEndDrag);resizing=null;if(D){A.entry.resizing=false;moveEntry(A)}}function resizeDrag(D){var B=resizing.resizable;var G=B.cumulativeOffset();var E=B.minSize||MIN_ENTRY_SIZE;var A=Math.max(E.width,D.pointerX()-G.left-resizing.offsetX);var C=Math.max(E.height,D.pointerY()-G.top-resizing.offsetY);var F=B.maxSize;if(F){A=Math.min(F.width||A,A);C=Math.min(F.height||C,C)}B.setStyle({"width":A+"px","height":C+"px"});if(B.hasClassName("entryBg")){updateEntryBackgroundSize(B,null)}if(B.resizeHandler){B.resizeHandler()}D.stop()}function getGripFromResizable(A){return A.$$("grip")}function getResizableFromGrip(A){return A.up(".resizable")}function isResizing(){return resizing!=null}function installTagHandler(A){A.select(".tag .tagItem").each(function(B){B.observe("click",function(C){toggleHilightedTag(B["tag"])})})}function uninstallTagHandler(A){A.select(".tag .tagItem").each(function(B){B.stopObserving("click")})}function toggleHilightedTag(A){var B=A.stringValue();if(g_hilightedTags.indexOf(B)!=-1){g_hilightedTags=g_hilightedTags.without(B)}else{g_hilightedTags.push(B)}updateEntriesForHilightedTags()}function clearHilightedTags(){g_hilightedTags=new Array();updateEntriesForHilightedTags()}function isTagsHilighted(){return g_hilightedTags.length!=0}function updateEntriesForHilightedTags(){$("canvas").select(".entry").each(function(A){A.entry.updateForTag(g_hilightedTags)})}function ensureAllEntriesNotHidden(){if(!isTagsHilighted()){return }var A=$("canvas").select(".entry");for(var C=0;C<A.length;++C){var B=A[C].entry;if(!(B.maskStatus&Entry.TAG_MASKED)){return }}clearHilightedTags()}function getMovableIntersectedEntries(A){return getIntersectedEntries(A,function(B){return B.entry.isFlag(Entry.FLAG_MOVE)})}function getIntersectedEntries(G,D){var B=$("canvas").select(".entry");var C=[G];for(var A=0;A<C.length;++A){var F=C[A];for(var H=0;H<B.length;++H){var E=B[H];if((!D||D(E))&&C.indexOf(E)==-1&&intersectEntry(E.entry,F.entry)){C.push(E)}}}C.shift();return C}function calcEntrySize(E,G,J,I,C,F){var A=$("bodySize");var D=C!=0?C-ENTRY_SIZE_MARGIN.width:0;A.setStyle({"width":D!=0?D+"px":"auto","fontSize":I+"%","padding":F?"0px 15px":"0px"});A.update2(formatBody(E.gsub(/\r/,""),G));var H=0;if(D==0){D=Math.max(A.getWidth(),MIN_ENTRY_SIZE.width-ENTRY_SIZE_MARGIN.width);if(D>MAX_AUTO_ENTRY_SIZE.width){D=MAX_AUTO_ENTRY_SIZE.width;A.setStyle({"width":D+"px"})}H=Math.max(A.getHeight(),MIN_ENTRY_SIZE.height-ENTRY_SIZE_MARGIN.height);if(D>H*1.5){D=Math.max(Math.floor(D/1.5),MIN_ENTRY_SIZE.width-ENTRY_SIZE_MARGIN.width)}A.setStyle({"width":D+"px"})}H=A.getHeight();if(J.length!=0){var B=$("tagSize");B.update2(formatTags(J,true));B.setStyle({"width":D+"px"});H+=B.getHeight()}H=Math.min(MAX_AUTO_ENTRY_SIZE.height,H);if(F){H+=F+Entry.IMAGE_FRAME_MARGIN.height-ENTRY_SIZE_MARGIN.height}else{H=Math.max(H,MIN_ENTRY_SIZE.height-ENTRY_SIZE_MARGIN.height)}return new Size(D+ENTRY_SIZE_MARGIN.width,H+ENTRY_SIZE_MARGIN.height)}function getImageHeightToCalcSize(A){if(A.image){if(A.isParam(Entry.PARAM_IMAGE_FRAME)){return A.image.height}}else{if(A.attachment){return Entry.ATTACHMENT_IMAGE_HEIGHT}}return null}function getPopup(){if(!g_popup){g_popup=new Popup($("canvasView"))}return g_popup}function addNormalEntry(D,E){var B=D.entryDate.value.length!=0?parseDate(D.entryDate.value):null;var A=Tag.getTags(D.entryTags?Tag.split(D.entryTags.value):[],B);var C=calcEntrySize(D.entryContent.value,D.entryIcon.value,A,D.entryFontSize.value,0,null);D.entryWidth.value=C.width;D.entryHeight.value=C.height;D.entryZIndex.value=getTopZIndex()+1;fillEntryPosition(D,E);Request.request("/api/entry/new",D,entryAdded,function(F){showErrorDialog(F);g_dialogsStub.getDialogs().enableNewEntryDialog()});if(E.index!=null){g_palette.setColor(E.index,D.entryColor.value)}}function entryAdded(A){var B=null;if(A){B=insertEntryElem(A,true,true,function(){info("canvas.info.entryAdded")});g_dock.loadEntries(g_canvasId);if(A.date){g_panel.getCalendar().refresh()}}else{info("canvas.info.entrySent")}g_dialogsStub.getDialogs().hideNewEntryDialog(B)}function addImageEntry(E,F){if(E.imageType[2].checked){var A=parseInt(E.entryWidth.value,10)+Entry.IMAGE_FRAME_MARGIN.width;var C=E.entryDate.value.length!=0?parseDate(E.entryDate.value):null;var B=Tag.getTags(E.entryTags?Tag.split(E.entryTags.value):[],C);var D=calcEntrySize(E.entryContent.value,0,B,E.entryFontSize.value,A,parseInt(E.entryHeight.value,10));E.entryWidth.value=A;E.entryHeight.value=D.height}E.entryZIndex.value=getTopZIndex()+1;fillEntryPosition(E,F);Request.request("/api/entry/new",E,imageEntryAdded,function(G){showErrorDialog(G);g_dialogsStub.getDialogs().enableImageEntryDialog()})}function imageEntryAdded(A){var B=insertEntryElem(A,true,true,function(){info("canvas.info.entryAdded")});g_dialogsStub.getDialogs().hideImageEntryDialog(B);g_dock.loadEntries(g_canvasId)}function imageUploaded(A,B){g_dialogsStub.getDialogs().updateImageEntryDialog(B)}function imageUploadFailed(A,B){showErrorDialog(B);g_dialogsStub.getDialogs().updateImageEntryDialog(null)}function addMovieEntry(A,B){A.entryZIndex.value=getTopZIndex()+1;fillEntryPosition(A,B);Request.request("/api/entry/new",A,movieEntryAdded,function(C){showErrorDialog(C);g_dialogsStub.getDialogs().enableMovieEntryDialog()})}function fillEntryPosition(A,B){if(B.left==0&&B.top==0){B.left=Math.floor((getWindowWidth()-A.entryWidth.value)/2+g_origin.x);B.top=Math.floor((getWindowHeight()-A.entryHeight.value)/3+g_origin.y)}A.entryLeft.value=B.left;A.entryTop.value=B.top}function movieEntryAdded(A){var B=insertEntryElem(A,true,true,function(){info("canvas.info.entryAdded")});g_dialogsStub.getDialogs().hideMovieEntryDialog(B);g_dock.loadEntries(g_canvasId)}function addAttachmentEntry(D,E){var B=D.entryDate.value.length!=0?parseDate(D.entryDate.value):null;var A=Tag.getTags(D.entryTags?Tag.split(D.entryTags.value):[],B);var C=calcEntrySize(D.entryContent.value,0,A,D.entryFontSize.value,parseInt(D.entryWidth.value,10),Entry.ATTACHMENT_IMAGE_HEIGHT);D.entryHeight.value=C.height;D.entryZIndex.value=getTopZIndex()+1;fillEntryPosition(D,E);Request.request("/api/entry/new",D,attachmentEntryAdded,function(F){showErrorDialog(F);g_dialogsStub.getDialogs().enableAttachmentEntryDialog()})}function attachmentEntryAdded(A){var B=insertEntryElem(A,true,true,function(){info("canvas.info.entryAdded")});g_dialogsStub.getDialogs().hideAttachmentEntryDialog(B);g_dock.loadEntries(g_canvasId)}function attachmentUploaded(A,B){g_dialogsStub.getDialogs().updateAttachmentEntryDialog(B)}function attachmentUploadFailed(A,B){showErrorDialog(B);g_dialogsStub.getDialogs().updateAttachmentEntryDialog(null)}function editEntry(G,F){var D=G.entryDate.value.length!=0?parseDate(G.entryDate.value):null;var C=Tag.getTags(G.entryTags?Tag.split(G.entryTags.value):[],D);var B=F.width;if(F.image&&G.imageType[2].checked){B=F.image.width+Entry.IMAGE_FRAME_MARGIN.width}var A=null;if(F.image){if(G.imageType[2].checked){A=F.image.height}}else{if(F.attachment){A=Entry.ATTACHMENT_IMAGE_HEIGHT}}var E=calcEntrySize(G.entryContent.value,G.entryIcon?G.entryIcon.value:0,C,G.entryFontSize.value,B,A);G.entryLeft.value=F.left;G.entryTop.value=F.top;G.entryWidth.value=B;G.entryHeight.value=Math.max(F.height,E.height);Request.request("/api/entry/edit",G,entryEdited,function(H){showErrorDialog(H);if(F.image){g_dialogsStub.getDialogs().enableEditImageEntryDialog()}else{g_dialogsStub.getDialogs().enableEditEntryDialog()}})}function entryEdited(A){var B=replaceEntryElem(A,true,function(){info("canvas.info.entryEdited")});ensureAllEntriesNotHidden();if(A.image){g_dialogsStub.getDialogs().hideEditImageEntryDialog(B)}else{if(A.attachment){g_dialogsStub.getDialogs().hideEditAttachmentEntryDialog(B)}else{g_dialogsStub.getDialogs().hideEditEntryDialog(B)}}g_dock.loadEntries(g_canvasId);g_panel.getCalendar().refresh()}function moveEntry(F,G){if(!G){var E=F.positionedOffset();G=new Point(px2lx(E.left),py2ly(E.top))}var B=ps2ls(F.getWidth());var A=ps2ls(F.getHeight());var D=F.entry;if(G.x==D.left&&G.y==D.top&&B==D.width&&A==D.height){return }D.left=G.x;D.top=G.y;D.width=B;D.height=A;var C=$("moveEntryForm");C.entryId.value=F.entry.id;C.entryLeft.value=G.x;C.entryTop.value=G.y;C.entryWidth.value=B;C.entryHeight.value=A;Request.request("/api/entry/move",C,entryMoved,error)}function entryMoved(A){var B=getEntryElemFromId(A.id);var C=g_entries.indexOf(B.entry);g_entries[C]=A;Entry.rebind(A,B);A.updatePosition();B.show();A.updateBackgroundSize();A.adjustFont();g_panel.updateEntryElem(A);g_dock.loadEntries(g_canvasId)}function moveEntries(A){var B=A.map(function(D){var F=D.entry;var E=D.positionedOffset();F.left=px2lx(E.left);F.top=py2ly(E.top);F.width=ps2ls(D.getWidth());F.height=ps2ls(D.getHeight());return F.id+"="+[F.left,F.top,F.width,F.height].join(" ")}).join(",");var C=$("moveEntriesForm");C.positions.value=B;Request.request("/api/entry/moves",C,entriesMoved,error)}function entriesMoved(A){A.each(function(B){var C=getEntryElemFromId(B.id);var D=g_entries.indexOf(C.entry);g_entries[D]=B;Entry.rebind(B,C);B.updatePosition();C.show();B.updateBackgroundSize();g_panel.updateEntryElem(B)});updateEntriesVisibility();g_dock.loadEntries(g_canvasId)}function setEntryDueDate(F,D,G,A){var B=new Date(D,G,A);if(F.date!=null&&isSameDay(B,parseDate(F.date))){return }var C=calcEntrySize(F.subject+"\n"+F.body,F.icon,Tag.getTags(F.tags,B),F.fontSize,F.width,getImageHeightToCalcSize(F));var E=$("setEntryDueDateForm");E.entryId.value=F.id;E.year.value=D;E.month.value=G+1;E.day.value=A;E.entryWidth.value=F.width;E.entryHeight.value=Math.max(F.height,C.height);Request.request("/api/entry/setDueDate",E,entryDueDateSet,error)}function clearEntryDueDate(C){var A=calcEntrySize(C.subject+"\n"+C.body,C.icon,Tag.getTags(C.tags,null),C.fontSize,C.width,getImageHeightToCalcSize(C));var B=$("setEntryDueDateForm");B.entryId.value=C.id;B.year.value=0;B.month.value=0;B.day.value=0;B.entryWidth.value=C.width;B.entryHeight.value=Math.max(C.height,A.height);Request.request("/api/entry/setDueDate",B,entryDueDateSet,error)}function entryDueDateSet(A){var B=A.entry;replaceEntryElem(B,false);ensureAllEntriesNotHidden();info("canvas.info.entryDueDateSet",A.undoId);g_dock.loadEntries(g_canvasId);g_panel.getCalendar().refresh()}function sendEntry(B,A){var C=$("sendEntryForm");C.entryId.value=B;C.friendId.value=A;Request.request("/api/entry/send",C,entrySent,error)}function sendEntryEx(B,D,A){var C=$("sendEntryExForm");C.entryId.value=B;Request.request("/api/entry/sendEx",C,function(E){D();entrySent(E)},A)}function entrySent(A){if(A.copy){info("canvas.info.entrySent")}else{var B=function(){removeEntryElem(A.entryId);ensureAllEntriesNotHidden();info("canvas.info.entrySent")};var C=getEntryElemFromId(A.entryId);if(C.entry.isFlag(Entry.FLAG_EFFECT)){hideEntryElemWithEffect(C,flickAction,B)}else{dimEntryElemFunc(C,B).delay(0.1)}g_dock.loadEntries(g_canvasId);g_panel.getCalendar().refresh()}}function copyEntry(B,C,D){var A=$("copyEntryForm");A.entryId.value=B.id;A.canvasId.value=C;if(D){A.entryLeft.value=D.x;A.entryTop.value=D.y}Request.request("/api/entry/copy",A,entryCopied,error)}function entryCopied(A){if(A.canvasId==g_canvasId){insertEntryElem(A,true,true,function(){info("canvas.info.entryCopied")})}else{info("canvas.info.entryCopied")}g_dock.loadEntries(A.canvasId)}function copyEntries(B,E,A){var C=B.map(function(F,H){var G=A[H];return F.entry.id+"="+[G.x,G.y].join(" ")}).join(",");var D=$("copyEntriesForm");D.canvasId.value=E;D.positions.value=C;Request.request("/api/entry/copys",D,entriesCopied,error)}function entriesCopied(A){if(A.length==0){return }var B=A[0];if(B.canvasId==g_canvasId){for(var C=0;C<A.length;++C){var B=A[C];insertEntryElem(B,true,true,C!=A.length-1?null:function(){info("canvas.info.entryCopied")})}}else{info("canvas.info.entryCopied")}g_dock.loadEntries(B.canvasId)}function doneEntry(B){var A=$("doneEntryForm");A.entryId.value=B.id;Request.request("/api/entry/done",A,entryDone,error)}function entryDone(A){var B=function(){removeEntryElem(A.entryId);ensureAllEntriesNotHidden();info("canvas.info.entryDone",A.undoId)};var C=getEntryElemFromId(A.entryId);if(C.entry.isFlag(Entry.FLAG_EFFECT)){hideEntryElemWithEffect(C,screwUpAction,B)}else{dimEntryElemFunc(C,B).delay(0.1)}g_dock.loadEntries(g_canvasId);g_panel.getCalendar().refresh()}function lightEntryElem(C,A){if(Prototype.Browser.IE&&C.entry.isFlag(Entry.FLAG_SHADOW)){C.select(".bg *").each(function(D){if(!D.hasClassName("bgCenter")){D.hide()}})}C.setStyle({"opacity":0});var B=function(){var D=Math.floor(C.getStyle("opacity")*10);if(D<10){C.setStyle({"opacity":(D+1)/10});B.delay(0.1)}else{if(Prototype.Browser.IE&&C.entry.isFlag(Entry.FLAG_SHADOW)){C.select(".bg *").each(function(E){if(!E.hasClassName("bgCenter")){E.show()}})}if(A){A()}}};B()}function dimEntryElemFunc(C,A){uninstallHandlers(C);if(Prototype.Browser.IE){C.select(".bg *").each(function(D){if(!D.hasClassName("bgCenter")){D.hide()}})}var B=function(){var D=Math.floor(C.getStyle("opacity")*10);if(D>0){C.setStyle({"opacity":(D-1)/10});B.delay(0.1)}else{if(A){A()}}};return B}function hideEntryElemWithEffect(C,B,A){uninstallHandlers(C);effect(C,B,A)}function updateEntryPin(B,A){var C=$("pinEntryForm");C.entryId.value=B;C.entryPin.value=A?"1":"0";Request.request("/api/entry/pin",C,entryPinUpdated,error)}function entryPinUpdated(A){var B=replaceEntryElem(A,false);info(A.pin?"canvas.info.entryPinned":"canvas.info.entryUnpinned")}function updateEntryZIndices(A){var B=A.map(function(D,E){return D.id+"="+D.zIndex}).join(",");var C=$("updateEntryZIndicesForm");C.zIndices.value=B;Request.request("/api/entry/updateZIndices",C,zIndicesUpdated,error)}function zIndicesUpdated(){g_dock.loadEntries(g_canvasId)}function transferEntry(C,B,D){var A=$("transferEntryForm");A.canvasId.value=B;A.entryId.value=C.entry.id;A.entryLeft.value=D.x;A.entryTop.value=D.y;Request.request("/api/entry/transfer",A,entryTransferred,error)}function entryTransferred(A){removeEntryElem(A.entryId);info("canvas.info.entryTransferred",A.undoId);ensureAllEntriesNotHidden();g_dock.loadEntries(A.canvasId);g_dock.loadEntries(g_canvasId)}function transferEntries(A,E,B){var C=A.map(function(F,H){var G=B[H];return F.entry.id+"="+[G.x,G.y].join(" ")}).join(",");var D=$("transferEntriesForm");D.canvasId.value=E;D.positions.value=C;Request.request("/api/entry/transfers",D,entriesTransferred,error)}function entriesTransferred(A){A.entryIds.each(removeEntryElem);info("canvas.info.entryTransferred");ensureAllEntriesNotHidden();g_dock.loadEntries(A.canvasId);g_dock.loadEntries(g_canvasId)}function undo(A){var B=$("undoForm");B.undoId.value=A;Request.request("/api/entry/undo",B,undone,error)}function undone(A){loadEntries();g_dock.loadAllEntries();g_panel.getCalendar().refresh();info(A?"canvas.info.undoSucceeded":"canvas.info.undoFailed")}function updateSubscription(){var A=$("isSubscribedForm");new AjaxUtil().get("/api/canvas/subscribed",A,function(B){g_palette.setSubscribed(B)},function(B){g_palette.setSubscribed(false);error(B)});g_dock.load();g_panel.getCalendar().refresh()}function insertEntryElem(F,G,C,E){var H=insertNormalEntryElem(F);g_panel.insertEntryElem(F);var B=H.$$("pin");if(B&&F.pin){B.addClassName("pushed")}if(!F.isFlag(Entry.FLAG_SHADOW)){var D=["bgLeftTop","bgLeft","bgLeftBottom","bgRightTop","bgRight","bgRightBottom","bgBottom"];D.each(function(I){H.$$(I).remove()})}if(!F.isFlag(Entry.FLAG_LOGO)){H.select(".logo, .logoIE").each(Element.remove)}else{if(F.color=="white"){H.$$("logo").addClassName("logoWhite");H.$$("logoIE").addClassName("logoWhiteIE")}}if(!F.isFlag(Entry.FLAG_GRIP)){var A=H.$$("grip");if(A){A.setStyle({"backgroundImage":"url(/image/nogrip.png)"})}}if(F.isFlag(Entry.FLAG_AUTOHIDE)){setupAutoHide(F,H)}if(G){g_entries.push(F)}if(isTagsHilighted()){F.updateForTag(g_hilightedTags)}F.updateVisibility($("canvasView").getDimensions());if(C&&H.visible()){lightEntryElem(H,E)}return H}function insertNormalEntryElem(G){var B=G.image!=null;var C=G.movie!=null;var E=!B&&G.attachment!=null;G.maskStatus=0;var H=null;if(B){H=$("imageEntryTemplate").cloneNode(true)}else{if(C){H=$("movieEntryTemplate").cloneNode(true)}else{if(E){H=$("attachmentEntryTemplate").cloneNode(true)}else{H=$("entryTemplate").cloneNode(true)}}}Entry.bind(G,H);if(B&&!G.isParam(Entry.PARAM_IMAGE_FRAME)){H.select(".image, .body, .tag").each(Element.remove)}var A=G.intimate&&(!(g_canvasTypeFlags&CanvasType.FLAG_PRIVATE)||!g_showPrivate);G.fill(A);if(G.intimate){H.addClassName("privateEntry")}if(!G.isFlag(Entry.FLAG_MOVE)){H.removeClassName("draggable");H.$$("handle").removeClassName("handle")}if(!C){if(!G.isFlag(Entry.FLAG_RESIZE)){H.removeClassName("resizable");H.$$("grip").remove()}if(!G.isFlag(Entry.FLAG_EDIT)){H.$$("editEntry").remove()}if(!G.isFlag(Entry.FLAG_DUE)){H.$$("dueEntry").remove()}if(!G.isFlag(Entry.FLAG_DOWNLOAD)){H.$$("downloadEntry").remove()}}if(!G.isFlag(Entry.FLAG_SEND)){H.$$("sendEntry").remove()}if(!G.isFlag(Entry.FLAG_DONE)){H.$$("doneEntry").remove()}if(!G.isFlag(Entry.FLAG_COPY)){H.$$("copyEntry").remove()}if(!G.isFlag(Entry.FLAG_PIN)){H.$$("pin").remove()}if(Prototype.Browser.IE){var J=H.$$("tag");if(J){J.setStyle({"fontFamily":'"MS PGothic",Verdana,Arial,Helvetica,sans-serif'})}}$("canvas").appendChild(H);G.updatePosition();if(G.getTags(true).length==0){var J=H.$$("tag");if(J){J.remove()}}H.show();if(Prototype.Browser.IE){var D=H.$$("action");if(D){var F=D.positionedOffset();var I=D.getOffsetParent().getDimensions();D.setStyle({"marginBottom":(F.top+16-I.height)+"px"})}}G.updateBackgroundSize();G.adjustFont();if(A){G.maskPrivate()}H.observe("mouseover",installHandlers);return H}function setupAutoHide(B,C){var A=["action","creatorIcon"].map(function(D){return C.$$(D)}).select(function(D){return D!=null});if(A.length!=0){A.each(Element.hide);C.observe("mouseover",function(){if(!C.entry.resizing){A.each(Element.show)}});C.observe("mouseout",function(){A.each(Element.hide)});B.updateBackgroundSize()}}function installHandlers(D){var M=getEntryElemFromChild(D.element());M.stopObserving("mouseover",installHandlers);var K=M.entry;K.setupHandle();if(K.isFlag(Entry.FLAG_MOVE)){installDragHandler(M)}if(K.isFlag(Entry.FLAG_RESIZE)){installResizeHandler(M)}var L=M.$$("editEntry");if(L){L.observe("click",ActionHandlers.edit)}var J=M.$$("dueEntry");if(J){J.observe("click",ActionHandlers.due)}var G=M.$$("sendEntry");if(G){G.observe("click",ActionHandlers.send)}var C=M.$$("copyEntry");if(C){C.observe("click",ActionHandlers.copy)}var B=M.$$("downloadEntry");if(B){B.observe("click",ActionHandlers.open)}var H=M.$$("doneEntry");if(H){H.observe("click",ActionHandlers.done)}var F=M.$$("creatorIcon");if(F){if(K.creatorId!=0&&K.ownerId==g_userId){F.observe("click",ActionHandlers.reply)}}var A=M.$$("pin");if(A){A.observe("click",ActionHandlers.togglePin)}var E=M.$$$(".play span");if(E){E.observe("click",ActionHandlers.play)}var I=M.$$("attachment");if(I){I.select("img, .download span").each(function(N){N.observe("click",ActionHandlers.download)})}if(K.isFlag(Entry.FLAG_ZINDEX)){installZIndexHandler(M)}installTagHandler(M);if(Prototype.Browser.IE6){if(L){L.observe("mouseover",ActionHandlers.hoverEntryButton);L.observe("mouseout",ActionHandlers.unhoverEntryButton)}if(J){J.observe("mouseover",ActionHandlers.hoverEntryButton);J.observe("mouseout",ActionHandlers.unhoverEntryButton)}if(G){G.observe("mouseover",ActionHandlers.hoverEntryButton);G.observe("mouseout",ActionHandlers.unhoverEntryButton)}if(C){C.observe("mouseover",ActionHandlers.hoverEntryButton);C.observe("mouseout",ActionHandlers.unhoverEntryButton)}if(H){H.observe("mouseover",ActionHandlers.hoverEntryButton);H.observe("mouseout",ActionHandlers.unhoverEntryButton)}if(A){A.observe("mouseover",ActionHandlers.hoverPin);A.observe("mouseout",ActionHandlers.unhoverPin)}}if(Prototype.Browser.Opera){if(L){L.observe("mousedown",Event.stop)}if(J){J.observe("mousedown",Event.stop)}if(G){G.observe("mousedown",Event.stop)}if(C){C.observe("mousedown",Event.stop)}if(H){H.observe("mousedown",Event.stop)}if(F){F.observe("mousedown",Event.stop)}}}function uninstallHandlers(L){var J=L.entry;if(J.isFlag(Entry.FLAG_MOVE)){uninstallDragHandler(L)}if(J.isFlag(Entry.FLAG_RESIZE)){uninstallResizeHandler(L)}var K=L.$$("editEntry");if(K){K.stopObserving("click",ActionHandlers.edit)}var I=L.$$("dueEntry");if(I){I.stopObserving("click",ActionHandlers.due)}var F=L.$$("sendEntry");if(F){F.stopObserving("click",ActionHandlers.send)}var C=L.$$("copyEntry");if(C){C.stopObserving("click",ActionHandlers.copy)}var B=L.$$("downloadEntry");if(B){B.stopObserving("click",ActionHandlers.open)}var G=L.$$("doneEntry");if(G){G.stopObserving("click",ActionHandlers.done)}var E=L.$$("creatorIcon");if(E){if(J.creatorId!=0&&J.ownerId==g_userId){E.stopObserving("click",ActionHandlers.reply)}}var A=L.$$("pin");if(A){A.stopObserving("click",ActionHandlers.togglePin)}var D=L.$$$(".play span");if(D){D.stopObserving("click",ActionHandlers.play)}var H=L.$$("attachment");if(H){H.select("img, .download").each(function(M){M.stopObserving("click",ActionHandlers.download)})}if(J.isFlag(Entry.FLAG_ZINDEX)){uninstallZIndexHandler(L)}uninstallTagHandler(L)}var ActionHandlers={edit:function(B){var C=getEntryElemFromChild(B.element());var A=C.entry;g_dialogsStub.bind(function(D){if(A.image){D.showEditImageEntryDialog(A,C)}else{if(A.attachment){D.showEditAttachmentEntryDialog(A,C)}else{D.showEditEntryDialog(A,C)}}})},due:function(C){var B=getEntryElemFromChild(C.element()).entry;var A=B.date?parseDate(B.date):null;getPopup().showDueCalendar(A,C.pointerX(),C.pointerY(),function(F,D,E){if(!Object.isUndefined(F)&&!Object.isUndefined(D)&&!Object.isUndefined(E)){setEntryDueDate(B,F,D,E)}else{clearEntryDueDate(B)}})},send:function(B){var A=getEntryElemFromChild(B.element()).entry;if(g_hasFriends){getPopup().showFriendList(A,B.pointerX(),B.pointerY())}else{g_dialogsStub.bind(function(C){C.showSendEntryDialog(A)})}},copy:function(B){var A=getEntryElemFromChild(B.element()).entry;getPopup().showCanvasList(A,B.pointerX(),B.pointerY())},download:function(B){if(g_userId==0){if(confirm(MESSAGES["confirm.downloadAttachment"])){openAtTop("/session/top?redirect="+encodeURIComponent(document.URL))}}else{var A=getEntryElemFromChild(B.element()).entry;document.location.href="/entry/attachment/"+A.attachment.id+"/"+encodeURIComponent(A.attachment.name)}},open:function(B){if(g_userId==0){if(confirm(MESSAGES["confirm.openImage"])){openAtTop("/session/top?redirect="+encodeURIComponent(document.URL))}}else{var A=getEntryElemFromChild(B.element()).entry;window.open("/entry/attachment/"+A.attachment.id+"/"+encodeURIComponent(A.attachment.name)+"?inline=1")}},done:function(A){doneEntry(getEntryElemFromChild(A.element()).entry)},reply:function(C){var B=getEntryElemFromChild(C.element()).entry;if(C.shiftKey){var A=B.canReplyInSameColor()?B.color:"blue";var D=new NewEntry(A,false);D.sendTo=B.creator;g_dialogsStub.bind(function(E){E.showNewEntryDialog(D)});C.stop()}},hoverEntryButton:function(B){var A=B.element();var C=A.classNames().grep(/.+Entry/)[0];A.addClassName(C+"Hover")},unhoverEntryButton:function(B){var A=B.element();var C=A.classNames().grep(/.+EntryHover/)[0];A.removeClassName(C)},togglePin:function(B){var A=getEntryElemFromChild(B.element()).entry;updateEntryPin(A.id,!A.pin)},hoverPin:function(A){var B=getEntryElemFromChild(A.element());B.$$("pin").addClassName(B.entry.pin?"pinPushedHover":"pinHover")},unhoverPin:function(A){var B=getEntryElemFromChild(A.element());B.$$("pin").removeClassName(B.entry.pin?"pinPushedHover":"pinHover")},play:function(A){startMovie(getEntryElemFromChild(A.element()).entry)}};function getEntryElemFromChild(A){return A.hasClassName("entry")?A:A.up(".entry")}function removeEntryElem(B,A){var C=getEntryElemFromId(B);uninstallHandlers(C);C.remove();g_panel.removeEntryElem(B);g_entries.splice(g_entries.indexOf(C.entry),1);if(g_newEntryMode&&!A){var D=g_newEntryElems.indexOf(C);if(D!=-1){if(g_currentNewEntryElem==C){nextNewEntry()}g_newEntryElems.splice(D,1)}}}function replaceEntryElem(E,B,D){var A=0;var H=-1;var F=false;if(g_newEntryMode){var C=getEntryElemFromId(E.id);A=C.entry.newIndex;H=g_newEntryElems.indexOf(C);F=C==g_currentNewEntryElem}removeEntryElem(E.id,true);var G=insertEntryElem(E,true,B,D);if(A){E.markNew(A);g_newEntryElems[H]=G;if(F){g_currentNewEntryElem=G}}return G}function stopEventHandler(A){A.stopPropagation()}function startMovie(A){leaveNewEntryMode();var B=$("movie");if(!B){B=new Element("iframe",{"id":"movie","frameBorder":"0"});$("movieContainer").appendChild(B)}B.src="/entry/movie/"+A.movie.id;layoutMovie(A);B.show();g_movieNotification.showInformation();g_movieEntry=A}function stopMovie(){if(!g_movieEntry){return }var A=$("movie");A.hide();A.src="/resource/empty.html";g_movieNotification.hide();g_movieEntry=null}function showMovie(){--g_hideMovie;if(g_hideMovie==0){if(g_movieEntry){layoutMovie(g_movieEntry)}$("movieContainer").setStyle({"visibility":"visible"})}}function hideMovie(){if(g_hideMovie==0){$("movieContainer").setStyle({"visibility":"hidden"})}++g_hideMovie}function layoutMovie(A){var B=$("movie");B.setStyle({"left":(A.left+6)+"px","top":A.top+"px","width":(A.width-14)+"px","height":(A.height-8)+"px"})}function toggleShowPrivate(){setShowPrivate(!g_showPrivate)}function setShowPrivate(A){g_showPrivate=A;$("canvas").select(".privateEntry").each(function(B){if(g_showPrivate){B.entry.unmaskPrivate()}else{B.entry.maskPrivate()}});saveLocalPreferences();g_palette.updateShowPrivate()}function toggleNewEntryMode(){if(g_newEntryMode){leaveNewEntryMode()}else{enterNewEntryMode()}}function enterNewEntryMode(){if(g_newEntryMode){return }g_newEntryMode=true;stopMovie();var A=g_entries.clone();A.sort(function(H,G){var F=H.getUpdated().getTime();var E=G.getUpdated().getTime();return F<E?1:F>E?-1:G.id-H.id});var B=[];for(var D=0;D<Math.min(10,A.length);++D){var C=A[D];B.push(C.elem);C.markNew(D+1)}for(;D<A.length;++D){A[D].markNew()}g_newEntryElems=B;$("newEntryShadow").show();if(B.length!=0){setCurrentNewEntryElem(B[0])}g_palette.updateNewEntryMode()}function leaveNewEntryMode(){if(!g_newEntryMode){return }g_newEntryMode=false;g_newEntryElems=[];setCurrentNewEntryElem(null);g_entries.each(function(A){A.unmarkNew()});$("newEntryShadow").hide();g_palette.updateNewEntryMode()}function nextNewEntry(){var A=g_newEntryElems.indexOf(g_currentNewEntryElem);if(A!=-1&&A+1<g_newEntryElems.length){setCurrentNewEntryElem(g_newEntryElems[A+1])}else{leaveNewEntryMode()}}function previousNewEntry(){var A=g_newEntryElems.indexOf(g_currentNewEntryElem);if(A!=-1&&A!=0){setCurrentNewEntryElem(g_newEntryElems[A-1])}else{leaveNewEntryMode()}}function setCurrentNewEntryElem(B){var A=g_currentNewEntryHilight?g_currentNewEntryElem.entry:null;g_currentNewEntryElem=B;g_currentNewEntryHilight=B!=null;if(A){A.updateZIndex()}if(B){ensureEntryElemVisible(B);B.entry.updateZIndex()}}function stopHilightCurrentNewEntryElem(){if(g_newEntryMode&&g_currentNewEntryHilight){g_currentNewEntryHilight=false;g_currentNewEntryElem.entry.updateZIndex()}}function getSearch(){if(!g_search){g_search=new Search($("canvasView"))}return g_search}function getEntryElemFromId(A){return $("entry"+A)}function isEntryInCanvasView(F,C){var E=lx2px(C.left)-g_origin.x;var D=ly2py(C.top)-g_origin.y;var B=E+ls2ps(C.width);var A=D+ls2ps(C.height);return !(D>F.height||A<0||E>F.width||B<0)}function updateEntriesVisibility(){var A=$("canvasView").getDimensions();$("canvas").select(".entry").each(function(B){B.entry.updateVisibility(A)})}function lx2px(A){return Math.floor(A*g_zoom)}function ly2py(A){return Math.floor(A*g_zoom)}function px2lx(A){return Math.floor(A/g_zoom)}function py2ly(A){return Math.floor(A/g_zoom)}function ls2ps(A){return g_zoom<1?Math.floor(A*g_zoom):A}function ps2ls(A){return g_zoom<1?Math.floor(A/g_zoom):A}function formatUpdated(A){return formatYearMonthDate(A.getFullYear(),A.getMonth(),A.getDate())+" "+format2(A.getHours())+":"+format2(A.getMinutes())}function format2(B){var A=B.toString();if(A.length==1){A="0"+A}return A}function formatTags(A,B){if(B){var C=document.createDocumentFragment();A.each(function(D){var F=new Element("span");var H="tagItem";var E=D.flag;if(E&TF_TODAY){H+=" tagItemToday"}else{if(E&TF_TOMORROW){H+=" tagItemTomorrow"}else{if(E&TF_OVERDUE){H+=" tagItemOverDue"}else{if(E&TF_DUE){H+=" tagItemDue"}}}}F.addClassName(H);F.appendChild(document.createTextNode("["));if(E&TF_DUE){var G=new Element("img",{"src":"/image/duetag.png"});G.addClassName("dueTag");F.appendChild(G)}F.appendChild(document.createTextNode(D.tag+"]"));F["tag"]=D;C.appendChild(F);C.appendChild(document.createTextNode(" "))});return C}else{return A.map(function(D){return D.tag}).join(" ")}}function formatBody(A,E){var D="";if(E!=0){D+='<div class="icon" style="background-position:-'+Entry.getIconIndex(E)*32+'px 0px;"></div>'}var C=A.split("\n");var B=C.length;for(;B>0;--B){if(C[B-1].length!=0){break}}for(var F=0;F<B;++F){D+=formatLine(C[F])}return D}function formatLine(A){if(A.match(/^\s*$/)){return'<p><span class="nodrag">&nbsp;</span></p>'}else{var B='<p><span class="nodrag">';var D=0;while(D<A.length&&A.charAt(D)==" "){B+="&nbsp;";++D}if(D!=0){A=A.substring(D)}var C=A.split(/((?:https?:\/\/(?:.+\.)?linoit.com\/(?:canvas|group)\/[^\/]+\/?[^ <>\",;]*)|(?:https?:\/\/(?:.+\.)?linoit.com\/(?:users|groups)\/[^\/]+\/canvases\/[^ ?#<>\",;]+(?:[?#][^ <>\",;]*)?)|(?:https?:\/\/(?:.+\.)?linoit.com\/(?:canvas|group)\/[^ \/]+\/?)|(?:https?:\/\/(?:.+\.)?linoit.com\/(?:users|groups)\/[^ \/]+\/?)|(?:https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:@&=+$,%#]+[A-Za-z0-9_\/]))/);for(var D=0;D<C.length;D+=2){B+=C[D].escapeHTML();if(D+1<C.length){B+=formatLink(C[D+1])}}B+="</span></p>";return B}}function formatLink(B){var I=B.escapeHTML();var F=B.match(/^https?:\/\/(?:.+\.)?linoit.com\//);var J=I;var E=false;if(B.match(/^https?:\/\/(?:.+\.)?linoit.com\//)){if(B.match(/^(https?:\/\/(?:.+\.)?linoit.com\/)(canvas|group)\/([^\/]+)\/([^ ?#<>\",;]+)([?#][^ <>\",;]*)?$/)||B.match(/^(https?:\/\/(?:.+\.)?linoit.com\/)(users|groups)\/([^\/]+)\/canvases\/([^ ?#<>\",;]+)([?#][^ <>\",;]*)?$/)){var C=RegExp.$1;var H=RegExp.$2=="canvas"||RegExp.$2=="users"?"users":"groups";var G=RegExp.$3;var A=RegExp.$4;var D=RegExp.$5;if(A=="inbox"){J=MESSAGES["canvas.inbox"]}else{J=decodeURIComponent(A).escapeHTML()}I=(C+H+"/"+escapeName(G)+"/canvases/"+escapeName(A)+D).escapeHTML();E=true}else{if(B.match(/^(https?:\/\/(?:.+\.)?linoit.com\/)(canvas|group)\/([^ \/]+)\/?$/)||B.match(/^(https?:\/\/(?:.+\.)?linoit.com\/)(users|groups)\/([^ \/]+)\/?$/)){var C=RegExp.$1;var H=RegExp.$2=="canvas"||RegExp.$2=="users"?"users":"groups";var A=RegExp.$3;J=decodeURIComponent(A).escapeHTML();I=(C+H+"/"+escapeName(A)).escapeHTML();E=true}}}var K='<a href="'+I+'"'+(F?"":' target="_blank"')+">"+J+"</a>";if(E){K+='<a href="'+I+'"'+(F?"":' target="_blank"')+' class="canvasLink"><img src="/image/link.png" /></a>'}return K}function escapeName(A){return A.split("%").map(encodeURIComponent).join("%")}function canvasPath(A){if(A.group){return"/group/"+encodeURIComponent(A.group)+"/"+encodeURIComponent(A.name)}else{return"/canvas/"+A.owner+"/"+encodeURIComponent(A.name)}}var Request={ongoingRequest:0,request:function(D,C,B,A){++this.ongoingRequest;new AjaxUtil().post(D,C,function(E){B(E);--this.ongoingRequest}.bind(this),function(E){A(E);--this.ongoingRequest}.bind(this))},requestOngoing:function(){return this.ongoingRequest!=0}};function openAtTop(A){if(g_inner){window.open(A)}else{document.location.href=A}}function info(B,A){g_notification.showInformation(MESSAGES[B],A)}function error(A){g_notification.showError(getErrorString(A))}var Entry={PRIVATE_MASKED:1,TAG_MASKED:2,PARAM_IMAGE_NOSHADOW:1,PARAM_IMAGE_FRAME:2,FLAG_DUE:1,FLAG_TAG:2,FLAG_SEND:4,FLAG_MOVE:8,FLAG_RESIZE:16,FLAG_ZINDEX:32,FLAG_EDIT:64,FLAG_EDITMOBILE:128,FLAG_DONE:256,FLAG_COPY:512,FLAG_DOWNLOAD:1024,FLAG_FONT:2048,FLAG_ICON:4096,FLAG_PRIVATE:8192,FLAG_DOCK:16384,FLAG_PANEL:32768,FLAG_AUTOHIDE:65536,FLAG_GRIP:131072,FLAG_LOGO:262144,FLAG_SHADOW:524288,FLAG_CREATOR:1048576,FLAG_EFFECT:2097152,FLAG_PIN:4194304,FLAG_ADJUSTFONT:8388608,IMAGE_FRAME_MARGIN:new Size(52,60),IMAGE_FRAME_PADDING:15,ATTACHMENT_IMAGE_HEIGHT:48-10,prebind:function(A){Object.extend(A,Entry.Methods)},bind:function(B,C){Object.extend(B,Entry.Methods);B.elem=C;C.entry=B;B.setId();if(B.image){if(B.isParam(Entry.PARAM_IMAGE_FRAME)){var A=B.image.width+Entry.IMAGE_FRAME_MARGIN.width;C.minSize=new Size(A,B.image.height+Entry.IMAGE_FRAME_MARGIN.height);C.maxSize=new Size(A,null)}}else{if(B.attachment){C.minSize=new Size(MIN_ENTRY_SIZE.width,MIN_ENTRY_SIZE.height+Entry.ATTACHMENT_IMAGE_HEIGHT)}}},rebind:function(B,C){var A=C.entry;B.maskStatus=A.maskStatus;B.newIndex=A.newIndex;Entry.bind(B,C)},compareZIndex:function(A,B){return A.zIndex-B.zIndex},getSolidColor:function(A){switch(A){case"blue":return"#a6dbff";case"yellow":return"#fff293";case"green":return"#c4ffd8";case"purple":return"#d3cdfc";case"red":return"#ffa09b";case"grass":return"#eafc86";case"gray":return"#e4e4e4";case"orange":return"#ffdb9b";case"peach":return"#ffc7c4";case"pink":return"#edbbff";case"white":return"#ffffff";case"black":return"#111111";default:return"white"}},getIconIndex:function(A){if(A==1){return 0}else{if(100<=A&&A<110){return A-99}else{if(201<=A){return A-190}}}}};Entry.Methods={getContent:function(){return this.body.length!=0?this.subject+"\n"+this.body:this.subject},fill:function(D,C){C=C||this.elem;if(this.image&&this.isParam(Entry.PARAM_IMAGE_FRAME)){C.$$("image").setStyle({"width":this.image.width+"px","height":this.image.height+"px","backgroundImage":"url(/entry/image/"+this.image.id+")"})}var G=C.$$("body");if(G){G.setStyle({"fontSize":this.fontSize+"%","color":this.fontColor});G.update2(formatBody(this.subject+"\n"+this.body,this.icon))}var H=C.$$("tag");if(H){H.$$("value").update2(formatTags(this.getTags(true),true))}if(this.movie){var E=C.$$$(".thumbnail img");E.src="/entry/movieThumbnail?movieId="+this.movie.id;E.setStyle({"width":this.movie.thumbnailWidth+"px","height":this.movie.thumbnailHeight+"px"});E.up().setStyle({"height":this.movie.thumbnailHeight+"px"});C.$$("information").innerHTML="<div>"+(this.movie.title?this.movie.title.escapeHTML():"")+"</div><div>"+(this.movie.duration?"("+Math.floor(this.movie.duration/60)+":"+show2(this.movie.duration%60)+")":"")+"</div>"}if(!this.image&&this.attachment){var F=C.$$$(".attachment .attachmentIcon");F.src="/entry/attachmentIcon/"+encodeURIComponent(this.attachment.contentType);var A=C.$$$(".attachment .name span");A.innerHTML=this.attachment.name.escapeHTML();var I=C.$$$(".attachment .size");I.innerHTML=this.attachment.size>=1024*1024?Math.ceil(this.attachment.size/1024/1024*10)/10+"MB":Math.ceil(this.attachment.size/1024)+"KB"}var B=C.$$("creatorIcon");if(B){if(this.isFlag(Entry.FLAG_CREATOR)){if(this.creatorId==g_groupOwnerId){B.href="/group/"+g_groupName}else{if(this.creatorId!=0){B.href="/canvas/"+this.creator}}var F=null;var A=null;if(this.creatorId==g_groupOwnerId){F="/grouphelper/icon/"+g_groupId;A=g_groupName}else{F="/user/icon/"+this.creatorId;A=this.creator}B.setStyle({"backgroundImage":"url("+F+"?size=small)"});B.title=A+" ("+formatUpdated(this.getUpdated())+")"}else{B.remove()}}this.updateBackgroundColor(D?TYPE_MASKED:TYPE_NORMAL,C)},updatePosition:function(){this.elem.setStyle({"left":lx2px(this.left)+"px","top":ly2py(this.top)+"px","width":ls2ps(this.width)+"px","height":ls2ps(this.height)+"px","zIndex":this.getActualZIndex()})},canReplyInSameColor:function(){return !this.image&&!this.movie&&this.color!="transparent"},setupHandle:function(){if(Prototype.Browser.IE){var A=this.elem.$$("handle");if(A){A.removeClassName("handle");this.elem.$$("bg").addClassName("handle")}}},updateBackgroundColor:function(A,B){B=B||this.elem;if(this.image&&!this.isParam(Entry.PARAM_IMAGE_FRAME)&&A!=TYPE_MASKED){B.$$("bgCenter").src="/entry/image/"+this.image.id}else{updateEntryBackgroundColor(B,A,this.color)}},updateBackgroundSize:function(A){updateEntryBackgroundSize(A||this.elem,this)},setZIndex:function(A){this.zIndex=A;if(this.elem){this.elem.setStyle({"zIndex":this.getActualZIndex()})}g_panel.setZIndex(this.id,A)},updateZIndex:function(){this.setZIndex(this.zIndex)},maskPrivate:function(){this.maskFlag(Entry.PRIVATE_MASKED)},unmaskPrivate:function(){this.unmaskFlag(Entry.PRIVATE_MASKED)},markNew:function(B){if(B){this.newIndex=B;var A=new Element("div");A.setStyle({"backgroundPosition":-((B-1)*32)+"px 0px"});A.addClassName("newEntryIcon");this.elem.appendChild(A);this.updateZIndex()}else{this.newIndex=0;g_panel.hideEntryElem(this.id)}},unmarkNew:function(){var A=this.newIndex;this.newIndex=null;if(A){this.elem.$$("newEntryIcon").remove();this.updateZIndex()}else{g_panel.showEntryElem(this.id)}},maskFlag:function(A){var B=this.maskStatus!=0;this.maskStatus|=A;if(!B){this.mask()}},unmaskFlag:function(A){var B=this.maskStatus!=0;this.maskStatus&=~A;if(B&&this.maskStatus==0){this.unmask()}},mask:function(){this.elem.select(".content, .grip, .footer").each(Element.hide);this.updateBackgroundColor(TYPE_MASKED);g_panel.maskEntryElem(this.id)},unmask:function(){this.elem.select(".content, .grip"+(g_zoom>=1?", .footer":"")).each(Element.show);this.updateBackgroundColor(TYPE_NORMAL);g_panel.unmaskEntryElem(this.id)},getTags:function(A){return Tag.getTags(this.tags,A?this.date?parseDate(this.date):null:null)},isParam:function(A){return(this.params&A)!=0},isFlag:function(A){return(this.flags&A)!=0},updateForTag:function(C){var A=true;var B=this.getTags(true).map(function(E){return E.stringValue()});if(B.length!=0){for(var D=0;D<C.length&&A;++D){A=B.indexOf(C[D])!=-1}}else{A=C.length==0}if(A){this.unmaskFlag(Entry.TAG_MASKED);this.elem.select(".tag .tagItem").each(function(E){var F=C.indexOf(E["tag"].stringValue())!=-1;if(F){E.addClassName("selected")}else{E.removeClassName("selected")}})}else{this.maskFlag(Entry.TAG_MASKED)}},updateVisibility:function(B){var A=this.elem.visible();if(isEntryInCanvasView(B,this)){if(!A){this.elem.show()}}else{if(A){this.elem.hide()}}},adjustFont:function(){if(this.isFlag(Entry.FLAG_ADJUSTFONT)){var C=this.elem;var A=C.$$("body");A.setStyle({"fontSize":this.fontSize+"%"});var B=function(J){var G=C.$$("content");var I=A.getHeight();var F=G.getHeight();if(A.positionedOffset().top+I>G.positionedOffset().top+F){if(this.image){F-=this.image.height+Entry.IMAGE_FRAME_PADDING*2}var D=parseInt(A.getStyle("fontSize"),10);var E=Math.sqrt(F/I)*0.95;var H=Math.max(50,Math.floor(D*E/10)*10);A.setStyle({"fontSize":H+"%"})}if(!J){C.show()}}.bind(this);if(Prototype.Browser.IE){this.elem.hide();B.defer()}else{B(true)}}},getUpdated:function(){if(!this.updatedDate){this.updatedDate=parseDateTime(this.updated)}return this.updatedDate},getActualZIndex:function(){var A=this.zIndex;if(this.newIndex){A+=NEW_ENTRY_MODE_ZINDEX;if(g_currentNewEntryHilight&&g_currentNewEntryElem==this.elem){A+=200}}return A},setId:function(){this.elem.setAttribute("id","entry"+this.id)},equals:function(A){return this.id==A.id&&this.updated==A.updated&&this.pin==A.pin&&this.left==A.left&&this.top==A.top&&this.width==A.width&&this.height==A.height}};var TF_NORMAL=0;var TF_DUE=1;var TF_TODAY=2;var TF_TOMORROW=4;var TF_YESTERDAY=8;var TF_OVERDUE=16;var Tag=Class.create({initialize:function(A,B){this.tag=A;this.flag=B},equals:function(A){return this.tag==A.tag&&this.flag==A.flag},stringValue:function(){return this.tag+"$$$"+this.flag}});Tag.split=function(A){A=A.strip();return A.length!=0?A.split(/\s/):[]};Tag.parse=function(A){return Tag.split(A).map(function(B){return new Tag(B,TF_NORMAL)})};Tag.getTags=function(C,B){var A=new Array();if(B){A.push(Tag.getDateTag(B))}if(C){A=A.concat(C.map(function(D){return new Tag(D,TF_NORMAL)}))}return A};Tag.getDateTag=function(C){var A=TF_DUE;var B=getTodayDate();if(isSameDay(C,B)){A|=TF_TODAY}else{if(isSameDay(C,new Date(B.getTime()+24*60*60*1000))){A|=TF_TOMORROW}else{if(C.getTime()<B.getTime()){A|=TF_OVERDUE}}}return new Tag(formatDueDate(C),A)};var TYPE_NORMAL="normal";var TYPE_MASKED="masked";var TYPE_DIALOG="dialog";function updateEntryBackgroundColor(D,B,A){var C=B!=TYPE_DIALOG?B:TYPE_NORMAL;D.$$("bgCenter").src="/image/entry/"+C+"/"+A+".png";if(Prototype.Browser.IE6){if(A=="transparent"){D.$$("bgCenter").setOpacity(B==TYPE_DIALOG?0.2:0.1)}}}var LEFTSHADOW_WIDTH=6;var RIGHTSHADOW_WIDTH=8;var TOPSHADOW_HIGHT=8;var BOTTOMSHADOW_HIGHT=8;function updateEntryBackgroundSize(G,F){var B=F?ls2ps(F.width):G.getWidth();var I=F?ls2ps(F.height):G.getHeight();if(B==0||I==0){return }G.$$("bgCenter").setStyle({"width":(B-LEFTSHADOW_WIDTH-RIGHTSHADOW_WIDTH)+"px","height":(I-BOTTOMSHADOW_HIGHT)+"px"});var A=G.$$("bgBottom");if(A){A.setStyle({"width":(B-LEFTSHADOW_WIDTH-RIGHTSHADOW_WIDTH)+"px"})}var C=G.$$("bgLeft");if(C){C.setStyle({"height":(I-TOPSHADOW_HIGHT-BOTTOMSHADOW_HIGHT)+"px"})}var H=G.$$("bgRight");if(H){H.setStyle({"height":(I-TOPSHADOW_HIGHT-BOTTOMSHADOW_HIGHT)+"px"})}updateContentSize(G,B,I);if(Prototype.Browser.IE){var E=G.$$("logoIE");if(E){E.setStyle({"width":(B-LEFTSHADOW_WIDTH-RIGHTSHADOW_WIDTH)+"px","height":(I-BOTTOMSHADOW_HIGHT)+"px"});if(!E.visible()){E.show()}var D=G.$$("logo");if(D.visible()){D.hide()}}}else{var D=G.$$("logo");if(D){D.setStyle({"width":(B-LEFTSHADOW_WIDTH-RIGHTSHADOW_WIDTH)+"px","height":(I-BOTTOMSHADOW_HIGHT)+"px"})}}}var CONTENT_MARGIN=22;function updateContentSize(E,B,A){var C=E.$$("content");var F=C?C.next(".footer"):E.$$("footer");var D=0;if(F){F.setStyle({"width":(B-CONTENT_MARGIN)+"px"});if(F.visible()&&(!E.entry||!E.entry.isFlag(Entry.FLAG_AUTOHIDE))){D=F.getHeight()+5}}if(C){C.setStyle({"height":Math.max(0,(A-D-13))+"px"})}}function intersectEntry(I,G){var D=I.left+LEFTSHADOW_WIDTH;var F=I.top;var B=I.left+I.width-RIGHTSHADOW_WIDTH;var J=I.top+I.height-BOTTOMSHADOW_HIGHT;var C=G.left+LEFTSHADOW_WIDTH;var E=G.top;var A=G.left+G.width-RIGHTSHADOW_WIDTH;var H=G.top+G.height-BOTTOMSHADOW_HIGHT;return !(B<C||A<D||J<E||H<F)}var MiniCalendar=Class.create({elem:null,clickFunc:null,dayFunc:null,current:null,year:null,month:null,initialize:function(D,A,B){this.elem=D;this.clickFunc=A;this.dayFunc=B;this.current=null;var C=D.$$("miniCalendarBar");if(Prototype.Browser.IE){var E=D.$$("miniCalendar");E.observe("resize",function(){C.setStyle({"width":(E.getWidth())+"px"})})}C.$$("miniCalendarPrev").observe("click",function(){var F=this.year;var G=this.month;if(G==0){--F;G=11}else{--G}this.refresh(F,G)}.bindAsEventListener(this));C.$$("miniCalendarNext").observe("click",function(){var F=this.year;var G=this.month;if(G==11){++F;G=0}else{++G}this.refresh(F,G)}.bindAsEventListener(this));C.$$("miniCalendarCurrent").observe("click",function(){this.setDate(getTodayDate(),this.current)}.bindAsEventListener(this));this.setDate(getTodayDate(),null)},element:function(){return this.elem},refresh:function(E,G){this.year=E;this.month=G;this.elem.$$("miniCalendarTitle").update(formatYearMonth(E,G));var B=this.elem.$$("miniCalendar");B.select(".miniCalendarWeek").each(Element.remove);var A=B.$$$("tbody");var C=getTodayDate();var D=new Date(E,G,1);D.setDate(D.getDate()-D.getDay());do{var F=new Element("tr");F.addClassName("miniCalendarWeek");F.appendChild(this.createMarginCell());for(var H=0;H<7;++H){F.appendChild(this.createDay(D,C,D.getMonth()==G));D.setDate(D.getDate()+1)}F.appendChild(this.createMarginCell());A.appendChild(F)}while(D.getMonth()==G);this.layoutBackground()},setDate:function(A,B){this.current=B;this.refresh(A.getFullYear(),A.getMonth())},layoutBackground:function(){var A=this.elem.getDimensions();var C=this.elem.$$("miniCalendarHeader");var B=C.cumulativeOffset().top+C.getHeight()-this.elem.cumulativeOffset().top;this.elem.$$("miniCalendarBgTop").setStyle({"width":Math.max(A.width-7*2,0)+"px","height":B+"px"});this.elem.$$("miniCalendarBgBody").setStyle({"width":Math.max(A.width-7*2,0)+"px","height":Math.max(A.height-B-7,0)+"px"});this.elem.$$("miniCalendarBgLeft").setStyle({"height":Math.max(A.height-7,0)+"px"});this.elem.$$("miniCalendarBgRight").setStyle({"height":Math.max(A.height-7,0)+"px"});this.elem.$$("miniCalendarBgBottom").setStyle({"width":Math.max(A.width-7*2,0)+"px"})},createDay:function(C,B,E){var H=new Element("td");if(C!=null){var G=C.getFullYear();var A=C.getMonth();var F=C.getDate();H.appendChild(document.createTextNode(F));if(this.clickFunc){H.observe("click",this.clickFunc.bind(this,G,A,F))}H.addClassName("miniCalendarDay");if(E){switch(C.getDay()){case 0:H.addClassName("miniCalendarSunday");break;case 6:H.addClassName("miniCalendarSaturday");break}if(isSameDay(B,C)){H.addClassName("miniCalendarToday")}if(isSameDay(this.current,C)){H.addClassName("miniCalendarSelection")}var D=getHolidayName(C);if(D){H.addClassName("miniCalendarHoliday");H.setAttribute("title",D)}}else{H.addClassName("miniCalendarOtherMonth")}if(this.dayFunc){this.dayFunc(H,C)}H.observe("mouseover",this.overDay);H.observe("mouseout",this.outDay)}return H},createMarginCell:function(){var A=new Element("td");A.addClassName("miniCalendarMarginCell");return A},overDay:function(A){A.element().addClassName("hilighted")},outDay:function(A){A.element().removeClassName("hilighted")}});var NotificationBase=Class.create({elem:null,messageElem:null,height:0,message:"",delay:-1,timer:null,initialize:function(A){this.elem=A;this.messageElem=this.elem.$$("notificationMessage");this.height=this.elem.getHeight()+16;this.elem.setStyle({"top":-this.height+"px","height":this.height+"px"})},showNotification:function(B,C,A){if(this.timer!=null){clearTimeout(this.timer)}this.elem.setStyle({"left":Math.floor((getWindowWidth()-this.elem.getWidth())/2)+"px","backgroundImage":"url(/image/notification/"+(C||"information")+".png)"});this.message=B;this.delay=A||-1;if(this.message){this.messageElem.update2(this.message);this.elem.setStyle({"height":"auto"});this.height=this.elem.getHeight()+16;this.elem.setStyle({"top":-this.height+"px","height":this.height+"px"});this.messageElem.innerHTML=""}this.elem.setStyle({"top":-this.height+"px"});this.show()},show:function(){var A=this.elem.positionedOffset().top;if(A<0){A=Math.min(0,A+10);this.elem.setStyle({"top":A+"px"});this.timer=setTimeout(this.show.bind(this),100)}else{if(this.message){this.messageElem.update2(this.message)}if(this.delay!=-1){this.timer=setTimeout(this.hide.bind(this),this.delay)}}},hide:function(){var A=this.elem.positionedOffset().top;if(this.message){this.messageElem.innerHTML=""}if(A>-this.height){A=Math.max(-this.height,A-10);this.elem.setStyle({"top":A+"px"});this.timer=setTimeout(this.hide.bind(this),100)}}});var Notification=Class.create(NotificationBase,{initialize:function(A){NotificationBase.prototype.initialize.apply(this,arguments);this.elem.$$("notificationClose").observe("click",function(){if(this.timer){clearTimeout(this.timer)}this.hide()}.bindAsEventListener(this))},showInformation:function(D,B){var A=D.escapeHTML();var C=Notification.DELAY_INFORMATION;if(B){A+=' (<a href="javascript:undo('+B+')" class="undo">'+MESSAGES["canvas.undo"].escapeHTML()+"</a>)";C=Notification.DELAY_UNDO}this.showNotification(A,"information",C)},showError:function(A){this.showNotification(A.escapeHTML(),"error",Notification.DELAY_ERROR)}});Notification.DELAY_INFORMATION=3000;Notification.DELAY_ERROR=10000;Notification.DELAY_UNDO=20000;var MovieNotification=Class.create(NotificationBase,{initialize:function(A){NotificationBase.prototype.initialize.apply(this,arguments);this.elem.$$("stopMovie").observe("click",function(){stopMovie()})},showInformation:function(){this.showNotification()}});var Board=Class.create({board:null,visible:false,initialize:function(A){this.board=A},show:function(){B;this.board.show();this.board.setStyle({"height":"auto"});var A=this.board.getHeight();if(Prototype.Browser.IE){this.board.setStyle({"height":A+"px"});layoutCanvasView()}else{var C=0;var B=function(){this.board.setStyle({"height":C+"px"});layoutCanvasView();if(C<A){C=Math.min(C+Board.STEP,A);B.delay(0.1)}}.bind(this);B()}this.visible=true},hide:function(){if(Prototype.Browser.IE){this.board.setStyle({"height":"0px"});this.board.hide();layoutCanvasView()}else{var B=this.board.getHeight();var A=function(){this.board.setStyle({"height":B+"px"});layoutCanvasView();if(B>0){B=Math.max(B-Board.STEP,0);A.delay(0.1)}else{this.board.hide()}}.bind(this);A()}this.visible=false},toggle:function(){if(this.visible){this.hide()}else{this.show()}},getHeight:function(){return this.board.visible()?this.board.getHeight():0}});Board.STEP=30;var PaletteEntry=Class.create({initialize:function(D,C,G,A,B,F,E){this.index=D;this.name=C;this.width=G;this.height=A;this.color=B;this.type=F;this.points=E}});var Palette=Class.create({MIN_PALETTE_HEIGHT:52,MAX_MY_PALETTE_HEIGHT:188,MAX_READWRITE_PALETTE_HEIGHT:188,MAX_READONLY_PALETTE_HEIGHT:77,MAX_PALETTE_ENTRIES:8,MAX_NORMAL_ENTRIES:4,PALETTE_ENTRIES:[new PaletteEntry(0,"yellow",280,200,"yellow",NewEntry.TYPE_NORMAL,[new Point(19,45),new Point(19,101),new Point(80,101),new Point(80,45)]),new PaletteEntry(1,"green",280,200,"green",NewEntry.TYPE_NORMAL,[new Point(92,45),new Point(92,101),new Point(153,101),new Point(153,45)]),new PaletteEntry(2,"blue",280,200,"blue",NewEntry.TYPE_NORMAL,[new Point(165,45),new Point(165,101),new Point(226,101),new Point(226,45)]),new PaletteEntry(3,"peach",280,200,"peach",NewEntry.TYPE_NORMAL,[new Point(238,45),new Point(238,101),new Point(298,101),new Point(298,45)]),new PaletteEntry(4,"image",280,200,"white",NewEntry.TYPE_IMAGE,[new Point(127,110),new Point(127,149),new Point(166,149),new Point(166,110)]),new PaletteEntry(5,"movie",280,200,"black",NewEntry.TYPE_MOVIE,[new Point(169,110),new Point(169,149),new Point(210,149),new Point(210,110)]),new PaletteEntry(6,"attachment",280,200,"white",NewEntry.TYPE_ATTACHMENT,[new Point(213,110),new Point(213,149),new Point(254,149),new Point(254,110)]),new PaletteEntry(7,"transparent",280,200,"transparent",NewEntry.TYPE_NORMAL,[new Point(257,110),new Point(257,149),new Point(298,149),new Point(298,110)])],initialize:function(D){this.palette=$("palette");this.body=$("paletteBody");this.header=$("paletteHeader");this.footer=$("paletteFooter");this.newEntryMode=$("newEntryMode");this.newEntryNext=$("newEntryNext");this.showPrivate=$("showPrivate");this.expandElem=$("paletteExpand");this.pinElem=$("palettePin");this.imgBody=$("paletteImgBody");this.pinned=true;this.expandingTimer=null;this.preHideTimer=null;if(g_canvasTypeFlags&CanvasType.FLAG_NEW){for(var C=0;C<this.MAX_PALETTE_ENTRIES;++C){var G=this.PALETTE_ENTRIES[C];$("paletteItem"+C).setStyle({"backgroundImage":"url(/image/palette/entry/"+G.name+".png)"})}}if(this.body){this.palette.observe("mousedown",function(M){if(!M.isLeftClick()){return }if(!this.isExpanded()){return }var L=this.getPaletteEntryFromScreenPos(M.pointerX(),M.pointerY());if(L){D(M,L)}M.stop()}.bindAsEventListener(this))}if(this.expandElem){this.palette.observe("mouseover",this.expandAuto.bindAsEventListener(this));this.palette.observe("mouseout",this.collapseAuto.bindAsEventListener(this))}var I=function(M){var L=M.element();if(Prototype.Browser.IE6){var N=L.classNames().grep(/action.+/)[0];L.addClassName(N+"Hover");L.removeClassName(N)}else{L.setStyle({"backgroundPosition":L.getStyle("backgroundPosition").split(" ")[0]+" -22px"})}};var E=function(M){var L=M.element();if(Prototype.Browser.IE6){var N=L.classNames().grep(/action.+/)[0];L.addClassName(N.slice(0,-5));L.removeClassName(N)}else{L.setStyle({"backgroundPosition":L.getStyle("backgroundPosition").split(" ")[0]+" 0px"})}};this.palette.select(".action").each(function(L){L.observe("mouseover",I);L.observe("mouseout",E)}.bind(this));this.newEntryMode.observe("click",toggleNewEntryMode);this.newEntryNext.observe("click",function(L){if(g_newEntryMode){nextNewEntry();L.stop()}});if(Prototype.Browser.IE6){var A=function(){if(!g_newEntryMode){IE6.addClassName(this.newEntryMode,"","newEntryButtonHover","newEntryButton")}}.bindAsEventListener(this);var F=function(){if(!g_newEntryMode){IE6.removeClassName(this.newEntryMode,"","newEntryButtonHover","newEntryButton")}}.bindAsEventListener(this);this.newEntryMode.observe("mouseover",A);this.newEntryMode.observe("mouseout",F)}if(this.showPrivate){this.showPrivate.observe("click",toggleShowPrivate);if(Prototype.Browser.IE6){var B=function(){if(!g_showPrivate){IE6.addClassName(this.showPrivate,"","showPrivateButtonHover","showPrivateButton")}}.bindAsEventListener(this);var H=function(){if(!g_showPrivate){IE6.removeClassName(this.showPrivate,"","showPrivateButtonHover","showPrivateButton")}}.bindAsEventListener(this);this.showPrivate.observe("mouseover",B);this.showPrivate.observe("mouseout",H)}}var J=function(L){IE6.addClassName(L.element(),"pushed","subscriptionPushed","")};var K=function(L){IE6.removeClassName(L.element(),"pushed","subscriptionPushed","")};this.palette.select(".subscription").each(function(L){L.observe("mousedown",J);L.observe("mouseup",K);L.observe("mouseout",K)});this.palette.$$("subscribe").observe("click",function(){var L=$("subscribeCanvasForm");L.canvasId.value=g_canvasId;new AjaxUtil().post("/api/canvas/subscribe",L,function(){info("canvas.info.canvasSubscribed");updateSubscription()})});this.palette.$$("unsubscribe").observe("click",function(){var L=$("unsubscribeCanvasForm");L.canvasId.value=g_canvasId;new AjaxUtil().post("/api/canvas/unsubscribe",L,function(){info("canvas.info.canvasUnsubscribed");updateSubscription()})});if(this.expandElem){this.expandElem.observe("click",function(){if(this.isExpanded()){this.collapse()}else{this.expand()}}.bindAsEventListener(this))}if(this.pinElem){this.pinElem.observe("click",function(){this.setPinned(!this.isPinned())}.bindAsEventListener(this))}},restore:function(B,C,A){if(!B){this.setPinned(B)}if(!C&&this.expandElem){if(this.body){this.body.hide()}this.footer.hide();this.setHeight(this.MIN_PALETTE_HEIGHT);this.expandElem.addClassName("collapsed");if(this.pinElem){this.pinElem.hide()}}if(A){for(var D=0;D<this.MAX_NORMAL_ENTRIES;++D){this.setColor(D,A[D])}}},element:function(){return this.palette},expand:function(){if(this.expandingTimer){clearTimeout(this.expandingTimer);this.expandingTimer=null}var B=this.getMaxHeight();var A=this.palette.getHeight();var C=function(){A=Math.min(A+10,B);this.setHeight(A);if(A!=B){this.expandingTimer=setTimeout(C,20)}else{if(this.body){this.body.show()}this.footer.show();this.expandElem.removeClassName("collapsed");if(this.pinElem){this.pinElem.show()}saveLocalPreferences();this.expandingTimer=null}}.bind(this);this.expandingTimer=setTimeout(C,0)},collapse:function(){if(this.expandingTimer){clearTimeout(this.expandingTimer);this.expandingTimer=null}if(this.body){this.body.hide()}this.footer.hide();var A=this.palette.getHeight();var B=function(){A=Math.max(A-10,this.MIN_PALETTE_HEIGHT);this.setHeight(A);if(A!=this.MIN_PALETTE_HEIGHT){this.expandingTimer=setTimeout(B,20)}else{this.expandElem.addClassName("collapsed");if(this.pinElem){this.pinElem.hide()}saveLocalPreferences();this.expandingTimer=null}}.bind(this);this.expandingTimer=setTimeout(B,0)},setHeight:function(A){this.palette.setStyle({"height":A+"px"});this.imgBody.setStyle({"height":(A-(this.MIN_PALETTE_HEIGHT-4))+"px"})},getMaxHeight:function(){return g_canvasType==CanvasType.MY?this.MAX_MY_PALETTE_HEIGHT:g_canvasTypeFlags&CanvasType.FLAG_NEW?this.MAX_READWRITE_PALETTE_HEIGHT:this.MAX_READONLY_PALETTE_HEIGHT},isExpanded:function(){return this.expandElem&&!this.expandElem.hasClassName("collapsed")},isExpandable:function(){return this.expandElem},isPinned:function(){return this.pinned},setPinned:function(A){this.pinned=A;if(A){this.pinElem.addClassName("pinned")}else{this.pinElem.removeClassName("pinned")}if(this.expandElem){if(A){this.expandElem.show()}else{this.expandElem.hide()}}saveLocalPreferences()},expandAuto:function(A){if(!this.pinned){if(this.preHideTimer){clearTimeout(this.preHideTimer);this.preHideTimer=null}this.expand()}},collapseAuto:function(A){if(Position.within(this.palette,A.pointerX(),A.pointerY())){return }if(!this.pinned){if(!this.preHideTimer){this.preHideTimer=setTimeout(this.collapse.bind(this),500)}}},getColors:function(){var A=[];for(var B=0;B<this.MAX_NORMAL_ENTRIES;++B){A.push(this.PALETTE_ENTRIES[B].color)}return A},setColor:function(B,A){if(!(g_canvasTypeFlags&CanvasType.FLAG_NEW)){return }if(this.PALETTE_ENTRIES.find(function(E){return E.color==A})){return }var D=this.PALETTE_ENTRIES[B];if(D.type!=NewEntry.TYPE_NORMAL||D.color=="transparent"){return }D.name=A;D.color=A;var C=$("paletteItem"+B);C.setStyle({"backgroundImage":"url(/image/palette/entry/"+D.name+".png)"});IEPNGFIX.fix(C);saveLocalPreferences()},getPaletteEntryFromScreenPos:function(B,F){var E=this.palette.cumulativeOffset();var A=new Point(B-E.left,F-E.top);for(var D=0;D<this.PALETTE_ENTRIES.length;++D){var C=this.PALETTE_ENTRIES[D];if(inside(A,C.points)){return C}}return null},updateNewEntryMode:function(){if(g_newEntryMode){var A=this.newEntryMode.classNames().grep(/newEntryButton.*/)[0];IE6.addClassName(this.newEntryMode,"pushed","newEntryButtonPushed",A);this.newEntryNext.show()}else{IE6.removeClassName(this.newEntryMode,"pushed","newEntryButtonPushed","newEntryButton");this.newEntryNext.hide()}},updateShowPrivate:function(){if(g_showPrivate){IE6.addClassName(this.showPrivate,"pushed","showPrivateButtonPushed","showPrivateButtonHover")}else{IE6.removeClassName(this.showPrivate,"pushed","showPrivateButtonPushed","showPrivateButton")}},setSubscribed:function(A){(A?Element.addClassName:Element.removeClassName)(this.header,"subscribed");(A?Element.removeClassName:Element.addClassName)(this.header,"unsubscribed")}});var Dock=Class.create({initialize:function(){this.dock=$("dock");this.view=$("dockView");this.bg=$("dockBg");this.body=$("dockBody");this.grip=$("dockGrip");this.close=$("dockClose");this.pin=$("dockPin");this.leftArrow=$("dockLeft");this.rightArrow=$("dockRight");this.info=$("dockInfo");this.visible=true;this.width=Dock.DEFAULT_WIDTH;this.scrollPos=0;this.restoredScrollPos=0;this.type=Dock.TYPE_MY;this.resizing=null;this.showingTimer=null;this.pinned=true;this.preHideTimer=null;this.items=this.dock.select(".dockItem");var A=function(B){if(B.isLeftClick()){B.stop()}};this.grip.observe("mousedown",this.resizeStartDrag.bindAsEventListener(this));this.close.observe("click",this.toggleShow.bindAsEventListener(this));this.close.observe("mousedown",A);this.pin.observe("click",this.togglePin.bindAsEventListener(this));this.pin.observe("mousedown",A);this.bg.observe("mouseover",this.showAuto.bindAsEventListener(this));this.bg.observe("mouseout",this.hideAuto.bindAsEventListener(this));this.leftArrow.observe("click",this.scrollLeft.bindAsEventListener(this));this.rightArrow.observe("click",this.scrollRight.bindAsEventListener(this));this.selector=new DockSelector(this)},restore:function(B,D,C,A){if(B){this.width=B}if(D){this.restoredScrollPos=D}this.setVisible(C);this.setWidth(C?this.width:Dock.MIN_WIDTH);this.setPinned(A)},load:function(){if(g_canvasType==CanvasType.GROUP){this.type=Dock.TYPE_GROUP}this.loadWithType(this.type,g_groupId)},loadWithType:function(C,B){if(!(g_canvasTypeFlags&CanvasType.FLAG_DOCK)){return }this.selector.set(C,B);if(this.type==Dock.TYPE_MY&&this.restoredScrollPos==-1){this.restoredScrollPos=this.getScrollPos()}this.type=C;var A=null;switch(C){case Dock.TYPE_MY:A="my";break;case Dock.TYPE_FAVORITES:A="favorites";break;case Dock.TYPE_GROUP:A="group";break}var D="?type="+A;if(C==Dock.TYPE_GROUP){D+="&groupId="+B}new AjaxUtil().get("/api/canvas/docks"+D,null,this.update.bindAsEventListener(this),error)},update:function(B){var D=this.hideInfo();if(D&&!Prototype.Browser.IE){this.dock.setOpacity(0)}var A=B.docks;var C=Dock.ITEM_TEMPLATE;this.dock.innerHTML=$A(A).map(function(I){I.name=I.name.escapeHTML();I.path=I.path.escapeHTML();var J=[];if(I.id==g_canvasId){J.push("dockSelfItem")}if(I.my){J.push("dockMyItem")}if(I.writable){J.push("dockWritableItem")}I.classNames=J.join(" ");return C.evaluate(I)}).join("");this.items=this.dock.select(".dockItem");this.bg.show();var F=this.type==Dock.TYPE_MY;var H=F?this.restoredScrollPos:0;if(Prototype.Browser.WebKit){this.fixupScrollPos.curry(H).bind(this).defer()}else{this.fixupScrollPos(H)}if(F){this.restoredScrollPos=-1}this.adjustScrollPos();this.updateArrows();if(D&&!Prototype.Browser.IE){var G=0.1;var E=function(){this.dock.setOpacity(G);G+=0.1;if(G<1){E.delay(0.1)}}.bind(this);E()}},showInfo:function(A,B,D){this.info.setStyle({"width":this.view.getWidth()+"px"});var C=this.info.$$$("img");C.src=A;IEPNGFIX.fix(C);if(D){this.info.$$("dockInfoGroup").innerHTML=D.escapeHTML()}this.info.select(".dockInfo").each(Element.hide);this.info.$$(B).show();this.info.show();this.dock.hide()},hideInfo:function(){if(!this.info.visible()){return false}this.info.hide();this.dock.show();return true},loadAllEntries:function(){this.items.each(this.loadEntriesByDockItem.bind(this))},loadEntries:function(A){var B=this.getDockItemFromCanvasId(A);if(B){return this.loadEntriesByDockItem(B)}},loadEntriesByDockItem:function(B){var A=B.$$("dockItemImg");A.src="/dock/"+this.getCanvasIdFromDockItem(B)+"?"+new Date().getTime();if(Prototype.Browser.IE){IEPNGFIX.fix(A)}},getWidth:function(){return this.width},setWidth:function(A){this.bg.setStyle({"width":A+"px"});this.body.setStyle({"width":Math.max(0,A-Dock.GRIP_WIDTH)+"px"});this.view.setStyle({"width":Math.max(0,A-(Dock.ARROW_WIDTH*2+Dock.SELECTOR_WIDTH+Dock.GRIP_WIDTH))+"px"})},adjustWidth:function(){if(!this.visible){return }var A=Math.min(this.bg.getWidth(),getWindowWidth()-$("panelBg").getWidth()-50);var B=Dock.GRIP_WIDTH+Dock.ARROW_WIDTH*2+Dock.SELECTOR_WIDTH;var C=Math.floor((A-B)/Dock.ITEM_WIDTH+0.5);if(C<=0){A=Dock.MIN_WIDTH}else{A=B+Dock.ITEM_WIDTH*C}this.setWidth(A);this.width=A;this.adjustScrollPos();this.updateArrows();saveLocalPreferences()},isVisible:function(){return this.visible},setVisible:function(A){this.visible=A;if(A){IE6.removeClassName(this.close,"closed","dockOpenButton","dockCloseButton")}else{IE6.addClassName(this.close,"closed","dockOpenButton","dockCloseButton")}saveLocalPreferences()},resizeStartDrag:function(D){if(!D.isLeftClick()){return }if(this.resizing){this.resizeEndDrag(D)}var E=this.grip.cumulativeOffset();var C=this.grip.getDimensions();var B=this.resizeDrag.bindAsEventListener(this);var A=this.resizeEndDrag.bindAsEventListener(this);this.resizing=new DockResizing(D.pointerX()-(E.left+C.width),B,A);Event.observe(document,"mousemove",B);Event.observe(document,"mouseup",A);D.stop()},resizeEndDrag:function(A){this.resizeDrag(A);this.setVisible(true);this.adjustWidth();Event.stopObserving(document,"mousemove",this.resizing.move);Event.stopObserving(document,"mouseup",this.resizing.up);this.resizing=null},resizeDrag:function(B){var A=Math.max(Dock.MIN_WIDTH,B.pointerX()-this.resizing.offsetX);this.setWidth(A);B.stop()},toggleShow:function(A){if(this.visible){this.hide()}else{this.show()}saveLocalPreferences()},show:function(){if(this.visible){return }this.changeWidth(Dock.MIN_WIDTH,function(A){return A>=this.width?null:Math.min(A+50,this.width)}.bind(this));this.setVisible(true)},hide:function(){if(!this.visible){return }this.changeWidth(this.width,function(A){return A<=Dock.MIN_WIDTH?null:Math.max(A-50,Dock.MIN_WIDTH)}.bind(this));this.setVisible(false)},changeWidth:function(B,A){if(this.showingTimer!=null){clearTimeout(this.showingTimer)}var C=function(){this.setWidth(B);B=A(B);if(B){this.showingTimer=setTimeout(C,10)}else{this.adjustWidth();this.showingTimer=null}}.bind(this);this.showingTimer=setTimeout(C,10)},togglePin:function(A){this.setPinned(!this.pinned)},setPinned:function(A){this.pinned=A;if(A){IE6.addClassName(this.pin,"pinned","dockPinButton","dockPinnedButton");this.close.show()}else{IE6.removeClassName(this.pin,"pinned","dockPinButton","dockPinnedButton");this.close.hide()}saveLocalPreferences()},isPinned:function(){return this.pinned},showAuto:function(A){if(!this.pinned&&!this.showingTimer){if(this.preHideTimer){clearTimeout(this.preHideTimer);this.preHideTimer=null}this.show()}},hideAuto:function(A){if(Position.within(this.bg,A.pointerX(),A.pointerY())){return }if(!this.pinned&&!this.resizing){if(!this.preHideTimer){this.preHideTimer=setTimeout(this.hide.bind(this),800)}}},within:function(A,B){return Position.within(this.bg,A,B)},scrollLeft:function(B){var C=this.getScrollPos();if(C>=0){return }var A=this.view.getWidth();this.setScrollPos(Math.min(0,C+Math.max(1,Math.floor(A/Dock.ITEM_WIDTH-1))*Dock.ITEM_WIDTH))},scrollRight:function(D){var A=this.dock.getDimensions();var C=this.items.length;if(A.width>=C*Dock.ITEM_WIDTH){return }var E=this.getScrollPos();var B=this.view.getWidth();this.setScrollPos(Math.max(-(Dock.ITEM_WIDTH*C-B),E-Math.max(1,Math.floor(B/Dock.ITEM_WIDTH-1))*Dock.ITEM_WIDTH))},getScrollPos:function(){return this.scrollPos},setScrollPos:function(C){var A=this.getScrollPos();var B=function(){if(A<C){A=Math.min(A+(Dock.ITEM_WIDTH),C)}else{if(A>C){A=Math.max(A-(Dock.ITEM_WIDTH),C)}}if(A!=C){this.dock.setStyle({"left":A+"px"});B.delay(0.1)}else{this.fixupScrollPos(A)}}.bind(this);B.defer()},adjustScrollPos:function(){var B=this.view.getWidth();var D=this.dock.positionedOffset();var A=this.dock.getDimensions();if(D.left+A.width<B){var C=Math.floor((B-(D.left+A.width))/Dock.ITEM_WIDTH);this.fixupScrollPos(Math.min(0,D.left+C*Dock.ITEM_WIDTH))}},fixupScrollPos:function(A){this.scrollPos=Math.floor(A/Dock.ITEM_WIDTH)*Dock.ITEM_WIDTH;this.dock.setStyle({"left":this.scrollPos+"px"});this.updateArrows();saveLocalPreferences()},getMyScrollPos:function(){return this.selector.type==Dock.TYPE_MY?this.getScrollPos():this.restoredScrollPos},updateArrows:function(){var C=this.getScrollPos();if(C==0){this.leftArrow.addClassName("disabled")}else{this.leftArrow.removeClassName("disabled")}var A=this.view.getWidth();var B=this.items.length;if(C<=-(Dock.ITEM_WIDTH*B-A)){this.rightArrow.addClassName("disabled")}else{this.rightArrow.removeClassName("disabled")}},getCanvasIdFromDockItem:function(A){return A.id.substring(8)},getDockItemFromCanvasId:function(A){return $("dockItem"+A)},getDockItemFromPosition:function(A,C){if(this.isVisible()&&Position.within(this.view,A,C)){for(var B=0;B<this.items.length;++B){if(Position.within(this.items[B].$$("dockView"),A,C)){return this.items[B]}}}return null},mapScreenDockPosToCanvasPos:function(D,A,C){var B=D.$$("dockView").cumulativeOffset();return new Point(this.mapDockToCanvasX(A-B.left),this.mapDockToCanvasY(C-B.top))},mapDockToCanvasX:function(A){return Math.floor(A*CANVAS_SIZE.width/Dock.VIEW_SIZE.width)},mapDockToCanvasY:function(A){return Math.floor(A*CANVAS_SIZE.height/Dock.VIEW_SIZE.height)},mapCanvasToDockX:function(A){return Math.floor(A*Dock.VIEW_SIZE.width/CANVAS_SIZE.width)},mapCanvasToDockY:function(A){return Math.floor(A*Dock.VIEW_SIZE.height/CANVAS_SIZE.height)}});Dock.TYPE_MY=0;Dock.TYPE_FAVORITES=1;Dock.TYPE_GROUP=2;Dock.DEFAULT_WIDTH=605;Dock.MIN_WIDTH=27;Dock.ITEM_WIDTH=130;Dock.VIEW_SIZE=new Size(78,58);Dock.GRIP_WIDTH=27;Dock.ARROW_WIDTH=17;Dock.SELECTOR_WIDTH=30;Dock.ITEM_TEMPLATE=new Template('<div id="dockItem#{id}" class="dockItem #{classNames}">  <div class="dockName"><nobr><a href="#{path}" title="#{name}">#{name}</a></nobr></div>  <img class="dockItemImg" src="/dock/#{id}" />  <a class="dockView" href="#{path}" title="#{name}"></a></div>');var DockResizing=Class.create({offsetX:null,move:null,up:null,initialize:function(B,C,A){this.offsetX=B;this.move=C;this.up=A}});var DockSelector=Class.create({dock:null,type:null,groupId:null,timer:null,initialize:function(A){this.dock=A;$("dockSelectorNext").observe("click",this.next.bindAsEventListener(this));$("dockSelectorPrev").observe("click",this.previous.bindAsEventListener(this));$("dockSelectorMy").observe("click",this.my.bindAsEventListener(this))},set:function(B,A){this.type=B;this.groupId=A},next:function(){var B=(this.type||Dock.TYPE_MY);var A=null;switch(B){case Dock.TYPE_MY:B=Dock.TYPE_FAVORITES;break;case Dock.TYPE_FAVORITES:if(g_groups.length==0){B=Dock.TYPE_MY}else{B=Dock.TYPE_GROUP;A=g_groups[0].id}break;case Dock.TYPE_GROUP:var C=g_groups.indexOf(g_groups.find(function(D){return D.id==this.groupId}.bind(this)));if(C==-1||C==g_groups.length-1){B=Dock.TYPE_MY}else{A=g_groups[C+1].id}break}this.select(B,A)},previous:function(){var B=(this.type||Dock.TYPE_MY);var A=null;switch(B){case Dock.TYPE_MY:if(g_groups.length==0){B=Dock.TYPE_FAVORITES}else{B=Dock.TYPE_GROUP;A=g_groups[g_groups.length-1].id}break;case Dock.TYPE_FAVORITES:B=Dock.TYPE_MY;break;case Dock.TYPE_GROUP:var C=g_groups.indexOf(g_groups.find(function(D){return D.id==this.groupId}.bind(this)));if(C==-1||C==0){B=Dock.TYPE_FAVORITES}else{A=g_groups[C-1].id}break}this.select(B,A)},my:function(){if(this.type!=Dock.TYPE_MY){this.select(Dock.TYPE_MY,null)}},select:function(D,B){this.type=D;this.groupId=B;var A="";var C="";var E=null;switch(D){case Dock.TYPE_MY:A="/user/icon/"+g_userId+"?size=large";C="dockInfoMy";break;case Dock.TYPE_FAVORITES:A="/image/dock/favorites.png";C="dockInfoFavorites";break;case Dock.TYPE_GROUP:A="/grouphelper/icon/"+B+"?size=large";C="dockInfoGroup";E=g_groups.find(function(F){return F.id==B}).name;break}this.dock.showInfo(A,C,E);if(this.timer){clearTimeout(this.timer)}this.timer=setTimeout(function(){this.dock.loadWithType(D,B);this.timer=null}.bind(this),500)}});var Panel=Class.create({panel:null,view:null,grip:null,movingView:null,bg:null,close:null,pin:null,canvasView:null,calendar:null,viewSize:null,parentSize:null,visible:true,maxPanelWidth:0,width:0,resizing:null,moving:null,movingTimer:null,showingTimer:null,pinned:true,preHideTimer:null,initialize:function(C,B){this.panel=$("panel");this.view=$("panelView");this.grip=$("panelGrip");this.movingView=$("panelViewMoving");this.bg=$("panelBg");this.close=$("panelClose");this.pin=$("panelPin");this.canvasView=C;this.calendar=new PanelCalendar($("panelCalendar"),B);this.viewSize=this.view.getDimensions();this.parentSize=this.view.getOffsetParent().getDimensions();this.maxPanelWidth=B?Panel.MAX_WITH_CALENDAR_WIDTH:Panel.MAX_WITHOUT_CALENDAR_WIDTH;this.width=this.maxPanelWidth;var A=function(D){if(D.isLeftClick()){D.stop()}};this.grip.observe("mousedown",this.resizeStartDrag.bindAsEventListener(this));this.close.observe("click",this.toggleShow.bindAsEventListener(this));this.close.observe("mousedown",A);this.pin.observe("click",this.togglePin.bindAsEventListener(this));this.pin.observe("mousedown",A);this.bg.observe("mouseover",this.showAuto.bindAsEventListener(this));this.bg.observe("mouseout",this.hideAuto.bindAsEventListener(this));this.view.observe("mousedown",this.moveStartDrag.bindAsEventListener(this))},restore:function(B,C,A){if(B){this.width=Math.min(B,this.maxPanelWidth)}this.setVisible(C);this.setWidth(C?this.width:Panel.MIN_WIDTH);this.setPinned(A)},layout:function(){var A=this.canvasView.getDimensions();this.view.setStyle({"left":this.mapCanvasToPanelX(g_origin.x)+"px","top":this.mapCanvasToPanelY(g_origin.y)+"px","width":(this.mapCanvasToPanelX(A.width)+1)+"px","height":(this.mapCanvasToPanelY(A.height)+1)+"px"});this.viewSize=this.view.getDimensions()},adjustWidth:function(){if(!this.visible){return }var A=this.bg.getWidth();if(A>(Panel.MAX_WITH_CALENDAR_WIDTH+Panel.MAX_WITHOUT_CALENDAR_WIDTH)/2){A=Panel.MAX_WITH_CALENDAR_WIDTH}else{if(A>(Panel.MAX_WITHOUT_CALENDAR_WIDTH+Panel.MIN_WIDTH)/2){A=Panel.MAX_WITHOUT_CALENDAR_WIDTH}else{A=Panel.MIN_WIDTH}}A=Math.min(this.maxPanelWidth,A);this.setWidth(A);this.width=A;saveLocalPreferences()},resizeStartDrag:function(C){if(!C.isLeftClick()){return }if(this.resizing){this.resizeEndDrag(C)}var D=this.grip.cumulativeOffset();var B=this.resizeDrag.bindAsEventListener(this);var A=this.resizeEndDrag.bindAsEventListener(this);this.resizing=new PanelResizing(C.pointerX()-D.left,B,A);Event.observe(document,"mousemove",B);Event.observe(document,"mouseup",A);C.stop()},resizeEndDrag:function(A){this.resizeDrag(A);this.setVisible(true);this.adjustWidth();g_dock.adjustWidth();Event.stopObserving(document,"mousemove",this.resizing.move);Event.stopObserving(document,"mouseup",this.resizing.up);this.resizing=null},resizeDrag:function(B){var A=Math.min(this.maxPanelWidth,Math.max(Panel.MIN_WIDTH,getWindowWidth()-(B.pointerX()-this.resizing.offsetX)));this.setWidth(A);B.stop()},toggleShow:function(){if(this.visible){this.hide()}else{this.show()}saveLocalPreferences()},show:function(){if(this.visible){return }this.changeWidth(Panel.MIN_WIDTH,function(A){return A>=this.width?null:Math.min(A+20,this.width)}.bind(this));this.setVisible(true)},hide:function(){if(!this.visible){return }this.changeWidth(this.width,function(A){return A<=Panel.MIN_WIDTH?null:Math.max(A-20,Panel.MIN_WIDTH)}.bind(this));this.setVisible(false)},changeWidth:function(B,A){if(this.showingTimer){clearTimeout(this.showingTimer)}var C=function(){this.setWidth(B);B=A(B);if(B){this.showingTimer=setTimeout(C,10)}else{g_dock.adjustWidth();this.showingTimer=null}}.bind(this);this.showingTimer=setTimeout(C,10)},togglePin:function(){this.setPinned(!this.pinned)},setPinned:function(A){this.pinned=A;if(A){IE6.addClassName(this.pin,"pinned","panelPinButton","panelPinnedButton");this.close.show()}else{IE6.removeClassName(this.pin,"pinned","panelPinButton","panelPinnedButton");this.close.hide()}saveLocalPreferences()},isPinned:function(){return this.pinned},getWidth:function(){return this.width},setWidth:function(A){this.bg.setStyle({"width":A+"px"});if(A>Panel.MAX_WITHOUT_CALENDAR_WIDTH){this.calendar.show()}else{this.calendar.hide()}},isVisible:function(){return this.visible},setVisible:function(A){this.visible=A;if(A){IE6.removeClassName(this.close,"closed","panelOpenButton","panelCloseButton")}else{IE6.addClassName(this.close,"closed","panelOpenButton","panelCloseButton")}saveLocalPreferences()},showAuto:function(A){if(!this.pinned&&!this.showingTimer){if(this.preHideTimer){clearTimeout(this.preHideTimer);this.preHideTimer=null}this.show()}},hideAuto:function(A){if(Position.within(this.bg,A.pointerX(),A.pointerY())){return }if(!this.pinned&&!this.resizing){if(!this.preHideTimer){this.preHideTimer=setTimeout(this.hide.bind(this),500)}}},within:function(A,B){return Position.within(this.bg,A,B)},moveStartDrag:function(E){if(!E.isLeftClick()){return }if(this.moving){moveEndDrag(E)}var F=this.view.cumulativeOffset();var B=this.moveDrag.bindAsEventListener(this);var A=this.moveEndDrag.bindAsEventListener(this);this.moving=new PanelMoving(E.pointerX()-F.left,E.pointerY()-F.top,B,A);var D=this.view.positionedOffset();var C=this.view.getDimensions();this.movingView.setStyle({"left":D.left+"px","top":D.top+"px","width":C.width+"px","height":C.height+"px"});this.movingView.show();Event.observe(document,"mousemove",B);Event.observe(document,"mouseup",A);E.stop()},moveEndDrag:function(A){var B=this.parentSize.width-this.viewSize.width;var E=this.parentSize.height-this.viewSize.height;var I=this.movingView.getOffsetParent().cumulativeOffset();var D=Math.max(0,Math.min(B,A.pointerX()-I.left-this.moving.offsetX));var K=Math.max(0,Math.min(E,A.pointerY()-I.top-this.moving.offsetY));var M=D==B?CANVAS_SIZE.width-this.canvasView.getDimensions().width:D*CANVAS_SIZE.width/Panel.SIZE.width;var J=K==E?CANVAS_SIZE.height-this.canvasView.getDimensions().height:K*CANVAS_SIZE.height/Panel.SIZE.height;var L=new Array(10);var O=M-g_origin.x;var N=J-g_origin.y;var H=Math.max(1,Math.min(10,Math.floor(Math.log(Math.sqrt(O*O+N*N)))));for(var C=1;C<H;++C){L[C-1]={"x":g_origin.x+Math.floor((M-g_origin.x)*C/H),"y":g_origin.y+Math.floor((J-g_origin.y)*C/H)}}L[H-1]={"x":M,"y":J};var G=0;var F=function(){setOrigin(L[G]["x"],L[G]["y"]);if(G<H-1){++G;this.movingTimer=window.setTimeout(F,0)}else{this.movingView.hide();this.movingTimer=null}}.bind(this);if(this.movingTimer){window.clearTimeout(this.movingTimer)}this.movingTimer=window.setTimeout(F,0);Event.stopObserving(document,"mousemove",this.moving.move);Event.stopObserving(document,"mouseup",this.moving.up);this.moving=null},moveDrag:function(A){var D=this.movingView.getOffsetParent().cumulativeOffset();var C=Math.max(0,Math.min(this.parentSize.width-this.viewSize.width,A.pointerX()-D.left-this.moving.offsetX));var B=Math.max(0,Math.min(this.parentSize.height-this.viewSize.height,A.pointerY()-D.top-this.moving.offsetY));this.movingView.setStyle({"left":C+"px","top":B+"px"});A.stop()},getCalendar:function(){return this.calendar},initializeEntry:function(A){var B=this.getEntryElemFromId(A.id);B.entry=A},insertEntryElem:function(A){var B=$("panelEntryTemplate").cloneNode(true);this.setEntryId(B,A.id);this.panel.appendChild(B);this.fillEntryElem(B,A);if(A.maskStatus!=0){B.setStyle({"opacity":0.3})}else{if(A.image||A.movie){B.setStyle({"opacity":0.5})}}B.show()},updateEntryElem:function(A){this.fillEntryElem(this.getEntryElemFromId(A.id),A)},removeEntryElem:function(A){this.getEntryElemFromId(A).remove()},showEntryElem:function(A){var B=this.getEntryElemFromId(A);if(B){B.show()}},hideEntryElem:function(A){var B=this.getEntryElemFromId(A);if(B){B.hide()}},maskEntryElem:function(A){var B=this.getEntryElemFromId(A);if(B){B.setStyle({"opacity":0.3})}},unmaskEntryElem:function(A){var C=this.getEntryElemFromId(A);var B=C.entry;C.setStyle({"opacity":(B.image||B.movie)?0.5:1})},fillEntryElem:function(B,A){B.entry=A;B.setStyle({"left":this.mapCanvasToPanelX(A.left)+"px","top":this.mapCanvasToPanelY(A.top)+"px","width":this.mapCanvasToPanelX(A.width)+"px","height":this.mapCanvasToPanelY(A.height)+"px","zIndex":A.zIndex,"backgroundColor":A.isFlag(Entry.FLAG_PANEL)?Entry.getSolidColor(A.color):"transparent"})},setZIndex:function(A,C){var B=this.getEntryElemFromId(A);if(B){B.setStyle({"zIndex":C})}},setEntryId:function(B,A){B.setAttribute("id","pentry"+A)},getEntryElemFromId:function(A){return $("pentry"+A)},isInside:function(A,B){if(this.isVisible()){if(Position.within(this.panel,A,B)){return true}}return false},mapScreenPanelPosToCanvasPos:function(A,C){var B=this.panel.cumulativeOffset();return new Point(this.mapPanelToCanvasX(A-B.left),this.mapPanelToCanvasY(C-B.top))},mapPanelToCanvasX:function(A){return Math.floor(A*CANVAS_SIZE.width/Panel.SIZE.width)},mapPanelToCanvasY:function(A){return Math.floor(A*CANVAS_SIZE.height/Panel.SIZE.height)},mapCanvasToPanelX:function(A){return Math.floor(A*Panel.SIZE.width/CANVAS_SIZE.width)},mapCanvasToPanelY:function(A){return Math.floor(A*Panel.SIZE.height/CANVAS_SIZE.height)}});Panel.SIZE=new Size(106,79);Panel.MIN_WIDTH=27;Panel.MAX_WITH_CALENDAR_WIDTH=308;Panel.MAX_WITHOUT_CALENDAR_WIDTH=158;var PanelMoving=Class.create({offsetX:null,offsetY:null,move:null,up:null,initialize:function(B,D,C,A){this.offsetX=B;this.offsetY=D;this.move=C;this.up=A}});var PanelCalendar=Class.create({elem:null,date:null,visible:false,initialize:function(A,B){this.elem=A;this.date=null;this.visible=B;if(this.visible){this.build(getTodayDate());this.elem.$$$(".nav .prev").observe("click",function(){var C=this.date;C.setDate(C.getDate()-3*7);this.build(C)}.bindAsEventListener(this));this.elem.$$$(".nav .next").observe("click",function(){var C=this.date;C.setDate(C.getDate()+3*7);this.build(C)}.bindAsEventListener(this));this.elem.$$$(".nav .today").observe("click",function(){this.build(getTodayDate())}.bindAsEventListener(this))}else{this.elem.hide()}},show:function(){this.elem.show()},hide:function(){this.elem.hide()},build:function(B){this.date=new Date(B.getTime());var H=B.getFullYear();var E=B.getMonth();B=this.getStartDate(B);this.elem.$$("title").update2(formatYearMonth(H,E));var K=this.elem.$$$("tbody");K.removeAllChildren();var I=getTodayDate();for(var J=0;J<4;++J){var G=new Element("tr");for(var F=0;F<7;++F){var C=new Element("td");var A=new Element("div");C.appendChild(A);A.appendChild(document.createTextNode(B.getDate()));C.addClassName("day");A.addClassName("day"+formatDate(B));if(B.getMonth()==E){C.addClassName("thisMonth")}switch(B.getDay()){case 0:C.addClassName("sunday");break;case 6:C.addClassName("saturday");break}if(isSameDay(B,I)){C.addClassName("today")}var D=getHolidayName(B);if(D){C.addClassName("holiday");C.setAttribute("title",D)}G.appendChild(C);B.setDate(B.getDate()+1)}K.appendChild(G)}this.refresh.bind(this).delay(0.1)},rebuild:function(){if(this.visible){this.build(this.date)}},mark:function(A){if(!this.visible){return }var B=$("dueEntriesForm");B.year.value=A.getFullYear();B.month.value=A.getMonth()+1;B.day.value=A.getDate();B.days.value=4*7;new AjaxUtil().get("/api/entry/dueEntries",B,this.update.bind(this,A),error)},update:function(D,B){if(!isSameDay(this.getStartDate(this.date),D)){return }this.elem.select(".day").each(function(E){var F=E.$$$("div");F.removeClassName("due");F.removeClassName("overdue");F.removeClassName("todaydue");F.stopObserving("click");F.title=F.up("td").getAttribute("title")});var A=getTodayDate().getTime();var C=null;B.each(function(H){var E=H.date;var G=this.elem.$$("day"+E);var F=parseDate(E).getTime();G.addClassName(F==A?"todaydue":F<A?"overdue":"due");G.title+=(G.title.length!=0?" ":"")+H.subject;if(E!=C){G.observe("click",this.handler.bindAsEventListener(this))}C=E}.bind(this))},handler:function(B){var A=B.element();A.classNames().find(function(D){return D.match(/day(\d+)-(\d+)-(\d+)/)});var C=g_userId==0?g_canvasId:null;getSearch().searchByDueDate(RegExp.$1,RegExp.$2-1,RegExp.$3,C)},refresh:function(){if(this.visible){this.mark(this.getStartDate(this.date))}},getStartDate:function(A){var B=new Date(A.getTime());while(B.getDay()!=0){B.setDate(B.getDate()-1)}B.setDate(B.getDate()-7);return B}});var PanelResizing=Class.create({offsetX:null,move:null,up:null,initialize:function(B,C,A){this.offsetX=B;this.move=C;this.up=A}});var DialogsStub=Class.create({initialize:function(){this.dialogs=null;this.elem=null;this.func=null},isDialogVisible:function(){return this.dialogs&&this.dialogs.isDialogVisible()},bind:function(A){if(this.dialogs){A(this.dialogs)}else{this.func=A;if(!this.elem){this.elem=new Element("div");document.body.appendChild(this.elem);new Ajax.Request("/canvashelper/dialogs",{"method":"get","parameters":{"canvasId":g_canvasId},"onSuccess":function(C){this.elem.innerHTML=C.responseText;var B=new Element("script",{"type":"text/javascript","src":"/script/canvas/dialog.js.5136"});document.body.appendChild(B)}.bind(this)})}}},getDialogs:function(){return this.dialogs},loadDialogs:function(){this.dialogs=new Dialogs();this.func(this.dialogs);this.func=null}});var g_dialogsStub=new DialogsStub();var Popup=Class.create({canvasView:null,elem:null,dueCalendar:null,friendList:null,canvasList:null,iconList:null,initialize:function(A){this.canvasView=A;this.elem=$("popupBg");this.elem.observe("click",function(D){var B=D.pointerX();var F=D.pointerY();var C=this.elem.select(".popup");for(var E=0;E<C.length;++E){if(C[E].visible()&&Position.within(C[E],B,F)){return }}C.each(Element.hide);this.hide()}.bindAsEventListener(this));Event.observe(window,"resize",this.adjustBgSize.bindAsEventListener(this))},showDueCalendar:function(C,B,D,A){if(!this.dueCalendar){this.dueCalendar=new DueCalendar(this,$("dueCalendar"))}return this.dueCalendar.show(C,B,D,A)},showFriendList:function(B,A,C){return this.showFriendList2(A,C,function(E,D){if(!confirm(new Template(MESSAGES["confirm.sendEntry"]).evaluate({"name":D}))){return }sendEntry(B.id,E)},function(){g_dialogsStub.bind(function(D){D.showSendEntryDialog(B)})})},showFriendList2:function(A,D,B,C){if(!this.friendList){this.friendList=new FriendList(this,$("friendList"))}return this.friendList.show(A,D,B,C)},showCanvasList:function(B,A,C){if(!this.canvasList){this.canvasList=new CanvasList(this,$("canvasList"))}return this.canvasList.show(B,A,C)},showIconList:function(A,C,B){if(!this.iconList){this.iconList=new IconList(this,$("iconList"))}return this.iconList.show(A,C,B)},show:function(){this.adjustBgSize();this.elem.show();if(Prototype.Browser.IE6){$(document.body).select("select").each(function(A){A.setStyle({"visibility":"hidden"})})}},hide:function(){this.elem.hide();if(Prototype.Browser.IE6){$(document.body).select("select").each(function(A){A.setStyle({"visibility":"visible"})})}},adjustPosition:function(D,A,F){if(this.canvasView){var B=D.getDimensions();var C=this.canvasView.getDimensions();var E=new Point(Math.min(A,C.width-B.width-10),Math.min(F,C.height-B.height-10));D.setStyle({"left":E.x+"px","top":E.y+"px"})}else{D.setStyle({"left":A+"px","top":F+"px"})}},adjustBgSize:function(){this.elem.setStyle({"width":getWindowWidth()+"px","height":getWindowHeight()+"px"})}});var DueCalendar=Class.create(MiniCalendar,{popup:null,setFunc:null,initialize:function(B,D){this.popup=B;var A=function(H,F,G){this.setFunc(H,F,G);this.hide()}.bind(this);MiniCalendar.prototype.initialize.apply(this,[D,A,null]);var E=D.$$("miniCalendarFooter");E.innerHTML='<span class="none">'+MESSAGES["canvas.dueCalendar.none"]+"</span>";var C=E.$$("none");C.observe("mouseover",function(){C.addClassName("selected")});C.observe("mouseout",function(){C.removeClassName("selected")});C.observe("click",function(){this.setFunc();this.hide()}.bindAsEventListener(this))},show:function(C,B,E,A){C=C||getTodayDate();this.setDate(C,C);this.setFunc=A;var D=this.element();D.show();this.popup.show();this.popup.adjustPosition(D,B,E);this.layoutBackground()},hide:function(){this.element().hide();this.popup.hide()}});var FriendList=Class.create({popup:null,elem:null,menu:null,initialize:function(B,C){this.popup=B;this.elem=C;this.menu=new Menu(C);if(Prototype.Browser.IE6){var A=this.elem.$$("otherFriends");A.observe("mouseover",function(){A.addClassName("otherFriendsHover")});A.observe("mouseout",function(){A.removeClassName("otherFriendsHover")})}},show:function(B,F,C,E){var D=this.elem.$$("friends");new AjaxUtil().get("/api/user/buddies",null,function(H){D.innerHTML="";H.each(function(J,L){if(L!=0){var I=new Element("div");I.addClassName("menuSeparator");D.appendChild(I)}var K=new Element("div");K.addClassName("friend");K.innerHTML='<img class="icon" src="/user/icon/'+J.id+'" /><img src="/image/iconseparator.png" />'+J.name.escapeHTML();D.appendChild(K);K.observe("click",function(){C(J.id,J.name);this.hide()}.bindAsEventListener(this));if(Prototype.Browser.IE6){K.observe("mouseover",function(){K.addClassName("friendHover")});K.observe("mouseout",function(){K.removeClassName("friendHover")})}},this);if(Prototype.Browser.IE6){var G=this.elem.$$("friendsScroll");if(G.getHeight()>300){G.setStyle({"height":"300px"})}}this.popup.adjustPosition(this.elem,B,F);this.menu.layout()}.bind(this),function(){});D.innerHTML="Loading ...";var A=this.elem.$$("otherFriends");if(E){A.stopObserving("click");A.observe("click",function(){this.hide();E()}.bindAsEventListener(this));A.show()}else{A.hide()}if(Prototype.Browser.IE6){this.elem.$$("friendsScroll").setStyle({"height":"auto"})}this.elem.show();this.popup.show();this.popup.adjustPosition(this.elem,B,F);this.menu.layout()},hide:function(){this.elem.hide();this.popup.hide()}});var CanvasList=Class.create({popup:null,elem:null,menu:null,initialize:function(A,B){this.popup=A;this.elem=B;this.menu=new Menu(B)},show:function(C,A,D){var B=this.elem.$$("canvases");new AjaxUtil().get("/api/canvas/getWritables",null,function(F){B.innerHTML="";F.each(function(H,K){if(K!=0){var G=new Element("div");G.addClassName("menuSeparator");B.appendChild(G)}var J=new Element("div");J.addClassName("canvas");var I="<div>"+H.name.escapeHTML()+"</div>";if(H.groupId){I+='<div class="group">at '+H.group.escapeHTML()+"</div>"}else{if(H.ownerId!=g_userId){I+='<div class="owner">by '+H.owner.escapeHTML()+"</div>"}}J.innerHTML=I;B.appendChild(J);J.observe("click",function(){if(!C.intimate||H.ownerId==g_userId||confirm(MESSAGES["confirm.copyPrivateEntry"])){copyEntry(C,H.id)}this.hide()}.bindAsEventListener(this));if(Prototype.Browser.IE6){J.observe("mouseover",function(){J.addClassName("canvasHover")});J.observe("mouseout",function(){J.removeClassName("canvasHover")})}},this);if(Prototype.Browser.IE6){var E=this.elem.$$("canvasesScroll");if(E.getHeight()>300){E.setStyle({"height":"300px"})}}this.popup.adjustPosition(this.elem,A,D);this.menu.layout()}.bind(this),function(){});B.innerHTML="Loading ...";if(Prototype.Browser.IE6){this.elem.$$("canvasesScroll").setStyle({"height":"auto"})}this.elem.show();this.popup.show();this.popup.adjustPosition(this.elem,A,D);this.menu.layout()},hide:function(){this.elem.hide();this.popup.hide()}});var IconList=Class.create({popup:null,elem:null,func:null,initialize:function(A,D){this.popup=A;this.elem=D;var F=function(H){var G=H.element().classNames().grep(/icon[0-9]+/)[0].substring(4);this.func(parseInt(G,10));this.hide()}.bindAsEventListener(this);var E=function(H){var G=H.element();G.setStyle({"backgroundPosition":G.getStyle("backgroundPosition").split(" ")[0]+" -24px"})}.bindAsEventListener(this);var C=function(H){var G=H.element();G.setStyle({"backgroundPosition":G.getStyle("backgroundPosition").split(" ")[0]+" -0px"})}.bindAsEventListener(this);this.elem.select(".icon").each(function(G){G.observe("click",F);G.observe("mouseover",E);G.observe("mouseout",C)});var B=this.elem.$$("iconNone");B.observe("click",function(){this.func(0);this.hide()}.bindAsEventListener(this));if(Prototype.Browser.IE6){B.observe("mouseover",function(){B.addClassName("iconNoneHover")});B.observe("mouseout",function(){B.removeClassName("iconNoneHover")})}},show:function(A,C,B){this.func=B;this.elem.show();this.popup.show();this.popup.adjustPosition(this.elem,A,C);this.layoutBackground()},hide:function(){this.elem.hide();this.popup.hide()},layoutBackground:function(){var A=this.elem.getDimensions();this.elem.$$("iconListBgBody").setStyle({"width":Math.max(A.width-7*2,0)+"px","height":Math.max(A.height-7,0)+"px"});this.elem.$$("iconListBgLeft").setStyle({"height":Math.max(A.height-7,0)+"px"});this.elem.$$("iconListBgRight").setStyle({"height":Math.max(A.height-7,0)+"px"});this.elem.$$("iconListBgBottom").setStyle({"width":Math.max(A.width-7*2,0)+"px"})}});var Search=Class.create({canvasView:null,result:null,initialize:function(A){this.canvasView=A;this.result=$("searchResult");this.result.observe("click",function(){this.hide()}.bindAsEventListener(this))},searchByDueDate:function(C,D,A,E){var B="due:"+formatDate(new Date(C,D,A));if(E){B+=" canvasId:"+E}return this.search(B)},search:function(C){var B=$("searchForm");B.condition.value=C;var A=this.canvasView.getDimensions();B.width.value=A.width;B.height.value=A.height;new AjaxUtil().get("/api/entry/search",B,this.searched.bind(this),error)},searched:function(A){leaveNewEntryMode();hideMovie();this.result.show();A.entries.each(function(B){B.canvas=A.canvases.find(function(D){return D.id==B.canvasId});var C=$("searchEntryTemplate").cloneNode(true);if(B.image||B.attachment){C.$$("body").setStyle({"padding":"0px 15px"})}if(!B.image){C.$$("image").remove()}if(B.image||!B.attachment){C.$$("attachment").remove()}this.result.appendChild(C);Entry.bind(B,C);C.removeAttribute("id");B.fill();B.updatePosition();C.observe("click",this.showEntry.bindAsEventListener(this));C.show();B.updateBackgroundSize()}.bind(this))},hide:function(){this.result.innerHTML="";this.result.hide();showMovie()},showEntry:function(B){var A=getEntryElemFromChild(B.element()).entry;if(A.canvasId==g_canvasId){var C=getEntryElemFromId(A.id);if(C){ensureEntryElemVisible(C)}}else{if(A.canvas){openAtTop(canvasPath(A.canvas)+"#e"+A.id)}}this.hide()}});var Mark=Class.create({initialize:function(D,C,B,A){this.image=D;this.left=C;this.top=B;this.delay=A}});var EffectAction=Class.create({initialize:function(A,B){this.name=A;this.marks=B}});var screwUpAction=new EffectAction("screwup",[new Mark(1,0,0,80),new Mark(2,0,0,80),new Mark(3,0,0,80)]);var flickAction=new EffectAction("flick",[new Mark(1,-30,0,80),new Mark(2,-35,0,80),new Mark(3,-80,-45,80),new Mark(3,-150,-50,80),new Mark(3,-250,-50,80)]);function effect(F,B,A){var G=$("effect").cloneNode(true);$("canvas").appendChild(G);var D=F.positionedOffset();var I=F.getDimensions();var H=Math.min(I.width,I.height);D.left=Math.floor(D.left+(I.width-H)/2);D.top=Math.floor(D.top+(I.height-H)/2);G.setStyle({"left":D.left+"px","top":D.top+"px","width":H+"px","height":H+"px","opacity":1});function E(J){return function(){var K=B.marks[J];G.src="/image/entry/"+B.name+"/"+F.entry.color+"/"+K.image+".png";G.setStyle({"left":(D.left+K.left)+"px","top":(D.top+K.top)+"px"});if(J<B.marks.length-1){E(J+1).delay(K.delay/1000)}else{C(10)()}if(J==0){if(Prototype.Browser.IE){F.select(".bg *").each(function(L){if(!L.hasClassName("bgCenter")){L.hide()}})}F.setStyle({"opacity":0.5})}else{if(J==1){F.hide()}}}}function C(J){return function(){$("effect").setStyle({"opacity":J/10});if(J!=0){C(J-1).delay(0.05)}else{G.remove();A()}}}G.show();E(0)()}