var jwebDeco={
	
	_urlBase:0,
	_argSeparator:0,
	_history:{},
	_anHistoryId:'jwebDecoHistoryId',
	_anHasDeco:'jwebDecoHasDeco',
	
	init:function(bgUrlBase,argSeparator){
		this._urlBase=bgUrlBase;
		this._argSeparator=argSeparator;
		
		var os=document.all||document.getElementsByTagName('*'),i=os.length,tmp;
		while(--i>-1){
			if(tmp=os[i].getAttribute('jwebdeco')){
				this.make(os[i],tmp);
				}
			}
		},
	
	unmake:function(o){
		//return;
		var tmp;
		if(tmp=o.getAttribute(this._anHistoryId)){
			tmp=this._history[tmp]
			
			o.style.border=tmp.style.border;
			o.style.backgroundImage=tmp.style.backgroundImage;
			o.style.backgroundPosition=tmp.style.backgroundPosition;
			o.style.backgroundRepeat=tmp.style.backgroundRepeat;
			o.style.backgroundColor=tmp.style.backgroundColor;
			o.style.padding=tmp.style.padding;
			
			o.setAttribute(this._anHasDeco,null);
			}
		
		},
	
	make:function(o,args,keep){
		
		var tmp;
		
		// dont aply deco twice
		if(o.getAttribute(this._anHasDeco))return;
		o.setAttribute(this._anHasDeco,1);
		
		// keep original style
		if(keep){
			tmp='jwebDeco'+Math.round(Math.random()*123456);
			this._history[tmp]=o.cloneNode(true);
			o.setAttribute(this._anHistoryId,tmp);
			}
		
		var jqo=$(o);
			
		var w=parseInt(jqo.outerWidth())||0;
		var h=parseInt(jqo.outerHeight())||0;
		
		if(!w||!h)return;
		
		var bgc=jqo.css('backgroundColor')||'';
		var bct=jqo.css('borderTopColor')||'';
		var bcr=jqo.css('borderRightColor')||'';
		var bcb=jqo.css('borderBottomColor')||'';
		var bcl=jqo.css('borderLeftColor')||'';
		
		var bwt=parseInt(jqo.css('borderTopWidth'))||0;
		var bwr=parseInt(jqo.css('borderRightWidth'))||0;
		var bwb=parseInt(jqo.css('borderBottomWidth'))||0;
		var bwl=parseInt(jqo.css('borderLeftWidth'))||0;
		
		if(bwt)o.style.paddingTop=((parseInt(jqo.css('paddingTop'))||0)+bwt)+'px';
		if(bwr)o.style.paddingRight=((parseInt(jqo.css('paddingRight'))||0)+bwr)+'px';
		if(bwb)o.style.paddingBottom=((parseInt(jqo.css('paddingBottom'))||0)+bwb)+'px';
		if(bwl)o.style.paddingLeft=((parseInt(jqo.css('paddingLeft'))||0)+bwl)+'px';
		
		var data=[w,h,bwt,bwr,bwb,bwl,bct,bcr,bcb,bcl,bgc,args].join(this._argSeparator).replace(/[#\s]+/g,'');
		var url=this._urlBase+data;
		
		o.style.border='none';
		o.style.background="url('"+url+"') transparent no-repeat 0px 0px";
		
		}
	
	};