Да понял я вас!
Вот еще вариант!
(function(){
var global = (function(){return this;})();
//Image Loader
global.loadImage = function(src,onload){
var img = new Image();
img.src = src;
img.onload = onload;
return img;
};
var xDOM = function(elem){
var init = new DOM(elem);
return init;
}
//DOM Object
var DOM = function(element){
this._elem = element;
};
//Set Attributes
DOM.prototype.attr = function(src){
if(src==null){src={}}
for(var i in src){
this._elem.setAttribute(i,src[i]);
}
return this;
}
//Set CSS
DOM.prototype.css = function(src){
if(src==null){src={}}
for(var i in src){
if(typeof this._elem.style.setProperty != "undefined"){
this._elem.style.setProperty(i,src[i],null);
} else {
this._elem.style.setAttribute(i,src[i]);
}
}
return this;
}
//Event Attach
DOM.prototype.event = function(src){
if(src==null){src={}}
var self = this;
for(var i in src){
(function(i){
if(self._elem.addEventListener) {
self._elem.addEventListener(i, src[i], false);
} else
if(self._elem.attachEvent) {
self._elem.attachEvent('on' + i, function(e){ src[i].call(self._elem, e); });
}
})(i);
}
return this;
}
global.DOM = xDOM;
})();