var Coordinates={ORIGIN:new Coordinate(0,0),center:function(a){return Coordinates.northwestOffset(a,true).plus(new Coordinate(Math.round(a.offsetWidth/2),Math.round(a.offsetHeight/2)));},scrollOffsetMoz:function(a,c){offset=new Coordinate(a.scrollLeft,a.scrollTop);if(!c){return offset;}var b=a.parentNode;while(b){if(b.nodeName!="BODY"){offset=offset.plus(new Coordinate(b.scrollLeft,b.scrollTop));}else{break;}b=b.parentNode;}return offset;},scrollOffsetIE:function(a,c){if(!a){return new Coordinate(0,0);}offset=new Coordinate(a.scrollLeft,a.scrollTop);if(!c){return offset;}var b=a.offsetParent;while(b){offset=offset.plus(new Coordinate(b.scrollLeft,b.scrollTop));b=b.offsetParent;}return offset;},northwestPosition:function(b){var a=parseInt(b.style.left);var c=parseInt(b.style.top);return new Coordinate(isNaN(a)?0:a,isNaN(c)?0:c);},southeastPosition:function(a){return Coordinates.northwestPosition(a).plus(new Coordinate(a.offsetWidth,a.offsetHeight));},southeastOffset:function(a,b,c){return Coordinates.northwestOffset(a,b,c).plus(new Coordinate(a.offsetWidth,a.offsetHeight));},southeastOffsetIE:function(a,b,c){return Coordinates.northwestOffsetIE(a,b,c).plus(new Coordinate(a.offsetWidth,a.offsetHeight));},fixEvent:function(a){a.windowCoordinate=new Coordinate(a.clientX,a.clientY);}};function Coordinate(a,b){this.x=a;this.y=b;}Coordinate.prototype.toString=function(){return"("+this.x+","+this.y+")";};Coordinate.prototype.plus=function(a){return new Coordinate(this.x+a.x,this.y+a.y);};Coordinate.prototype.minus=function(a){return new Coordinate(this.x-a.x,this.y-a.y);};Coordinate.prototype.distance=function(c){var b=this.x-c.x;var a=this.y-c.y;return Math.sqrt(Math.pow(b,2)+Math.pow(a,2));};Coordinate.prototype.myDistance=function(c){var b=this.x-c.x;var a=this.y-c.y;return new Coordinate(b,a);};Coordinate.prototype.absolute=function(c){c=!c?3:c;if(c&1){var b=Math.abs(this.x);}else{var b=this.x;}if(c&2){var a=Math.abs(this.y);}else{var a=this.y;}return new Coordinate(b,a);};Coordinate.prototype.max=function(b){var a=Math.max(this.x,b.x);var c=Math.max(this.y,b.y);return new Coordinate(a,c);};Coordinate.prototype.constrain=function(c,b){if(c.x>b.x||c.y>b.y){return this;}var a=this.x;var d=this.y;if(c.x!=null){a=Math.max(a,c.x);}if(b.x!=null){a=Math.min(a,b.x);}if(c.y!=null){d=Math.max(d,c.y);}if(b.y!=null){d=Math.min(d,b.y);}return new Coordinate(a,d);};Coordinate.prototype.reposition=function(a){a.style.top=this.y+"px";a.style.left=this.x+"px";};Coordinate.prototype.equals=function(a){if(this==a){return true;}if(!a||a==null){return false;}return this.x==a.x&&this.y==a.y;};Coordinate.prototype.inside=function(b,a){if((this.x>=b.x)&&(this.x<=a.x)&&(this.y>=b.y)&&(this.y<=a.y)){return true;}return false;};Coordinate.prototype.outside=function(b,a){if((this.x<=b.x)||(this.x>=a.x)||(this.y<=b.y)||(this.y>=a.y)){return true;}return false;};Coordinates.northwestOffsetIE=function(a,c,e){e=!!e?e:-1;var d=new Coordinate(a.offsetLeft,a.offsetTop);if(!c){return d;}var b=a.offsetParent;while(b){d=d.plus(new Coordinate(b.offsetLeft+e*b.scrollLeft,b.offsetTop+e*b.scrollTop));b=b.offsetParent;}return d;};Coordinates.northwestOffsetMoz=function(a,c,e){e=!!e?e:-1;var d=new Coordinate(a.offsetLeft,a.offsetTop);if(!c){return d;}var b=a.parentNode;while(b){if(b.nodeName!="BODY"){d=d.plus(new Coordinate(e*b.scrollLeft,e*b.scrollTop));}else{break;}b=b.parentNode;}if(d.x==0&&d.y==0){d=Coordinates.northwestOffsetIE(a,c,e);}return d;};if(browserDetect.bIsIE){Coordinates.northwestOffset=Coordinates.northwestOffsetIE;Coordinates.scrollOffset=Coordinates.scrollOffsetIE;}else{Coordinates.northwestOffset=Coordinates.northwestOffsetMoz;Coordinates.scrollOffset=Coordinates.scrollOffsetMoz;}Coordinates.northwestOffsetAbsolute=function(a,c,e){e=!!e?e:-1;var d=new Coordinate(a.offsetLeft,a.offsetTop);if(!c){return d;}var b=a.parentNode;while(b&&!!a.offsetParent){if(b.nodeName!="BODY"){d=d.plus(new Coordinate(e*b.scrollLeft,e*b.scrollTop));}else{break;}a=b;b=b.parentNode;}return d;};Coordinates.northWestOffset=function(g,f,j,i,h){return this.northwestOffset(g,f,j,i,h);};Coordinates.northWestOffsetIE=function(g,f,j,i,h){return this.northwestOffsetIE(g,f,j,i,h);};Coordinates.northWestOffsetMoz=function(g,f,j,i,h){return this.northwestOffsetMoz(g,f,j,i,h);};Coordinates.northWestOffsetAbsolute=function(g,f,j,i,h){return this.northwestOffsetAbsolute(g,f,j,i,h);};
