// * date 2011/10/19 * /** * misc */// ------ TRACE ------ function trace(e,t){window.console&&window.console.debug&&(arguments.length===2?window.console.debug(e,t):window.console.debug(e))}function Timeout(e,t){var n=setTimeout(e,t);this.cleared=!1;this.clear=function(){this.cleared=!0;clearTimeout(n)}}function HexToRGB(e){if(e.charAt(0)=="#"){var t=e.substring(1,7),n=parseInt(t.substring(0,2),16),r=parseInt(t.substring(2,4),16),i=parseInt(t.substring(4,6),16);return"rgb("+n+", "+r+", "+i+")"}return null}function pair(e){return typeof e=="number"?e%2==0?!0:!1:null}function random(e,t){return arguments.length===1&&typeof e=="number"?Math.random()*e:arguments.length===2&&typeof e==typeof t&&typeof e=="number"?e+Math.random()*(t-e):NaN}function round(e,t){if(arguments.length==1)e=Math.round(e);else{t=t.toString();t=t.replace(/./gi,0);t=t.replace(/^./gi,1);t=parseInt(t);e=Math.round(e*t)/t}return e}function floor(e,t){if(arguments.length==1)e=Math.floor(e);else{t=t.toString();t=t.replace(/./gi,0);t=t.replace(/^./gi,1);t=parseInt(t);e=Math.floor(e*t)/t}return e}function ceil(e,t){if(arguments.length==1)e=Math.ceil(e);else{t=t.toString();t=t.replace(/./gi,0);t=t.replace(/^./gi,1);t=parseInt(t);e=Math.ceil(e*t)/t}return e}function ArraySubtract(e,t){var n=new Array;for(var r=e.length-1;r>=0;r--)t.contains(e[r])||n.push(e[r]);return n}function objectSize(e){var t=e.length?--e.length:0;for(var n in e)t++;return t}function objectGetKey(e,t){var n=0;for(var r in e){if(r==="length"||!e.hasOwnProperty(r))continue;if(n==t)return r;n++}}function objectSort(e,t){var n=new Array;for(var r=objectSize(e)-1;r>=0;r--){var i=objectGetKey(e,r);for(var s=objectSize(e[i].wit)-1;s>=0;s--){var o=objectGetKey(e[i].wit,s);if(o==t){var u=parseFloat(e[i].wit[o]);n.push({wit:u,nid:i})}}}n.sort(function(e,t){return t.wit-e.wit});var a={};for(var r=n.length-1;r>=0;r--)a[n[r].nid]=e[n[r].nid];return a}function getElementAngle(e,t,n,r){var i=n-e,s=r-t,o=Math.abs(Math.atan(s/i)*180/Math.PI);i>0&&s<0?o=90-o:i>=0&&s>=0?o+=90:i<0&&s>=0?o=180+(90-o):o+=270;return o}String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/gi,"").replace(/[ ]{2,}/gi," ").replace(/\n /,"\n")};Array.prototype.unique=function(){var e=new Array;e:for(var t=0,n=this.length;t