var SBM={};

function T$(i){return document.getElementById(i)}


SBM.box=function(){
	var p,m,b,fn,ic,iu,iw,ih,ia,f=0,id;
	return{
		show:function(c,u,w,h,a,t){

			if(!f){
				p=document.createElement('div'); p.id='sbmbox';
				m=document.createElement('div'); m.id='sbmmask';
				b=document.createElement('div'); b.id='sbmcontent';
				b.style.cursor='pointer';
				document.body.appendChild(m); document.body.appendChild(p); p.appendChild(b);
				m.onmousemove=SBM.box.close; f=1;
			}
			p.style.width=w;
			p.style.height=h;
			b.style.width=w;
			b.style.height=h;

			ic=c; iu=u; iw=w; ih=h; ia=a; this.alpha(m,1,0,0);

		this.alpha(m,1,0,0,c);
		},
		fill:function(c,u,w,h,a){
			if(u){
				p.style.backgroundImage='';
				var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
				x.onreadystatechange=function(){
					if(x.readyState==4&&x.status==200){SBM.box.psh(x.responseText,w,h,a)}
				};
				x.open('GET',c,1); x.send(null)
			}else{
				this.psh(c,w,h,a)
			}
		},
		psh:function(c,w,h,a){
			b.innerHTML=c;
		},
		hide:function(c){
				SBM.box.alpha(p,-1,0,3,c);
		},
		close:function(c){
				SBM.box.alpha(p,-1,0,3,c);
		},

		pos:function(c){

		    var topValue= 0,leftValue= 0;
			var obj = document.getElementById('sbm');
		    while(obj){
				leftValue+= obj.offsetLeft;
				topValue+= obj.offsetTop;
				obj= obj.offsetParent;
		    }

			var top = 17;
			var right = 10;

			topValue = topValue - top;
			leftValue = leftValue - right;

			p.style.top=topValue+'px';
			p.style.left=leftValue+'px';
		},
		alpha:function(e,d,a,k,c){
			clearInterval(e.ai);
			if(d==1){
				e.style.opacity=0; e.style.filter='alpha(opacity=0)';
				e.style.display='block'; this.pos(c);
			}

			e.ai=setInterval(function(){SBM.box.ta(e,a,d,c)},1);

		},
		ta:function(e,a,d,c){

			var o=Math.round(e.style.opacity*100);

			if(o==a){
				clearInterval(e.ai);
				if(d==-1){
					e.style.display='none';
					e==p?SBM.box.alpha(m,-1,0,2,c):b.innerHTML=p.style.backgroundImage=''
				}else{
					e==m?this.alpha(p,1,100,'',c):SBM.box.fill(ic,iu,iw,ih,ia)
				}
			}else{
				//var n=Math.ceil((o+((a-o)*.5))); n=n==1?0:n;
				if (a==100) {
					n=100;
				} else if (a==0) {
					n=0;
				}
				e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'
			}
		}
	}
}();




