var vx=Vector;
var vx0=vx.vx(0,0)
var canSize = true;
function Sizer(){}
Object.extend(Sizer,{
	factor:5,
	timer:20,
	px:document.layers?'':'px',
	to:function(e,v1,v2,dir){
		if(typeof e!='String' && e.id=='') e.id='layer-'+(Math.random()*9999999);
		e=$(e);
		if( ((dir=='+')&&(v1.x<v2.x&&v1.y<v2.y))) {
			var B=vx.Diff(v1,v2),
			A=vx.vx(Math.ceil(B.x/this.factor),Math.ceil(B.y/this.factor));
			v1.x+=A.x;v1.y+=A.y;
		}
		else if( ((dir=='-')&&(v1.x>v2.x&&v1.y>v2.y)) ) {
			var B=vx.Diff(v2,v1),
			A=vx.vx(Math.ceil(B.x/this.factor),Math.ceil(B.y/this.factor));
			v1.x-=A.x;v1.y-=A.y;
		} else {canSize=true;return;}
		e.style.width=v1.x+this.px;
		e.style.height=v1.y+this.px;
		setTimeout('Sizer.to("'+e.id+'",vx.vx('+v1.x+','+v1.y+'),vx.vx('+v2.x+','+v2.y+'),"'+dir+'")',this.timer);
	},
	toFx:function(e,fx,limit,dir){
		e=$(e);
		if(dir=='+'&&fx<1) fx+=1;
		var w=e.offsetWidth,h=e.offsetHeight,
		v1=vx.vx(w,h),
		v2=vx.vx(Math.ceil(w*fx),Math.ceil(h*fx));
		if(dir=='-') {
			if(v2.x<limit.x) v2.x=limit.x;
			if(v2.y<limit.y) v2.y=limit.y;
		}
		if(dir=='+') {
			if(v2.x>limit.x) v2.x=limit.x;
			if(v2.y>limit.y) v2.y=limit.y;
		}
		Sizer.to(e,v1,v2,dir);
	},
	grow:function(e,v1,v2){Sizer.to(e,v1,v2,vx.vx0,'+');},
	shrink:function(e,v1,v2){Sizer.to(e,v1,v2,vx.vx0,'-');},
	growFx:function(e,fx,xmax){	Sizer.toFx(e,fx,xmax,vx0,'+');},
	shrinkFx:function(e,fx,xmin){Sizer.toFx(e,fx,xmin,vx0,'-');}	
});
/****************************************/
/*			MOVE TO A POSITION			*/
/****************************************/
function Move(){}
Object.extend(Move,{
	factor:5,
	timer:20,
	px:document.layers?'':'px',
	getPos:function (e){e=$(e);var left=0,top=0;
		if(e.style.left!=''){var s=e.style.left;s.replace('/px/','');left=parseFloat(s);}else{
			var o=e;while(e.offsetParent){left+=e.offsetLeft;e=e.offsetParent;}
			left+=e.offsetLeft;
			e=o;
		}
		if(e.style.top!=''){var s=e.style.top;s.replace('/px/','');top=parseFloat(s);}else{
			var o=e;while(e.offsetParent){top+=e.offsetTop;e=e.offsetParent;}
			top+=e.offsetTop;
			e=o;
		}
		return vx.vx(left,top);		
	},
	setPos:function(e,V) {
		e.style.left = V.x+this.px;
		e.style.top  = V.y+this.px;
	},
	moveTo:function(e,vtx) {
		if(typeof e!='String' && e.id=='') e.id='layer-'+(Math.random()*9999999);e=$(e);
		var o=this.getPos(e),
		A=vx.Diff(o,vtx);
		if(A.x>0 || A.y>0) {
			A.x=Math.ceil(A.x/this.factor);if(A.x<0)A.x=A.x*-1;
			A.y=Math.ceil(A.y/this.factor);if(A.y<0)A.y=A.y*-1;
			var B=vx.vx(o.x+A.x,o.y+A.y);
			e.style.position='absolute';
			if(B.x>1000) return;
			e.style.left = B.x+this.px;
			e.style.top  = B.y+this.px;
			setTimeout('Move().moveTo("'+e.id+'",vx.vx('+vtx.x+','+vtx.y+'))',this.timer);
		}
	}
});
function Fadder(){}
Object.extend(Fadder, {
	fadeValue:0,
	step:10,
	fadeIn: function(object) {
		$(object).style.display='block';
		return this.fade(object,15,100,'+');
	},
	fadeOut: function (object) {		
		return this.fade(object,100,0,'-');
	},
	fade: function (object,start,end,dir) {
		this.fadeValue = start;
		object=$(object);
		$(object).style.display='block';
		object.style.opacity=parseFloat(this.fadeValue/100);
		object.style.filter='alpha(Opacity='+this.fadeValue+')';
		if(dir == '+' && start>end) {return 0;}
		if(dir == '-' && start<end) {$(object).style.display='none';canShow = true; return 0;}
		setTimeout('Fadder.fade("'+object.id+'",'+(dir=='+'?start+this.step:start-this.step)+','+end+',"'+dir+'")',50);
		return this.fadeValue;
	}
});