function stlGroupFaderMove_Entry(idElement)
{
	this.idElement = idElement;
	this.elElement = document.getElementById(idElement);
	
	this.start		= 0;
	this.stop		= 0;
	this.delta		= 0;
	this.middle		= 0;
	this.radius		= 0;
}

function stlGroupFaderMoveDelta(idElement)
{
	var that		= this;
	var _elements	= new Array();
	var _radStart	= 0;
	var _stepTotal	= 50;
	var _multiplier = 100;
	var _speed		= 20;
	var _property	= "top";
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.addElement = function(idElement)
	{
		_elements[_elements.length] = new stlGroupFaderMove_Entry(idElement);
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.setProperty = function(name)
	{
		_property = name;
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.move = function(delta)
	{
		var el;
		
		_radStart		= 0;
		_radEnd			= Math.PI;
		_radDelta		= _radEnd - _radStart;
		_stepCurrent	= 0;
		
		var index;
		for(index = 0; index < _elements.length; index++)
		{
			el = _elements[index].elElement;
			
			switch(_property)
			{
				case "top":		_elements[index].start	= stlApp.library.getElementTop(el) * _multiplier; break;
				case "left":	_elements[index].start	= stlApp.library.getElementLeft(el) * _multiplier; break;
				case "height":	_elements[index].start	= el.offsetHeight * _multiplier; break;
				case "width":	_elements[index].start	= el.offsetWidth * _multiplier; break;
			}
			
			_elements[index].delta	= (delta * _multiplier);
			_elements[index].radius	= _elements[index].delta / 2;
			_elements[index].stop	= _elements[index].start + _elements[index].delta;
			_elements[index].middle	= _elements[index].start + _elements[index].radius
		}
		
		window.setTimeout(function() { that.moveMore(); }, 10);
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.moveMore = function()
	{
		if(_stepCurrent > _stepTotal + 1)
			return;
		
		var index, el, pos, radCurrent;
		for(index = 0; index < _elements.length; index++)
		{
			radCurrent = _radStart + (_radDelta * _stepCurrent / _stepTotal);

			// Move Top Element		
			pos = ( _elements[index].middle - (Math.cos(radCurrent) * _elements[index].radius) ) / _multiplier + "px";
			
			switch(_property)
			{
				case "top":		_elements[index].elElement.style.top = pos; break;
				case "left":	_elements[index].elElement.style.left = pos; break;
				case "height":	_elements[index].elElement.style.height = pos; break;
				case "width":	_elements[index].elElement.style.width = pos; break;
			}
		}

		_stepCurrent++;
		window.setTimeout(function() { that.moveMore(); }, _speed);
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		if(idElement !== undefined)
			this.addElement(idElement);
}


function stlFaderVerticalSwitch(idElementTop, idElementBottom)
{
	var that = this;
	
	var elTopElement;
	var elTopHeight;
	var elTopX;
	var elTopStopY;
	var elTopDeltaY;
	var elTopMiddleY;
	var elTopRadiusY;

	var elBotElement;	
	var elBotHeight;
	var elBotX;
	var elBotY;

	var elBotStartY;
	var elBotStopY;
	var elBotDeltaY;

	var multiplier;
	
	var currentStep;
	var steps;

	var radStart;
	var radEnd;
	var radDelta;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// 
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.move = function()
	{
		var elTopStartY;
		var elTopDeltaY;
		
		elTopStartY		= stlApp.library.getElementTop(elTopElement) * multiplier;
		elBotStartY		= stlApp.library.getElementTop(elBotElement) * multiplier;
		elTopHeight		= elTopElement.offsetHeight * multiplier;
		elBotHeight		= elTopElement.offsetHeight * multiplier;
		
		elTopStopY		= elBotStartY - (elTopHeight - elBotHeight);
		elTopDeltaY		= elTopStopY - elTopStartY;
		elTopRadiusY	= elTopDeltaY / 2;
		elTopMiddleY	= elTopStartY + elTopDeltaY / 2;

		elBotStopY		= elTopStartY;
		elBotDeltaY		= elBotStopY - elBotStartY;
		elBotRadiusY	= elBotDeltaY / 2;
		elBotMiddleY	= elBotStartY + elBotDeltaY / 2;


		currentStep = 0;

		radStart	= 0;
		radEnd		= Math.PI;
		radDelta	= radEnd - radStart;

		window.setTimeout(function () { that.makeAMove(); }, 1);
	}
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function: makeAMove
	//
	//
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.makeAMove = function()
	{
		if(currentStep > steps + 1)
		{
			elTopElement.style.top = (elTopStopY / multiplier) + "px";
			elBotElement.style.top = (elBotStopY / multiplier)  + "px";
			
			if(this.oncomplete !== null)
				this.oncomplete();
			return;
		}

		var elTopY;
		var radCurrent = radStart + (radDelta * currentStep / steps);

		// Move Top Element		
		elTopY = elTopMiddleY - (Math.cos(radCurrent) * elTopRadiusY);
		elTopElement.style.top = (elTopY / multiplier) + "px";
		
		// Move Bottom Element
		elBotY = elBotMiddleY - (Math.cos(radCurrent) * elBotRadiusY);
		elBotElement.style.top = (elBotY / multiplier) + "px";
				
		currentStep++;
		window.setTimeout(function () { that.makeAMove(); }, speed);
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:	Constructor
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		elTopElement = document.getElementById(idElementTop);
		if(elTopElement == null)
			return stlApp.messages.add("Appliation error: Could not find element " + idElementTop + ".");
		
		elBotElement = document.getElementById(idElementBottom);
		if(elBotElement == null)
			return stlApp.messages.add("Appliation error: Could not find element " + idElementBottom + ".");

		multiplier  = 100;	// Used for increased accuracy. All internal coordinates are multiplied.
 		steps		= 50;	// The fade takes 100 iterations
		speed		= 20;	// The time interval between each iteration

 		this.oncomplete = null;
 }
 



function stlElementFader(idElement)
{
	var that = this;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Inheritance: stlDhtmlxCommon
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.inheritFrom_stlDhtmlxCommon = stlDhtmlxCommon;
	this.inheritFrom_stlDhtmlxCommon();	

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:	Constructor
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		this.idContainer = idElement;
		this.elContainer = document.getElementById(idElement);
		if(this.elContainer == null)
			return this.generateSystemError("ERROR\nElement not found.\n\nCould not find element " + this.idContainer + " to create form in.");

}
	
function stlElementFader_PushUp(idElement)
{
	var that = this;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Inheritance: stlDhtmlxCommon
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.inheritFrom_stlElementFader = stlElementFader;
	this.inheritFrom_stlElementFader(idElement);	
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:		fade()
	//
	// Description:		Fades, and ultimately removes the object.
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.fade = function()
	{
		this.heightCurrent = parseInt(this.elContainer.offsetHeight, 10) * 5000;
		window.setTimeout(function() { that.fadeMore() }, 1);
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:		fadeMore()
	//
	// Description:		Continues the fading process.
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.fadeMore = function()
	{
		heightNew = (this.heightCurrent * this.fraction);

		if(heightNew == this.heightCurrent)
			heightNew = heightNew - 1;
		if(heightNew < 0)
			heightNew = 0;

		this.heightCurrent = heightNew;

		heightNew = (heightNew / 5000).toFixed(0);

		if(heightNew == 0)
			if(this.ondone !== null)
			{
				this.ondone();
				return;
			}

		this.elContainer.style.height = heightNew + "px";
		setTimeout(function() { that.fadeMore() }, this.speed);		
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:	Constructor
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		this.fraction	= 0.93;
		this.speed		= 25;

		this.ondone		= null;
}

function stlElementFader_PushDown(idElement)
{
	var that = this;

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Inheritance: stlDhtmlxCommon
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.inheritFrom_stlElementFader = stlElementFader;
	this.inheritFrom_stlElementFader(idElement);	
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:		fade()
	//
	// Description:		Fades, and ultimately removes the object.
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.fade = function()
	{
		this.heightCurrent = (parseInt(this.elContainer.scrollHeight, 10) - parseInt(this.elContainer.offsetHeight, 10)) * 5000;
		window.setTimeout(function() { that.fadeMore() }, 1);
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:		fadeMore()
	//
	// Description:		Continues the fading process.
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	this.fadeMore = function()
	{
		heightNew = (this.heightCurrent * this.fraction);

		if(heightNew == this.heightCurrent)
			heightNew = heightNew - 1;
		if(heightNew < 0)
			heightNew = 0;

		this.heightCurrent = heightNew;

		heightNew = (heightNew / 5000).toFixed(0);

		if(heightNew == 0)
			if(this.ondone !== null)
			{
				this.ondone();
				return;
			}

		this.elContainer.style.height = (this.elContainer.scrollHeight - heightNew) + "px";
		setTimeout(function() { that.fadeMore() }, this.speed);		
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Function:	Constructor
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		this.fraction	= 0.93;
		this.speed		= 25;

		this.ondone		= null;
}
