/**
*	Layer Controller Javascript Class
*
*	Class to encapsolate and control the movement and display of a layer,
*	uses the Layer Class and the PositionerClass to create a single entry
*	point object that can show/hide, and toggle a layer display between
*	two display points.
*	Params:
*	startPosition	object	Object that contains parameters defining the start position to use for this controller.
*	endPosition		object	Object that contains parameters defining the end position to use for this controller.
*	moveToStart		boolean	Flag indicating that once created, this object should move the layer to its start point.
*	startPosition and endPosition contain the following parameters:
*	 (see positioner class for explaination)
*			alignFrom:	Align from position
*			alignTo:	Align to definition
*			offset:		Offset definition
*/

function LayerController(layer,startPosition,endPosition,moveToStart){
	this.layer=layer;
	this.startPos=new Positioner(this.container, layer, startPosition.alignFrom, startPosition.alignTo, startPosition.offset);
	this.endPos=new Positioner(this.container, layer, endPosition.alignFrom, endPosition.alignTo, endPosition.offset);
	
	//	-1=not positioned, 0=start, 1=end
	this.curPos=-1;
	
	this.gotoStart=LayerController_gotoStart;
	this.gotoEnd=LayerController_gotoEnd;
	this.toggle=LayerController_toggle;
	this.show=LayerController_show;
	this.hide=LayerController_hide;
	
	if(moveToStart)this.start();
}	//	LayerController

function LayerController_gotoStart(){
	this.startPos.position();
	this.curPos=0;
}	//	start

function LayerController_gotoEnd(){
	this.endPos.position();
	this.curPos=1;
}	//	end

/**
*	toggle
*	Toggles this layers position between start and end points.
*/
function LayerController_toggle(){
	if(this.curPos==0)this.gotoEnd();
	else this.gotoStart();
}	//	toggle

function LayerController_show(){this.layer.show();}
function LayerController_hide(){this.layer.hide();}

