- attr: function(o,a,v){
- if ( a && a.constructor == String ) {
- var fix = {
- "for": "htmlFor",
- "class": "className",
- "float": "cssFloat"
- };
-
- a = (fix[a] && fix[a].replace && fix[a] || a)
- .replace(/-([a-z])/ig,function(z,b){
- return b.toUpperCase();
- });
-
- if ( v != undefined ) {
- o[a] = v;
- if ( o.setAttribute && a != "disabled" )
- o.setAttribute(a,v);
- }
-
- return o[a] || o.getAttribute && o.getAttribute(a) || "";
- } else
- return "";
+ attr: function(elem, name, value){
+ var fix = {
+ "for": "htmlFor",
+ "class": "className",
+ "float": "cssFloat",
+ innerHTML: "innerHTML",
+ className: "className",
+ value: "value",
+ disabled: "disabled"
+ };
+
+ if ( fix[name] ) {
+ if ( value != undefined ) elem[fix[name]] = value;
+ return elem[fix[name]];
+ } else if ( elem.getAttribute ) {
+ if ( value != undefined ) elem.setAttribute( name, value );
+ return elem.getAttribute( name, 2 );
+ } else {
+ name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
+ if ( value != undefined ) elem[name] = value;
+ return elem[name];
+ }