if(!window.Node){window.Node={};Node.ELEMENT_NODE=1;Node.ATTRIBUTE_NODE=2;Node.TEXT_NODE=3;Node.CDATA_SECTION_NODE=4;Node.ENTITY_REFERENCE_NODE=5;Node.ENTITY_NODE=6;Node.PROCESSING_INSTRUCTION_NODE=7;Node.COMMENT_NODE=8;Node.DOCUMENT_NODE=9;Node.DOCUMENT_TYPE_NODE=10;Node.DOCUMENT_FRAGMENT_NODE=11;Node.NOTATION_NODE=12}if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}var ProtoJS={Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1),Opera:navigator.userAgent.indexOf("Opera")>-1,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},MAX_DUMP_DEPTH:10,dump:function dump(g,c,a,h){c=c||"";a=a||"";h=h||0;if(h>ProtoJS.MAX_DUMP_DEPTH){return a+c+": <Maximum Depth Reached>\n"}if(typeof g=="object"){var k=null;var b=a+c+"\n";a+="\t";for(var d in g){try{k=g[d]}catch(f){k="<Unable to Evaluate>"}if(d.substring(0,1)=="_"){}else{if(typeof k=="function"){}else{if(typeof k=="object"){b+=ProtoJS.dump(k,d,a,h+1)}else{b+=a+d+": "+k+"\n"}}}}return b}else{return g}}};if(typeof console=="undefined"){console={log:function(){}}}ProtoJS.mix=function(b,a,d){d=d||false;for(var c in b){if(d||!a[c]){a[c]=b[c]}else{console.log("ProtoJS: Found an implementation for "+c)}}};ProtoJS.Event={observe:function(b,a,c){if(!b){console.log("WARN: passed invalid element to ProtoJS.Event.observe.")}else{if(b.addEventListener){b.addEventListener(a,c,false)}else{b.attachEvent("on"+a,c)}}return b},enable:function enable(a){ProtoJS.mix(ProtoJS.Event.Handling,a)}};ProtoJS.Event.Handling={on:function on(b,a){if(!this.eventHandlers){this.eventHandlers=[]}if(!this.eventHandlers[b]){this.eventHandlers[b]=[]}this.eventHandlers[b].push(a)},fireEvent:function fireEvent(a,b){if(!this.eventHandlers){return}if(this.eventHandlers[a]){this.eventHandlers[a].iterate(function(c){c(b)})}}};ProtoJS.Object={isArray:function(a){a=a||this;return a!=null&&typeof a=="object"&&"splice" in a&&"join" in a},isHash:function(a){a=a||this;return a instanceof Hash},isFunction:function(a){a=a||this;return typeof a=="function"},isString:function(a){a=a||this;return typeof a=="string"},isNumber:function(a){a=a||this;return typeof a=="number"},isUndefined:function(a){return typeof a=="undefined"}};ProtoJS.mix(ProtoJS.Object,Object);ProtoJS.String={contains:function contains(a){return this.indexOf(a)>-1},containsOneOf:function containsOneOf(b){var a=false;b.iterate(function(c){a=a||this.contains(c)}.scope(this));return a},trim:function trim(a){if(typeof this.replace=="function"){a=this}return a.replace(/^\s*/,"").replace(/\s*$/,"")},isArray:function isArray(){return false},isHash:function isHash(){return false},isFunction:function isFunction(){return false},isString:function isString(){return true},isNumber:function isNumber(){return false}};ProtoJS.mix(ProtoJS.String,String.prototype);ProtoJS.Number={isArray:function(){return false},isHash:function(){return false},isFunction:function(){return false},isString:function(){return false},isNumber:function(){return true}};ProtoJS.mix(ProtoJS.Number,Number.prototype);(function(){var a=false,b=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(h){var g=this.prototype;a=true;var f=new this();a=false;function c(k,l){return function(){var n=this._super;this._super=g[k];var m=l.apply(this,arguments);this._super=n;return m}}for(var e in h){f[e]=typeof h[e]=="function"&&typeof g[e]=="function"&&b.test(h[e])?c(e,h[e]):h[e]}if(ProtoJS.Browser.IE&&h.toString){f.toString=c("toString",h.toString)}function d(){if(!a&&this.init){this.init.apply(this,arguments)}}d.prototype=f;d.constructor=d;d.extend=arguments.callee;return d};Class.extendMethod=function(c,g,f,e){var d=c.prototype[g];c.prototype[g]=function(){if(e){f.apply(this,arguments)}d.apply(this,arguments);if(!e){f.apply(this,arguments)}}}})();ProtoJS.Array={compare:function compare(a){if(this.length!=a.length){return false}for(var b=0;b<a.length;b++){if(this[b].compare){if(!this[b].compare(a[b])){return false}}if(this[b]!==a[b]){return false}}return true},has:function has(a){return this.indexOf(a)>-1},unique:function unique(){var a=this.dup();this.clear();a.iterate(function(b){if(!this.has(b)){this.push(b)}}.scope(this));return this},iterate:function iterate(c,b){for(var a=0,d=this.length;a<d;a++){c.call(b,this[a],a)}},dup:function dup(){return[].concat(this)},clear:function clear(){this.length=0;return this},remove:function remove(c){var b=(c&&c.isArray&&c.isArray())?c:$A(arguments);var a=this.dup();this.clear();a.iterate(function(d){if(!b.has(d)){this.push(d)}}.scope(this));return this},min:function min(){var a=null;this.iterate(function(b){if(a==null||b<a){a=b}});return a},max:function max(){var a=null;this.iterate(function(b){if(a==null||b>a){a=b}});return a},isArray:function(){return true},isHash:function(){return false},isFunction:function(){return false},isString:function(){return false},isNumber:function(){return false}};ProtoJS.mix(ProtoJS.Array,Array.prototype);function $A(a){var c=a.length||0;var b=new Array(c);while(c--){b[c]=a[c]}return b}var Hash=Class.extend({init:function init(a){this.hash=a||{}},set:function(a,b){this.hash[a]=b},get:function(a){return this.hash[a]},keys:function keys(){var a=[];this.iterate(function(b,c){a.push(b)});return a},values:function values(){var a=[];this.iterate(function(b,c){a.push(c)});return a},hasKey:function has(a){return this.keys().has(a)},hasValue:function has(a){return this.values().has(a)},iterate:function each(c,b){for(var a in this.hash){c.call(b,a,this.hash[a])}},isArray:function(){return false},isHash:function(){return true},isFunction:function(){return false},isString:function(){return false},isNumber:function(){return false}});var $H=function(a){return new Hash(a)};ProtoJS.Function={after:function(){var c=this;var a=$A(arguments);var b=a.shift();return window.setTimeout(function(){return c.apply(c,a)},b)},scope:function scope(a){var b=this;return function(){return b.apply(a,arguments)}},isArray:function(){return false},isHash:function(){return false},isFunction:function(){return true},isString:function(){return false},isNumber:function(){return false}};ProtoJS.mix(ProtoJS.Function,Function.prototype);ProtoJS.Ajax=Class.extend({init:function(){this.xmlhttp=null;if(window.XMLHttpRequest){this.xmlhttp=new XMLHttpRequest()}else{if(window.ActiveXObject){this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}else{alert("Your browser does not support XMLHTTP!")}}},fetch:function(a,b){if(a.substring(0,4)=="http"){return this.fetchUsingXDR(a,b)}this.xmlhttp.open("GET",a,typeof b=="function");if(b){this.xmlhttp.onreadystatechange=function(){b.call(this,this.xmlhttp)}.scope(this)}this.xmlhttp.send(null);return this.xmlhttp.responseText},fetchUsingXDR:function(a,d){ProtoJS.XDR.push(d);var b=document.createElement("script");var c=a.contains("?")?"&":"?";b.src=a+c+"f=ProtoJS.XDR["+(ProtoJS.XDR.length-1)+"]";b.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(b)}});ProtoJS.XDR=[];ProtoJS.Timer=Class.extend({init:function init(){this.reset()},start:function start(){this.startTime=this.startTime||this.getTime();this.stopTime=null;return this},stop:function stop(){this.stopTime=this.getTime();return this},getTime:function getTime(){return new Date().getTime()},reset:function reset(){this.startTime=null},getElapsed:function getElapsed(){var a=this.getTime();return(this.stopTime||a)-(this.startTime||a)}});ProtoJS.Font=Class.extend({init:function init(b){this.scale=null;this.size=null;var a=b.match("(\\d+)([^\\s/]+)[\\s/]*");if(a){this.size=a[1];this.scale=a[2]}},getSize:function getSize(a){if(this.scale&&this.size&&ProtoJS.Font.SizeMap[this.scale]){return ProtoJS.Font.SizeMap[this.scale][this.size][a]}return 0},getPxSize:function getPxSize(){return this.getSize("px")},getPtSize:function getPtSize(){return this.getSize("pt")},getEmSize:function getEmSize(){return this.getSize("em")},getPctSize:function getPctSize(){return this.getSize("em")*100}});ProtoJS.Font.SizeMap={px:{},pt:{},em:{}};[{pt:5.5,px:6,em:0.375},{pt:6,px:8,em:0.5},{pt:7,px:9,em:0.55},{pt:7.5,px:10,em:0.625},{pt:8,px:11,em:0.7},{pt:9,px:12,em:0.75},{pt:10,px:13,em:0.8},{pt:10.5,px:14,em:0.875},{pt:11,px:15,em:0.95},{pt:12,px:16,em:1},{pt:13,px:17,em:1.05},{pt:13.5,px:18,em:1.125},{pt:14,px:19,em:1.2},{pt:14.5,px:20,em:1.25},{pt:15,px:21,em:1.3},{pt:16,px:22,em:1.4},{pt:17,px:23,em:1.45},{pt:18,px:24,em:1.5},{pt:20,px:26,em:1.6},{pt:22,px:29,em:1.8},{pt:24,px:32,em:2},{pt:26,px:35,em:2.2},{pt:27,px:36,em:2.25},{pt:28,px:37,em:2.3},{pt:29,px:38,em:2.35},{pt:30,px:40,em:2.45},{pt:32,px:42,em:2.55},{pt:34,px:45,em:2.75},{pt:36,px:48,em:3}].iterate(function(a){ProtoJS.Font.SizeMap.px[a.px]=a;ProtoJS.Font.SizeMap.pt[a.pt]=a;ProtoJS.Font.SizeMap.em[a.em]=a});ProtoJS.Test=Class.extend({init:function init(){this.waitingFor=0},setTester:function setTester(a){this.tester=a},isReady:function isReady(){return this.waitingFor<1},assertEqual:function assertEqual(b,a,c){b==a?this.tester.success(this.currentTestName):this.tester.fail(this.currentTestName,"  Expected:\n"+a+"\n  Got:\n"+b+"\n  "+(c||"")+"\n")},assertNotEqual:function assertEqual(b,a,c){b!=a?this.tester.success(this.currentTestName):this.tester.fail(this.currentTestName,"  Expected:\n"+a+"\n  Got:\n"+b+"\n  "+(c||"")+"\n")},assertTrue:function assertEqual(b,a){this.assertEqual(b,true,a)},assertFalse:function assertEqual(b,a){this.assertEqual(b,false,a)},assertEqualAfter:function assertEqualAfter(b,a,e,d){this.waitingFor++;var c=this;window.setTimeout(function(){c.assertEqual(a(),e,d);c.waitingFor--},b)}});ProtoJS.Test.RunDriver=Class.extend({init:function init(){this.units=[];this.logDetails=true},withoutDetails:function withoutDetails(){this.logDetails=false;return this},log:function log(a){if(this.logDetails){print(a)}},addTestUnit:function addTestUnit(a){this.units.push(a);return this},start:function start(){this.prepare();this.testNextUnit();if(Envjs.wait){Envjs.wait()}},prepare:function prepare(){this.successful=0;this.failed=0;this.waitingFor=0;this.currentUnitIndex=-1;this.currentUnit=null},testNextUnit:function testNextUnit(){if(this.currentUnit==null||this.currentUnit.isReady()){if(this.currentUnitIndex<this.units.length-1){this.currentUnitIndex++;this.currentUnit=new this.units[this.currentUnitIndex]();this.currentUnit.setTester(this);this.currentTests=$H(this.units[this.currentUnitIndex].prototype).keys().sort();this.currentTestIndex=-1;if(this.currentUnit.getScope){this.log("Testing "+this.currentUnit.getScope())}this.performNextTest();this.testNextUnit()}else{this.fireEvent("ready",this)}}else{this.testNextUnit.scope(this).after(10)}},performNextTest:function performNextTest(){if(this.currentUnit.isReady()){if(this.currentTests.length>0&&this.currentTestIndex<this.currentTests.length){this.currentTestIndex++;var a=this.currentTests[this.currentTestIndex];if(a&&a.match(/^test/)){this.log("- "+a);this.currentTestName=a;if(this.currentUnit.before){this.currentUnit.before()}this.currentUnit[a].scope(this.currentUnit)();if(this.currentUnit.after){this.currentUnit.after()}}this.performNextTest()}else{}}else{this.performNextTest.scope(this).after(10)}},success:function success(a){this.successful++},fail:function fail(a,b){this.failed++;this.log("FAIL: "+a+"\n"+b)},getResults:function getResults(){return{total:this.failed+this.successful,failed:this.failed,successful:this.successful}},test:function test(a){this.testFunction=a;return this},using:function using(a){if(!this.testFunction){print("Please provide a function to test first...");return}a.iterate(function(d){this.log("- "+d.name);var c=this.testFunction(d.data,d.msg,d.result);var b=typeof d.expected!="undefined"?d.expected:true;c.result==b?this.success(d.name):this.fail(d.name,c.info)}.scope(this))}});ProtoJS.Event.enable(ProtoJS.Test.RunDriver.prototype);ProtoJS.Test.Runner=new ProtoJS.Test.RunDriver();ProtoJS.version="0.2-16";if(!document.createElement("canvas").getContext){(function(){var ac=Math;var n=ac.round;var l=ac.sin;var B=ac.cos;var I=ac.abs;var O=ac.sqrt;var d=10;var f=d/2;var A=+navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];function z(){return this.context_||(this.context_=new E(this))}var u=Array.prototype.slice;function g(p,Z,ah){var m=u.call(arguments,2);return function(){return p.apply(Z,m.concat(u.call(arguments)))}}function ag(m){return String(m).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function aa(Z,p,m){if(!Z.namespaces[p]){Z.namespaces.add(p,m,"#default#VML")}}function S(p){aa(p,"g_vml_","urn:schemas-microsoft-com:vml");aa(p,"g_o_","urn:schemas-microsoft-com:office:office");if(!p.styleSheets.ex_canvas_){var m=p.createStyleSheet();m.owningElement.id="ex_canvas_";m.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}S(document);var e={init:function(m){var p=m||document;p.createElement("canvas");p.attachEvent("onreadystatechange",g(this.init_,this,p))},init_:function(Z){var p=Z.getElementsByTagName("canvas");for(var m=0;m<p.length;m++){this.initElement(p[m])}},initElement:function(p){if(!p.getContext){p.getContext=z;S(p.ownerDocument);p.innerHTML="";p.attachEvent("onpropertychange",y);p.attachEvent("onresize",X);var m=p.attributes;if(m.width&&m.width.specified){p.style.width=m.width.nodeValue+"px"}else{p.width=p.clientWidth}if(m.height&&m.height.specified){p.style.height=m.height.nodeValue+"px"}else{p.height=p.clientHeight}}return p}};function y(p){var m=p.srcElement;switch(p.propertyName){case"width":m.getContext().clearRect();m.style.width=m.attributes.width.nodeValue+"px";m.firstChild.style.width=m.clientWidth+"px";break;case"height":m.getContext().clearRect();m.style.height=m.attributes.height.nodeValue+"px";m.firstChild.style.height=m.clientHeight+"px";break}}function X(p){var m=p.srcElement;if(m.firstChild){m.firstChild.style.width=m.clientWidth+"px";m.firstChild.style.height=m.clientHeight+"px"}}e.init();var k=[];for(var af=0;af<16;af++){for(var ae=0;ae<16;ae++){k[af*16+ae]=af.toString(16)+ae.toString(16)}}function C(){return[[1,0,0],[0,1,0],[0,0,1]]}function K(ah,Z){var p=C();for(var m=0;m<3;m++){for(var ak=0;ak<3;ak++){var ai=0;for(var aj=0;aj<3;aj++){ai+=ah[m][aj]*Z[aj][ak]}p[m][ak]=ai}}return p}function w(p,m){m.fillStyle=p.fillStyle;m.lineCap=p.lineCap;m.lineJoin=p.lineJoin;m.lineWidth=p.lineWidth;m.miterLimit=p.miterLimit;m.shadowBlur=p.shadowBlur;m.shadowColor=p.shadowColor;m.shadowOffsetX=p.shadowOffsetX;m.shadowOffsetY=p.shadowOffsetY;m.strokeStyle=p.strokeStyle;m.globalAlpha=p.globalAlpha;m.font=p.font;m.textAlign=p.textAlign;m.textBaseline=p.textBaseline;m.arcScaleX_=p.arcScaleX_;m.arcScaleY_=p.arcScaleY_;m.lineScale_=p.lineScale_}var b={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",grey:"#808080",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",oldlace:"#FDF5E6",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",whitesmoke:"#F5F5F5",yellowgreen:"#9ACD32"};function N(p){var ah=p.indexOf("(",3);var m=p.indexOf(")",ah+1);var Z=p.substring(ah+1,m).split(",");if(Z.length!=4||p.charAt(3)!="a"){Z[3]=1}return Z}function c(m){return parseFloat(m)/100}function r(p,Z,m){return Math.min(m,Math.max(Z,p))}function J(aj){var m,al,am,ak,an,ai;ak=parseFloat(aj[0])/360%360;if(ak<0){ak++}an=r(c(aj[1]),0,1);ai=r(c(aj[2]),0,1);if(an==0){m=al=am=ai}else{var Z=ai<0.5?ai*(1+an):ai+an-ai*an;var ah=2*ai-Z;m=a(ah,Z,ak+1/3);al=a(ah,Z,ak);am=a(ah,Z,ak-1/3)}return"#"+k[Math.floor(m*255)]+k[Math.floor(al*255)]+k[Math.floor(am*255)]}function a(p,m,Z){if(Z<0){Z++}if(Z>1){Z--}if(6*Z<1){return p+(m-p)*6*Z}else{if(2*Z<1){return m}else{if(3*Z<2){return p+(m-p)*(2/3-Z)*6}else{return p}}}}var D={};function G(m){if(m in D){return D[m]}var ai,ah=1;m=String(m);if(m.charAt(0)=="#"){ai=m}else{if(/^rgb/.test(m)){var Z=N(m);var ai="#",aj;for(var p=0;p<3;p++){if(Z[p].indexOf("%")!=-1){aj=Math.floor(c(Z[p])*255)}else{aj=+Z[p]}ai+=k[r(aj,0,255)]}ah=+Z[3]}else{if(/^hsl/.test(m)){var Z=N(m);ai=J(Z);ah=Z[3]}else{ai=b[m]||m}}}return D[m]={color:ai,alpha:ah}}var o={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"};var M={};function F(m){if(M[m]){return M[m]}var ah=document.createElement("div");var Z=ah.style;try{Z.font=m}catch(p){}return M[m]={style:Z.fontStyle||o.style,variant:Z.fontVariant||o.variant,weight:Z.fontWeight||o.weight,size:Z.fontSize||o.size,family:Z.fontFamily||o.family}}function v(ah,Z){var m={};for(var ak in ah){m[ak]=ah[ak]}var aj=parseFloat(Z.currentStyle.fontSize),ai=parseFloat(ah.size);if(typeof ah.size=="number"){m.size=ah.size}else{if(ah.size.indexOf("px")!=-1){m.size=ai}else{if(ah.size.indexOf("em")!=-1){m.size=aj*ai}else{if(ah.size.indexOf("%")!=-1){m.size=(aj/100)*ai}else{if(ah.size.indexOf("pt")!=-1){m.size=ai/0.75}else{m.size=aj}}}}}m.size*=0.981;return m}function ad(m){return m.style+" "+m.variant+" "+m.weight+" "+m.size+"px "+m.family}var s={butt:"flat",round:"round"};function T(m){return s[m]||"square"}function E(m){this.m_=C();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=d*1;this.globalAlpha=1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=m;var Z="width:"+m.clientWidth+"px;height:"+m.clientHeight+"px;overflow:hidden;position:absolute";var p=m.ownerDocument.createElement("div");p.style.cssText=Z;m.appendChild(p);var ah=p.cloneNode(false);ah.style.backgroundColor="red";ah.style.filter="alpha(opacity=0)";m.appendChild(ah);this.element_=p;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var q=E.prototype;q.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=null}this.element_.innerHTML=""};q.beginPath=function(){this.currentPath_=[]};q.moveTo=function(Z,m){var ah=W(this,Z,m);this.currentPath_.push({type:"moveTo",x:ah.x,y:ah.y});this.currentX_=ah.x;this.currentY_=ah.y};q.lineTo=function(Z,m){var ah=W(this,Z,m);this.currentPath_.push({type:"lineTo",x:ah.x,y:ah.y});this.currentX_=ah.x;this.currentY_=ah.y};q.bezierCurveTo=function(ah,Z,an,am,al,aj){var m=W(this,al,aj);var ak=W(this,ah,Z);var ai=W(this,an,am);L(this,ak,ai,m)};function L(m,ai,ah,Z){m.currentPath_.push({type:"bezierCurveTo",cp1x:ai.x,cp1y:ai.y,cp2x:ah.x,cp2y:ah.y,x:Z.x,y:Z.y});m.currentX_=Z.x;m.currentY_=Z.y}q.quadraticCurveTo=function(al,ah,Z,m){var ak=W(this,al,ah);var aj=W(this,Z,m);var am={x:this.currentX_+2/3*(ak.x-this.currentX_),y:this.currentY_+2/3*(ak.y-this.currentY_)};var ai={x:am.x+(aj.x-this.currentX_)/3,y:am.y+(aj.y-this.currentY_)/3};L(this,am,ai,aj)};q.arc=function(ao,am,an,aj,Z,ah){an*=d;var at=ah?"at":"wa";var ap=ao+B(aj)*an-f;var ar=am+l(aj)*an-f;var m=ao+B(Z)*an-f;var aq=am+l(Z)*an-f;if(ap==m&&!ah){ap+=0.125}var ai=W(this,ao,am);var al=W(this,ap,ar);var ak=W(this,m,aq);this.currentPath_.push({type:at,x:ai.x,y:ai.y,radius:an,xStart:al.x,yStart:al.y,xEnd:ak.x,yEnd:ak.y})};q.rect=function(Z,p,m,ah){this.moveTo(Z,p);this.lineTo(Z+m,p);this.lineTo(Z+m,p+ah);this.lineTo(Z,p+ah);this.closePath()};q.strokeRect=function(Z,p,m,ah){var ai=this.currentPath_;this.beginPath();this.moveTo(Z,p);this.lineTo(Z+m,p);this.lineTo(Z+m,p+ah);this.lineTo(Z,p+ah);this.closePath();this.stroke();this.currentPath_=ai};q.fillRect=function(Z,p,m,ah){var ai=this.currentPath_;this.beginPath();this.moveTo(Z,p);this.lineTo(Z+m,p);this.lineTo(Z+m,p+ah);this.lineTo(Z,p+ah);this.closePath();this.fill();this.currentPath_=ai};q.createLinearGradient=function(p,ah,m,Z){var ai=new V("gradient");ai.x0_=p;ai.y0_=ah;ai.x1_=m;ai.y1_=Z;return ai};q.createRadialGradient=function(ah,aj,Z,p,ai,m){var ak=new V("gradientradial");ak.x0_=ah;ak.y0_=aj;ak.r0_=Z;ak.x1_=p;ak.y1_=ai;ak.r1_=m;return ak};q.drawImage=function(au,Z){var am,ak,ao,aB,ar,ap,aw,aD;var an=au.runtimeStyle.width;var at=au.runtimeStyle.height;au.runtimeStyle.width="auto";au.runtimeStyle.height="auto";var al=au.width;var az=au.height;au.runtimeStyle.width=an;au.runtimeStyle.height=at;if(arguments.length==3){am=arguments[1];ak=arguments[2];ar=ap=0;aw=ao=al;aD=aB=az}else{if(arguments.length==5){am=arguments[1];ak=arguments[2];ao=arguments[3];aB=arguments[4];ar=ap=0;aw=al;aD=az}else{if(arguments.length==9){ar=arguments[1];ap=arguments[2];aw=arguments[3];aD=arguments[4];am=arguments[5];ak=arguments[6];ao=arguments[7];aB=arguments[8]}else{throw Error("Invalid number of arguments")}}}var aC=W(this,am,ak);var ah=aw/2;var p=aD/2;var aA=[];var m=10;var aj=10;aA.push(" <g_vml_:group",' coordsize="',d*m,",",d*aj,'"',' coordorigin="0,0"',' style="width:',m,"px;height:",aj,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]||this.m_[1][1]!=1||this.m_[1][0]){var ai=[];ai.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",n(aC.x/d),",","Dy=",n(aC.y/d),"");var ay=aC;var ax=W(this,am+ao,ak);var av=W(this,am,ak+aB);var aq=W(this,am+ao,ak+aB);ay.x=ac.max(ay.x,ax.x,av.x,aq.x);ay.y=ac.max(ay.y,ax.y,av.y,aq.y);aA.push("padding:0 ",n(ay.x/d),"px ",n(ay.y/d),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",ai.join(""),", sizingmethod='clip');")}else{aA.push("top:",n(aC.y/d),"px;left:",n(aC.x/d),"px;")}aA.push(' ">','<g_vml_:image src="',au.src,'"',' style="width:',d*ao,"px;"," height:",d*aB,'px"',' cropleft="',ar/al,'"',' croptop="',ap/az,'"',' cropright="',(al-ar-aw)/al,'"',' cropbottom="',(az-ap-aD)/az,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",aA.join(""))};q.stroke=function(an){var al=[];var ah=false;var Z=10;var ao=10;al.push("<g_vml_:shape",' filled="',!!an,'"',' style="position:absolute;width:',Z,"px;height:",ao,'px;"',' coordorigin="0,0"',' coordsize="',d*Z,",",d*ao,'"',' stroked="',!an,'"',' path="');var ap=false;var ai={x:null,y:null};var am={x:null,y:null};for(var aj=0;aj<this.currentPath_.length;aj++){var m=this.currentPath_[aj];var ak;switch(m.type){case"moveTo":ak=m;al.push(" m ",n(m.x),",",n(m.y));break;case"lineTo":al.push(" l ",n(m.x),",",n(m.y));break;case"close":al.push(" x ");m=null;break;case"bezierCurveTo":al.push(" c ",n(m.cp1x),",",n(m.cp1y),",",n(m.cp2x),",",n(m.cp2y),",",n(m.x),",",n(m.y));break;case"at":case"wa":al.push(" ",m.type," ",n(m.x-this.arcScaleX_*m.radius),",",n(m.y-this.arcScaleY_*m.radius)," ",n(m.x+this.arcScaleX_*m.radius),",",n(m.y+this.arcScaleY_*m.radius)," ",n(m.xStart),",",n(m.yStart)," ",n(m.xEnd),",",n(m.yEnd));break}if(m){if(ai.x==null||m.x<ai.x){ai.x=m.x}if(am.x==null||m.x>am.x){am.x=m.x}if(ai.y==null||m.y<ai.y){ai.y=m.y}if(am.y==null||m.y>am.y){am.y=m.y}}}al.push(' ">');if(!an){x(this,al)}else{H(this,al,ai,am)}al.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",al.join(""))};function x(Z,aj){var p=G(Z.strokeStyle);var ah=p.color;var ai=p.alpha*Z.globalAlpha;var m=Z.lineScale_*Z.lineWidth;if(m<1){ai*=m}aj.push("<g_vml_:stroke",' opacity="',ai,'"',' joinstyle="',Z.lineJoin,'"',' miterlimit="',Z.miterLimit,'"',' endcap="',T(Z.lineCap),'"',' weight="',m,'px"',' color="',ah,'" />')}function H(at,ak,aM,au){var al=at.fillStyle;var aD=at.arcScaleX_;var aC=at.arcScaleY_;var m=au.x-aM.x;var Z=au.y-aM.y;if(al instanceof V){var ap=0;var aH={x:0,y:0};var az=0;var ao=1;if(al.type_=="gradient"){var an=al.x0_/aD;var p=al.y0_/aC;var am=al.x1_/aD;var aO=al.y1_/aC;var aL=W(at,an,p);var aK=W(at,am,aO);var ai=aK.x-aL.x;var ah=aK.y-aL.y;ap=Math.atan2(ai,ah)*180/Math.PI;if(ap<0){ap+=360}if(ap<0.000001){ap=0}}else{var aL=W(at,al.x0_,al.y0_);aH={x:(aL.x-aM.x)/m,y:(aL.y-aM.y)/Z};m/=aD*d;Z/=aC*d;var aF=ac.max(m,Z);az=2*al.r0_/aF;ao=2*al.r1_/aF-az}var ax=al.colors_;ax.sort(function(aQ,aP){return aQ.offset-aP.offset});var ar=ax.length;var aw=ax[0].color;var av=ax[ar-1].color;var aB=ax[0].alpha*at.globalAlpha;var aA=ax[ar-1].alpha*at.globalAlpha;var aG=[];for(var aJ=0;aJ<ar;aJ++){var aq=ax[aJ];aG.push(aq.offset*ao+az+" "+aq.color)}ak.push('<g_vml_:fill type="',al.type_,'"',' method="none" focus="100%"',' color="',aw,'"',' color2="',av,'"',' colors="',aG.join(","),'"',' opacity="',aA,'"',' g_o_:opacity2="',aB,'"',' angle="',ap,'"',' focusposition="',aH.x,",",aH.y,'" />')}else{if(al instanceof U){if(m&&Z){var aj=-aM.x;var aE=-aM.y;ak.push("<g_vml_:fill",' position="',aj/m*aD*aD,",",aE/Z*aC*aC,'"',' type="tile"',' src="',al.src_,'" />')}}else{var aN=G(at.fillStyle);var ay=aN.color;var aI=aN.alpha*at.globalAlpha;ak.push('<g_vml_:fill color="',ay,'" opacity="',aI,'" />')}}}q.fill=function(){this.stroke(true)};q.closePath=function(){this.currentPath_.push({type:"close"})};function W(Z,ai,ah){var p=Z.m_;return{x:d*(ai*p[0][0]+ah*p[1][0]+p[2][0])-f,y:d*(ai*p[0][1]+ah*p[1][1]+p[2][1])-f}}q.save=function(){var m={};w(this,m);this.aStack_.push(m);this.mStack_.push(this.m_);this.m_=K(C(),this.m_)};q.restore=function(){if(this.aStack_.length){w(this.aStack_.pop(),this);this.m_=this.mStack_.pop()}};function h(p){return isFinite(p[0][0])&&isFinite(p[0][1])&&isFinite(p[1][0])&&isFinite(p[1][1])&&isFinite(p[2][0])&&isFinite(p[2][1])}function ab(Z,p,ah){if(!h(p)){return}Z.m_=p;if(ah){var ai=p[0][0]*p[1][1]-p[0][1]*p[1][0];Z.lineScale_=O(I(ai))}}q.translate=function(Z,p){var m=[[1,0,0],[0,1,0],[Z,p,1]];ab(this,K(m,this.m_),false)};q.rotate=function(p){var ah=B(p);var Z=l(p);var m=[[ah,Z,0],[-Z,ah,0],[0,0,1]];ab(this,K(m,this.m_),false)};q.scale=function(Z,p){this.arcScaleX_*=Z;this.arcScaleY_*=p;var m=[[Z,0,0],[0,p,0],[0,0,1]];ab(this,K(m,this.m_),true)};q.transform=function(ai,ah,ak,aj,p,m){var Z=[[ai,ah,0],[ak,aj,0],[p,m,1]];ab(this,K(Z,this.m_),true)};q.setTransform=function(aj,ai,al,ak,ah,Z){var p=[[aj,ai,0],[al,ak,0],[ah,Z,1]];ab(this,p,true)};q.drawText_=function(ap,an,am,at,al){var ar=this.m_,aw=1000,Z=0,av=aw,ak={x:0,y:0},aj=[];var p=v(F(this.font),this.element_);var ah=ad(p);var ax=this.element_.currentStyle;var ai=this.textAlign.toLowerCase();switch(ai){case"left":case"center":case"right":break;case"end":ai=ax.direction=="ltr"?"right":"left";break;case"start":ai=ax.direction=="rtl"?"right":"left";break;default:ai="left"}switch(this.textBaseline){case"hanging":case"top":ak.y=p.size/1.75;break;case"middle":break;default:case null:case"alphabetic":case"ideographic":case"bottom":ak.y=-p.size/2.25;break}switch(ai){case"right":Z=aw;av=0.05;break;case"center":Z=av=aw/2;break}var au=W(this,an+ak.x,am+ak.y);aj.push('<g_vml_:line from="',-Z,' 0" to="',av,' 0.05" ',' coordsize="100 100" coordorigin="0 0"',' filled="',!al,'" stroked="',!!al,'" style="position:absolute;width:1px;height:1px;">');if(al){x(this,aj)}else{H(this,aj,{x:-Z,y:0},{x:av,y:p.size})}var aq=ar[0][0].toFixed(3)+","+ar[1][0].toFixed(3)+","+ar[0][1].toFixed(3)+","+ar[1][1].toFixed(3)+",0,0";var ao=n(au.x/d)+","+n(au.y/d);aj.push('<g_vml_:skew on="t" matrix="',aq,'" ',' offset="',ao,'" origin="',Z,' 0" />','<g_vml_:path textpathok="true" />','<g_vml_:textpath on="true" string="',ag(ap),'" style="v-text-align:',ai,";font:",ag(ah),'" /></g_vml_:line>');this.element_.insertAdjacentHTML("beforeEnd",aj.join(""))};q.fillText=function(Z,m,ah,p){this.drawText_(Z,m,ah,p,false)};q.strokeText=function(Z,m,ah,p){this.drawText_(Z,m,ah,p,true)};q.measureText=function(Z){if(!this.textMeasureEl_){var m='<span style="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;"></span>';this.element_.insertAdjacentHTML("beforeEnd",m);this.textMeasureEl_=this.element_.lastChild}var p=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(p.createTextNode(Z));return{width:this.textMeasureEl_.offsetWidth}};q.clip=function(){};q.arcTo=function(){};q.createPattern=function(p,m){return new U(p,m)};function V(m){this.type_=m;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}V.prototype.addColorStop=function(p,m){m=G(m);this.colors_.push({offset:p,color:m.color,alpha:m.alpha})};function U(p,m){R(p);switch(m){case"repeat":case null:case"":this.repetition_="repeat";break;case"repeat-x":case"repeat-y":case"no-repeat":this.repetition_=m;break;default:P("SYNTAX_ERR")}this.src_=p.src;this.width_=p.width;this.height_=p.height}function P(m){throw new Q(m)}function R(m){if(!m||m.nodeType!=1||m.tagName!="IMG"){P("TYPE_MISMATCH_ERR")}if(m.readyState!="complete"){P("INVALID_STATE_ERR")}}function Q(m){this.code=this[m];this.message=m+": DOM Exception "+this.code}var Y=Q.prototype=new Error;Y.INDEX_SIZE_ERR=1;Y.DOMSTRING_SIZE_ERR=2;Y.HIERARCHY_REQUEST_ERR=3;Y.WRONG_DOCUMENT_ERR=4;Y.INVALID_CHARACTER_ERR=5;Y.NO_DATA_ALLOWED_ERR=6;Y.NO_MODIFICATION_ALLOWED_ERR=7;Y.NOT_FOUND_ERR=8;Y.NOT_SUPPORTED_ERR=9;Y.INUSE_ATTRIBUTE_ERR=10;Y.INVALID_STATE_ERR=11;Y.SYNTAX_ERR=12;Y.INVALID_MODIFICATION_ERR=13;Y.NAMESPACE_ERR=14;Y.INVALID_ACCESS_ERR=15;Y.VALIDATION_ERR=16;Y.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=e;CanvasRenderingContext2D=E;CanvasGradient=V;CanvasPattern=U;DOMException=Q})()}var CanvasTextFunctions={};CanvasTextFunctions.letters={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},"$":{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},"0":{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},"1":{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},"2":{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},"3":{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"4":{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},"5":{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"6":{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},"7":{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},"8":{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},"9":{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},",":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};CanvasTextFunctions.letter=function(a){return CanvasTextFunctions.letters[a]};CanvasTextFunctions.ascent=function(a,b){return b};CanvasTextFunctions.descent=function(a,b){return 7*b/25};CanvasTextFunctions.measure=function(b,d,f){var e=0;var a=f.length;for(i=0;i<a;i++){var g=CanvasTextFunctions.letter(f.charAt(i));if(g){e+=g.width*d/25}}return e};CanvasTextFunctions.italics={};CanvasTextFunctions.makeItalic=function(g,h,f){if(!CanvasTextFunctions.italics[g]){var d=[];for(var e=0;e<h.points.length;e++){var b=h.points[e];if(b[0]!=-1&&b[1]!=-1){d[e]=[b[0]+(b[1]/3),b[1]]}else{d[e]=[-1,-1]}}CanvasTextFunctions.italics[g]={width:h.width,points:d}}return CanvasTextFunctions.italics[g]};CanvasTextFunctions.draw=function(q,d,r,p,m,l){var n=0;var h=l.length;var f=r/25;q.save();q.lineCap="round";q.lineWidth=2*f;for(i=0;i<h;i++){var g=l.charAt(i);var k=CanvasTextFunctions.letter(g);if(!k){continue}if(d.toLowerCase().indexOf("italic")>-1){k=CanvasTextFunctions.makeItalic(g,k,r)}q.beginPath();var e=1;var b=0;for(j=0;j<k.points.length;j++){var o=k.points[j];if(o[0]==-1&&o[1]==-1){e=1;continue}if(e){q.moveTo(p+o[0]*f,m-o[1]*f);e=false}else{q.lineTo(p+o[0]*f,m-o[1]*f)}}q.stroke();p+=k.width*f}q.restore();return n};CanvasTextFunctions.enable=function(a){a.drawText=function(c,d,b,f,e){return CanvasTextFunctions.draw(a,c,d,b,f,e)};a.measureText=function(b,c,d){return CanvasTextFunctions.measure(b,c,d)};a.fontAscent=function(b,c){return CanvasTextFunctions.ascent(b,c)};a.fontDescent=function(b,c){return CanvasTextFunctions.descent(b,c)};a.drawTextRight=function(d,e,b,g,f){var c=CanvasTextFunctions.measure(d,e,f);return CanvasTextFunctions.draw(a,d,e,b-c,g,f)};a.drawTextCenter=function(d,e,b,g,f){var c=CanvasTextFunctions.measure(d,e,f);return CanvasTextFunctions.draw(a,d,e,b-c/2,g,f)}};var ADL={};ADL.base=Class.extend({getValue:function getValue(){return this.value}});ADL.Boolean=ADL.base.extend({init:function(a){this.value=a=="true"?true:false},toString:function(){return this.value?"true":"false"}});ADL.Integer=ADL.base.extend({init:function(a){this.value=a},toString:function(){return this.value}});ADL.String=ADL.base.extend({init:function(a){this.value=a},toString:function(){return'"'+this.value+'"'}});ADL.Value=Class.extend({init:function(a){this.value=a},getValue:function getValue(){return this.value.getValue()},toString:function(){return" := "+this.value.toString()}});ADL.Annotation=ADL.base.extend({init:function(a){this.value=a},toString:function(){return"[@"+this.value+"]"}});ADL.Multiplicity=Class.extend({init:function(a,b){this.low=a;this.high=b},getLow:function getLow(){return this.low},getHigh:function getHigh(){return this.high},toString:function(){return"["+this.low+(this.high?".."+this.high:"")+"]"}});ADL.Reference=Class.extend({init:function(a,b){this.constructName=a;this.multiplicity=b},getConstructName:function getConstructName(){return this.constructName},getMultiplicity:function getMultiplicity(){return this.multiplicity},toString:function(){return this.constructName+(this.multiplicity?this.multiplicity.toString():"")}});ADL.Modifier=ADL.base.extend({init:function(a,b){this.name=a;this.value=b},getName:function getName(){return this.name},toString:function(){return"+"+this.name+(this.value?"="+this.value.toString():"")}});ADL.Construct=Class.extend({init:function(e,b,f,g,d,a,c){this.type=e;this.name=b;this.value=f||null;this.annotations=g||new Array();this.supers=d||new Array();this.children=c||new Array();this.modifiers=new Hash();if(a){a.iterate(function(h){this.addModifier(h)}.scope(this))}},getType:function getType(){return this.type},getName:function getName(){return this.name},setName:function setName(a){this.name=a},getValue:function getValue(){return this.value},setValue:function setValue(a){if(!(a instanceof ADL.Value)){a=new ADL.Value(a)}this.value=a},getAnnotations:function getAnnotations(){return this.annotations},addAnnotation:function addAnnotation(a){if(!(a instanceof ADL.Annotation)){a=new ADL.Annotation(a)}this.annotations.push(a);return this},getSupers:function getSupers(){return this.supers},addSuper:function addSuper(a){this.supers.push(a);return this},getModifiers:function getModifiers(){return this.modifiers.values()},getModifier:function getModifier(a){return this.modifiers.get(a)},addModifier:function addModifier(a,b){if(!(a instanceof ADL.Modifier)){a=new ADL.Modifier(a,b)}this.modifiers.set(a.getName(),a)},getChildren:function getChildren(){return this.children},addChild:function addChild(a){this.children.push(a);return this},toString:function(c){c=c||"";var d=new Array();this.annotations.iterate(function(e){d.push(e.toString())});var a=new Array();this.modifiers.iterate(function(e,f){a.push(f.toString())});var b=new Array();this.children.iterate(function(e){b.push(e.toString("  "+c))});return(d.length>0?c+d.join("\n"+c)+"\n":"")+c+this.type+" "+this.name+(this.supers.length>0?" : "+this.supers.join(" : "):"")+(a.length>0?" "+a.join(" "):"")+(this.value?this.value.toString():"")+(b.length>0?" {\n"+b.join("\n")+"\n"+c+"}":";")},accept:function(b,a){return b.visit(this,a)},childrenAccept:function(b,a){this.children.iterate(function(c){b.visit(c,a)});return a}});ADL.include=function(b){var a=new ProtoJS.Ajax().fetch(b.value+".adl");return new ADL.Parser().parse(a).getRoot().getChildren()};ADL.AST=Class.extend({init:function(a){this.root=new ADL.Construct("","root",null,null,null,null,a)},getRoot:function(){return this.root}});ADL.ast=null;ADL.Parser=Class.extend({parse:function(f){var h=0;var c=new Array();var a=new Array();ADL.ast=null;try{if((h=__parse(f,c,a))>0){var b;var g="";for(b=0;b<h;b++){g+="Parse error: "+f.substr(c[b],30)+'. Expecting "'+a[b].join()+"\n"}this.errors=g;return null}}catch(d){this.errors="Semantic error: "+d;return null}this.errors="";return ADL.ast}});function makeList(){var b=new Array();if(arguments){for(var a=0;a<arguments.length;a++){if(Object.isArray(arguments[a])){for(var c=0;c<arguments[a].length;c++){if(arguments[a][c]){b.push(arguments[a][c])}}}else{if(arguments[a]){b.push(arguments[a])}}}}return b}var _dbg_withtrace=false;var _dbg_string=new String();function __dbg_print(a){_dbg_string+=a+"\n"}function __lex(d){var c=0;var a=-1;var b=0;var f=0;var e=d.offset+1;do{e--;c=0;a=-2;f=e;if(d.src.length<=f){return 49}do{switch(c){case 0:if((d.src.charCodeAt(e)>=9&&d.src.charCodeAt(e)<=10)||d.src.charCodeAt(e)==13||d.src.charCodeAt(e)==32){c=1}else{if(d.src.charCodeAt(e)==40){c=2}else{if(d.src.charCodeAt(e)==41){c=3}else{if(d.src.charCodeAt(e)==42){c=4}else{if(d.src.charCodeAt(e)==43){c=5}else{if(d.src.charCodeAt(e)==44){c=6}else{if(d.src.charCodeAt(e)==45){c=7}else{if(d.src.charCodeAt(e)==46){c=8}else{if(d.src.charCodeAt(e)==47){c=9}else{if(d.src.charCodeAt(e)==48){c=10}else{if(d.src.charCodeAt(e)==58){c=11}else{if(d.src.charCodeAt(e)==59){c=12}else{if(d.src.charCodeAt(e)==60){c=13}else{if(d.src.charCodeAt(e)==61){c=14}else{if(d.src.charCodeAt(e)==62){c=15}else{if((d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=101)||(d.src.charCodeAt(e)>=103&&d.src.charCodeAt(e)<=115)||(d.src.charCodeAt(e)>=117&&d.src.charCodeAt(e)<=122)){c=16}else{if(d.src.charCodeAt(e)==91){c=17}else{if(d.src.charCodeAt(e)==93){c=18}else{if(d.src.charCodeAt(e)==123){c=19}else{if(d.src.charCodeAt(e)==124){c=20}else{if(d.src.charCodeAt(e)==125){c=21}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=8)||(d.src.charCodeAt(e)>=11&&d.src.charCodeAt(e)<=12)||(d.src.charCodeAt(e)>=14&&d.src.charCodeAt(e)<=31)||(d.src.charCodeAt(e)>=36&&d.src.charCodeAt(e)<=39)||(d.src.charCodeAt(e)>=63&&d.src.charCodeAt(e)<=64)||d.src.charCodeAt(e)==92||d.src.charCodeAt(e)==94||d.src.charCodeAt(e)==96||(d.src.charCodeAt(e)>=126&&d.src.charCodeAt(e)<=254)){c=30}else{if((d.src.charCodeAt(e)>=49&&d.src.charCodeAt(e)<=57)){c=32}else{if(d.src.charCodeAt(e)==33){c=35}else{if(d.src.charCodeAt(e)==34){c=39}else{if(d.src.charCodeAt(e)==35){c=41}else{if(d.src.charCodeAt(e)==116){c=61}else{if(d.src.charCodeAt(e)==102){c=64}else{c=-1}}}}}}}}}}}}}}}}}}}}}}}}}}}}break;case 1:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=1;b=e;break;case 2:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=6;b=e;break;case 3:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=7;b=e;break;case 4:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=22;b=e;break;case 5:if(d.src.charCodeAt(e)==48){c=37}else{if((d.src.charCodeAt(e)>=49&&d.src.charCodeAt(e)<=57)){c=40}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}}a=17;b=e;break;case 6:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=16;b=e;break;case 7:if(d.src.charCodeAt(e)==48){c=37}else{if((d.src.charCodeAt(e)>=49&&d.src.charCodeAt(e)<=57)){c=40}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}}a=18;b=e;break;case 8:if(d.src.charCodeAt(e)==46){c=24}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}a=15;b=e;break;case 9:if(d.src.charCodeAt(e)==47){c=44}else{c=-1}a=23;b=e;break;case 10:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=3;b=e;break;case 11:if(d.src.charCodeAt(e)==58){c=25}else{if(d.src.charCodeAt(e)==61){c=26}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}}a=13;b=e;break;case 12:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=12;b=e;break;case 13:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=26;b=e;break;case 14:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=19;b=e;break;case 15:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=27;b=e;break;case 16:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}a=29;b=e;break;case 17:if(d.src.charCodeAt(e)==47){c=42}else{if(d.src.charCodeAt(e)==64){c=45}else{c=-1}}a=10;b=e;break;case 18:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=11;b=e;break;case 19:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=8;b=e;break;case 20:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=24;b=e;break;case 21:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}a=9;b=e;break;case 22:c=-1;a=20;b=e;break;case 23:c=-1;a=4;b=e;break;case 24:c=-1;a=25;b=e;break;case 25:c=-1;a=14;b=e;break;case 26:c=-1;a=21;b=e;break;case 27:c=-1;a=5;b=e;break;case 28:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=122)){c=33}else{c=-1}a=2;b=e;break;case 29:c=-1;a=28;b=e;break;case 30:if(d.src.charCodeAt(e)==47){c=42}else{c=-1}break;case 31:c=-1;a=1;b=e;break;case 32:if((d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)){c=40}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}a=3;b=e;break;case 33:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=122)){c=33}else{c=-1}a=29;b=e;break;case 34:if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=46}else{if(d.src.charCodeAt(e)==42){c=49}else{c=-1}}a=4;b=e;break;case 35:if(d.src.charCodeAt(e)==61){c=22}else{if(d.src.charCodeAt(e)==47){c=42}else{c=-1}}break;case 36:if(d.src.charCodeAt(e)==34){c=23}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=254)){c=63}else{c=-1}}a=1;b=e;break;case 37:c=-1;a=3;b=e;break;case 38:if(d.src.charCodeAt(e)==101){c=28}else{if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=100)||(d.src.charCodeAt(e)>=102&&d.src.charCodeAt(e)<=122)){c=33}else{c=-1}}a=29;b=e;break;case 39:if(d.src.charCodeAt(e)==34){c=23}else{if(d.src.charCodeAt(e)==47){c=59}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=254)){c=63}else{c=-1}}}break;case 40:if((d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)){c=40}else{c=-1}a=3;b=e;break;case 41:if(d.src.charCodeAt(e)==47){c=42}else{if(d.src.charCodeAt(e)==105){c=43}else{c=-1}}break;case 42:if(d.src.charCodeAt(e)==42){c=46}else{c=-1}break;case 43:if(d.src.charCodeAt(e)==110){c=48}else{c=-1}break;case 44:if(d.src.charCodeAt(e)==10){c=31}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=9)||(d.src.charCodeAt(e)>=11&&d.src.charCodeAt(e)<=254)){c=44}else{c=-1}}break;case 45:if(d.src.charCodeAt(e)==93){c=27}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=92)||(d.src.charCodeAt(e)>=94&&d.src.charCodeAt(e)<=254)){c=45}else{c=-1}}break;case 46:if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=46}else{if(d.src.charCodeAt(e)==42){c=49}else{c=-1}}break;case 47:if(d.src.charCodeAt(e)==34){c=34}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=47}else{if(d.src.charCodeAt(e)==42){c=50}else{c=-1}}}break;case 48:if(d.src.charCodeAt(e)==99){c=51}else{c=-1}break;case 49:if(d.src.charCodeAt(e)==47){c=31}else{if(d.src.charCodeAt(e)==42){c=49}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=254)){c=52}else{c=-1}}}break;case 50:if(d.src.charCodeAt(e)==47){c=36}else{if(d.src.charCodeAt(e)==42){c=50}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=254)){c=53}else{if(d.src.charCodeAt(e)==34){c=58}else{c=-1}}}}break;case 51:if(d.src.charCodeAt(e)==108){c=54}else{c=-1}break;case 52:if(d.src.charCodeAt(e)==42){c=49}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=52}else{c=-1}}break;case 53:if(d.src.charCodeAt(e)==42){c=50}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=53}else{if(d.src.charCodeAt(e)==34){c=58}else{c=-1}}}break;case 54:if(d.src.charCodeAt(e)==117){c=55}else{c=-1}break;case 55:if(d.src.charCodeAt(e)==100){c=56}else{c=-1}break;case 56:if(d.src.charCodeAt(e)==101){c=29}else{c=-1}break;case 57:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=116)||(d.src.charCodeAt(e)>=118&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==117){c=38}else{c=-1}}a=29;b=e;break;case 58:if(d.src.charCodeAt(e)==42){c=49}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=52}else{c=-1}}a=4;b=e;break;case 59:if(d.src.charCodeAt(e)==34){c=23}else{if(d.src.charCodeAt(e)==42){c=47}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=41)||(d.src.charCodeAt(e)>=43&&d.src.charCodeAt(e)<=254)){c=63}else{c=-1}}}break;case 60:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=114)||(d.src.charCodeAt(e)>=116&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==115){c=38}else{c=-1}}a=29;b=e;break;case 61:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=113)||(d.src.charCodeAt(e)>=115&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==47){c=42}else{if(d.src.charCodeAt(e)==114){c=57}else{c=-1}}}a=29;b=e;break;case 62:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=97&&d.src.charCodeAt(e)<=107)||(d.src.charCodeAt(e)>=109&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==108){c=60}else{c=-1}}a=29;b=e;break;case 63:if(d.src.charCodeAt(e)==34){c=23}else{if((d.src.charCodeAt(e)>=0&&d.src.charCodeAt(e)<=33)||(d.src.charCodeAt(e)>=35&&d.src.charCodeAt(e)<=254)){c=63}else{c=-1}}break;case 64:if((d.src.charCodeAt(e)>=45&&d.src.charCodeAt(e)<=46)||(d.src.charCodeAt(e)>=48&&d.src.charCodeAt(e)<=57)||(d.src.charCodeAt(e)>=65&&d.src.charCodeAt(e)<=90)||d.src.charCodeAt(e)==95||(d.src.charCodeAt(e)>=98&&d.src.charCodeAt(e)<=122)){c=33}else{if(d.src.charCodeAt(e)==47){c=42}else{if(d.src.charCodeAt(e)==97){c=62}else{c=-1}}}a=29;b=e;break}e++}while(c>-1)}while(1>-1&&a==1);if(a>-1){d.att=d.src.substr(f,b-f);d.offset=b;switch(a){case 2:d.att=new ADL.Boolean(d.att);break;case 3:d.att=new ADL.Integer(d.att);break;case 4:d.att=new ADL.String(d.att.substr(1,d.att.length-2));break;case 5:d.att=new ADL.Annotation(d.att.substr(2,d.att.length-3));break}}else{d.att=new String();a=-1}return a}function __parse(a,r,s){var b=new Array();var n=new Array();var e=0;var q;var f;var g;var v;var h=new Function("","var offset; var src; var att;");var o=new h();var l=new Array(new Array(0,1),new Array(31,1),new Array(30,2),new Array(30,0),new Array(32,1),new Array(32,1),new Array(33,8),new Array(34,2),new Array(35,2),new Array(35,0),new Array(43,3),new Array(44,1),new Array(42,3),new Array(42,1),new Array(42,0),new Array(38,1),new Array(38,2),new Array(37,1),new Array(37,2),new Array(39,2),new Array(39,0),new Array(45,3),new Array(46,3),new Array(46,5),new Array(46,0),new Array(36,2),new Array(36,0),new Array(47,2),new Array(47,4),new Array(40,2),new Array(40,0),new Array(48,1),new Array(48,1),new Array(48,1),new Array(41,3),new Array(41,1));var d=new Array(new Array(49,-3,28,-3,29,-3,5,-3,17,-3),new Array(49,0),new Array(28,7,49,-1,17,-9,29,-9,5,-9),new Array(49,-2,28,-2,29,-2,5,-2,17,-2,9,-2),new Array(49,-4,28,-4,29,-4,5,-4,17,-4,9,-4),new Array(49,-5,28,-5,29,-5,5,-5,17,-5,9,-5),new Array(5,8,29,-26,17,-26),new Array(4,10),new Array(17,-8,29,-8,5,-8),new Array(29,13,17,14),new Array(49,-7,28,-7,29,-7,5,-7,17,-7,9,-7),new Array(29,-25,17,-25,21,-25,8,-25,12,-25),new Array(29,16),new Array(26,18,29,-17,10,-17,17,-17,21,-17,8,-17,12,-17,13,-17),new Array(29,19),new Array(17,-20,21,-20,8,-20,12,-20,13,-20),new Array(26,18,13,-15,17,-15,21,-15,8,-15,12,-15),new Array(29,-18,10,-18,17,-18,21,-18,8,-18,12,-18,13,-18),new Array(29,24,27,-14,16,-14),new Array(19,25,29,-27,17,-27,21,-27,8,-27,12,-27),new Array(13,28,21,-26,8,-26,12,-26,17,-26),new Array(13,-16,17,-16,21,-16,8,-16,12,-16),new Array(16,29,27,30),new Array(27,-13,16,-13),new Array(27,-11,16,-11),new Array(4,32,3,33,2,34),new Array(17,-19,21,-19,8,-19,12,-19,13,-19),new Array(21,36,17,14,8,-30,12,-30),new Array(29,13),new Array(29,24),new Array(29,-10,13,-10,17,-10,21,-10,8,-10,12,-10,10,-10),new Array(29,-28,17,-28,21,-28,8,-28,12,-28),new Array(29,-31,17,-31,21,-31,8,-31,12,-31),new Array(29,-32,17,-32,21,-32,8,-32,12,-32),new Array(29,-33,17,-33,21,-33,8,-33,12,-33),new Array(8,40,12,41),new Array(4,32,3,33,2,34),new Array(10,44,17,-24,21,-24,8,-24,12,-24,13,-24),new Array(27,-12,16,-12),new Array(49,-6,28,-6,29,-6,5,-6,17,-6,9,-6),new Array(9,-3,28,-3,29,-3,5,-3,17,-3),new Array(49,-35,28,-35,29,-35,5,-35,17,-35,9,-35),new Array(8,-29,12,-29),new Array(17,-21,21,-21,8,-21,12,-21,13,-21),new Array(3,46),new Array(9,47,28,7,17,-9,29,-9,5,-9),new Array(11,48,25,49),new Array(49,-34,28,-34,29,-34,5,-34,17,-34,9,-34),new Array(17,-22,21,-22,8,-22,12,-22,13,-22),new Array(3,50),new Array(11,51),new Array(17,-23,21,-23,8,-23,12,-23,13,-23));var k=new Array(new Array(31,1,30,2),new Array(),new Array(32,3,33,4,34,5,35,6),new Array(),new Array(),new Array(),new Array(36,9),new Array(),new Array(),new Array(47,11,37,12),new Array(),new Array(),new Array(38,15),new Array(43,17),new Array(),new Array(39,20),new Array(43,21),new Array(),new Array(42,22,44,23),new Array(),new Array(45,26,36,27),new Array(),new Array(),new Array(),new Array(),new Array(48,31),new Array(),new Array(47,11,40,35),new Array(37,37),new Array(44,38),new Array(),new Array(),new Array(),new Array(),new Array(),new Array(41,39),new Array(48,42),new Array(46,43),new Array(),new Array(),new Array(30,45),new Array(),new Array(),new Array(),new Array(),new Array(32,3,33,4,34,5,35,6),new Array(),new Array(),new Array(),new Array(),new Array(),new Array());var p=new Array("Program'","WHITESPACE","Boolean","Integer","String","Annotation","(",")","{","}","[","]",";",":","::",".",",","+","-","=","!=",":=","*","/","|","..","<",">","IncludeDirective","Identifier","Statements","Program","Statement","Construct","Directive","Annotations","Modifiers","Type","Name","Supers","Value","Children","GenericArguments","Generic","GenericArgument","Super","Multiplicity","Modifier","Constant","$");o.offset=0;o.src=a;o.att=new String();if(!r){r=new Array()}if(!s){s=new Array()}b.push(0);n.push(0);g=__lex(o);while(true){q=53;for(var m=0;m<d[b[b.length-1]].length;m+=2){if(d[b[b.length-1]][m]==g){q=d[b[b.length-1]][m+1];break}}if(_dbg_withtrace&&b.length>0){__dbg_print("\nState "+b[b.length-1]+"\n\tLookahead: "+p[g]+' ("'+o.att+'")\n\tAction: '+q+'\n\tSource: "'+o.src.substr(o.offset,30)+((o.offset+30<o.src.length)?"...":"")+'"\n\tStack: '+b.join()+"\n\tValue stack: "+n.join()+"\n")}if(q==53){if(_dbg_withtrace){__dbg_print("Error detected: There is no reduce or shift on the symbol "+p[g])}e++;r.push(o.offset-o.att.length);s.push(new Array());for(var m=0;m<d[b[b.length-1]].length;m+=2){s[s.length-1].push(p[d[b[b.length-1]][m]])}var c=new Array();var u=new Array();for(var m=0;m<b.length;m++){c[m]=b[m];u[m]=n[m]}while(q==53&&g!=49){if(_dbg_withtrace){__dbg_print("\tError recovery\nCurrent lookahead: "+p[g]+" ("+o.att+")\nAction: "+q+"\n\n")}if(g==-1){o.offset++}while(q==53&&b.length>0){b.pop();n.pop();if(b.length==0){break}q=53;for(var m=0;m<d[b[b.length-1]].length;m+=2){if(d[b[b.length-1]][m]==g){q=d[b[b.length-1]][m+1];break}}}if(q!=53){break}for(var m=0;m<c.length;m++){b.push(c[m]);n.push(u[m])}g=__lex(o)}if(q==53){if(_dbg_withtrace){__dbg_print("\tError recovery failed, terminating parse process...")}break}if(_dbg_withtrace){__dbg_print("\tError recovery succeeded, continuing")}}if(q>0){if(_dbg_withtrace){__dbg_print("Shifting symbol: "+p[g]+" ("+o.att+")")}b.push(q);n.push(o.att);g=__lex(o);if(_dbg_withtrace){__dbg_print("\tNew lookahead symbol: "+p[g]+" ("+o.att+")")}}else{q*=-1;if(_dbg_withtrace){__dbg_print("Reducing by producution: "+q)}v=void (0);if(_dbg_withtrace){__dbg_print("\tPerforming semantic action...")}switch(q){case 0:v=n[n.length-1];break;case 1:ADL.ast=new ADL.AST(n[n.length-1]);break;case 2:v=makeList(n[n.length-2],n[n.length-1]);break;case 3:v=n[n.length-0];break;case 4:v=n[n.length-1];break;case 5:v=n[n.length-1];break;case 6:v=new ADL.Construct(n[n.length-6],n[n.length-5],n[n.length-2],n[n.length-8],n[n.length-4],makeList(n[n.length-7],n[n.length-3]),n[n.length-1]);break;case 7:v=ADL.include(n[n.length-1]);break;case 8:v=makeList(n[n.length-2],n[n.length-1]);break;case 9:v=n[n.length-0];break;case 10:if(n[n.length-2]){v=n[n.length-3]+n[n.length-2].join(",")+n[n.length-1]}else{throw ("Missing GenericArguments")}break;case 11:v=n[n.length-1];break;case 12:v=makeList(n[n.length-3],n[n.length-1]);break;case 13:v=makeList(n[n.length-1]);break;case 14:v=n[n.length-0];break;case 15:v=n[n.length-1];break;case 16:v=n[n.length-2]+n[n.length-1];break;case 17:v=n[n.length-1];break;case 18:v=n[n.length-2]+n[n.length-1];break;case 19:v=makeList(n[n.length-2],n[n.length-1]);break;case 20:v=n[n.length-0];break;case 21:v=new ADL.Reference(n[n.length-2],n[n.length-1]);break;case 22:v=new ADL.Multiplicity(n[n.length-2]);break;case 23:v=new ADL.Multiplicity(n[n.length-4],n[n.length-2]);break;case 24:v=n[n.length-0];break;case 25:v=makeList(n[n.length-2],n[n.length-1]);break;case 26:v=n[n.length-0];break;case 27:v=new ADL.Modifier(n[n.length-1]);break;case 28:v=new ADL.Modifier(n[n.length-3],n[n.length-1]);break;case 29:v=new ADL.Value(n[n.length-1]);break;case 30:v=n[n.length-0];break;case 31:v=n[n.length-1];break;case 32:v=n[n.length-1];break;case 33:v=n[n.length-1];break;case 34:v=n[n.length-2];break;case 35:v=null;break}if(_dbg_withtrace){__dbg_print("\tPopping "+l[q][1]+" off the stack...")}for(var m=0;m<l[q][1];m++){b.pop();n.pop()}f=-1;for(var m=0;m<k[b[b.length-1]].length;m+=2){if(k[b[b.length-1]][m]==l[q][0]){f=k[b[b.length-1]][m+1];break}}if(q==0){break}if(_dbg_withtrace){__dbg_print("\tPushing non-terminal "+p[l[q][0]])}b.push(f);n.push(v)}if(_dbg_withtrace){alert(_dbg_string);_dbg_string=new String()}}if(_dbg_withtrace){__dbg_print("\nParse complete.");alert(_dbg_string)}return e}ADL.version="0.4-11";function tabberObj(b){var a;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=["h2","h3","h4","h5","h6"];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat="<tabberid>nav<tabnumberone>";for(a in b){this[a]=b[a]}this.REclassMain=new RegExp("\\b"+this.classMain+"\\b","gi");this.REclassMainLive=new RegExp("\\b"+this.classMainLive+"\\b","gi");this.REclassTab=new RegExp("\\b"+this.classTab+"\\b","gi");this.REclassTabDefault=new RegExp("\\b"+this.classTabDefault+"\\b","gi");this.REclassTabHide=new RegExp("\\b"+this.classTabHide+"\\b","gi");this.tabs=new Array();if(this.div){this.init(this.div);this.div=null}}tabberObj.prototype.init=function(f){var k,d,b,m,g=0,n,a,l,c,h;if(!document.getElementsByTagName){return false}if(f.id){this.id=f.id}this.tabs.length=0;k=f.childNodes;for(d=0;d<k.length;d++){if(k[d].className&&k[d].className.match(this.REclassTab)){m=new Object();m.div=k[d];this.tabs[this.tabs.length]=m;if(k[d].className.match(this.REclassTabDefault)){g=this.tabs.length-1}}}n=document.createElement("ul");n.className=this.classNav;for(d=0;d<this.tabs.length;d++){m=this.tabs[d];m.headingText=m.div.title;if(this.removeTitle){m.div.title=""}if(!m.headingText){for(b=0;b<this.titleElements.length;b++){h=m.div.getElementsByTagName(this.titleElements[b])[0];if(h){m.headingText=h.innerHTML;if(this.titleElementsStripHTML){m.headingText.replace(/<br>/gi," ");m.headingText=m.headingText.replace(/<[^>]+>/g,"")}break}}}if(!m.headingText){m.headingText=d+1}a=document.createElement("li");m.li=a;l=document.createElement("a");l.appendChild(document.createTextNode(m.headingText));l.href="javascript:void(null);";l.title=m.headingText;l.onclick=this.navClick;l.tabber=this;l.tabberIndex=d;if(this.addLinkId&&this.linkIdFormat){c=this.linkIdFormat;c=c.replace(/<tabberid>/gi,this.id);c=c.replace(/<tabnumberzero>/gi,d);c=c.replace(/<tabnumberone>/gi,d+1);c=c.replace(/<tabtitle>/gi,m.headingText.replace(/[^a-zA-Z0-9\-]/gi,""));l.id=c}a.appendChild(l);n.appendChild(a)}f.insertBefore(n,f.firstChild);f.className=f.className.replace(this.REclassMain,this.classMainLive);this.tabShow(g);if(typeof this.onLoad=="function"){this.onLoad({tabber:this})}return this};tabberObj.prototype.navClick=function(g){var d,b,c,f,e;b=this;if(!b.tabber){return false}c=b.tabber;f=b.tabberIndex;b.blur();if(typeof c.onClick=="function"){e={tabber:c,index:f,event:g};if(!g){e.event=window.event}d=c.onClick(e);if(d===false){return false}}c.tabShow(f);return false};tabberObj.prototype.tabHideAll=function(){var a;for(a=0;a<this.tabs.length;a++){this.tabHide(a)}};tabberObj.prototype.tabHide=function(a){var b;if(!this.tabs[a]){return false}b=this.tabs[a].div;if(!b.className.match(this.REclassTabHide)){b.className+=" "+this.classTabHide}this.navClearActive(a);return this};tabberObj.prototype.tabShow=function(a){var b;if(!this.tabs[a]){return false}this.tabHideAll();b=this.tabs[a].div;b.className=b.className.replace(this.REclassTabHide,"");this.navSetActive(a);if(typeof this.onTabDisplay=="function"){this.onTabDisplay({tabber:this,index:a})}return this};tabberObj.prototype.navSetActive=function(a){this.tabs[a].li.className=this.classNavActive;return this};tabberObj.prototype.navClearActive=function(a){this.tabs[a].li.className="";return this};function tabberAutomatic(d){var a,c,b;if(!d){d={}}a=new tabberObj(d);c=document.getElementsByTagName("div");for(b=0;b<c.length;b++){if(c[b].className&&c[b].className.match(a.REclassMain)){d.div=c[b];c[b].tabber=new tabberObj(d)}}return this}function tabberAutomaticOnLoad(b){var a;if(!b){b={}}a=window.onload;if(typeof window.onload!="function"){window.onload=function(){tabberAutomatic(b)}}else{window.onload=function(){a();tabberAutomatic(b)}}}if(typeof tabberOptions=="undefined"){tabberAutomaticOnLoad()}else{if(!tabberOptions.manualStartup){tabberAutomaticOnLoad(tabberOptions)}}if(!window.Node){window.Node=new Object();Node.ELEMENT_NODE=1;Node.ATTRIBUTE_NODE=2;Node.TEXT_NODE=3;Node.CDATA_SECTION_NODE=4;Node.ENTITY_REFERENCE_NODE=5;Node.ENTITY_NODE=6;Node.PROCESSING_INSTRUCTION_NODE=7;Node.COMMENT_NODE=8;Node.DOCUMENT_NODE=9;Node.DOCUMENT_TYPE_NODE=10;Node.DOCUMENT_FRAGMENT_NODE=11;Node.NOTATION_NODE=12}if(typeof decomposeVersion!="function"){function decomposeVersion(b){var a=b.match(/([0-9]+)\.([0-9]+)(-([0-9]+))?/);return{major:parseInt(a[1]),minor:parseInt(a[2]),build:parseInt(a[4])||0}}}if(typeof iRequire!="function"){function iRequire(d,a,c){var b=decomposeVersion(d.version);a=decomposeVersion(a);if((b.major<a.major)||(b.major==a.major&&b.minor<a.minor)||(b.major==a.major&&b.minor==a.minor&&b.build<a.build)){return false}if(c){c=decomposeVersion(c);if((b.major>c.major)||(b.major==c.major&&b.minor>c.minor)||(b.major==c.major&&b.minor==c.minor&&b.build>c.build)){return false}}return true}}if(!iRequire(ADL,"0.1-4")){alert("Canvas2D requires at least ADL version 0.1-4. Current ADL version = "+ADL.version)}if(!document.createElement("canvas").getContext&&!G_vmlCanvasManager.initElement){alert("You browser doesn't support the Canvas element. If you're using IE, ExplorerCanvas is required.")}else{if(typeof CanvasTextFunctions=="undefined"){alert("Canvas2D requires the CanvasText implementation.")}}function unless(b,a){if(!b){a()}}function max(d,c){return d<c?c:d}function min(d,c){return d<c?d:c}if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}Array.prototype.contains=function(a){return this.indexOf(a)>-1};function getFontSize(a){var b=null;b=toPx(a,"px");if(b==null){b=toPx(a,"pt");if(b==null){b=toPx(a,"em");if(b==null){b=toPx(a,"pct");if(b!=null){return b}}else{return b}}else{return b}}else{return b}throw ("cannot get size from font specifier: "+a)}function toPx(b,e){if(!b){console.log("Common::toPx: require a valid font. Got: '"+b+"'");return}var d=[{pt:5.5,px:6,em:0.375,pct:37.5},{pt:6,px:8,em:0.5,pct:50},{pt:7,px:9,em:0.55,pct:55},{pt:7.5,px:10,em:0.625,pct:62.5},{pt:8,px:11,em:0.7,pct:70},{pt:9,px:12,em:0.75,pct:75},{pt:10,px:13,em:0.8,pct:80},{pt:10.5,px:14,em:0.875,pct:87.5},{pt:11,px:15,em:0.95,pct:95},{pt:12,px:16,em:1,pct:100},{pt:13,px:17,em:1.05,pct:105},{pt:13.5,px:18,em:1.125,pct:112.5},{pt:14,px:19,em:1.2,pct:120},{pt:14.5,px:20,em:1.25,pct:125},{pt:15,px:21,em:1.3,pct:130},{pt:16,px:22,em:1.4,pct:140},{pt:17,px:23,em:1.45,pct:145},{pt:18,px:24,em:1.5,pct:150},{pt:20,px:26,em:1.6,pct:160},{pt:22,px:29,em:1.8,pct:180},{pt:24,px:32,em:2,pct:200},{pt:26,px:35,em:2.2,pct:220},{pt:27,px:36,em:2.25,pct:225},{pt:28,px:37,em:2.3,pct:230},{pt:29,px:38,em:2.35,pct:235},{pt:30,px:40,em:2.45,pct:245},{pt:32,px:42,em:2.55,pct:255},{pt:34,px:45,em:2.75,pct:275},{pt:36,px:48,em:3,pct:300}];var a=b.match("(\\d+)"+e+"\\s*/");if(a==null){a=b.match("(\\d+)"+e+"\\s*");if(a!=null){a=a[1]}}else{a=a[1]}if(a!=null){for(var c=0;c<d.length;c++){if(d[c][e]==a){return d[c]["px"]}}}return null}function Timer(){this.now=new Date().getTime();this.stop=function(){return new Date().getTime()-this.now}}var Canvas2D={shapes:$H(),libraries:$H(),extensions:[],activate:function activate(d){var a=document.getElementById(d);if(a){var c=new Canvas2D.Manager();var a=c.setupBook(d);var b=a.addSheet();c.startAll();return b}throw (d+" does not reference a known id on the document.")},registerShape:function registerShape(b){b.prototype.__CLASS__=b;b.prototype.getClass=function a(){return this.__CLASS__};Canvas2D.Shape.manifestHandling.iterate(function(c,d){b[c]=d});b.getTypes().iterate(function(c){Canvas2D.shapes.set(c,b)});b.getLibraries().iterate(function(c){if(!Canvas2D.libraries.get(c)){Canvas2D.libraries.set(c,[])}Canvas2D.libraries.get(c).push(b)})},getBook:function(a){return Canvas2D.KickStarter.manager.getBook(a)}};Canvas2D.Factory={extensions:{all:{}}};Canvas2D.Factory.extensions.all.ShortHands={clear:function clear(){this.clearRect(0,0,this.canvas.width,this.canvas.height)},fillTextCenter:function fillTextCenter(d,a,e,c){var b=this.measureText(d)/2;this.fillText(d,a-b,e,c)},fillTextRight:function fillTextRight(d,a,e,c){var b=this.measureText(d);this.fillText(d,a-b,e,c)},strokeTextCenter:function strokeTextCenter(d,a,e,c){var b=this.measureText(d)/2;this.strokeText(d,a-b,e,c)},strokeTextRight:function strokeTextRight(d,a,e,c){var b=this.measureText(d);this.strokeText(d,a-b,e,c)},fillStrokeRect:function fillStrokeRect(d,c,b,a){this.fillRect(d,c,b,a);this.strokeRect(d,c,b,a)}};Canvas2D.Factory.extensions.all.EventHandling={on:function on(b,a){if(!this.eventHandlers){this.eventHandlers=[]}if(!this.eventHandlers[b]){this.eventHandlers[b]=[]}this.eventHandlers[b].push(a)},fireEvent:function fireEvent(a,b){if(!this.eventHandlers){return}if(this.eventHandlers[a]){this.eventHandlers[a].iterate(function(c){c(b)})}}};Canvas2D.Factory.extensions.all.ExtendedCanvasSupport={__extend__:function __extend__(a){var c=["useCrispLines","textDecoration","lineStyle"];var b=a.save;a.save=function(){var e={};var f=this;c.iterate(function(g){e[g]=f[g]});if(!this.savedValues){this.savedValues=[]}this.savedValues.push(e);b.apply(this)};var d=a.restore;a.restore=function(){if(!this.savedValues){return}var e=this.savedValues.pop();var f=this;c.iterate(function(g){f[g]=e[g]});d.apply(this)};return a}};Canvas2D.Factory.extensions.all.DashedLineSupport={__extend__:function __extend__(a){["_setCurrentXY","_plotPixel","_drawLine"].iterate(function(b){a[b]=Canvas2D.Factory.extensions.all.DashedLineSupport[b]});a.nativeMoveTo=a.moveTo;a.moveTo=function(b,c){a.nativeMoveTo.apply(this,arguments);this._setCurrentXY(b,c)};a.nativeLineTo=a.lineTo;a.lineTo=function(b,c){if(this.lineStyle=="dashed"){this._drawLine(this.currentX,this.currentY,b,c)}else{this.nativeLineTo.apply(this,arguments)}this._setCurrentXY(b,c)};return a},_setCurrentXY:function _setCurrentXY(a,b){if(!this.currentX){this.currentX=0}if(!this.currentY){this.currentY=0}this.currentX=a;this.currentY=b},_plotPixel:function _plotPixel(a,e,d){var b=this.strokeStyle;this.beginPath();this.strokeStyle=d;this.fillStyle=d;this.moveTo(a,e);this.nativeLineTo(a+1,e+1);this.stroke();this.closePath();this.strokeStyle=b},_drawLine:function _drawLine(g,s,e,q){g=Math.floor(g);e=Math.floor(e);s=Math.floor(s-1);q=Math.floor(q-1);this.stroke();var n=this.strokeStyle;var d=this.lineStyle;var o=Math.abs(q-s)>Math.abs(e-g);if(o){t=s;s=g;g=t;t=q;q=e;e=t}var l=Math.abs(e-g);var k=Math.abs(q-s);var m=0;var u=k;var f;var a;var r=g;var p=s;if(g<e){f=1}else{f=-1}if(s<q){a=1}else{a=-1}if(o){this._plotPixel(p,r,n)}else{this._plotPixel(r,p,n)}var b=0;while(r!=e){r=r+f;m=m+u;if(2*m>=l){p=p+a;m=m-l}var h=(d!="dashed"||++b%15)<10?n:"white";if(o){this._plotPixel(p,r,h)}else{this._plotPixel(r,p,h)}}}};Canvas2D.Factory.extensions.all.CrispLineSupport={__extend__:function __extend__(a){["strokeRect","moveTo","lineTo","rect"].iterate(function(b){var c=a[b];a[b]=function(d,k,e,g){if(!this.useCrispLines){return c.apply(this,arguments)}var f=Canvas2D.Factory.extensions.all.CrispLineSupport.makeCrisp(d,k,e,g,this.lineWidth);return c.apply(this,[f.x,f.y,f.w,f.h])}});return a},makeCrisp:function makeCrisp(m,k,a,f,e){var c=m;var l=k;var b=a;var g=f;var n=a;var d=f;if(e%2){c=Math.floor(m)+0.5;l=Math.floor(k)+0.5;if(typeof b!="undefined"){b=Math.floor(a)+0.5;g=Math.floor(f)+0.5}if(a%1!=0){n=Math.floor(a)}if(f%1!=0){d=Math.floor(f)}}else{c=Math.floor(m);l=Math.floor(k);if(typeof b!="undefined"){b=Math.floor(a);g=Math.floor(f)}if(a%1!=0){n=Math.floor(a)+0.5}if(f%1!=0){d=Math.floor(f)+0.5}}return{x:c,y:l,x1:c,y1:l,w:n,h:d,x2:b,y2:g}}};Canvas2D.Factory.extensions.all.TextDecorationSupport={decorateText:function decorateText(c,a,d,b){if(!this.textDecoration){return}this.save();this.useCrispLines=true;this.strokeStyle="black";this.textDecoration.toLowerCase().split(" ").iterate(function(f){var e=null;switch(f){case"underline":e=this.underlineText;break;case"overline":e=this.overlineText;break;case"line-through":e=this.linethroughText;break}if(e){this.beginPath();var g=this.measureText(c);if(g>b){g=b}e.call(this,c,a,d,g);this.stroke();this.closePath()}}.scope(this));this.restore()},underlineText:function underlineText(c,a,d,b){this.moveTo(a,d+3);this.lineTo(a+b,d+3)},overlineText:function overlineText(c,a,d,b){this.moveTo(a,d-getFontSize(this.font));this.lineTo(a+b,d-getFontSize(this.font))},linethroughText:function linethroughText(c,a,d,b){this.moveTo(a,d-(getFontSize(this.font)/2)+2);this.lineTo(a+b,d-(getFontSize(this.font)/2)+2)}};Canvas2D.Factory.extensions.all.MouseEvents={setupMouseEventHandlers:function setupMouseEventHandlers(){ProtoJS.Event.observe(this.canvas,"mousedown",this.handleMouseDown.scope(this));ProtoJS.Event.observe(this.canvas,"mouseup",this.handleMouseUp.scope(this));ProtoJS.Event.observe(document,"mousemove",this.handleMouseMove.scope(this));ProtoJS.Event.observe(this.canvas,"dblclick",this.handleDoubleClick.scope(this))},getLeft:function getLeft(){var a=this.canvas;var b=0;while(a!=null){b+=a.offsetLeft;a=a.offsetParent}return b},getTop:function getTop(){var a=this.canvas;var b=0;while(a!=null){b+=a.offsetTop;a=a.offsetParent}return b},getXY:function getXY(b){var a,c;if(ProtoJS.Browser.IE){a=event.clientX+document.body.scrollLeft;c=event.clientY+document.body.scrollTop}else{a=b.pageX;c=b.pageY}return{x:a-this.getLeft(),y:c-this.getTop()}},handleMouseDown:function handleMouseDown(a){this.mousepressed=true;var b=this.getXY(a);this.fireEvent("mousedown",b);this.mousePos=b},handleMouseUp:function handleMouseUp(a){this.mousepressed=false;var b=this.getXY(a);this.fireEvent("mouseup",b);this.mousePos=b},handleMouseMove:function handleMouseMove(b){if(this.mousepressed){this.handleMouseDrag(b)}var c=this.getXY(b);if(c){var a=this.mouseOver;this.mouseOver=(c.x>=0&&c.x<=this.canvas.width)&&(c.y>=0&&c.y<=this.canvas.height);if(this.mouseOver&&!a){this.fireEvent("mouseEnter")}if(!this.mouseOver&&a){this.fireEvent("mouseLeave")}}},handleMouseDrag:function handleMouseDrag(a){var b=this.getXY(a);this.fireEvent("mousedrag",{x:b.x,y:b.y,dx:b.x-this.mousePos.x,dy:b.y-this.mousePos.y});this.mousePos=b},handleDoubleClick:function handleDoubleClick(a){var b=this.getXY(a);this.fireEvent("dblclick",b);this.mousePos=b}};Canvas2D.Factory.extensions.TouchEvents={setupTouchEventHandlers:function setupTouchEventHandlers(){ProtoJS.Event.observe(this.canvas,"touchstart",this.handleTouchStart.scope(this));ProtoJS.Event.observe(this.canvas,"touchmove",this.handleTouchMove.scope(this));ProtoJS.Event.observe(this.canvas,"touchend",this.handleTouchEnd.scope(this))},handleTouchStart:function handleTouchStart(a){if(a.touches.length==1){this.handleMouseDown(a.touches[0]);a.preventDefault()}},handleTouchMove:function handleTouchMove(a){if(a.touches.length==1){this.handleMouseDrag(a.touches[0]);a.preventDefault()}},handleTouchEnd:function handleTouchEnd(a){this.handleMouseUp(a);a.preventDefault()}};Canvas2D.Factory.extensions.all.TextSupport={adjustToAlignment:function adjustToAlignment(a,b){switch(this.textAlign){case"center":a-=this.measureText(b)/2;break;case"right":a-=this.measureText(b);break}return a},getFontSize:function(){return getFontSize(this.font||Canvas2D.Sheet.Defaults.font)}};Canvas2D.Factory.extensions.CanvasText={fillText:function fillText(c,a,d,b){this.strokeText(c,a,d,b)},strokeText:function strokeText(c,a,d,b){this.beginPath();this.save();this.strokeStyle=this.fillStyle;a=this.adjustToAlignment(a,c);CanvasTextFunctions.draw(this,this.font,getFontSize(this.font),a,d,c);this.decorateText(c,a,d,b);this.restore();this.closePath()},measureText:function measureText(a){return CanvasTextFunctions.measure(this.font,getFontSize(this.font),a)}};Canvas2D.Factory.extensions.HTML5CanvasText={__extend__:function __extend__(d){var g=d.measureText;d.measureText=function c(h){return g.apply(this,arguments).width};var f=d.fillText;d.fillText=function e(l,h,m,k){k=k||this.measureText(l);f.apply(this,arguments);h=this.adjustToAlignment(h,l);this.decorateText(l,h,m,k)};var b=d.strokeText;d.strokeText=function a(l,h,m,k){k=k||this.measureText(l);b.apply(this,arguments);h=this.adjustToAlignment(h,l);this.decorateText(l,h,m,k)};return d}};Canvas2D.Factory.extensions.GeckoCanvasText={fillText:function fillText(c,a,d,b){a=this.adjustToAlignment(a,c);this._drawText(c,a,d,true);this.decorateText(c,a,d,b)},strokeText:function strokeText(c,a,d,b){a=this.adjustToAlignment(a,c);this._drawText(c,a,d,false);this.decorateText(c,a,d,b)},measureText:function measureText(b){this.save();this.mozTextStyle=this.font;var a=this.mozMeasureText(b);this.restore();return a},_drawText:function _drawText(c,a,d,b){this.save();this.beginPath();this.translate(a,d);this.mozTextStyle=this.font;this.mozPathText(c);if(b){this.fill()}else{this.stroke()}this.closePath();this.restore()}};Canvas2D.Factory.setup=function(b){if(!Canvas2D.initialized){Canvas2D.initialized=true;if(!window.CanvasRenderingContext2D){window.CanvasRenderingContext2D=document.createElement("canvas").getContext("2d").__proto__}else{window.CanvasRenderingContext2D=CanvasRenderingContext2D.prototype}}unless(b&&b.nodeType&&b.nodeType==1,function(){throw ("CanvasBase:initialize: expected HTMLElement")});try{var a=b.getContext("2d")}catch(c){throw ("Canvas2D: element is no HTML5 Canvas.")}if(a.strokeText&&a.fillText&&a.measureText&&!navigator.userAgent.contains("OS 3_2")){a=Canvas2D.Factory.extensions.HTML5CanvasText.__extend__(a)}else{if(a.mozMeasureText&&a.mozPathText){ProtoJS.mix(Canvas2D.Factory.extensions.GeckoCanvasText,a,true)}else{ProtoJS.mix(Canvas2D.Factory.extensions.CanvasText,a,true);if(ProtoJS.Browser.IE){Canvas2D.Book.prototype.addWaterMark=function(){}}}}if(ProtoJS.Browser.MobileSafari){ProtoJS.mix(Canvas2D.Factory.extensions.TouchEvents,a,true);a.setupTouchEventHandlers()}$H(Canvas2D.Factory.extensions.all).values().iterate(function(d){if(d.__extend__){a=d.__extend__(a)}else{ProtoJS.mix(d,a,true)}});$H(Canvas2D.Defaults.Canvas).iterate(function(d,e){a[d]=e});a.setupMouseEventHandlers();return a};ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D);Canvas2D.KeyboardDriver=Class.extend({init:function initialize(){this.currentKeysDown=[];ProtoJS.Event.observe(document,"keydown",this.handleKeyDownEvent.scope(this));ProtoJS.Event.observe(document,"keyup",this.handleKeyUpEvent.scope(this))},handleKeyDownEvent:function(b){var a=(b||window.event).keyCode;this.currentKeysDown.push(a);this.fireEvent("keydown",a)},handleKeyUpEvent:function handleKeyUpEvent(b){var a=(b||window.event).keyCode;this.currentKeysDown=this.currentKeysDown.remove(a);this.fireEvent("keyup",a)},getCurrentKeysDown:function getCurrentKeysDown(){return this.currentKeysDown},keyDown:function keyDown(a){return this.currentKeysDown.contains(a)}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.KeyboardDriver.prototype);Canvas2D.Keyboard=new Canvas2D.KeyboardDriver();Canvas2D.ImageManager={};Canvas2D.ImageManager.work=0;Canvas2D.ImageManager.load=function(c,b){var a=new Image();Canvas2D.ImageManager.work++;a.onload=function(){Canvas2D.ImageManager.work--;b()};a.src=c;return a};Canvas2D.ImageManager.isReady=function(){return Canvas2D.ImageManager.work==0};Canvas2D.Manager=Class.extend({init:function(){this.plugins=[];this.books=$H()},setupBook:function(a){return this.addBook(new Canvas2D.Book(a))},addBook:function(a){unless(a instanceof Canvas2D.Book,function(){throw ("Manager::addBook: book must be instance of Canvas2D.Book")});this.books.set(a.name,a);return a},getBook:function(a){return this.books.get(a)},startAll:function(){if(Canvas2D.ImageManager.isReady()){this.plugins.iterate(function(a){a.start()});this.books.values().iterate(function(a){a.start()})}else{this.startAll.scope(this).after(10)}}});Canvas2D.ADLVisitor=Class.extend({init:function(){this.errors=[]},visit:function(a,c){var d=a.type.toLowerCase();if(d=="root"){a.childrenAccept(this,c);return c}else{if(Canvas2D.shapes.get(d)){var b=Canvas2D.shapes.get(d).from(a,c);if(b){if(b.errors){b.errors.iterate(function(h){this.errors.push(h)}.scope(this))}else{if(b.warnings){b.warnings.iterate(function(h){this.errors.push(h)}.scope(this))}var f,e;if(a.annotation&&c.at){var g=a.annotation.data.split(",");f=parseInt(g[0]);e=parseInt(g[1]);c.at(f,e).add(b)}else{c.add(b)}a.childrenAccept(this,b)}}return a}else{this.errors.push("Unknown Construct Type: "+a.type);return c}}}});Canvas2D.Book=Class.extend({init:function(a){unless(a&&a.nodeType&&a.nodeType==Node.ELEMENT_NODE,function(){a=document.getElementById(a)});this.canvas=Canvas2D.Factory.setup(a);this.sheets=[];this.currentSheet=0;this.canvas.on("mousedown",function(c){this.fireEvent("mousedown");var b;if(b=this.getCurrentSheet()){b.handleMouseDown(c)}}.scope(this));this.canvas.on("mouseup",function(c){this.fireEvent("mouseup");var b;if(b=this.getCurrentSheet()){b.handleMouseUp(c)}}.scope(this));this.canvas.on("mousedrag",function(c){this.fireEvent("mousedrag");var b;if(b=this.getCurrentSheet()){b.handleMouseDrag(c)}}.scope(this));this.console=document.getElementById(a.id+"Console");this.source=document.getElementById(a.id+"Source");this.generated=document.getElementById(a.id+"Generated");this.name=a.id;this.setupExtensions();this.setupPlugins()},add:function(a){return this.addSheet(a)},addSheet:function(a){unless(a instanceof Canvas2D.Sheet,function(){a=new Canvas2D.Sheet({book:this})}.scope(this));a.setCanvas(this.canvas);a.on("change",this.rePublish.scope(this));a.on("newShape",this.log.scope(this));this.sheets.push(a);return a},setupExtensions:function(){this.extensions=new Hash();Canvas2D.extensions.iterate(function(a){this.extensions.set(a.name,a)}.scope(this))},setupPlugins:function(){this.plugins={};$H(Canvas2D.Book.plugins).iterate(function(a,c){var b=new (c)(this);this.plugins[a]=b;if(c.exposes){c.exposes.iterate(function(d){this[d]=function(g,f,e){this.plugins[a][d](g,f,e)}}.scope(this))}}.scope(this))},log:function(a){if(this.console){this.console.value="["+(new Date).toLocaleString()+"] "+a+"\n"+this.console.value}},getCurrentSheet:function(){return this.sheets[this.currentSheet]},clear:function(){this.sheets.length=0},start:function(){this.stop();this.rePublish();this.publish()},stop:function(){if(this.nextPublish){window.clearTimeout(this.nextPublish)}},freeze:function(){this.wait=true},thaw:function(){this.wait=false},load:function(c){var d=new ADL.Parser();var a;this.errors="";if((a=d.parse(c))){this.clear();this.freeze();var b=new Canvas2D.ADLVisitor();a.getRoot().accept(b,this);this.thaw();this.rePublish();if(b.errors.length>0){this.errors="ADLVisitor reported errors:";b.errors.iterate(function(e){this.log(e);this.errors+="\n   - "+e}.scope(this))}this.fireEvent("sourceLoaded");return true}else{this.log(d.errors);this.errors=d.errors;this.fireEvent("sourceLoaded");return false}},toADL:function(){var a="";this.sheets.iterate(function(b){a+=b.toADL()+"\n"});return a},rePublish:function(){this.rePublishNeeded=true},publish:function(){if(this.rePublishNeeded&&!this.wait){this.publishOnce();this.rePublishNeeded=false;this.afterPublish()}this.nextPublish=this.publish.scope(this).after(10)},publishOnce:function(){var a=new Timer();this.canvas.clear();if(this.getCurrentSheet()){this.beforeRender();this.getCurrentSheet().render();this.afterRender()}this.log("Canvas2D::publish: RenderTime: "+a.stop()+"ms")},afterPublish:function afterPublish(){$H(this.plugins).iterate(function(a,b){if(b.afterPublish){b.afterPublish(this)}}.scope(this))},beforeRender:function beforeRender(){$H(this.plugins).iterate(function(a,b){if(b.beforeRender){b.beforeRender(this)}}.scope(this))},afterRender:function afterRender(){$H(this.plugins).iterate(function(a){if(a.afterRender){a.afterRender(this)}}.scope(this));this.updateExternalSource()},updateExternalSource:function updateExternalSource(){if(this.getCurrentSheet()){var a=this.getCurrentSheet().toADL();if(this.generated&&a!=this.generated.value){this.generated.value=a}this.fireEvent("sourceUpdated",a)}}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.Book.prototype);Canvas2D.Book.plugins={};Canvas2D.ShapeCounter={};Canvas2D.Shape=Class.extend({init:function initialize(b){b=b||{};if(!b.name){b.name=this.getPropertyDefault("name")||"__shape__";if(!Canvas2D.ShapeCounter[b.name]){Canvas2D.ShapeCounter[b.name]=0}b.name+=Canvas2D.ShapeCounter[b.name]++}b=this.preprocess(b);this.setProperties(b);this.getPropertyList().iterate(function a(e){var d=e.substr(0,1).toUpperCase()+e.substr(1);var c="get"+d;if(typeof this[c]=="undefined"){this[c]=function(){return this.getProperty(e)}}}.scope(this));this.postInitialize()},setParent:function setParent(a){this.parent=a},getParent:function getParent(){return this.parent},prepare:function prepare(a){},setProperties:function setProperties(b){this.getPropertyList().iterate(function a(c){this[c]=b[c]!=null?b[c]:null}.scope(this))},setProperty:function setProperty(b,a){this[b]=a!=null?a:null;this.fireEvent("change")},getProperty:function getProperty(c){if(typeof this[c]=="undefined"){var b=c.substr(0,1).toUpperCase()+c.substr(1);var a="get"+b;return this[a]()}else{return this[c]!=null?this[c]:this.getPropertyDefault(c)}},getPropertyDefault:function getPropertyDefault(c){var a=null;this.getClassHierarchy().reverse().iterate(function b(d){if(a==null&&typeof d.Defaults[c]!="undefined"){a=d.Defaults[c]}});return a},toADL:function(a){return this.constructToString(this.asConstruct(),a)},asConstruct:function(){var a={__SHAPE__:this,annotation:{data:null},type:this.getType(),name:this.getName(),supers:[],modifiers:{},children:[],addModifiers:function(b){b.iterate(function(c){if(this.__SHAPE__.getProperty(c)){this.addModifier(c,this.__SHAPE__.getProperty(c))}}.scope(this))},addModifier:function(b,c){if(this.__SHAPE__.getPropertyDefault(b)!=c){this.modifiers[b]='"'+c+'"'}}};a.addModifiers(["label","labelPos","labelColor"]);return a},constructToString:function(a,e){if(a==null){return""}var b="";if(a.annotation&&a.annotation.data){b+=e+"[@"+a.annotation.data+"]\n"}b+=e+a.type+" "+a.name;a.supers.iterate(function(g){b+=" : "+g});$H(a.modifiers).iterate(function f(g,h){if(typeof h!="function"){b+=" +"+g;if(h){b+="="+h}}});if(a.children.length>0){b+=" {\n";var c=this;a.children.iterate(function d(g){b+=c.constructToString(g,e+"  ")+"\n"});b+=e+"}"}else{b+=";"}return b},delayRender:function(){return false},drawLabel:function(a,c,b){if(this.getLabel()&&this.getHeight()!=null&&this.getCenter()){c+=this.getCenter().left;switch(this.getLabelPos()){case"top":b+=-5;break;case"top-inner":b+=+16;break;case"bottom":b+=this.getHeight()+11;break;case"bottom-inner":b+=this.getHeight()-8;break;case"center":default:b+=this.getCenter().top+2.5}a.save();a.fillStyle=this.getLabelColor();a.textAlign=this.getLabelAlign();a.font=this.getLabelFont();a.useCrispLines=this.getLabelUseCrispLines();a.fillText(this.getLabel(),c,b);a.restore()}},render:function(a,c,b){this.prepare(a);a.save();this.draw(a,c,b);this.drawLabel(a,c,b);a.restore()},getType:function(){throw ("Missing getType. Did you register the shape?")},getClasSHierarchy:function(){throw ("Missing getClassHierarchy. Did you register the shape?")},preprocess:function preprocess(a){return a},postInitialize:function postInitialize(){},draw:function draw(a,c,b){},hit:function hit(a,b){return false},hitArea:function hitArea(b,c,a,d){return false},getCenter:function getCenter(){return null},getPort:function getPort(a){return null}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.Shape.prototype);Canvas2D.Shape.MANIFEST={name:"shape",properties:["name","label","labelPos","labelColor","labelAlign","labelFont","labelUseCrispLines","useCrispLines","topDown"]};Canvas2D.Shape.manifestHandling=$H({getManifest:function getManifest(){return this.MANIFEST||this.__CLASS__.MANIFEST},getType:function getType(){return this.getManifest().name},getTypes:function getTypes(){return[this.getType()].concat(this.getAliasses())},getPropertyPath:function getPropertyPath(){return this.getManifest().propertyPath||[]},getClassHierarchy:function getClassHierarchy(){var a=[Canvas2D.Shape].concat(this.getPropertyPath());a.push(this.getClass());return a},getLocalProperties:function getLocalProperties(){return this.getManifest().properties||[]},getPropertyList:function getPropertyList(){if(!this.allPropertiesCache){this.allPropertiesCache=[];this.getClassHierarchy().iterate(function a(b){this.allPropertiesCache=this.allPropertiesCache.concat(b.getLocalProperties())}.scope(this))}return this.allPropertiesCache},getAliasses:function getAliasses(){return this.getManifest().aliasses||[]},getLibraries:function getLibraries(){return this.getManifest().libraries||[]}});Canvas2D.Shape.manifestHandling.iterate(function(a,b){Canvas2D.Shape.prototype[a]=b;Canvas2D.Shape[a]=b});Canvas2D.Sheet=Class.extend({init:function init(a){a=a||{};this.book=a.book;this.name=a.name||"default";this.style=a.style||"static";this.clear();this.dirty=false;if(a.canvas){this.setCanvas(a.canvas)}Canvas2D.Keyboard.on("keyup",this.handleKeyDown.scope(this))},setCanvas:function setCanvas(a){this.canvas=a;this.wireCanvasDelegation();this.setupProperties()},getHeight:function getHeight(){return this.canvas.canvas.height},wireCanvasDelegation:function wireCanvasDelegation(){if(!this.canvas){return}Canvas2D.Sheet.Operations.iterate(function(a){if(a=="restore"){this[a]=function(){this.canvas[a].apply(this.canvas,arguments);this.transferBackProperties();return}.scope(this)}else{this[a]=function(){this.transferProperties();return this.canvas[a].apply(this.canvas,arguments)}.scope(this)}}.scope(this))},setupProperties:function setupProperties(){Canvas2D.Sheet.Properties.iterate(function(a){this[a]=Canvas2D.Sheet.Defaults[a]||this.canvas[a]}.scope(this))},transferProperties:function(){Canvas2D.Sheet.Properties.iterate(function(a){this.canvas[a]=this[a]}.scope(this))},transferBackProperties:function(){Canvas2D.Sheet.Properties.iterate(function(a){this[a]=this.canvas[a]}.scope(this))},makeDirty:function(){this.dirty=true;this.fireEvent("change")},isDirty:function(){return this.dirty},clear:function(){this.positions=[];this.shapesMap={};this.positionsMap={};this.selectedShapes=[];this.fireEvent("change")},makeDynamic:function(){this.style="dynamic"},makeStatic:function(){this.style="static"},isDynamic:function(){return this.style=="dynamic"},isStatic:function(){return !this.isDynamic()},freeze:function(){this.fireEvent("freeze")},thaw:function(){this.fireEvent("thaw")},at:function(b,a){this.newTop=a;this.newLeft=b;return this},put:function(a){return this.add(a)},add:function(b){var d=b.getName().replace(/<.*$/,"");if(this.shapesMap[d]){var c=this.book?this.book:console;c.log("WARNING: Shape with name '"+d+"' already exists. Skipping.");return null}var a=new Canvas2D.Position(b,this.newLeft,this.newTop);b.on("change",this.makeDirty.scope(this));a.on("change",this.makeDirty.scope(this));this.newLeft=null;this.newTop=null;this.positions.push(a);this.shapesMap[d]=b;this.positionsMap[b.getName()]=a;this.fireEvent("newShape","added new shape"+(a.getLeft()!=null?"@"+a.getLeft()+","+a.getTop():""));this.makeDirty();return b},getPosition:function getPosition(a){return this.positionsMap[a.getName()]},hit:function(b,d){for(var c=this.positions.length-1;c>=0;c--){var a=this.positions[c];if(a.hit(b,d)){if(Canvas2D.Keyboard.keyDown(91)||Canvas2D.Keyboard.keyDown(17)){if(this.selectedShapes.contains(a)){this.selectedShapes.remove(a)}else{this.selectedShapes.push(a)}}else{if(!this.selectedShapes.contains(a)){this.selectedShapes=[a]}else{return}}this.fireEvent("shapeSelected",a);return}}this.selectedShapes=[]},hitArea:function(f,e,c,b){var a=(Canvas2D.Keyboard.keyDown(91)||Canvas2D.Keyboard.keyDown(17))?this.selectedShapes:[];for(var d=this.positions.length-1;d>=0;d--){if(this.positions[d].hitArea(f,e,c,b)){a.push(this.positions[d]);this.fireEvent("shapeSelected",this.positions[d])}}this.selectedShapes=a.unique()},handleMouseDown:function(a){if(!this.isDynamic()){return}this.hit(a.x,a.y);this.currentPos=a;this.makeDirty()},handleMouseUp:function(a){if(!this.isDynamic()){return}this.selectedShapes.iterate(function(b){this.fireEvent("shapesMoved","Shape moved to "+b.left+", "+b.top)}.scope(this));this.showSelection=false;this.makeDirty()},handleMouseDrag:function(a){if(!this.isDynamic()){return}if(!this.showSelection&&this.selectedShapes.length>0){this.moveCurrentSelection(a.dx,a.dy)}else{if(!this.currentPos){this.currentPos=a}this.showSelection=true;this.hitArea(this.currentPos.x,this.currentPos.y,a.x,a.y);this.selectionPos=a}this.makeDirty()},selectAllShapes:function(){this.selectedShapes=[];this.positions.iterate(function(a){this.selectedShapes.push(a)}.scope(this));this.makeDirty()},moveCurrentSelection:function(b,a){this.selectedShapes.iterate(function(c){c.move(b,a)}.scope(this))},handleKeyDown:function(a){if(Canvas2D.Keyboard.keyDown(16)){switch(a){case 37:this.moveCurrentSelection(-5,0);break;case 38:this.moveCurrentSelection(0,-5);break;case 39:this.moveCurrentSelection(5,0);break;case 40:this.moveCurrentSelection(0,5);break}}if((Canvas2D.Keyboard.keyDown(91)||Canvas2D.Keyboard.keyDown(17))&&a==65&&this.canvas.mouseOver){this.selectAllShapes()}},addSelectionOverlay:function(){if(this.showSelection){var c=this.selectionPos;var b=c.x-this.currentPos.x;var a=c.y-this.currentPos.y;this.canvas.fillStyle="rgba( 0, 0, 255, 0.1 )";this.canvas.fillRect(c.x<=this.currentPos.x?c.x:this.currentPos.x,c.y<=this.currentPos.y?c.y:this.currentPos.y,Math.abs(b),Math.abs(a))}},addSelectionMarkers:function(){this.selectedShapes.iterate(function(a){var b=a.getBox();this.canvas.fillStyle="rgba( 200, 200, 255, 1 )";[[b.left,b.top],[b.right,b.top],[b.left,b.bottom],[b.right,b.bottom]].iterate(function(c){this.canvas.beginPath();this.canvas.arc(c[0],c[1],5,0,Math.PI*2,true);this.canvas.fill()}.scope(this))}.scope(this))},render:function(){var a=[];this.positions.iterate(function(b){if(b.delayRender()){a.push(b)}else{b.render(this)}}.scope(this));a.iterate(function(b){b.render(this)}.scope(this));this.addSelectionOverlay();this.addSelectionMarkers()},toADL:function(){var a="";a+="Sheet "+this.name;a+=" +"+this.style+" {\n";this.positions.iterate(function(b){var c=b.toADL("  ");if(c){a+=c+"\n"}});a+="}";return a}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.Sheet.prototype);Canvas2D.Sheet.Properties=["globalAlpha","globalCompositeOperation","strokeStyle","fillStyle","lineWidth","lineCap","lineJoin","miterLimit","shadowOffsetX","shadowOffsetY","shadowBlur","shadowColor","font","textAlign","textBaseline","lineStyle","useCrispLines","textDecoration"];Canvas2D.Sheet.Operations=["save","restore","scale","rotate","translate","transform","setTransform","createRadialGradient","createPattern","clearRect","fillRect","strokeRect","beginPath","closePath","moveTo","lineTo","quadraticCurveTo","bezierCurveTo","arcTo","rect","arc","fill","stroke","clip","isPointInPath","fillText","fillText","strokeText","strokeText","measureText","drawImage","createImageData","getImageData","putImageData","getFontSize","fillStrokeRect"];Canvas2D.Sheet.from=function(a,c){var d="static";var b=a.modifiers.get("style");if(b){d=b.value.value.toLowerCase()}a.modifiers.iterate(function(e,f){if(e.toLowerCase()=="static"||e.toLowerCase()=="dynamic"){d=e.toLowerCase()}});return new Canvas2D.Sheet({book:c,name:a.name,style:d})};Canvas2D.Sheet.MANIFEST={name:"sheet",properties:[],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Sheet);Canvas2D.Position=Class.extend({init:function(a,c,b){this.shape=a;this.left=c||null;this.top=b||null},toADL:function(a){var b="";if(this.left!=null&&this.top!=null){b=a+"[@"+this.left+","+this.top+"]\n"}return b+this.shape.toADL(a)},getLeft:function(){return this.left},getTop:function(){return this.top},getWidth:function(){return this.shape.getWidth()},getHeight:function(){return this.shape.getHeight()},getCenter:function(){var a=this.shape.getCenter();a.left+=this.left;a.top+=this.top;return a},getBox:function(){return{left:this.left,right:this.left+this.shape.getWidth(),top:this.top,bottom:this.top+this.shape.getHeight()}},getPort:function(a){var a=this.shape.getPort(a);a.left+=this.left;a.top+=this.top;return a},render:function(a){this.shape.render(a,this.left,this.top)},move:function(a,b){this.left+=a;this.top+=b;this.fireEvent("change","from "+this.left-a+","+this.top-b+" to "+this.left+","+this.top)},getName:function(){return this.shape.getName()},hit:function(a,d){var c=a-this.left;var b=d-this.top;if(c<0||b<0){return false}return this.shape.hit(c,b)},hitArea:function(g,f,c,b){var h=g-this.left;var e=f-this.top;var a=c-this.left;var d=b-this.top;return this.shape.hitArea(min(h,a),min(e,d),max(h,a),max(e,d))},delayRender:function(){return this.shape.delayRender()}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.Position.prototype);Canvas2D.Connector=Canvas2D.Shape.extend({preprocess:function preprocess(a){a=this._super(a);if(a.from==a.to){a.routing="recursive"}return a},getFrom:function getFrom(a){return a?a.getPosition(this.from):this.from},getTo:function getTo(a){return a?a.getPosition(this.to):this.to},delayRender:function delayRender(){return true},isValid:function isValid(){return this.to!=null&&this.from!=null},draw:function draw(a,c,b){if(!this.isValid()){return}a.save();a.useCrispLines=this.getUseCrispLines();a.strokeStyle=this.getLineColor();a.lineWidth=this.getLineWidth();a.lineStyle=this.getLineStyle();a.beginPath();switch(this.getRouting()){case"custom":this._custom(a);break;case"recursive":this._recursive(a);break;case"vertical":this._vertical(a);break;case"horizontal":this._horizontal(a);break;case"direct":default:this._direct(a)}a.stroke();a.closePath();this.addLabels(a);a.restore()},_custom:function _custom(h){var g=this.getFrom(h);var f=this.getTo(h);var a=g.getPort(this.getRouteBegin());var d=f.getPort(this.getRouteEnd());if(this.getRouteStyle()=="straight"){if(this.getRouteBegin()=="e"||this.getRouteBegin()=="w"){var k=a.top-((a.top-d.top)/2);a.top=k;d.top=k}else{var m=a.left-((a.left-d.left)/2);a.left=m;d.left=m}}var e={e:{left:+5,top:-5,align:"left"},n:{left:+5,top:-5,align:"left"},w:{left:-5,top:-5,align:"right"},s:{left:+5,top:+10,align:"left"}};var b;if(this.getRouteBegin()){b=this.getRouteBegin().substring(0,1);this.beginLabelPos={left:a.left+e[b].left,top:a.top+e[b].top};this.beginLabelAlign=e[b].align}else{console.log("WARNING: missing routeBegin on "+this.name)}if(this.getRouteEnd()){b=this.getRouteEnd().substring(0,1);this.endLabelPos={left:d.left+e[b].left,top:d.top+e[b].top};this.endLabelAlign=e[b].align}else{console.log("WARNING: missing routeBegin on "+this.name)}d=this._draw_end_connector(h,d);a=this._draw_start_connector(h,a);switch(this.getRouteStyle()){case"corner":this._draw_corner(h,a,d);break;case"tree":this._draw_tree(h,a,d);break;case"recursive":this._draw_recursive(h,a,d);break;default:var c=a.left-((a.left-d.left)/2);var n=a.top-((a.top-d.top)/2);if(a.top==d.top){n-=5}this.centerLabelPos={left:c,top:n}}h.lineTo(d.left,d.top)},addLabels:function addLabels(a){if(this.getBeginLabel()&&this.getBeginLabelPos()){this.addLabel(a,this.getBeginLabel(),this.getBeginLabelPos(),this.getBeginLabelAlign())}if(this.getEndLabel()&&this.getEndLabelPos()){this.addLabel(a,this.getEndLabel(),this.getEndLabelPos(),this.getEndLabelAlign())}if(this.getCenterLabel()&&this.getCenterLabelPos()){this.addLabel(a,this.getCenterLabel(),this.getCenterLabelPos(),"center")}},addLabel:function addLabel(b,a,d,c){b.save();b.textAlign=c||"left";b.font=this.getLabelFont();b.fillText(a,d.left,d.top);b.restore()},getBeginLabelPos:function getBeginLabelPos(){return this.beginLabelPos},getEndLabelPos:function getEndLabelPos(){return this.endLabelPos},getCenterLabelPos:function getCenterLabelPos(){return this.centerLabelPos},getBeginLabelAlign:function getBeginLabelAlign(){return this.beginLabelAlign||"left"},getEndLabelAlign:function getEndLabelAlign(){return this.endLabelAlign||"left"},_draw_corner:function _draw_corner(c,d,a){var b=this.getRouteBegin().substring(0,1);if(b=="n"||b=="s"){c.lineTo(d.left,a.top);this.centerLabelPos={left:d.left,top:a.top+(b=="n"?-5:10)}}else{c.lineTo(a.left,d.top);this.centerLabelPos={left:a.left,top:d.top+(b=="e"?-5:10)}}c.lineTo(a.left,a.top)},_draw_tree:function _draw_tree(d,f,b){var e=this.getRouteBegin().substring(0,1);var c=b.left-f.left;var a=b.top-f.top;if(e=="n"||e=="s"){d.lineTo(f.left,f.top+a/2);d.lineTo(b.left,f.top+a/2);this.centerLabelPos={left:f.left-((f.left-b.left)/2),top:f.top+(a/2)+10}}else{d.lineTo(f.left+c/2,f.top);d.lineTo(f.left+c/2,b.top);this.centerLabelPos={left:f.left+(c/2),top:f.top-((f.top-b.top)/2)-5}}},_draw_recursive:function _draw_recursive(n,c,h){var l=30;var g=c.left;var p=c.top;var f=h.left;var o=h.top;var a={e:[[g+l,p],[g+l,o-l],[f,o-l]],n:[[g,p-l],[f-l,p-l],[f-l,o]],w:[[g-l,p],[g-l,o+l],[f,o+l]],s:[[g,p+l],[f+l,p+l],[f+l,o]]};var b=this.getRouteBegin().substring(0,1);var m=a[b];n.lineTo(m[0][0],m[0][1]);n.lineTo(m[1][0],m[1][1]);n.lineTo(m[2][0],m[2][1]);var k={e:{left:0,top:-5},n:{left:0,top:-5},w:{left:0,top:+10},s:{left:0,top:+10}};this.centerLabelPos={left:m[1][0]+k[b].left,top:m[1][1]+k[b].top}},_draw_start_connector:function draw_start_connector(d,e){var b=null;var c=this.getRouteBegin();if(this.getBegin()){var a=this.getBegin();b=a[c]?a[c]:a[c.substring(0,1)]}return this._draw_connector(d,b,e.left,e.top)},_draw_end_connector:function draw_start_connector(d,e){var b=null;var c=this.getRouteEnd();if(this.getEnd()){var a=this.getEnd();b=a[c]?a[c]:a[c.substring(0,1)]}return this._draw_connector(d,b,e.left,e.top)},_draw_connector:function _draw_connector(c,b,e,d){c.moveTo(e,d);if(b){var a=c.lineStyle;c.lineStyle="solid";c.stroke();c.beginPath();c.moveTo(e,d);b.lines.iterate(function(f){if(f=="fill"){c.fillStyle="rgba( 0, 0, 0, 1 )";c.fill()}else{c.lineTo(e+f[0],d+f[1])}});c.stroke();c.beginPath();c.lineStyle=a;c.moveTo(e+b.end[0],d+b.end[1]);return{left:e+b.end[0],top:d+b.end[1]}}return{left:e,top:d}},_direct:function _direct(d){var h=this.getFrom(d).getCenter();var g=this.getTo(d).getCenter();var c={"-1":{"-1":["nw","se"],"0":["n","s"],"1":["ne","sw"]},"0":{"-1":["w","e"],"0":["n","s"],"1":["e","w"]},"1":{"-1":["sw","ne"],"0":["s","n"],"1":["se","nw"]}};var a=100;var f=g.top-h.top;f=Math.round(f/a)*a;if(f!=0){f/=Math.abs(f)}var e=g.left-h.left;e=Math.round(e/a)*a;if(e!=0){e/=Math.abs(e)}var b=c[f][e];this.routeStyle="direct";this.routeBegin=b[0];this.routeEnd=b[1];this._custom(d)},_recursive:function _recursive(b){this.routeStyle="recursive";this.routeBegin=this.routeBegin||"ene";var a={nnw:"wnw",ene:"nne",wsw:"ssw",sse:"ese"};this.routeEnd=a[this.routeBegin];this._custom(b)},_vertical:function _vertical(b){var f=this.getFrom(b);var e=this.getTo(b);var a=f.getBox().top<e.getBox().top;var d=a?e.getBox().top-f.getBox().bottom:f.getBox().top-e.getBox().bottom;var c=a?e.getCenter().top-f.getBox().bottom:f.getCenter().top-e.getBox().bottom;if(d>=Canvas2D.Connector.Defaults.minTreeDist){this.routeStyle="tree";this.routeBegin=a?"s":"n";this.routeEnd=a?"n":"s"}else{if(c>=Canvas2D.Connector.Defaults.minCornerDist){this.routeStyle="corner";this.routeBegin=a?"s":"n";this.routeEnd=f.getPort(this.routeBegin).left<e.getPort("w").left?"w":"e"}else{this.routeStyle="straight";this.routeBegin=f.getPort("e").left<e.getPort("w").left?"e":"w";this.routeEnd=this.routeBegin=="e"?"w":"e"}}this._custom(b)},_horizontal:function _horizontal(b){var f=this.getFrom(b);var e=this.getTo(b);var a=f.getBox().left<e.getBox().left;var d=a?e.getBox().left-f.getBox().right:f.getBox().left-e.getBox().right;var c=a?e.getCenter().left-f.getBox().right:f.getCenter().left-e.getBox().right;if(d>=Canvas2D.Connector.Defaults.minTreeDist){this.routeStyle="tree";this.routeBegin=a?"e":"w";this.routeEnd=a?"w":"e"}else{if(c>=Canvas2D.Connector.Defaults.minCornerDist){this.routeStyle="corner";this.routeBegin=a?"e":"w";this.routeEnd=f.getPort(this.routeBegin).top<e.getPort("n").top?"n":"s"}else{this.routeStyle="straight";this.routeBegin=f.getPort("s").top<e.getPort("n").top?"s":"n";this.routeEnd=this.routeBegin=="n"?"s":"n"}}this._custom(b)},initialBranchLength:function initialBranchLength(b,a){return(a-b)/2},hit:function hit(a,b){return false},asConstruct:function asConstruct(){var a=this._super();if(this.getFrom()&&this.getTo()){a.modifiers[this.getFrom().getName()+"-"+this.getTo().getName()]=null}a.modifiers[this.getRouting()]=null;if(this.getRouting()=="custom"){a.annotation.data=this.getRouteStyle()+":"+this.getRouteBegin()+"-"+this.getRouteEnd()}a.addModifiers(["lineColor","lineStyle","lineWidth","begin","end","beginLabel","centerLabel","endLabel"]);if(this.getRouting()=="recursive"&&this.getRouteBegin()!="ene"){a.addModifiers(["routeBegin"])}return a}});Canvas2D.Connector.from=function from(b,c){var d={name:b.name};b.modifiers.iterate(function(g,h){if(h.value==null){if(g.contains("-")){var k=g.split("-");d.from=c.shapesMap[k[0]];d.to=c.shapesMap[k[1]]}else{d.routing=g;if(g=="custom"&&b.annotation&&b.annotation.data&&b.annotation.data.contains(":")&&b.annotation.data.contains("-")){var k=b.annotation.data.split(":");d.routeStyle=k[0];var f=k[1].split("-");d.routeBegin=f[0];d.routeEnd=f[1]}}}else{d[g]=(g=="from"||g=="to")?c.shapesMap[h.value.value]:h.value.value;if(g=="begin"||g=="end"){d[g]=Canvas2D.CustomConnectors[d[g]]}}});errors=[];warnings=[];if(!d.from){errors.push("Missing FROM connection-end on "+b.name)}if(!d.to){errors.push("Missing TO connection-end on "+b.name)}if(!["vertical","horizontal","direct","custom"].has(d.routing)){warnings.push("unknown routing: "+d.routing+", defaulting to direct.")}var a={};if(warnings.length>0){a.warnings=warnings}if(errors.length>0){a.errors=errors}else{var e=new Canvas2D.Connector(d);e.warnings=a.warnings;a=e}return a};Canvas2D.Connector.MANIFEST={name:"connector",aliasses:["link"],properties:["lineColor","lineStyle","lineWidth","from","to","begin","end","routing","routeStyle","routeBegin","routeEnd","beginLabel","centerLabel","endLabel"],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Connector);Canvas2D.CustomConnectors={};Canvas2D.registerConnector=function registerConnector(b,a){Canvas2D.CustomConnectors[b]=a};Canvas2D.Line=Canvas2D.Shape.extend({getWidth:function(){return this.getDx()},getHeight:function(){return this.getDy()},draw:function(a,c,b){a.beginPath();a.strokeStyle=this.getColor();a.lineWidth=this.getLineWidth();a.lineStyle=this.getLineStyle();a.moveTo(c,b);a.lineTo(c+this.getDx(),b+this.getDy());a.stroke();a.lineStyle="solid";a.closePath()},hit:function(a,b){return(this.getWidth()>=a&&this.getHeight()>=b)},hitArea:function(d,c,b,a){return !(0>b||this.getWidth()<d||0>a||this.getHeight()<c)},getCenter:function(){return{left:this.getWidth()/2,top:this.getHeight()/2}},getPort:function(a){switch(a){case"n":case"north":return{top:0,left:this.getWidth()/2};break;case"s":case"south":return{top:this.getHeight(),left:this.getWidth()/2};break;case"e":case"east":return{top:this.getHeight()/2,left:this.getWidth()};break;case"w":case"west":return{top:this.getHeight()/2,left:0};break}},getGeo:function(){return this.getWidth()&&this.getHeight()?this.getWidth()+"x"+this.getHeight():null},asConstruct:function(){var a=this._super();a.addModifiers(["geo","color"]);return a}});Canvas2D.Line.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){e=(e.value?e.value.value:"");if(d=="dx"||d=="dy"||d=="lineWidth"){e=parseInt(e)}else{if(e==""){e=d;d="color"}}c[d]=e});return new Canvas2D.Line(c)};Canvas2D.Line.MANIFEST={name:"line",properties:["color","dx","dy","lineWidth","lineStyle"],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Line);Canvas2D.LinePath=Canvas2D.Shape.extend({getWidth:function(){return this.dx},getHeight:function(){return this.dy},getStart:function(){return this.start},getMoves:function(){return this.moves},preprocess:function(d){if(d.start){var e=d.start.split(",");d.start={left:parseInt(e[0]),top:parseInt(e[1])}}else{d.start={left:0,top:0}}if(d.moves){var b=[];var c=max(0,d.start.left);var a=max(0,d.start.top);d.moves.split(";").iterate(function(f){var g=f.split(",");b.push({dx:parseInt(g[0]),dy:parseInt(g[1])});c=max(c,c+parseInt(g[0]));a=max(a,a+parseInt(g[1]))});d.moves=b;d.dx=c;d.dy=a}return d},draw:function(a,c,b){a.beginPath();a.strokeStyle=this.getColor();a.lineWidth=this.getLineWidth();a.lineStyle=this.getLineStyle();c+=this.start.left;b+=this.start.top;a.moveTo(c,b);this.getMoves().iterate(function(d){c=c+d.dx;b=b+d.dy;a.lineTo(c,b)});a.stroke();a.closePath()},hit:function(a,b){return(this.getWidth()>=a&&this.getHeight()>=b)},hitArea:function(d,c,b,a){return !(0>b||this.getWidth()<d||0>a||this.getHeight()<c)},getCenter:function(){return{left:this.getWidth()/2,top:this.getHeight()/2}},getPort:function(a){switch(a){case"n":case"north":return{top:0,left:this.getWidth()/2};break;case"s":case"south":return{top:this.getHeight(),left:this.getWidth()/2};break;case"e":case"east":return{top:this.getHeight()/2,left:this.getWidth()};break;case"w":case"west":return{top:this.getHeight()/2,left:0};break}},getGeo:function(){return this.getWidth()&&this.getHeight()?this.getWidth()+"x"+this.getHeight():null},asConstruct:function(){var a=this._super();a.addModifiers(["geo","color"]);return a}});Canvas2D.LinePath.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){e=(e.value?e.value.value:"");if(d=="dx"||d=="dy"||d=="lineWidth"){e=parseInt(e)}else{if(e==""){e=d;d="color"}}c[d]=e});return new Canvas2D.LinePath(c)};Canvas2D.LinePath.MANIFEST={name:"linepath",properties:["dx","dy","start","moves","color","lineWidth","lineStyle"],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.LinePath);Canvas2D.Alias=Canvas2D.Shape.extend({});Canvas2D.Alias.mapper={sheet:function(a){return function(b,d){var c=Canvas2D.Sheet.from(b,d);return c}},connector:function(a){return function(c,e){var b=new ADL.Modifier("routing",new ADL.String("vertical"));c.modifiers.set(b.key,b);var d=Canvas2D.Connector.from(c,e);return d}},image:function(a){var b=a.modifiers;return function(c,e){b.iterate(function(f,g){c.modifiers.set(f,g)});var d=Canvas2D.Image.from(c,e);return d}}};Canvas2D.Alias.from=function(a,b){Canvas2D.registerShape({prototype:{},MANIFEST:{name:a.name,libraries:["Aliasses"]},from:Canvas2D.Alias.mapper[a.supers[0]](a,b)})};Canvas2D.Alias.MANIFEST={name:"alias",aliasses:["shape"],libraries:[]};Canvas2D.registerShape(Canvas2D.Alias);Canvas2D.CompositeShape=Canvas2D.Shape.extend({hasChildren:function hasChildren(){return this.getChildren().length>0},hit:function(a,b){return(this.getWidth()>=a&&this.getHeight()>=b)},hitArea:function(d,c,b,a){return !(0>b||this.getWidth()<d||0>a||this.getHeight()<c)},getWidth:function getWidth(a){if(this.grows&&this.getParent().composition.widthGrows()&&!a){return this.getParent().getWidth(a)}if(this.hasChildren()){return max(this.composition.getWidth(),this.width)}return this.width},getHeight:function getHeight(a){if(this.grows&&this.getParent().composition.heightGrows()&&!a){return this.getParent().getHeight(a)}if(this.hasChildren()){return max(this.composition.getHeight(),this.height)}return this.height},getChildren:function getChildren(){if(!this.children){this.children=[]}return this.children},preprocess:function preprocess(b){b.composition=b.composition||"vertical-stack";var a=[];if(b.composition.contains(":")){a=b.composition.split(":");b.composition=a.shift()}b.composition=new Canvas2D.Compositors[b.composition](a,this);return b},draw:function(a,c,b){this.getChildren().iterate(function(f){var e=this.composition.getPosition(f,this.getChildren());f.render(a,c+e.left,b+e.top)}.scope(this))},prepare:function(a){this._super();if(this.hasChildren()){this.prepareChildren(a);this.composition.prepare()}},prepareChildren:function prepareChildren(a){this.getChildren().iterate(function(b){b.prepare(a)})},add:function add(a){a.topDown=true;this.getChildren().push(a);a.setParent(this)},asConstruct:function(){var a=this._super();return a}});Canvas2D.CompositeShape.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){e=(e.value?e.value.value:"");if(""+e==""){e=d;d="composition"}c[d]=e});return new Canvas2D.CompositeShape(c)};Canvas2D.CompositeShape.MANIFEST={name:"compositeShape",aliasses:["group"],properties:["width","height","grows","composition","padding"]};Canvas2D.registerShape(Canvas2D.CompositeShape);Canvas2D.Compositors={"vertical-stack":Class.extend({init:function init(b,a){this.align=b.contains("left")?"left":b.contains("right")?"right":"center";this.shape=a},prepare:function prepare(){this.left=0;this.top=0},getPadding:function getPadding(){return parseInt(this.shape.padding?this.shape.padding:0)},getPosition:function(d){var a=this.getPadding();var b=this.shape.getWidth();if(this.align=="center"){a=(b-d.getWidth())/2}else{if(this.align=="right"){a=b-d.getWidth()-this.getPadding()}}var c=this.top;this.top+=d.getHeight();return{left:this.left+a,top:c+this.getPadding()}},getWidth:function getWidth(){var a=0;this.shape.getChildren().iterate(function(b){a=max(b.getWidth(b.grows),a)});return a+this.getPadding()*2},getHeight:function getHeight(){var a=0;this.shape.getChildren().iterate(function(b){a+=b.getHeight(b.grows)});return a+this.getPadding()*2},heightGrows:function heightGrows(){return false},widthGrows:function widthGrows(){return true}}),"horizontal-stack":Class.extend({init:function init(b,a){this.align=b.contains("top")?"top":b.contains("bottom")?"bottom":"center";this.shape=a},prepare:function prepare(){this.left=0;this.top=0},getPosition:function(d){var b=0;var a=this.shape.getHeight();if(this.align=="center"){b=(a-d.getHeight())/2}else{if(this.align=="bottom"){b=a-d.getHeight()}}var c=this.left;this.left+=d.getWidth();return{left:c,top:this.top+b}},getWidth:function getWidth(){var a=0;this.shape.getChildren().iterate(function(b){a+=b.getWidth(b.grows)});return a},getHeight:function getHeight(){var a=0;this.shape.getChildren().iterate(function(b){a=max(b.getHeight(b.grows),a)});return a},heightGrows:function heightGrows(){return true},widthGrows:function widthGrows(){return false}})};Canvas2D.Rectangle=Canvas2D.CompositeShape.extend({draw:function draw(b,e,d){b.useCrispLines=this.getUseCrispLines();b.lineWidth=this.getLineWidth();b.strokeStyle=this.getLineColor();b.fillStyle=this.getFillColor();var c=this.getWidth();var a=this.getHeight();if(this.getRoundCorners()){this._drawRoundCorners(b,e,d,c,a)}else{this._drawStraightCorners(b,e,d,c,a)}this._super(b,e,d)},_drawRoundCorners:function _drawRoundCorners(b,e,d,c,a){b.beginPath();b.moveTo(e+20,d);b.lineTo(e+c-20,d);b.arcTo(e+c+0.5,d+0.5,e+c+0.5,d+20,20);b.lineTo(e+c,d+a-20);b.arcTo(e+c+0.5,d+a+0.5,e+c-20,d+a+0.5,20);b.lineTo(e+20,d+a);b.arcTo(e+0.5,d+a+0.5,e+0.5,d+a-20+0.5,20);b.lineTo(e,d+20);b.arcTo(e+0.5,d+0.5,e+20.5,d+0.5,20);b.closePath();b.fill();b.stroke()},_drawStraightCorners:function _drawStraightCorners(b,e,d,c,a){b.fillRect(e,d,c,a);b.strokeRect(e,d,c,a)},getCenter:function(){return{left:this.getWidth()/2,top:this.getHeight()/2}},getPort:function(b){var a={nw:{left:0,top:0},nnw:{left:0.25,top:0},n:{left:0.5,top:0},nne:{left:0.75,top:0},ne:{left:1,top:0},ene:{left:1,top:0.25},e:{left:1,top:0.5},ese:{left:1,top:0.75},se:{left:1,top:1},sse:{left:0.75,top:1},s:{left:0.5,top:1},ssw:{left:0.25,top:1},sw:{left:0,top:1},wsw:{left:0,top:0.75},w:{left:0,top:0.5},wnw:{left:0,top:0.25}};if(!a[b]){return{left:0,top:0}}return{left:a[b].left*this.getWidth(),top:a[b].top*this.getHeight()}},getGeo:function(){return this.getWidth()&&this.getHeight()?this.getWidth()+"x"+this.getHeight():null},asConstruct:function(){var a=this._super();a.addModifiers(["geo","lineColor","roundCorners"]);return a}});Canvas2D.Rectangle.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){e=(e.value?e.value.value:"");if(d=="width"||d=="height"){e=parseInt(e)}if(d=="geo"){c.width=parseInt(e.split("x")[0]);c.height=parseInt(e.split("x")[1])}if(""+e==""){if(d=="roundCorners"){e=true}else{e=d;d="lineColor"}}c[d]=e});return new Canvas2D.Rectangle(c)};Canvas2D.Rectangle.MANIFEST={name:"rectangle",aliasses:["box"],properties:["lineWidth","lineColor","fillColor","roundCorners"],propertyPath:[Canvas2D.CompositeShape],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Rectangle);Canvas2D.Text=Canvas2D.Rectangle.extend({prepare:function(a){a.useCrispLines=this.getUseCrispLines();a.strokeStyle=this.getColor();a.fillStyle=this.getColor();a.font=this.getFont();a.textAlign=this.getTextAlign();a.textDecoration=this.getTextDecoration();this.width=a.measureText(this.getText());this.height=a.getFontSize()},draw:function(a,c,b){if(this.getTopDown()){b+=this.getHeight()}a.fillText(this.getText(),c,b)},asConstruct:function(){var a=this._super();a.addModifiers(["color"]);return a}});Canvas2D.Text.from=function(a,c){var b={name:a.name,text:a.value.value};a.modifiers.iterate(function(d,e){e=(typeof e.value!="undefined"?e.value.value:"");b[d]=e});return new Canvas2D.Text(b)};Canvas2D.Text.MANIFEST={name:"text",properties:["text","color","font","textAlign","textDecoration"],propertyPath:[Canvas2D.Rectangle],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Text);Canvas2D.Image=Canvas2D.Rectangle.extend({getSource:function(){return this.src},getImage:function(){return this.image},postInitialize:function(){if(this.getSource()){this.image=Canvas2D.ImageManager.load(this.getSource(),this.updateSize.scope(this))}},updateSize:function(){this.width=this.image.width;this.height=this.image.height},draw:function(a,c,b){a.drawImage(this.getImage(),c,b)},asConstruct:function(){var a=this._super();a.addModifiers(["source"]);return a}});Canvas2D.Image.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){c[d]=e.value.value});return new Canvas2D.Image(c)};Canvas2D.Image.MANIFEST={name:"image",aliasses:["pic","picture"],properties:["src"],propertyPath:[Canvas2D.Rectangle],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Image);Canvas2D.Arrow=Canvas2D.Rectangle.extend({draw:function(a,c,b){a.useCrispLines=this.getUseCrispLines();a.lineWidth=this.getLineWidth();a.strokeStyle=this.getLineColor();a.fillStyle=this.getFillColor();a.fillRect(c,b,this.getWidth()-this.getArrowHeadWidth(),this.getHeight());a.strokeRect(c,b,this.getWidth()-this.getArrowHeadWidth(),this.getHeight());a.beginPath();a.moveTo(c+this.getWidth()-this.getArrowHeadWidth(),b);a.lineTo(c+this.getWidth()-this.getArrowHeadWidth(),b+(this.getHeight()/2)-(this.getArrowHeadHeight()/2));a.lineTo(c+this.getWidth(),b+(this.getHeight()/2));a.lineTo(c+this.getWidth()-this.getArrowHeadWidth(),b+(this.getHeight()/2)+(this.getArrowHeadHeight()/2));a.closePath();a.stroke();a.fill()},hit:function(a,b){return(this.getWidth()>=a&&this.getHeight()>=b)},hitArea:function(d,c,b,a){return !(0>b||this.getWidth()<d||0>a||this.getHeight()<c)},getCenter:function(){return{left:this.getWidth()/2,top:this.getHeight()/2}},getPort:function(a){switch(a){case"n":case"north":return{top:0,left:this.getWidth()/2};break;case"s":case"south":return{top:this.getHeight(),left:this.getWidth()/2};break;case"e":case"east":return{top:this.getHeight()/2,left:this.getWidth()};break;case"w":case"west":return{top:this.getHeight()/2,left:0};break}}});Canvas2D.Arrow.from=function(a,b){var c={name:a.name};a.modifiers.iterate(function(d,e){e=(e.value?e.value.value:"");if(d=="width"||d=="height"){e=parseInt(e)}if(d=="geo"){c.width=parseInt(e.split("x")[0]);c.height=parseInt(e.split("x")[1])}if(""+e==""){e=d;d="lineColor"}c[d]=e});return new Canvas2D.Arrow(c)};Canvas2D.Arrow.MANIFEST={name:"arrow",aliasses:["pointer"],properties:["width","height","arrowHeadWidth","arrowHeadHeight"],propertyPath:[Canvas2D.Rectangle],libraries:["Canvas2D"]};Canvas2D.registerShape(Canvas2D.Arrow);Canvas2D.Book.plugins.TabbedCanvas=Class.extend({init:function(a){this.book=a},makeTab:function(c,b,f){var e=document.createElement("div");e.className="tabbertab";e.style.height=(4+parseInt(b))+"px";var d=document.createElement("h2");var a=document.createTextNode(c);d.appendChild(a);e.appendChild(d);e.appendChild(f);return e},getAboutTab:function(){var d=this.book.canvas.canvas.width;var a=this.book.canvas.canvas.height;var c=document.createElement("div");c.className="Canvas2D-about";c.style.height=a+"px";c.style.width=(parseInt(d)-4)+"px";var b="";Canvas2D.extensions.iterate(function(e){b+="\n<hr>\n";b+="<b>Library: "+e.name+" "+e.version+"</b> by "+e.author+"<br>"+e.info});c.innerHTML='<span class="Canvas2D-about-text"><b>Canvas2D '+Canvas2D.version+'</b><br>Copyright &copy 2009, <a href="http://christophe.vg" target="_blank">Christophe VG</a> & <a href="http://thesoftwarefactory.be" target="_blank">The Software Factory</a><br>Visit <a href="http://thesoftwarefactory.be/wiki/Canvas2D" target="_blank">http://thesoftwarefactory.be/wiki/Canvas2D</a> for more info. Licensed under the <a href="http://thesoftwarefactory.be/wiki/BSD_License" target="_blank">BSD License</a>.'+b+"</span>";return this.makeTab("About",a,c)},getConsoleTab:function(){var b=this.book.canvas.canvas.width;var a=this.book.canvas.canvas.height;this.book.console=document.createElement("textarea");this.book.console.className="Canvas2D-console";this.book.console.style.height=a+"px";this.book.console.style.width=(parseInt(b)-4)+"px";return this.makeTab("Console",a,this.book.console)},getSourceTab:function(){var c=this.book.canvas.canvas.width;var a=this.book.canvas.canvas.height;var b=this.book.generated?this.book.generated.value:"";this.book.generated=document.createElement("textarea");this.book.generated.value=b;this.book.generated.className="Canvas2D-source";this.book.generated.style.height=a+"px";this.book.generated.style.width=(parseInt(c)-4)+"px";return this.makeTab("Source",a,this.book.generated)},applyTabber:function(){var d=this.book.canvas.canvas;this.tabber=document.createElement("div");this.tabber.className="tabber";this.tabber.style.width=(parseInt(d.width)+17)+"px";this.tabber.style.height=(parseInt(d.height)+37)+"px";d.parentNode.replaceChild(this.tabber,d);var b=document.createElement("div");b.className="tabbertab";var a=document.createElement("h2");var c=document.createTextNode("Diagram");a.appendChild(c);b.appendChild(a);b.appendChild(d);this.tabber.appendChild(b)},makeTabbed:function(a){if(!this.tabber){this.applyTabber()}if(!Object.isArray(a)){return}if(a.contains("console")){this.tabber.appendChild(this.getConsoleTab())}if(a.contains("source")){this.tabber.appendChild(this.getSourceTab())}if(a.contains("about")){this.tabber.appendChild(this.getAboutTab())}tabberAutomatic()}});Canvas2D.Book.plugins.TabbedCanvas.exposes=["makeTabbed"];Canvas2D.Book.plugins.AutoLayout=Class.extend({init:function(a){this.book=a;this.active=false},autoLayout:function autoLayout(a){this.strategy=a;this.strategy.start();this.active=true;this.book.rePublish()},beforeRender:function beforeRender(d){if(!this.active){return}var b=[];var a=$H();var e=0;d.getCurrentSheet().positions.iterate(function(c){if(!(c.shape instanceof Canvas2D.Connector)){b.push({position:c,x:c.left+c.shape.getWidth()/2,y:c.top+c.shape.getHeight()/2,s:c.shape.getWidth()>c.shape.getHeight()?c.shape.getWidth():c.shape.getHeight(),f1:0,f2:0,c:[]});a.set(c.shape.getName(),parseInt(e++))}});d.getCurrentSheet().positions.iterate(function(g){if(g.shape instanceof Canvas2D.Connector){var f=a.get(g.shape.getFrom(d.getCurrentSheet()).getName());var c=a.get(g.shape.getTo(d.getCurrentSheet()).getName());b[f].c.push(c);b[c].c.push(f)}});b=this.strategy.layout(b);if(b){b.iterate(function(c){c.position.left=c.x-c.position.shape.getWidth()/2;c.position.top=c.y-c.position.shape.getHeight()/2})}else{this.active=false}},afterPublish:function afterPublish(a){if(this.active){a.rePublish()}}});Canvas2D.Book.plugins.AutoLayout.exposes=["autoLayout"];var ForceLayoutStrategy=Class.extend({init:function initialize(a){this.max_repulsive_force_distance=a.max_repulsive_force_distance||50;this.k=a.k||20;this.c=a.c||0.05;this.max_movement=a.max_movement||10;this.max_iterations=a.max_iterations||1000;this.render=a.render||function(){};this.canContinue=a.canContinue||function(){return false}},getIterations:function getIterations(){return this.iteration},start:function start(){this.iteration=0},layout:function layout(a){this.elements=a;if(this.canContinue()){if(this.iteration<=this.max_iterations){this._layout();return this.elements}}return null},_layout:function layout(){this.iteration++;if(this.canContinue()){if(this.iteration<=this.max_iterations){this._layout_iteration()}else{console.log("max iterations ("+this.max_iterations+") reached.")}}},_layout_iteration:function _layout_iteration(){for(var d=0;d<this.elements.length;d++){this.elements[d].f1=0;this.elements[d].f2=0}for(var d=0;d<this.elements.length;d++){for(var e=0;e<this.elements.length;e++){if(d!==e){this._layout_repulsive(d,e)}}}for(var d=0;d<this.elements.length;d++){for(var e=0;e<this.elements.length;e++){if(d!==e&&this.elements[e].c.indexOf(d)>-1){this._layout_attractive(d,e)}}}for(var d=0;d<this.elements.length;d++){var c=this.c*this.elements[d].f1;var b=this.c*this.elements[d].f2;var a=this.max_movement;if(c>a){c=a}if(c<a*-1){c=a*-1}if(b>a){b=a}if(b<a*-1){b=a*-1}this.elements[d].x+=c;this.elements[d].y+=b}},_layout_repulsive:function _layout_repulsive(e,h){var b=this.elements[h].x-this.elements[e].x;var a=this.elements[h].y-this.elements[e].y;var f=b*b+a*a;if(f<0.01){b=Math.random()+0.1;a=Math.random()+0.1;f=b*b+a*a}var g=Math.sqrt(f);if(g<this.max_repulsive_force_distance){var c=this.k*this.k/g;this.elements[h].f1+=c*b/g;this.elements[h].f2+=c*a/g;this.elements[e].f1-=c*b/g;this.elements[e].f2-=c*a/g}},_layout_attractive:function _layout_attractive(e,k){var b=this.elements[k].x-this.elements[e].x;var a=this.elements[k].y-this.elements[e].y;var f=b*b+a*a;if(f<0.01){b=Math.random()+0.1;a=Math.random()+0.1;f=b*b+a*a}var h=Math.sqrt(f);if(h>this.max_repulsive_force_distance){h=this.max_repulsive_force_distance;f=h*h}var c=(f-this.k*this.k)/this.k;var g=this.elements[e].s;if(g<1){g=1}c*=Math.log(g)*0.5+1;this.elements[k].f1-=c*b/h;this.elements[k].f2-=c*a/h;this.elements[e].f1+=c*b/h;this.elements[e].f2+=c*a/h}});Canvas2D.Book.plugins.Watermark=Class.extend({afterPublish:function afterPublish(a){a.canvas.save();a.canvas.fillStyle="rgba(125,125,125,1)";a.canvas.textDecoration="none";a.canvas.rotate(Math.PI/2);var b="";a.extensions.iterate(function(c,d){b+=" + "+c});a.canvas.font="6pt Sans-Serif";a.canvas.textAlign="left";a.canvas.useCrispLines=false;a.canvas.lineStyle="solid";a.canvas.fillText("Canvas2D"+b+" / Christophe VG",3,(a.canvas.canvas.width*-1)+7+(ProtoJS.Browser.IE?4:0));a.canvas.restore()}});Canvas2D.KickStart={};Canvas2D.KickStart.Starter=Class.extend({init:function(){this.manager=new Canvas2D.Manager()},getTag:function(){return"Canvas2D"},makeInstance:function(a){return this.manager.setupBook(a)},start:function(){var m=document.getElementsByTagName("canvas");for(var k=0;k<m.length;k++){var d=m[k];var f=d.className;if(f.contains(this.getTag())){var b=d.id;var g=this.makeInstance(d);if(f.contains("Tabbed")){var l=[];if(f.contains("withSource")){l.push("source")}if(f.contains("withConsole")){l.push("console")}if(f.contains("withAbout")){l.push("about")}g.makeTabbed(l)}var e=document.getElementById(b+"Source");if(e){var a;try{a=e.firstChild.nodeValue}catch(h){a=e.value}g.load(a)}}}this.fireEvent("ready");this.manager.startAll()}});ProtoJS.mix(Canvas2D.Factory.extensions.all.EventHandling,Canvas2D.KickStart.Starter.prototype);Canvas2D.KickStarter=new Canvas2D.KickStart.Starter();ProtoJS.Event.observe(window,"load",function(){Canvas2D.KickStarter.start()});Canvas2D.KickStarter.on("ready",function(){Canvas2D.fireEvent("ready")});Canvas2D.Defaults={};Canvas2D.Defaults.Canvas={lineWidth:1,useCrispLines:true,lineStyle:"solid",strokeStyle:"black",fillStyle:"black",font:"10pt Sans-Serif",textAlign:"left",textBaseline:"alphabetic",textDecoration:"none"};Canvas2D.Sheet.Defaults={lineWidth:1,lineStyle:"solid",strokeStyle:"black",fillStyle:"black",font:"10pt Sans-Serif",textAlign:"left",textBaseline:"alphabetic",textDecoration:"none",shadowColor:"rgba(0,0,0,0.0)"};Canvas2D.Shape.Defaults={useCrispLines:true,label:"",labelFont:"7pt Sans-Serif",labelAlign:"center",labelPos:"center",labelColor:"black",labelUseCrispLines:false};Canvas2D.Rectangle.Defaults={useCrispLines:true,lineWidth:1,lineColor:"rgba(0,0,0,100)",fillColor:"rgba(255,255,255,0)",labelPos:"center",labelColor:"black",width:50,height:50};Canvas2D.Connector.Defaults={useCrispLines:true,lineWidth:1,lineColor:"black",lineStyle:"solid",begin:null,end:null,minTreeDist:30,minCornerDist:15};Canvas2D.Text.Defaults={useCrispLines:false,color:"black",font:"10pt Sans-Serif",textAlign:"left",textDecoration:"none"};Canvas2D.Line.Defaults={lineWidth:1,lineStyle:"solid",labelPos:"center",labelColor:"black",color:"black",dx:50,dy:50};Canvas2D.LinePath.Defaults={lineWidth:1,lineStyle:"solid",labelPos:"center",labelColor:"black",color:"black"};Canvas2D.Image.Defaults={};Canvas2D.Arrow.Defaults={};Canvas2D.CompositeShape.Defaults={};Canvas2D.version="0.3-47";