var dBuild = {
	build : function(tag_name, params, children){
		var el = this.getElement(tag_name);

		this.setAttributes(el, params);
		this.addChildren(el, children);
		return el;
	},
	getElement : function(tag_name){
		var el = null;
		if (this.isDOMElement(tag_name)){
			el = tag_name;
		}else{
			el = document.createElement(tag_name);
		}
		return el;
	},
	setAttributes : function(el, params){
		if (typeof params == "object" && params != null){
			for (key in params){
				if (!Object.prototype[key]){
					if (key == '_attrib'){
						for (attrib in params[key]){
							el.setAttribute(attrib,params[key][attrib]);
						}
					}else{
						this.setAttribute(el, key, params[key]);
					}
				}
			}
		}
	},
	addChildren : function(el, children){
		if (typeof children != "undefined" && children != null){
			if (typeof children == "string" || typeof children == "number"){
				var children = children.toString() || "";
				if (children != ''){
					if (el.innerHTML != ''){
						child = document.createTextNode(children);
						el.appendChild(child);
					}else{
						try{
							el.innerHTML = children || "";
						}catch(e){
	                                        }
					}
				}
			}else if (whi.functions.getConstructorName(children) == "Array"){
				if (children && children.length){
					for (var i=0; i<children.length; i++){
						if (typeof children[i] == "string" || typeof children[i] == "number"){
							child = document.createTextNode(children[i].toString());
						}else if (this.isDOMElement(children[i])){
							child = this.build(children[i]);
						}else if (whi.functions.getConstructorName(children[i]) == "Object"){
							if (children[i].documentFragment){
								this.addChildren(el, children[i].documentFragment);
							}
							continue;
						}else if (typeof children[i][0] == "string"){
							child = this.build(children[i][0], children[i][1] || "", children[i][2] || "");
						}
						el.appendChild(child);
					}
				}
			}
		}
        },
	setAttribute : function(obj, atr, val){
		if (typeof val != "undefined" && typeof atr == "string"){
			if (typeof val == "object" && val != null && typeof val.nodeType == "undefined"){
				if (typeof obj[atr] == "undefined" || obj[atr] == null){
					obj[atr] = {};
				}else if (typeof obj != "object" && typeof obj != "function"){
					return;
				}
				for (key in val){
					if (!Object.prototype[key]){
						this.setAttribute(obj[atr], key, val[key]);
					}
				}
			}else{
				obj[atr] = val;
			}
		}
	},
	isDOMElement : function(obj){
		return typeof obj == "object" && typeof obj.nodeType != "undefined";
	}
}