Object.extend(Object.extend('core.ui',Event.dispatcher),{
	_cssText:'float:left;overflow:hidden',
	skin:{css:{bgColor:'#DFDFDF',lightColor:'#fff',overColor:'#D1D1D1',borderColor:'#000'},images:null},
	initialize:function(id,options){this.element = $(document.body).append('div').css({cssText:this._cssText}).last();this.id(id);$.removeChild(this.element);this.setOptions(options);},
	id:function(o){
		var i=1,t;
		if(!o && this.element.id==''){while(!$(this.controlName+i).find){i++;}o = this.controlName+i}
		t=o?this.element.id = o:this.element.id;;
		return t;
	},
	setSkin:function(skin){
		var self = this,skin=$A(skin.childNodes||skin),oldSkin=this.skin;
		if(this==core.ui){
			skin.each(function(item,index){
				item.attributes?$A(item.attributes).each(function(i){self.skin[i.name]=i.value}):Object.each(function(name,value){self.skin[name]=value});
			});
		}else this.skin = skin;
		this.dispatchEvent({type:'onskin'});
	},
	getSkin:function(){return core.ui.skin[this.controlName]||core.ui.skin},
	setOptions:function(o){this.options={width:0,height:0};Object.extend(this.options,o);this.create()},
	create:function(){},
	_elem:function(){return this.elements ||[this.element]},
	width:function(t){var a=this._elem();return t!=null?a.each(function(i){i.style.width=(t+'').isInt()?t+'px':t}):a[0].offsetWidth},
	height:function(t){var a = this._elem();return t!=null?a.each(function(i){i.style.height=(t+'').isInt()?t+'px':t}):a[0].offsetHeight},
	top:function(t){var a = this._elem();return t!=null?a.each(function(i){i.style.left=(t+'').isInt()?t+'px':t}):$.getXY(a[0]).y},
	left:function(t){var a = this._elem();return t!=null?a.each(function(i){i.style.top=(t+'').isInt()?t+'px':t}):$.getXY(a[0]).x},	
	right:function(t){var a = this._elem();return t!=null?a.each(function(i){i.style.width=t-this.left()+'px'}):this.left()+this.width()},
	bottom:function(t){var a = this._elem();return t!=null?a.each(function(i){i.style.height=t-this.top()+'px'}):this.top()+this.height()},
	x:function(t){return this.left(t)},
	y:function(t){return this.top(t)},
	hide:function(){var a=this._elem(),t=this;a.each(function(i){i.style.display='none';if(t.dispatchEvent)t.dispatchEvent({type:'onhide'})})},
	show:function(){var a=this._elem(),t=this;a.each(function(i){i.style.display='';if(t.dispatchEvent)t.dispatchEvent({type:'onshow'})})},
	visible:function(){var a=this._elem();return a[0].style.display=='none'?false:true},
	add:function(t,b){var n=this.element;n=b?t.parentNode.insertBefore(n,t):t.appendChild(n)},
	remove:function(){this.element.parentNode.removeChild(this.element)},
	size:function(w,h){if(w!=null || h!=null)this.dispatchEvent({type:'onsize',width:w,height:h});return {width:this.width(w),height:this.height(h)}},
	point:function(x,y){if(x!=null || y!=null)this.dispatchEvent({type:'onmove',left:x,top:y});return {x:this.x(x),y:this.y(y)}}
});
['width','height','top','left','right','bottom','hide','show','visible','_elem'].each(function(i){
	$.prototype[i]=core.ui[i];
	$[i]=function(){var a=$A(arguments),o=$();n=$(a.removeAt(0));o.elements=[n];return o[i].apply(o,a)||this;}
});