var addEvent = function(e, type, fn){
if (e.length){
for(var i = 0; i < e.length; i++){
addEvent(e[i], type, fn);
}
return;
}
if (e.addEventListener) {
if( type && fn){
e.addEventListener(type, fn, false);
}
} else {
e.attachEvent(‘on’ + type, function(){
if (typeof fn === ‘function’){
fn.call(e, e);
}
});
}
}