/* (c) 2007 - now() Ondrej Zara, 1.5 */ var OZ = { $:function(x) { return typeof(x) == "string" ? document.getElementById(x) : x; }, opera:!!window.opera, ie:!!document.attachEvent && !window.opera, gecko:!!document.getAnonymousElementByAttribute, webkit:!!navigator.userAgent.match(/webkit/i), khtml:!!navigator.userAgent.match(/khtml/i) || !!navigator.userAgent.match(/konqueror/i), Event:{ _id:0, _byName:{}, _byID:{}, add:function(elm,event,cb) { var id = OZ.Event._id++; var element = OZ.$(elm); var fnc = cb; if (element) { if (element.addEventListener) { element.addEventListener(event,fnc,false); } else if (element.attachEvent) { fnc = function() { return cb.apply(elm,arguments); } element.attachEvent("on"+event,fnc); } } if (!(event in OZ.Event._byName)) { OZ.Event._byName[event] = {}; } var obj = OZ.Event._byName[event]; obj[id] = [element,event,fnc]; OZ.Event._byID[id] = obj; return id; }, remove:function(id) { var obj = OZ.Event._byID[id]; if (!obj) { return; } var e = obj[id]; var elm = e[0]; if (elm) { if (elm.removeEventListener) { elm.removeEventListener(e[1],e[2],false); } else if (elm.detachEvent) { elm.detachEvent("on"+e[1],e[2]); } } delete OZ.Event._byID[id]; delete obj[id]; }, stop:function(e) { e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; }, prevent:function(e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; }, target:function(e) { return e.target || e.srcElement; } }, Class:function() { var c = function() { var init = arguments.callee.prototype.init; if (init) { init.apply(this,arguments); } }; c.implement = function(parent) { for (var p in parent.prototype) { this.prototype[p] = parent.prototype[p]; } return this; }; c.extend = function(parent) { var tmp = function(){}; tmp.prototype = parent.prototype; this.prototype = new tmp(); return this; }; c.prototype.bind = function(fnc) { return fnc.bind(this); }; c.prototype.dispatch = function(type, data) { var obj = { type:type, target:this, timeStamp:(new Date()).getTime(), data:data } var tocall = []; var list = OZ.Event._byName[type]; for (var id in list) { var item = list[id]; if (!item[0] || item[0] == this) { tocall.push(item[2]); } } var len = tocall.length; for (var i=0;i-1;i--) { if (i in this && this[i] === item) { return i; } } return -1; } } if (!Array.lastIndexOf) { Array.lastIndexOf = function(obj, item, from) { return Array.prototype.lastIndexOf.call(obj, item, from); } } if (!Array.prototype.forEach) { Array.prototype.forEach = function(cb, _this) { var len = this.length; for (var i=0;i