	//************************************************************************************************************//
	//************************************************************************************************************//
	//
	//
	//  DIMENSION4 STUDIOS TWEEN MOTION CLASS
	//  
	//       Copyright 2009-2010
	//
	//
	//************************************************************************************************************//
	//************************************************************************************************************//

	var rtd = 3.14/180;				// Radians to Degrees.
	var originalleft;				// Original left
	var bounces = 3;				// Number of Bounces.
	var checkpoints = bounces * 4;			// Checkpoints to degrade and decay at
	var bouncerad = .45;				// Bounce radius (based on original length)
	var bouncedecay = .5;				// Decay Amount (at each iteration)
	var innerStep = .25;				// Inner Step Incrementation
	var outerStep = 5;				// Outer Step Value
	var decay = new Array();			// Decay amount array
	var stepper = new Array();			// step amount array
	var timeRef = new Array();			// timer reference array:
	for(i=0;i<checkpoints;i++)
	{
		// Set decay amount:
		if(i==0){decay[i] = 1;}else{decay[i] = Math.pow(bouncedecay,i);}
		// set inner stepper amount:
		stepper[i] = (i+1)*innerStep+outerStep;
	}

	// ANYTHING YOU NEED DONE AFTER THE TWEEN IS FINISHED GOES HERE: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function CleanUp(sectionID)
	{
		// Put Cleanup Code Here
	}

	// TWEEN BOUNCE SETTINGS: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function BounceSettings(numBounces, firstRadius, decayAmount, outerStepper, innerStepIncrement)
	{
		if(numBounces){bounce = numBounces;}
		if(firstRadius){bouncerad = firstRadius;}
		if(decayAmount){bouncedecay = decayAmount;}
		if(outerStepper){outerStep = outerStepper;}
		if(innerStepIncrement){innerStep = innerStepIncrement;}
		checkpoints = bounces * 4;
		for(i=0;i<checkpoints;i++)
		{
			if(i==0){decay[i] = 1;}else{decay[i] = Math.pow(bouncedecay,i);}
			stepper[i] = (i+1)*innerStep+outerStep;
		}
	}

	// TWEEN VERTICALLY ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function TweenVertical(sectionID, startY, endY, step, style)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthY = endY - startY;
		var newnumY = 0;
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, 0, startY, 0, 0, 0, lengthY, 0, 0, timeRef[sectionID], 0, step, 0, 0, 0, style, 0, 0, 0, newnumY, 0, 0, 0, 0, 0);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN HORIZONTALLY ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function TweenHorizontal(sectionID, startX, endX, step, style)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthX = endX - startX;
		var newnumX = 0;
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, startX, 0, 0, 0, lengthX, 0, 0, 0, timeRef[sectionID], step, 0, 0, 0, style, 0, 0, 0, newnumX, 0, 0, 0, 0, 0, 0);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN MOVE ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function TweenMove(sectionID, startX, endX, startY, endY, step, style)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthX = endX - startX;
		var newnumX = 0;
		var lengthY = endY - startY;
		var newnumY = 0;
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, startX, startY, 0, 0, lengthX, lengthY, 0, 0, timeRef[sectionID], step, step, 0, 0, style, style, 0, 0, newnumX, newnumY, 0, 0, 0, 0, 0);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN WIDTH ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------\
	function TweenWidth(sectionID, startWidth, endWidth, step, style, originalleft, centerit)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthWidth = endWidth - startWidth;
		var newnumWidth = 0;
		if(!originalleft){originalleft = parseInt(document.getElementById(sectionID).style.left);}
		if(!centerit){centerit=0;}
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, 0, 0, startWidth, 0, 0, 0, lengthWidth, 0, timeRef[sectionID], 0, 0, step, 0, 0, 0, style, 0, 0, 0, newnumWidth, 0, originalleft, 0, centerit);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN HEIGHT ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function TweenHeight(sectionID, startHeight, endHeight, step, style, originaltop, centerit)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthHeight = endHeight - startHeight;
		var newnumHeight = 0;
		if(!centerit){centerit=0;}
		if(!originaltop){originaltop = parseInt(document.getElementById(sectionID).style.top);}
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, 0, 0, 0, startHeight, 0, 0, 0, lengthHeight, timeRef[sectionID], 0, 0, 0, step, 0, 0, 0, style, 0, 0, 0, newnumHeight, 0, originaltop, centerit);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN SIZE ONLY: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function TweenSize(sectionID, startWidth, endWidth, startHeight, endHeight, step, style, originalleft, originaltop, centerit)
	{
		window.clearTimeout(timeRef[sectionID]);
		var lengthHeight = endHeight - startHeight;
		var newnumHeight = 0;
		var lengthWidth = endWidth - startWidth;
		var newnumWidth = 0;
		if(!centerit){centerit=0;}
		if(!originalleft){originalleft = parseInt(document.getElementById(sectionID).style.left);}
		if(!originaltop){originaltop = parseInt(document.getElementById(sectionID).style.top);}
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, 0, 0, startWidth, startHeight, 0, 0, lengthWidth, lengthHeight, timeRef[sectionID], 0, 0, step, step, 0, 0, style, style, 0, 0, newnumWidth, newnumHeight, originalleft, originaltop, centerit);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	// TWEEN MULTIPLE DIRECTIONS: //
	//--------------------------------------------------------------------------------------------------------------------------------------------
	function Tween(sectionID, startX, endX, startY, endY, startWidth, endWidth, startHeight, endHeight, stepX, stepY, stepWidth, stepHeight, styleX, styleY, styleWidth, styleHeight, originalleft, originaltop, centerit)
	{
		window.clearTimeout(timeRef[sectionID]);
		// Determine if movement to the right:
		var lengthX = endX - startX;
		var lengthY = endY - startY;
		var lengthWidth = endWidth - startWidth;
		var lengthHeight = endHeight - startHeight;
		var newnumX = 0;
		var newnumY = 0;
		var newnumWidth = 0;
		var newnumHeight = 0;
		if(!centerit){centerit=0;}
		if(!originalleft){originalleft = parseInt(document.getElementById(sectionID).style.left);}
		if(!originaltop){originaltop = parseInt(document.getElementById(sectionID).style.top);}
		if(style=="bounce"){BounceSettings(null,null,null,step,null);}
		TweenAction(sectionID, startX, startY, startWidth, startHeight, lengthX, lengthY, lengthWidth, lengthHeight, timeRef[sectionID], stepX, stepY, stepWidth, stepHeight, styleX, styleY, styleWidth, styleHeight, newnumX, newnumY, newnumWidth, newnumHeight, originalleft, originaltop, centerit);
	}
	//--------------------------------------------------------------------------------------------------------------------------------------------


	//////////////////////////////////////////////////////////////////////////////
	// DO NOT CALL THIS FUNCTION!  THIS IS CALLED BY THE APPROPRIATE INITIATOR: //
	//////////////////////////////////////////////////////////////////////////////
	function TweenAction(sectionID, startX, startY, startWidth, startHeight, lengthX, lengthY, lengthWidth, lengthHeight, timer_reference, stepX, stepY, stepWidth,stepHeight, styleX, styleY, styleWidth, styleHeight, newnumX, newnumY, newnumWidth, newnumHeight, originalleft, originaltop, centerit)
	{
		var mathnum = 0;
		var stop1 = 0;
		var stop2 = 0;
		var stop3 = 0;
		var stop4 = 0;


		if(lengthX!=0)
		{
			if(stop1==0)
			{
				if(styleX == "sin"){mathnum = Math.sin(newnumX*rtd);}
				if(styleX == "cos"){mathnum = Math.cos(newnumX*rtd);}
				if(styleX == "none"){mathnum = newnumX/90;}
				if(styleX == "bounce")
				{
					totallengthX = lengthX + lengthX * bouncerad;
					newlength = totallengthX;
					sx=0;
					bc=1;
					dc=1;
					number = newnumX * bounces * 4;
					if(number>=90)
					{
						stepX=stepper[parseInt(number/180)];
						sx=lengthX;
						totallengthX = lengthX;
						bc = bouncerad;
						dc = decay[parseInt(number/180)];
						newlength = lengthX * dc * bouncerad;
					}
					else
					{
						stepX=outerStep;
					}
					if(newnumX >= 90){extranum = lengthX;}
					extranum = Math.sin(number*rtd)*newlength+sx;
					newX = startX + extranum;
				}
				else{newX = startX + mathnum * lengthX;}
				if(newnumX >= 90){stop1=1;}
				newnumX += stepX;
				document.getElementById(sectionID).style.left = (newX + "px");
			}
		}else{stop1=1;}
		if(lengthY!=0)
		{
			if(stop2==0)
			{
				if(styleY == "sin"){mathnum = Math.sin(newnumY*rtd);}
				if(styleY == "cos"){mathnum = Math.cos(newnumY*rtd);}
				if(styleY == "none"){mathnum = newnumY/90;}
				if(styleY == "bounce")
				{
					totallengthY = lengthY + lengthY * bouncerad;
					newlength = totallengthY;
					sx=0;
					bc=1;
					dc=1;
					number = newnumY * bounces * 4;
					if(number>=90)
					{
						stepY=stepper[parseInt(number/180)];
						sx=lengthY;
						totallengthY = lengthY;
						bc = bouncerad;
						dc = decay[parseInt(number/180)];
						newlength = lengthY * dc * bouncerad;
					}
					else
					{
						stepY=outerStep;
					}
					if(newnumY >= 90){extranum = lengthY;}
					extranum = Math.sin(number*rtd)*newlength+sx;
					newY = startY + extranum;
				}
				else{var newY = startY + mathnum * lengthY;}
				if(newnumY >= 90){stop2=1;}
				newnumY += stepY;
				document.getElementById(sectionID).style.top = (newY + "px");
			}
		}else{stop2=1;}
		if(lengthWidth!=0)
		{
			if(stop3==0)
			{
				if(styleWidth == "sin"){mathnum = Math.sin(newnumWidth*rtd);}
				if(styleWidth == "cos"){mathnum = Math.cos(newnumWidth*rtd);}
				if(styleWidth == "none"){mathnum = newnumWidth/90;}
				if(styleWidth == "bounce")
				{
					totallengthWidth = lengthWidth + lengthWidth * bouncerad;
					newlength = totallengthWidth;
					sx=0;
					bc=1;
					dc=1;
					number = newnumWidth * bounces * 4;
					if(number>=90)
					{
						stepWidth=stepper[parseInt(number/180)];
						sx=lengthWidth;
						totallengthWidth = lengthWidth;
						bc = bouncerad;
						dc = decay[parseInt(number/180)];
						newlength = lengthWidth * dc * bouncerad;
					}
					else
					{
						stepWidth=outerStep;
					}
					if(newnumWidth >= 90){extranum = lengthWidth;}
					extranum = Math.sin(number*rtd)*newlength+sx;
					newWidth = startWidth + extranum;
				}
				else{var newWidth = startWidth + mathnum * lengthWidth;}
				if(newnumWidth >= 90){stop3=1;}
				newnumWidth += stepWidth;
				if(centerit){document.getElementById(sectionID).style.left = ((originalleft - newWidth/2) + "px");}
				document.getElementById(sectionID).style.width = (newWidth + "px");
			}
		}else{stop3=1;}
		if(lengthHeight!=0)
		{
			if(stop4==0)
			{
				if(styleHeight == "sin"){mathnum = Math.sin(newnumHeight*rtd);}
				if(styleHeight == "cos"){mathnum = Math.cos(newnumHeight*rtd);}
				if(styleHeight == "none"){mathnum = newnumHeight/90;}
				if(styleHeight == "bounce")
				{
					totallengthHeight = lengthHeight + lengthHeight * bouncerad;
					newlength = totallengthHeight;
					sx=0;
					bc=1;
					dc=1;
					number = newnumHeight * bounces * 4;
					if(number>=90)
					{
						stepHeight=stepper[parseInt(number/180)];
						sx=lengthHeight;
						totallengthHeight = lengthHeight;
						bc = bouncerad;
						dc = decay[parseInt(number/180)];
						newlength = lengthHeight * dc * bouncerad;
					}
					else
					{
						stepHeight=outerStep;
					}
					if(newnumHeight >= 90){extranum = lengthHeight;}
					extranum = Math.sin(number*rtd)*newlength+sx;
					newHeight = startHeight + extranum;
				}
				else{var newHeight = startHeight + mathnum * lengthHeight;}
				if(newnumHeight >= 90){stop4=1;}
				newnumHeight += stepHeight;
				if(centerit){document.getElementById(sectionID).style.top = ((originaltop - newHeight/2) + "px");}
				document.getElementById(sectionID).style.height = (newHeight + "px");
			}
		}else{stop4=1;}

		if(stop1==1 && stop2==1 && stop3==1 && stop4==1)
		{
			CleanUp(sectionID);
			window.clearTimeout(timeRef[sectionID]);
			return;
		}
		else
		{
			timeRef[sectionID] = window.setTimeout("TweenAction(\'" + sectionID + "\', " + startX + ", " + startY + ", " + startWidth + ", " + startHeight + ", " + lengthX + ", " + lengthY + ", " + lengthWidth + ", " + lengthHeight + ", " + timer_reference + ", " + stepX + ", " + stepY + ", " + stepWidth + ", " + stepHeight + ", \'" + styleX + "\', \'" + styleY + "\', \'" + styleWidth + "\', \'" + styleHeight + "\', " + newnumX + ", " + newnumY + ", " + newnumWidth + ", " + newnumHeight + ", " + originalleft + ", " + originaltop + ", " + centerit + ")", 20);
		}
	}
	/////////////////////
	// END TWEEN CLASS //
	/////////////////////







	function ease_class_const(num)
	{
		this.easeIn = (num-1)*2 + 4000;
		this.easeOut = (num-1)*2 + 4000 + 1;
	}

	var Back = new ease_class_const(1);
	var Bounce = new ease_class_const(2);
	var Circ = new ease_class_const(3);
	var Cubic = new ease_class_const(4);
	var Elastic = new ease_class_const(5);
	var Expo = new ease_class_const(6);
	var Linear = new ease_class_const(7);
	var Quad = new ease_class_const(8);
	var Quart = new ease_class_const(9);
	var Quint = new ease_class_const(10);
	var Sine = new ease_class_const(11);

	var SineVals = new Array();
	var SineInVals = new Array();

	function AssignEaseArrays()
	{
		var rtd = Math.PI/180;
		var samples = 1000;
		var incs = 90 / samples;

		// ease.SineOut
		for(x=0;x<samples;x++)
		{
			SineVals[x] = Math.sin(x*incs*rtd);
		}
		// ease.SineIn
		for(x=0;x<samples;x++)
		{
			SineInVals[x] = 1-Math.cos(x*incs*rtd);
		}
	}

	AssignEaseArrays();



	function tween_dummy_function()
	{

	}

	function TweenJS(sectionID, secondsLong, varArray)
	{
		window.clearTimeout(timeRef[sectionID]);

		var fps = 30;
		var intervals = secondsLong * fps;
		var timeWait = 1000 / fps;
		var delay = 0;

		if(varArray['delay']){delay = varArray['delay'];}

		// Increment Delay:
		delay *= 1000;

		// get current values:
		var currentStyle = document.getElementById(sectionID).style;
		ox = parseInt(currentStyle.left);
		oy = parseInt(currentStyle.top);
		owidth = parseInt(currentStyle.width);
		oheight = parseInt(currentStyle.height);

		// we have not yet found an opacity value:
		var foundOpac = 0;
		// check for older IE opacity:
		if(currentStyle.filter){oalpha = parseInt(currentStyle.filter.substr(22,currentStyle.filter.length-22-1))/100;foundOpac=1;}
		// check for Konquerer opacity:
		if(currentStyle.KHTMLOpacity){oalpha = currentStyle.KHTMLOpacity;foundOpac=1;}
		// check for older Mozilla opacity:
		if(currentStyle.MozOpacity){oalpha = currentStyle.MozOpacity;foundOpac=1;}
		// check for standardized opacity:
		if(currentStyle.opacity){oalpha = currentStyle.opacity;foundOpac=1;}
		
		// if no opacity found yet, set default to 1:
		if(!foundOpac){oalpha = 1;}


		if(!varArray['x']){varArray['x']=ox;}
		if(!varArray['y']){varArray['y']=oy;}
		if(!varArray['width']){varArray['width']=owidth;}
		if(!varArray['height']){varArray['height']=oheight;}
		if(!varArray['ease']){varArray['ease']=0;}
		if(!varArray['easeParams']){varArray['easeParams']="";}
		if(!varArray['onComplete']){varArray['onComplete']=tween_dummy_function;}
		if(!varArray['onCompleteParams']){varArray['onCompleteParams']="";}
		if(!varArray['alpha']){varArray['alpha']=oalpha;}

		var diffx = parseInt(varArray['x']) - ox;
		var diffy = parseInt(varArray['y']) - oy;
		var diffwidth = parseInt(varArray['width']) - owidth;
		var diffheight = parseInt(varArray['height']) - oheight;
		var diffalpha = varArray['alpha'] - oalpha;

		var curVal = (1/intervals)*1000;
		var valInc = curVal;

		// begin the tweening process:
		window.setTimeout("TweenLoop(\'" + sectionID + "\',0," + intervals + ", " + timeWait + ", " + ox + ", " + oy + ", " + owidth + ", " + oheight + ", " + oalpha + ", " + varArray['x'] + ", " + varArray['y'] + ", " + varArray['width'] + ", " + varArray['height'] + ", " + varArray['alpha'] + ", " + varArray['ease'] + ", \'" + varArray['easeParams'] + "\', " + varArray['onComplete'] + ", \'" + varArray['onCompleteParams'] + "\', " + diffx + ", " + diffy + ", " + diffwidth + ", " + diffheight + ", " + diffalpha + ", " + valInc + ", " + curVal + ")",delay);
	}

	function TweenLoop(sectionID,curIt,maxIt,timeWait,ox,oy,owidth,oheight,oalpha,dx,dy,dwidth,dheight,dalpha,ease,easeParams,onComplete,onCompleteParams,diffx,diffy,diffwidth,diffheight,diffalpha,valInc,curVal)
	{
		// push the current val into an integer:
		cVal = parseInt(curVal);

		// set up a placeholder variable:
		var pArray = new Array();

		switch(ease)
		{
		// sine easing out:
		case Sine.easeOut:
			pArray = SineVals;
			break;
		// sine easing in:
		case Sine.easeIn:
			pArray = SineInVals;
			break;
		// default easing (linear):
		case 0:

			break;
		}

		if(cVal>999){cVal=999;}

		if(diffx){cx=ox+parseInt(pArray[cVal] * diffx);}
		if(diffy){cy=oy+parseInt(pArray[cVal] * diffy);}
		if(diffwidth){cwidth=owidth+parseInt(pArray[cVal] * diffwidth);}
		if(diffheight){cheight=oheight+parseInt(pArray[cVal] * diffheight);}
		if(diffalpha){calpha=oalpha+pArray[cVal] * diffalpha;}

		var currentStyle = document.getElementById(sectionID).style;

		if(diffx){currentStyle.left = cx + "px";}
		if(diffy){currentStyle.top = cy + "px";}
		if(diffwidth){currentStyle.width = cwidth + "px";}
		if(diffheight){currentStyle.height = cheight + "px";}
		if(diffalpha)
		{
			currentStyle.filter = "alpha(style=0,opacity=" + (calpha*100) + ")";
			currentStyle.KHTMLOpacity = calpha;
			currentStyle.MozOpacity = calpha;
			currentStyle.opacity = calpha;
		}

		// Increment the current Iteration:
		curIt++;

		// Increment current val:
		curVal += valInc;

		// If maximum Iterations not met, Go again:
		if(curIt<=maxIt)
		{
			// Recurse:
			timeRef[sectionID] = window.setTimeout("TweenLoop(\'" + sectionID + "\', " + curIt + ", " + maxIt + ", " + timeWait + ", " + ox + ", " + oy + ", " + owidth + ", " + oheight + ", " + oalpha + ", " + dx + ", " + dy + ", " + dwidth + ", " + dheight + ", " + dalpha + ", " + ease + ", \'" + easeParams + "\', " + onComplete + ", \'" + onCompleteParams + "\', " + diffx + ", " + diffy + ", " + diffwidth + ", " + diffheight + ", " + diffalpha + ", " + valInc + ", " + curVal + ")",timeWait);
		}
		else
		{
			// make sure all values are at their destination now:
			if(diffx){currentStyle.left = dx + "px";}
			if(diffy){currentStyle.top = dy + "px";}
			if(diffwidth){currentStyle.width = dwidth + "px";}
			if(diffheight){currentStyle.height = dheight + "px";}

			// If there was an "onComplete" passed:
			if(onComplete)
			{
				// If there were parameters passed for the "onComplete" function:
				if(onCompleteParams)
				{
					//alert(onCompleteParams);
					var tarr = onCompleteParams.split(",");
					onCompleteParams = "";
					for(x=0;x<tarr.length;x++)
					{
						if(isNaN(tarr[x])){tarr[x] = "\"" + tarr[x] + "\"";}
						onCompleteParams += tarr[x];
						if(x<tarr.length-1){onCompleteParams += ",";}
					}
					// call the function with parameters:
					eval('onComplete(' + onCompleteParams + ')');
				}
				else
				{
					// call the function with no parameters:
					onComplete();
				}
			}
		}
	}
