init: function(){
var nodes = document.getElementsByTagName('img');
var index = [], res = [], node;
var reImg = /^img(\d+)$/;
for ( var i = 0; node = nodes[i]; i++ ) {
if ( reImg.test( node.id + "" ) ) {
index[ index.length ] = reImg.exec(node.id)[1] | 0;
res[ res.length ] = nodes[i];
}
}
var events = "mousedown mouseup mouseover mouseout".split(" ");
for ( var i = 0; node = res[i]; i++ ) {
for ( var j = events.length; j--; ) {
var handler = (function(ctx, name, img){
return function () {
ctx[name].call(ctx, img);
};
})( this, events[j].replace("mouse",""), node );
if ( node.addEventListener ) {
node.addEventListener(events[j], handler, false);
} else if ( node.attachEvent ) {
node.attachEvent('on' + events[j], handler );
} else {
node['on' + events[j]] = handler;
}
}
}
}