var DOMBuilder=(function()
{var o={apply:function(context)
{context=context||{};var tagNames=["a","abbr","acronym","address","bdo","blockquote","br","button","caption","cite","code","col","colgroup","dd","del","dfn","div","dl","dt","em","fieldset","form","h1","h2","h3","h4","h5","h6","hr","img","input","ins","kbd","label","legend","li","link","object","ol","optgroup","option","p","param","pre","samp","script","select","span","strong","style","table","tbody","td","textarea","tfoot","th","thead","tr","ul","var"];for(var i=0,tagName;tagName=tagNames[i];i++)
{context[tagName.toUpperCase()]=this.createElementFunction(tagName);}
return context;},createElementFunction:function(tagName)
{return function()
{if(arguments.length==0)
{return document.createElement(tagName);}
else
{return DOMBuilder.createElementFromArguments(tagName,arguments);}};},createElementFromArguments:function(tagName,args)
{var attributes;var children;if(args.length==1&&args[0]instanceof Array)
{children=args[0];}
else if(args.length==2&&args[0]&&args[0].constructor==Object&&args[1]instanceof Array)
{attributes=args[0];children=args[1];}
else if(args[0]&&(args[0].nodeName||typeof(args[0])=="string"||typeof(args[0])=="number"))
{children=args;}
else
{attributes=args[0];children=Array.prototype.slice.call(args,1);}
return this.createElement(tagName,attributes,children);},createElement:function(tagName,attributes,children)
{attributes=attributes||{};children=children||[];var element=document.createElement(tagName);for(var attr in attributes)
{if(attributes.hasOwnProperty(attr))
{if(typeof(attributes[attr])=="function"&&attr.toLowerCase().indexOf("on")==0)
{this.addEvent(element,attr.substr(2),attributes[attr]);}
else
{element.setAttribute(attr,attributes[attr]);}}}
for(var i=0,l=children.length;i<l;i++)
{var child=children[i];var childType=typeof(child);if(childType=="string"||childType=="number")
{element.appendChild(document.createTextNode(child));}
else
{element.appendChild(child);}}
return element;},addEvent:function(element,eventName,handler)
{return element.addEventListener(eventName,handler,false);},removeEvent:function(element,eventName,handler)
{element.removeEventListener(eventName,handler,false);}};if(/*@cc_on @*//*@if (@_win32)!/*@end @*/false)
{o.ATTR_TRANSLATIONS={"class":"className","for":"htmlFor"};o.setAttribute=function(element,attr,value)
{if(this.ATTR_TRANSLATIONS.hasOwnProperty(attr))
{element[this.ATTR_TRANSLATIONS[attr]]=value;}
else if(attr=="style")
{element.style.cssText=value;}
else
{element.setAttribute(attr,value);}};o.addEvent=function(element,eventName,handler)
{((element._evts=element._evts||[])[element._evts.length]=function(e){return handler.call(element,e);})._w=handler;return element.attachEvent("on"+eventName,element._evts[element._evts.length-1]);};o.removeEvent=function(element,eventName,handler)
{for(var evts=el._evts||[],i=evts.length;i--;)
if(evts[i]._w===f)
el.detachEvent("on"+ev,evts.splice(i,1)[0]);};o.createElement=function(tagName,attributes,children)
{attributes=attributes||{};children=children||[];if(attributes.hasOwnProperty("name"))
{var element=document.createElement("<"+tagName+" name="+attributes.name+">");}
else
{var element=document.createElement(tagName);}
for(var attr in attributes)
{if(attributes.hasOwnProperty(attr))
{if(typeof(attributes[attr])=="function"&&attr.toLowerCase().indexOf("on")==0)
{this.addEvent(element,attr.substr(2),attributes[attr]);}
else
{this.setAttribute(element,attr,attributes[attr]);}}}
for(var i=0,l=children.length;i<l;i++)
{var child=children[i];var childType=typeof(child);if(childType=="string"||childType=="number")
{element.appendChild(document.createTextNode(child));}
else
{element.appendChild(child);}}
return element;};}
return o;})();