Element.extend({
	getParentByTagName: function(tag) {
		var el = this;
		while (el && el.nodeName.toLowerCase() != "body" && el.nodeName.toLowerCase() != tag.toLowerCase()) {
			el = el.getParent();
		}
		return $(el);
	},
	getAttributes: function() {
		var res = new Object();
		$each(this.attributes,function(e) {
			res[e.nodeName] = e.nodeValue;
		})
		return res;
	},
	setAttributes: function(a) {
		$each(a,function(e,i) {
			this.setAttribute(i,e);
		}.bind(this))
	},
	destroy: function() {
		this.remove();
	},
	toggle: function() {
		this.setStyle("display",this.getStyle("display") != "none" ? "none" : "block");
	}
	/*
	,
	onElementReady: function(callback) {
   		if( this && (this.nextSibling || this.textContent) ){
     		callback();
   		}
   		else{
     		setTimeout( this.onElementReady.bind(this,callback), 1 );
   		}
 	}
 	*/
	
});
