window.htmlspecialchars = function(text) { return (''+text).replace(/&/g, '&') .replace(/'/g, ''') // ' .replace(/"/g, '"') // " .replace(//g, '>'); }; window.addListener = (function() { return window.addEventListener ? function(el, type, fn) { el.addEventListener(type, fn, false); } : function(el, type, fn) { el.attachEvent('on'+type, fn); }; })(); window.removeListener = (function() { return window.removeEventListener ? function(el, type, fn) { el.removeEventListener(type, fn, false); } : function(el, type, fn) { el.detachEvent('on'+type, fn); }; })(); window.getEventCoord = function(e) { if (!e) e = window.event; if (e && e.pageX == null && e.clientX != null) { var html = document.documentElement; var body = document.body; e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0); e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0); } if (e && !e.which && e.button) { if (e.button & 1) e.which = 1; else if (e.button & 4) e.which = 2; else if (e.button & 2) e.which = 3; } return e; } window.curStyle = function(e) { return window.getComputedStyle ? getComputedStyle(e) : e.currentStyle; };