var TINY={};

function T$(i){return document.getElementById(i)}
function T$$$(){return document.all?1:0}

TINY.drag=function(){
	var z=500;
  return{
    init:function(id,h){
			var d=T$(id); d.style.opacity=0; d.style.filter='alpha(opacity=0)';
			T$(h).onmousedown=new Function('event','TINY.drag.st(event,"'+id+'"); TINY.cursor.remprop(event)');
	  },
		show:function(id){
			var d=T$(id);
			d.style.top='100px'; d.style.left='100px';
			d.style.display='block'; TINY.alpha.set(d,100,2)
		},
		hide:function(id){
			var d=T$(id); TINY.alpha.set(d,0,1)
		},
	  st:function(e,id){
	    var d=T$(id),
			x=parseInt(TINY.style.get(d,'left')), y=parseInt(TINY.style.get(d,'top'));
			d.top=TINY.cursor.top(e)-y; d.left=TINY.cursor.left(e)-x;
			d.style.zIndex=z; z++;
      d.mv=new Function('event','TINY.drag.mv(event,"'+id+'"); TINY.cursor.remprop(event)');
      d.sp=new Function('event','TINY.drag.sp("'+id+'"); TINY.cursor.remprop(event)');
      if(T$$$()){
        document.attachEvent('onmousemove',d.mv); document.attachEvent('onmouseup',d.sp)
      }else{
        document.addEventListener('mousemove',d.mv,true); document.addEventListener('mouseup',d.sp,true)
      }
	  },
    mv:function(e,id,t,l){
      var d=T$(id);
      d.style.top=TINY.cursor.top(e)-d.top+'px';
			d.style.left=TINY.cursor.left(e)-d.left+'px';
    },
    sp:function(id){
      var d=T$(id);
      if(T$$$()){
        document.detachEvent('onmousemove',d.mv); document.detachEvent('onmouseup',d.sp)
      }else{
				d.focus();
        document.removeEventListener('mousemove',d.mv,true); document.removeEventListener('mouseup',d.sp,true)
      }
    }
  }
}();

TINY.alpha=function(){
	return{
		set:function(e,a,s){
			var o=e.style.opacity, d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai);
			e.ai=setInterval(function(){TINY.alpha.tw(e,a,d,s)},10)
		},
		tw:function(e,a,d,s){
			var o=Math.round(e.style.opacity*100);
			if(o==a){
				clearInterval(e.ai); if(!o){e.style.display='none'}
			}else{
				var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100;
				e.style.filter='alpha(opacity='+n+')'
			}
		}
	}
}();

TINY.style=function(){
	return{
		get:function(e,p){
			e=typeof e=='object'?e:$(e);
			return e.currentStyle?e.currentStyle[p]:document.defaultView.getComputedStyle(e,null).getPropertyValue(p)
		}
	}
}();

TINY.cursor=function(){
	return{
		top:function(e){
		  return T$$$()?window.event.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop):e.pageY
		},
		left:function(e){
		  return T$$$()?window.event.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft):e.pageX
		},
		remprop:function(e){
		  e=e||window.event; window.event?e.cancelBubble=true:e.stopPropagation()
		}
	}
}();

function updateChart(u,e,c){
	if(!u){
		var i=e.selectedIndex, v=e.options[i].value; u='data.php?id='+v;
	}
	T$(c).reloadData(u)
}

function loadEvents(){
	TINY.drag.init("chart","chartheader");
	TINY.drag.show("chart")
}

window.onload=loadEvents;