jade.require("jade.Object");jade.Application=function(){jade.Object.call(this,null,"application");
this.updateClientSize();this.updateScrollPos();this.setupEvents()};jade.inherit(jade.Application,jade.Object);
jade.Application.instance=null;jade.Application.prototype.clientWidth=0;jade.Application.prototype.clientHeight=0;
jade.Application.prototype.scrollLeft=0;jade.Application.prototype.scrollTop=0;jade.Application.prototype.mouseInApplication=false;
jade.Application.prototype.mouseCapturer=null;jade.Application.prototype.dragSource=null;
jade.Application.prototype.oldOnSelectStart=null;jade.Application.prototype.pageLoaded=false;
jade.Application.prototype.imagesNeedAlphaHack=false;jade.Application.getInstance=function(){return this.instance
};jade.Application.prototype.setupEvents=function(){if(window.attachEvent){window.attachEvent("onload",this.handleWindowLoad);
window.attachEvent("onbeforeunload",this.handleWindowBeforeUnload);window.attachEvent("onunload",this.handleWindowUnload);
window.attachEvent("onresize",this.handleWindowResize);window.attachEvent("onscroll",this.handleWindowScroll);
document.attachEvent("onmousemove",this.handleWindowMouseMove);document.attachEvent("onmouseout",this.handleWindowMouseOut);
document.attachEvent("onmousedown",this.handleWindowMouseDown);document.attachEvent("onmouseup",this.handleWindowMouseUp);
document.attachEvent("onclick",this.handleWindowClick);document.attachEvent("ondblclick",this.handleWindowDblClick);
document.attachEvent("onkeydown",this.handleWindowKeyDown);document.attachEvent("onkeyup",this.handleWindowKeyUp);
document.attachEvent("onkeypress",this.handleWindowKeyPress)}else{window.addEventListener("load",this.handleWindowLoad,false);
window.addEventListener("unload",this.handleWindowUnload,false);window.addEventListener("beforeunload",this.handleWindowBeforeUnload,false);
window.addEventListener("resize",this.handleWindowResize,false);window.addEventListener("scroll",this.handleWindowScroll,false);
window.addEventListener("mousemove",this.handleWindowMouseMove,false);window.addEventListener("mouseout",this.handleWindowMouseOut,false);
window.addEventListener("mousedown",this.handleWindowMouseDown,false);window.addEventListener("mouseup",this.handleWindowMouseUp,false);
window.addEventListener("click",this.handleWindowClick,false);window.addEventListener("dblclick",this.handleWindowDblClick,false);
window.addEventListener("keydown",this.handleWindowKeyDown,false);window.addEventListener("keyup",this.handleWindowKeyUp,false);
window.addEventListener("keypress",this.handleWindowKeyPress,false)}};jade.Application.prototype.cancelEvent=function(B){B.cancelBubble=true;
if(B.preventDefault){B.preventDefault()}if(B.stopPropagation){B.stopPropagation()
}return false};jade.Application.prototype.handleWindowLoad=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowLoad(B)
}this.updateClientSize();this.updateScrollPos();this.pageLoaded=true;this.sendSignal("load")
};jade.Application.prototype.handleWindowUnload=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowUnload(B)
}this.pageLoaded=false;this.sendSignal("unload")};jade.Application.prototype.handleWindowBeforeUnload=function(D){var C;
if(!(this instanceof jade.Application)){return jade.application.handleWindowBeforeUnload(D)
}C=this.sendQuery("beforeUnload",null);if(C){D.returnValue=C;return C}else{return undefined
}};jade.Application.prototype.handleWindowResize=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowResize(B)
}this.updateClientSize();this.updateScrollPos()};jade.Application.prototype.handleWindowScroll=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowScroll(B)
}this.updateScrollPos()};jade.Application.prototype.handleWindowMouseMove=function(I){var F,G,J,H;
if(!(this instanceof jade.Application)){return jade.application.handleWindowMouseMove(I)
}F=I.pageX!==undefined?I.pageX:I.clientX+this.scrollLeft;G=I.pageY!==undefined?I.pageY:I.clientY+this.scrollTop;
if(F<this.scrollLeft||G<this.scrollTop||F>=this.clientWidth+this.scrollLeft||G>=this.clientHeight+this.scrollTop){if(this.mouseInApplication){this.mouseInApplication=false;
this.sendSignal("mouseLeave")}return }if(!this.mouseInApplication){this.mouseInApplication=true;
this.sendSignal("mouseEnter",F,G)}J=this.mouseCapturer;if(J){H=J.getPagePosition();
J.mouseMove(F-H.x,G-H.y)}else{if(this.dragSource){this.sendSignal("dragOver",F,G,this.dragSource)
}else{this.sendSignal("mouseMove",F,G)}}};jade.Application.prototype.handleWindowMouseOut=function(F){var D,E;
if(!(this instanceof jade.Application)){return jade.application.handleWindowMouseOut(F)
}D=F.pageX!==undefined?F.pageX-this.scrollLeft:F.clientX;E=F.pageY!==undefined?F.pageY-this.scrollTop:F.clientY;
if(this.mouseInApplication&&(D<0||E<0||D>=this.clientWidth||E>=this.clientHeight)){this.mouseInApplication=false;
this.sendSignal("mouseLeave")}};jade.Application.prototype.handleWindowMouseDown=function(F){var D,E;
if(F.button>1){return }if(!(this instanceof jade.Application)){return jade.application.handleWindowMouseDown(F)
}D=F.pageX!==undefined?F.pageX:F.clientX+this.scrollLeft;E=F.pageY!==undefined?F.pageY:F.clientY+this.scrollTop;
this.sendSignal("mouseDown",D,E,F.shiftKey||F.altKey||F.ctrlKey)};jade.Application.prototype.handleWindowMouseUp=function(I){var F,G,J,H;
if(I.button>1){return }if(!(this instanceof jade.Application)){return jade.application.handleWindowMouseUp(I)
}F=I.pageX!==undefined?I.pageX:I.clientX+this.scrollLeft;G=I.pageY!==undefined?I.pageY:I.clientY+this.scrollTop;
J=this.mouseCapturer;if(J){H=J.getPagePosition();if(J.isMouseInWidget()&&(F<H.x||G<H.y||F>H.x+J.getWidth()||G>H.y+J.getHeight())){J.mouseLeave()
}J.mouseUp(F-H.x,G-H.y);this.releaseMouse()}else{if(this.dragSource){this.dragSource.endDrag()
}this.sendSignal("mouseUp",F,G)}};jade.Application.prototype.handleWindowClick=function(F){var D,E;
if(F.button>1){return }if(!(this instanceof jade.Application)){return jade.application.handleWindowClick(F)
}D=F.pageX!==undefined?F.pageX:F.clientX+this.scrollLeft;E=F.pageY!==undefined?F.pageY:F.clientY+this.scrollTop;
this.sendSignal("click",D,E)};jade.Application.prototype.handleWindowDblClick=function(F){var D,E;
if(F.button>1){return }if(!(this instanceof jade.Application)){return jade.application.handleWindowDblClick(F)
}D=F.pageX!==undefined?F.pageX:F.clientX+this.scrollLeft;E=F.pageY!==undefined?F.pageY:F.clientY+this.scrollTop;
this.sendSignal("dblClick",D,E)};jade.Application.prototype.handleWindowKeyDown=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowKeyDown(B)
}if(!this.sendSignal("keyDown",B.keyCode)){return this.cancelEvent(B)}};jade.Application.prototype.handleWindowKeyUp=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowKeyUp(B)
}if(!this.sendSignal("keyUp",B.keyCode)){return this.cancelEvent(B)}};jade.Application.prototype.handleWindowKeyPress=function(B){if(!(this instanceof jade.Application)){return jade.application.handleWindowKeyPress(B)
}if(!this.sendSignal("keyPress",B.keyCode,B.charCode)){return this.cancelEvent(B)
}};jade.Application.prototype.filterResults=function(F,G,H){var E;E=F;if(G&&(!E||G<E)){E=G
}if(H&&(!E)){E=H}return E};jade.Application.prototype.updateClientSize=function(){var D,C;
D=this.clientWidth;C=this.clientHeight;this.clientWidth=this.filterResults(window.innerWidth?window.innerWidth:0,document.documentElement?document.documentElement.clientWidth:0,document.body?document.body.clientWidth:0);
this.clientHeight=this.filterResults(window.innerHeight?window.innerHeight:0,document.documentElement?document.documentElement.clientHeight:0,document.body?document.body.clientHeight:0);
if(this.clientWidth!=D||this.clientHeight!=C){this.sendSignal("resize")}};jade.Application.prototype.updateScrollPos=function(){var D,C;
D=this.scrollLeft;C=this.scrollTop;this.scrollLeft=this.filterResults(window.pageXOffset?window.pageXOffset:0,document.documentElement?document.documentElement.scrollLeft:0,document.body?document.body.scrollLeft:0);
this.scrollTop=this.filterResults(window.pageYOffset?window.pageYOffset:0,document.documentElement?document.documentElement.scrollTop:0,document.body?document.body.scrollTop:0);
if(this.scrollLeft!=D||this.scrollTop!=C){this.sendSignal("scroll")}};jade.Application.prototype.getClientWidth=function(){return this.clientWidth
};jade.Application.prototype.getClientHeight=function(){return this.clientHeight};
jade.Application.prototype.getScrollLeft=function(){return this.scrollLeft};jade.Application.prototype.getScrollTop=function(){return this.scrollTop
};jade.Application.prototype.getContentWidth=function(){if(window.scrollMaxX){return this.clientWidth+window.scrollMaxX
}else{if(document.body.scrollWidth>document.body.offsetWidth){return document.body.scrollWidth
}else{return document.body.offsetWidth+document.body.offsetLeft}}};jade.Application.prototype.getContentHeight=function(){if(window.scrollMaxY){return this.clientHeight+window.scrollMaxY
}else{if(document.body.scrollHeight>document.body.offsetHeight){return document.body.scrollHeight
}else{return document.body.offsetHeight+document.body.offsetTop}}};jade.Application.prototype.getScrollMaxX=function(){if(window.scrollMaxX!==undefined){return window.scrollMaxX
}else{return this.getContentWidth()-this.clientWidth}};jade.Application.prototype.getScrollMaxY=function(){if(window.scrollMaxY){return window.scrollMaxY
}else{return this.getContentHeight()-this.clientHeight}};jade.Application.prototype.scrollTo=function(C,D){window.scrollTo(C,D);
this.updateScrollPos()};jade.Application.prototype.scrollBy=function(D,C){window.scrollBy(D,C);
this.updateScrollPos()};jade.Application.prototype.update=function(){this.updateClientSize();
this.updateScrollPos()};jade.Application.prototype.captureMouse=function(B){if(this.mouseCapturer){this.releaseMouse()
}this.mouseCapturer=B;this.oldOnSelectStart=document.onselectstart;document.onselectstart=function(){return false
};this.sendSignal("mouseCapture",B)};jade.Application.prototype.releaseMouse=function(){var B;
B=this.mouseCapturer;this.mouseCapturer=null;document.onselectstart=this.oldOnSelectStart;
this.oldOnSelectStart=null;this.sendSignal("mouseRelease",B)};jade.Application.prototype.isMouseCaptured=function(B){if(B){return this.mouseCapturer==B
}return this.mouseCapturer!==null};jade.Application.prototype.setCursor=function(B){document.body.style.cursor=B
};jade.Application.prototype.resetCursor=function(){this.setCursor("default")};jade.Application.prototype.getCursor=function(){return document.body.style.cursor
};jade.Application.prototype.isLoaded=function(){return this.pageLoaded};jade.Application.prototype.startDrag=function(B){this.dragSource=B;
this.oldOnSelectStart=document.onselectstart;document.onselectstart=function(){return false
};this.sendSignal("dragStart",B)};jade.Application.prototype.endDrag=function(){var B;
B=this.dragSource;this.dragSource=null;document.onselectstart=this.oldOnSelectStart;
this.oldOnSelectStart=null;this.sendSignal("dragEnd",B)};jade.Application.prototype.isDragging=function(){return this.dragSource!==null
};jade.Application.prototype.getDragSource=function(){return this.dragSource};jade.Application.prototype.setImagesNeedAlphaHack=function(B){this.imagesNeedAlphaHack=B
};jade.Application.prototype.getImagesNeedAlphaHack=function(){return this.imagesNeedAlphaHack
};jade.application=jade.Application.instance=new jade.Application();