addListener = function addListener(element, type, func) { if(element) { if (element.addEventListener) { element.addEventListener(type, func, false); } else if (element.attachEvent) { element.attachEvent("on" + type, func); } } } removeListener = function removeListener(element, type, func) { if(element) { if(element.removeEventListener){ element.removeEventListener(type, func, false); } else if(element.detachEvent){ element.detachEvent("on" + type, func); } } }