/*
 * @require jade/compat/Object.js
 */
jade.compat.Application=function(){jade.compat.Object.call(this,null,"application");
this.updateClientSize();this.updateScrollPos();this.setupEvents()};jade.inherit(jade.compat.Application,jade.compat.Object);
jade.compat.Application.instance=null;jade.compat.Application.prototype.clientWidth=0;
jade.compat.Application.prototype.clientHeight=0;jade.compat.Application.prototype.scrollLeft=0;
jade.compat.Application.prototype.scrollTop=0;jade.compat.Application.prototype.mouseInApplication=false;
jade.compat.Application.prototype.mouseCapturer=null;jade.compat.Application.prototype.dragSource=null;
jade.compat.Application.prototype.oldOnSelectStart=null;jade.compat.Application.prototype.pageLoaded=false;
jade.compat.Application.prototype.imagesNeedAlphaHack=false;jade.compat.Application.getInstance=function(){return this.instance
};jade.compat.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.compat.Application.prototype.cancelEvent=function(a){a.cancelBubble=true;
if(a.preventDefault){a.preventDefault()}if(a.stopPropagation){a.stopPropagation()
}return false};jade.compat.Application.prototype.handleWindowLoad=function(a){if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowLoad(a);
return}this.updateClientSize();this.updateScrollPos();this.pageLoaded=true;this.sendSignal("load")
};jade.compat.Application.prototype.handleWindowUnload=function(a){if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowUnload(a);
return}this.pageLoaded=false;this.sendSignal("unload")};jade.compat.Application.prototype.handleWindowBeforeUnload=function(b){var a;
if(!(this instanceof jade.compat.Application)){return jade.compat.application.handleWindowBeforeUnload(b)
}a=this.sendQuery("beforeUnload",null);if(a){b.returnValue=a;return a}else{return undefined
}};jade.compat.Application.prototype.handleWindowResize=function(a){if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowResize(a);
return}this.updateClientSize();this.updateScrollPos()};jade.compat.Application.prototype.handleWindowScroll=function(a){if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowScroll(a);
return}this.updateScrollPos()};jade.compat.Application.prototype.handleWindowMouseMove=function(c){var a,f,b,d;
if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowMouseMove(c);
return}a=c.pageX!==undefined?c.pageX:c.clientX+this.scrollLeft;f=c.pageY!==undefined?c.pageY:c.clientY+this.scrollTop;
if(a<this.scrollLeft||f<this.scrollTop||a>=this.clientWidth+this.scrollLeft||f>=this.clientHeight+this.scrollTop){if(this.mouseInApplication){this.mouseInApplication=false;
this.sendSignal("mouseLeave")}return}if(!this.mouseInApplication){this.mouseInApplication=true;
this.sendSignal("mouseEnter",a,f)}b=this.mouseCapturer;if(b){d=b.getPagePosition();
b.mouseMove(a-d.x,f-d.y)}else{if(this.dragSource){this.sendSignal("dragOver",a,f,this.dragSource)
}else{this.sendSignal("mouseMove",a,f)}}};jade.compat.Application.prototype.handleWindowMouseOut=function(b){var a,c;
if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowMouseOut(b);
return}a=b.pageX!==undefined?b.pageX-this.scrollLeft:b.clientX;c=b.pageY!==undefined?b.pageY-this.scrollTop:b.clientY;
if(this.mouseInApplication&&(a<0||c<0||a>=this.clientWidth||c>=this.clientHeight)){this.mouseInApplication=false;
this.sendSignal("mouseLeave")}};jade.compat.Application.prototype.handleWindowMouseDown=function(b){var a,c;
if(b.button>1){return}if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowMouseDown(b);
return}a=b.pageX!==undefined?b.pageX:b.clientX+this.scrollLeft;c=b.pageY!==undefined?b.pageY:b.clientY+this.scrollTop;
this.sendSignal("mouseDown",a,c,b.shiftKey||b.altKey||b.ctrlKey)};jade.compat.Application.prototype.handleWindowMouseUp=function(c){var a,f,b,d;
if(c.button>1){return}if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowMouseUp(c);
return}a=c.pageX!==undefined?c.pageX:c.clientX+this.scrollLeft;f=c.pageY!==undefined?c.pageY:c.clientY+this.scrollTop;
b=this.mouseCapturer;if(b){d=b.getPagePosition();if(b.isMouseInWidget()&&(a<d.x||f<d.y||a>d.x+b.getWidth()||f>d.y+b.getHeight())){b.mouseLeave()
}b.mouseUp(a-d.x,f-d.y);this.releaseMouse()}else{if(this.dragSource){this.dragSource.endDrag()
}this.sendSignal("mouseUp",a,f)}};jade.compat.Application.prototype.handleWindowClick=function(b){var a,c;
if(b.button>1){return}if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowClick(b);
return}a=b.pageX!==undefined?b.pageX:b.clientX+this.scrollLeft;c=b.pageY!==undefined?b.pageY:b.clientY+this.scrollTop;
this.sendSignal("click",a,c)};jade.compat.Application.prototype.handleWindowDblClick=function(b){var a,c;
if(b.button>1){return}if(!(this instanceof jade.compat.Application)){jade.compat.application.handleWindowDblClick(b);
return}a=b.pageX!==undefined?b.pageX:b.clientX+this.scrollLeft;c=b.pageY!==undefined?b.pageY:b.clientY+this.scrollTop;
this.sendSignal("dblClick",a,c)};jade.compat.Application.prototype.handleWindowKeyDown=function(a){if(!(this instanceof jade.compat.Application)){return jade.compat.application.handleWindowKeyDown(a)
}if(!this.sendSignal("keyDown",a.keyCode)){return this.cancelEvent(a)}else{return true
}};jade.compat.Application.prototype.handleWindowKeyUp=function(a){if(!(this instanceof jade.compat.Application)){return jade.compat.application.handleWindowKeyUp(a)
}if(!this.sendSignal("keyUp",a.keyCode)){return this.cancelEvent(a)}else{return true
}};jade.compat.Application.prototype.handleWindowKeyPress=function(a){if(!(this instanceof jade.compat.Application)){return jade.compat.application.handleWindowKeyPress(a)
}if(!this.sendSignal("keyPress",a.keyCode,a.charCode)){return this.cancelEvent(a)
}else{return true}};jade.compat.Application.prototype.filterResults=function(d,c,b){var a;
a=d;if(c&&(!a||c<a)){a=c}if(b&&(!a)){a=b}return a};jade.compat.Application.prototype.updateClientSize=function(){var b,a;
b=this.clientWidth;a=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!=b||this.clientHeight!=a){this.sendSignal("resize")}};jade.compat.Application.prototype.updateScrollPos=function(){var b,a;
b=this.scrollLeft;a=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!=b||this.scrollTop!=a){this.sendSignal("scroll")}};jade.compat.Application.prototype.getClientWidth=function(){return this.clientWidth
};jade.compat.Application.prototype.getClientHeight=function(){return this.clientHeight
};jade.compat.Application.prototype.getScrollLeft=function(){return this.scrollLeft
};jade.compat.Application.prototype.getScrollTop=function(){return this.scrollTop
};jade.compat.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.compat.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.compat.Application.prototype.getScrollMaxX=function(){if(window.scrollMaxX!==undefined){return window.scrollMaxX
}else{return this.getContentWidth()-this.clientWidth}};jade.compat.Application.prototype.getScrollMaxY=function(){if(window.scrollMaxY){return window.scrollMaxY
}else{return this.getContentHeight()-this.clientHeight}};jade.compat.Application.prototype.scrollTo=function(a,b){window.scrollTo(a,b);
this.updateScrollPos()};jade.compat.Application.prototype.scrollBy=function(b,a){window.scrollBy(b,a);
this.updateScrollPos()};jade.compat.Application.prototype.update=function(){this.updateClientSize();
this.updateScrollPos()};jade.compat.Application.prototype.captureMouse=function(a){if(this.mouseCapturer){this.releaseMouse()
}this.mouseCapturer=a;this.oldOnSelectStart=document.onselectstart;document.onselectstart=function(){return false
};this.sendSignal("mouseCapture",a)};jade.compat.Application.prototype.releaseMouse=function(){var a;
a=this.mouseCapturer;this.mouseCapturer=null;document.onselectstart=this.oldOnSelectStart;
this.oldOnSelectStart=null;this.sendSignal("mouseRelease",a)};jade.compat.Application.prototype.isMouseCaptured=function(a){if(a){return this.mouseCapturer==a
}return this.mouseCapturer!==null};jade.compat.Application.prototype.setCursor=function(a){document.body.style.cursor=a
};jade.compat.Application.prototype.resetCursor=function(){this.setCursor("default")
};jade.compat.Application.prototype.getCursor=function(){return document.body.style.cursor
};jade.compat.Application.prototype.isLoaded=function(){return this.pageLoaded};jade.compat.Application.prototype.startDrag=function(a){this.dragSource=a;
this.oldOnSelectStart=document.onselectstart;document.onselectstart=function(){return false
};this.sendSignal("dragStart",a)};jade.compat.Application.prototype.endDrag=function(){var a;
a=this.dragSource;this.dragSource=null;document.onselectstart=this.oldOnSelectStart;
this.oldOnSelectStart=null;this.sendSignal("dragEnd",a)};jade.compat.Application.prototype.isDragging=function(){return this.dragSource!==null
};jade.compat.Application.prototype.getDragSource=function(){return this.dragSource
};jade.compat.Application.prototype.setImagesNeedAlphaHack=function(a){this.imagesNeedAlphaHack=a
};jade.compat.Application.prototype.getImagesNeedAlphaHack=function(){return this.imagesNeedAlphaHack
};jade.compat.application=jade.compat.Application.instance=new jade.compat.Application();