function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
function setDiv (divname,starting_point_top,starting_point_left,dwidth,dheight,opacity,zindex,dtop,dleft,bg)
{
	var isIE = document.all?true:false;

	div_top = starting_point_top + dtop;
	div_left = starting_point_left + dleft;

	document.getElementById(divname).style.top = div_top+'px';
	document.getElementById(divname).style.left = div_left+'px';


	document.getElementById(divname).style.width = dwidth+'px';
	document.getElementById(divname).style.height = dheight+'px';

	document.getElementById(divname).style.zIndex = zindex;
	
	if ( isIE ) document.getElementById(divname).filters.alpha.opacity= opacity*100;
	else document.getElementById(divname).style.opacity = opacity;

	if ( bg != 'NONE' )
	document.getElementById(divname).style.background = bg;

}


Disolver.prototype.opacity;
Disolver.prototype.opacity_increment;
Disolver.prototype.delay;
Disolver.prototype.divname;
Disolver.prototype.object_name;
function Disolver (object_name,opacity,opacity_increment,delay,divname)
{
	this.opacity = opacity;
	this.opacity_increment = opacity_increment;
	this.delay = delay;
	this.divname = divname;
	this.object_name = object_name;
}

Disolver.prototype.fadeIn = function (call_back,call_back_delay)
{
	var isIE = document.all?true:false;

	if ( this.opacity >= 1 )
	{
		this.opacity = 1;
		if ( isIE ) document.getElementById(this.divname).filters.alpha.opacity= this.opacity*100;
		else document.getElementById(this.divname).style.opacity = this.opacity;
		setTimeout (call_back,call_back_delay);
	}
	else
	{
		this.opacity = this.opacity + this.opacity_increment;
		if ( isIE ) document.getElementById(this.divname).filters.alpha.opacity= this.opacity*100;
		else document.getElementById(this.divname).style.opacity = this.opacity;
		setTimeout(this.object_name+".fadeIn(\""+call_back+"\","+call_back_delay+")",this.delay);
	}
}

Disolver.prototype.fadeOut = function (call_back,call_back_delay)
{
	var isIE = document.all?true:false;

	if ( this.opacity <= 0 )
	{
		this.opacity = 0;
		if ( isIE )  document.getElementById(this.divname).filters.alpha.opacity= this.opacity*100;
		else document.getElementById(this.divname).style.opacity = this.opacity;
		setTimeout (call_back,call_back_delay);
	}
	else
	{
		this.opacity = this.opacity - this.opacity_increment;
		if ( isIE ) document.getElementById(this.divname).filters.alpha.opacity= this.opacity*100;
		else document.getElementById(this.divname).style.opacity = this.opacity;
		setTimeout(this.object_name+".fadeOut(\""+call_back+"\","+call_back_delay+")",this.delay);
	}
}




Motion.prototype.sourcex;
Motion.prototype.sourcey;
Motion.prototype.destx;
Motion.prototype.desty;
Motion.prototype.m;
Motion.prototype.pixel_increment;
Motion.prototype.xdist;
Motion.prototype.ydist;

Motion.prototype.tx;
Motion.prototype.ty;


Motion.prototype.delay;
Motion.prototype.increment;
Motion.prototype.divname;
Motion.prototype.object_name;
Motion.prototype.starting_point_top;
Motion.prototype.starting_point_left;

function Motion (object_name,divname,starting_point_top,starting_point_left,increment,delay,sourcey,sourcex)
{
	this.starting_point_top = starting_point_top;
	this.starting_point_left = starting_point_left;
	this.sourcex = sourcex+this.starting_point_left;
	this.sourcey = sourcey+this.starting_point_top;
	this.delay = delay;
	this.increment = increment;
	this.divname = divname;
	this.object_name = object_name;
}

Motion.prototype.calcM = function ()
{
	if (this.destx == this.sourcex ) this.m=0;
	else this.m = (this.desty-this.sourcey) / (this.destx-this.sourcex);
}

Motion.prototype.prepareMove = function (desty,destx)
{
	this.destx = destx+this.starting_point_left;
	this.desty = desty+this.starting_point_top;
	this.calcM ();
	this.xdist = Math.abs(this.sourcex-this.destx);
	this.ydist = Math.abs(this.sourcey-this.desty);

	this.tx = this.sourcex;
	this.ty = this.sourcey;

	if ( this.xdist >=  this.ydist )
	{
		this.pixel_increment = Math.round((this.xdist * this.increment)/100);
	}
	else
	{
		this.pixel_increment = Math.round((this.ydist * this.increment)/100);
	}
}

Motion.prototype.getRelativeY = function (xx)
{

	return Math.round(this.sourcey - ( this.m*(this.sourcex-xx)));
}

Motion.prototype.getRelativeX = function (yy)
{
	if ( this.m == 0 ) return this.sourcex;
	else return Math.round(((this.m* this.sourcex)+this.sourcey-yy)/this.m);
}

Motion.prototype.move = function  (callback,callback_delay)
{
/*	alert ( this.m);
	alert (this.xdist);
	alert (this.ydist);
	alert (this.pixel_increment);*/
	if ( this.xdist >=  this.ydist )
	{
		if (this.sourcex < this.destx)
		{
			this.tx = this.tx+this.pixel_increment;
			if (this.tx >= this.destx ) 
			{
				this.tx = this.destx;
				this.ty = this.desty;
			}		
			else this.ty = this.getRelativeY(this.tx);
		}
		else
		{
			this.tx = this.tx-this.pixel_increment;
			if (this.tx <= this.destx )
			{
				this.tx = this.destx;
				this.ty = this.desty;
			}
			else this.ty = this.getRelativeY(this.tx);
		}
		
	}
	else
	{
		if (this.sourcey < this.desty)
		{
			this.ty = this.ty+this.pixel_increment;
			if (this.ty >= this.desty ) 
			{
				this.tx = this.destx;
				this.ty = this.desty;
			}			
			else this.tx = this.getRelativeX(this.ty);
		}
		else
		{
			this.ty = this.ty-this.pixel_increment;
			if (this.ty <= this.desty ) 
			{
				this.tx = this.destx;
				this.ty = this.desty;
			}
			else this.tx = this.getRelativeX(this.ty);
		}
	}
	document.getElementById(this.divname).style.top = this.ty+'px';
	document.getElementById(this.divname).style.left = this.tx+'px';

	if ( this.tx == this.destx && this.ty == this.desty )
	{
		this.sourcex = this.tx;
		this.sourcey = this.ty;

		setTimeout (callback,callback_delay);
	}
	else
		setTimeout(this.object_name+".move(\""+callback+"\","+callback_delay+")",this.delay);
}



Resizer.prototype.sourcew;
Resizer.prototype.sourceh;
Resizer.prototype.destw;
Resizer.prototype.desth;

Resizer.prototype.tw;
Resizer.prototype.th;

Resizer.prototype.divname;
Resizer.prototype.object_name;
Resizer.prototype.increment;
Resizer.prototype.delay;
Resizer.prototype.wpixel_increment;
Resizer.prototype.hpixel_increment;

function Resizer (object_name,divname,sourcew,sourceh,increment,delay)
{
	this.sourcew = sourcew;
	this.sourceh = sourceh;
	this.divname = divname;
	this.object_name = object_name;
	this.increment = increment;
	this.delay = delay;
}

Resizer.prototype.prepareResize = function (destw,desth)
{
	this.destw = destw;
	this.desth = desth;
	this.tw = this.sourcew;
	this.th = this.sourceh;
	this.wpixel_increment = Math.round((Math.abs(this.destw-this.sourcew) * this.increment)/100);
	this.hpixel_increment = Math.round((Math.abs(this.desth-this.sourceh) * this.increment)/100);
}

Resizer.prototype.resize = function (callback,callback_delay)
{
	if ( this.destw > this.sourcew ) 
	{
		this.tw = this.tw + this.wpixel_increment;
		if ( this.tw >= this.destw ) this.tw = this.destw;
	}
	else 
	{
		this.tw = this.tw - this.wpixel_increment;
		if ( this.tw <= this.destw ) this.tw = this.destw;
	}

	if ( this.desth > this.sourceh ) 
	{
		this.th = this.th + this.hpixel_increment;
		if ( this.th >= this.desth ) this.th = this.desth;
	}
	else
	{
		this.th = this.th - this.hpixel_increment;
		if ( this.th <= this.desth ) this.th = this.desth;
	}


	document.getElementById(this.divname).style.width = this.tw+'px';
	document.getElementById(this.divname).style.height = this.th+'px';

	if ( this.tw == this.destw && this.th == this.desth )
	{
		this.sourcew = this.tw;
		this.sourceh = this.th;
		setTimeout (callback,callback_delay);
	}
	else
	{

		setTimeout (this.object_name+".resize(\""+callback+"\","+callback_delay+")",this.delay);
	}
}

