var TINY={};

function T$(i){return document.getElementById(i)}
	var p,m,b,fn,ic,iu,iw,ih,ia,f=0;

TINY.box=function(){
	return{
		show:function(c,u,w,h,a,t){
			if(!f){
				p=document.createElement('div'); p.id='tinybox';
				m=document.createElement('div'); m.id='tinymask';
				b=document.createElement('div'); b.id='tinycontent';
				document.body.appendChild(m); document.body.appendChild(p); p.appendChild(b);
				m.onclick=TINY.box.hide; window.onresize=TINY.box.resize; f=1
			}
			if(!a&&!u){
				p.style.width=w?w+'px':'auto'; p.style.height=h?h+'px':'auto';
				p.style.backgroundImage='none'; b.innerHTML=c
			}else{
				b.style.display='none'; p.style.width=p.style.height='100px'
			}
			this.mask();
			ic=c; iu=u; iw=w; ih=h; ia=a; this.alpha(m,1,80,3);
			if(t){setTimeout(function(){TINY.box.hide()},1000*t)}
		},
		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){TINY.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){
			if(a){
				if(!w||!h){
					var x=p.style.width, y=p.style.height; b.innerHTML=c;
					p.style.width=w?w+'px':''; p.style.height=h?h+'px':'';
					b.style.display='';
					w=parseInt(b.offsetWidth); h=parseInt(b.offsetHeight);
					b.style.display='none'; p.style.width=x; p.style.height=y;
				}else{
					b.innerHTML=c
				}
				this.size(p,w,h)
			}else{
				p.style.backgroundImage='none'
			}
			$('tinybox').innerHTML.evalScripts(); // trying to get javascript evaluation with prototype, ovv Aug09				
		},
		hide:function(){
			TINY.box.alpha(p,-1,0,3)
		},
		resize:function(){
			TINY.box.pos(); TINY.box.mask()
		},
		mask:function(){
			m.style.height=TINY.page.total(1)+'px';
			m.style.width=''; m.style.width=TINY.page.total(0)+'px'
		},
		pos:function(){
			var t=(TINY.page.height()/2)-(p.offsetHeight/2); t=t<10?10:t;
			p.style.top=(t+TINY.page.top())+'px';
			p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'
		},
		alpha:function(e,d,a){
			clearInterval(e.ai);
			if(d==1){
				e.style.opacity=0; e.style.filter='alpha(opacity=0)';
				e.style.display='block'; this.pos()
			}
			e.ai=setInterval(function(){TINY.box.ta(e,a,d)},20)
		},
		ta:function(e,a,d){
			var o=Math.round(e.style.opacity*100);
			if(o==a){
				clearInterval(e.ai);
				if(d==-1){
					e.style.display='none';
					e==p?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''
				}else{
					e==m?this.alpha(p,1,100):TINY.box.fill(ic,iu,iw,ih,ia)
				}
			}else{
				var n=Math.ceil((o+((a-o)*.5))); n=n==1?0:n;
				e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'
			}
		},
		size:function(e,w,h){
			e=typeof e=='object'?e:T$(e); clearInterval(e.si);
			var ow=e.offsetWidth, oh=e.offsetHeight,
			wo=ow-parseInt(e.style.width), ho=oh-parseInt(e.style.height);
			var wd=ow-wo>w?0:1, hd=(oh-ho>h)?0:1;
			e.si=setInterval(function(){TINY.box.ts(e,w,wo,wd,h,ho,hd)},20)
		},
		ts:function(e,w,wo,wd,h,ho,hd){
			var ow=e.offsetWidth-wo, oh=e.offsetHeight-ho;
			if(ow==w&&oh==h){
				clearInterval(e.si); p.style.backgroundImage='none'; b.style.display='block'
			}else{
				if(ow!=w){var n=ow+((w-ow)*.5); e.style.width=wd?Math.ceil(n)+'px':Math.floor(n)+'px'}
				if(oh!=h){var n=oh+((h-oh)*.5); e.style.height=hd?Math.ceil(n)+'px':Math.floor(n)+'px'}
				this.pos()
			}
		}
	}
}();

TINY.page=function(){
	return{
		top:function(){return document.documentElement.scrollTop||document.body.scrollTop},
		width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},
		height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},
		total:function(d){
			var b=document.body, e=document.documentElement;
			return d?Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight)):
			Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))
		}
	}
}();

function T$$(e,p){return p.getElementsByTagName(e)}

TINY.table=function(){
	function sorter(n){this.n=n;this.pagesize=20;this.paginate=0}
	sorter.prototype.init=function(e,f){var t=ge(e),i=0;this.e=e;this.l=t.r.length;t.a=[];t.h=T$$('thead',T$(e))[0].rows[0];t.w=t.h.cells.length;for(i;i<t.w;i++){var c=t.h.cells[i];if(c.className!='nosort'){c.className=this.head;c.onclick=new Function(this.n+'.wk(this.cellIndex)')}}for(i=0;i<this.l;i++){t.a[i]={}}if(f!=null){var a=new Function(this.n+'.wk('+f+')');a()}if(this.paginate){this.g=1;this.pages()}};sorter.prototype.wk=function(y){var t=ge(this.e),x=t.h.cells[y],i=0;for(i;i<this.l;i++){t.a[i].o=i;var v=t.r[i].cells[y];t.r[i].style.display='';while(v.hasChildNodes()){v=v.firstChild}t.a[i].v=v.nodeValue?v.nodeValue:''}for(i=0;i<t.w;i++){var c=t.h.cells[i];if(c.className!='nosort'){c.className=this.head}}if(t.p==y){t.a.reverse();x.className=t.d?this.asc:this.desc;t.d=t.d?0:1}else{t.p=y;t.a.sort(cp);t.d=0;x.className=this.asc}var n=document.createElement('tbody');for(i=0;i<this.l;i++){var r=t.r[t.a[i].o].cloneNode(true);n.appendChild(r);r.className=i%2==0?this.even:this.odd;var cells=T$$('td',r);for(var z=0;z<t.w;z++){cells[z].className=y==z?i%2==0?this.evensel:this.oddsel:''}}t.replaceChild(n,t.b);if(this.paginate){this.size(this.pagesize)}};sorter.prototype.page=function(s){var t=ge(this.e),i=0,l=s+parseInt(this.pagesize);if(this.currentid&&this.limitid){T$(this.currentid).innerHTML=this.g}for(i;i<this.l;i++){t.r[i].style.display=i>=s&&i<l?'':'none'}};sorter.prototype.move=function(d,m){var s=d==1?(m?this.d:this.g+1):(m?1:this.g-1);if(s<=this.d&&s>0){this.g=s;this.page((s-1)*this.pagesize)}};sorter.prototype.size=function(s){this.pagesize=s;this.g=1;this.pages();this.page(0);if(this.currentid&&this.limitid){T$(this.limitid).innerHTML=this.d}};sorter.prototype.pages=function(){this.d=Math.ceil(this.l/this.pagesize)};function ge(e){var t=T$(e);t.b=T$$('tbody',t)[0];t.r=t.b.rows;return t};function cp(f,c){var g,h;f=g=f.v.toLowerCase(),c=h=c.v.toLowerCase();var i=parseFloat(f.replace(/(\$|\,)/g,'')),n=parseFloat(c.replace(/(\$|\,)/g,''));if(!isNaN(i)&&!isNaN(n)){g=i,h=n}i=Date.parse(f);n=Date.parse(c);if(!isNaN(i)&&!isNaN(n)){g=i;h=n}return g>h?1:(g<h?-1:0)};return{sorter:sorter}}();
