/******************************************************************* 
* File    : JSFX_LeftSlidingDiv.js  © JavaScript-FX.com
* Created : 2002/03/14 
* Author  : Roy Whittle  (Roy@Whittle.com) www.Roy.Whittle.com 
* Purpose : To create a cross browser sliding layer.
* History 
* Date         Version        Description 
* 2001-09-08	1.0		Extended from JSFX.Layer
***********************************************************************/ 
if(window.opera)
{
	/*** moveTo (x,y) ***/
	JSFX.Layer.prototype.moveTo = function(x,y)
	{
		this.style.left = x;
		this.style.top = y;
	}
}
/**********************************************************************************/
//Class JSFX.LeftSlidingDiv extends Layer
JSFX.LeftSlidingDiv = function(newLayer, x, y, isStatic) 
{
	if(!newLayer)
		return;
	this.superC = JSFX.Layer;
	this.superC(newLayer);

	this.startX = x;
	this.startY = y;
	this.endX   = 0;
	this.x = x;
	this.y = isStatic ? y : -200;
	this.inStep  = 40;
	this.outStep = 10;
	this.state = "OFF";
	this.isStatic = isStatic;
	this.moveTo(this.x,this.y);
	this.addEventHandler("onmouseover", this.slideIn);
	this.addEventHandler("onmouseout",  this.slideOut);
	this.setTimeout("animate()", 30);
} 

JSFX.LeftSlidingDiv.prototype = new JSFX.Layer;

JSFX.LeftSlidingDiv.prototype.slideInImg	= function(theEvent)
{
	theLayer = this.nav;
	theLayer.slideIn(theLayer, theEvent);
}
JSFX.LeftSlidingDiv.prototype.slideIn	= function(theLayer, theEvent)
{
	if(theLayer.state == "OFF")
	{
		theLayer.state = "SLIDING_IN";
	}
	else if(theLayer.state == "SLIDING_IN")
	{
	}
	else if(theLayer.state == "SLIDING_IN_OUT")
	{
		theLayer.state = "SLIDING_IN";
	}
	else if(theLayer.state == "SLIDING_OUT")
	{
		theLayer.state = "SLIDING_IN";
	}
	else if(theLayer.state == "ON")
	{
	}

	return false;
}
JSFX.LeftSlidingDiv.prototype.slideOutImg	= function(theEvent)
{
	theLayer = this.nav;
	theLayer.slideOut(theLayer, theEvent);
}
JSFX.LeftSlidingDiv.prototype.slideOut	= function(theLayer, theEvent)
{
	if(theLayer.state == "ON")
	{
		theLayer.state = "SLIDING_OUT";
	}
	else if(theLayer.state == "SLIDING_OUT")
	{
	}
	else if(theLayer.state == "SLIDING_IN_OUT")
	{
	}
	else if(theLayer.state == "OFF")
	{
	}
	else if(theLayer.state == "SLIDING_IN")
	{
		theLayer.state="SLIDING_IN_OUT";
	}

	return false;
}
JSFX.LeftSlidingDiv.prototype.getTop	= function()
{
	if(this.isStatic)
		return 0;
	else if(typeof pageYOffset != "undefined")	
		return pageYOffset;
	else if(document.body && typeof document.body.scrollTop != "undefined")
		return document.body.scrollTop;
	else
		return 0;
}
JSFX.LeftSlidingDiv.prototype.animate	= function()
{
	var sliding = false;
	var ty;

	if(this.state == "SLIDING_IN")
	{
		this.x += this.inStep;
		if(this.x >= this.endX)
		{
			this.x = this.endX;
			this.state = "ON";
		}
		else
		{
			sliding = true;
		}
	}
	else if(this.state == "SLIDING_OUT")
	{
		this.x -= ((this.x - this.startX)/8) + 1;
		if(this.x <= this.startX)
		{
			this.x = this.startX;
			this.state = "OFF";
		}
		else
			sliding = true;
	}
	else if(this.state == "SLIDING_IN_OUT")
	{
		this.x += this.inStep;
		if(this.x >= this.endX)
		{
			this.x = this.endX;
			this.state = "SLIDING_OUT";
		}
		sliding = true;
	}
	var pY = this.getTop();
	this.moveTo(this.x, this.y += (pY + this.startY - this.y)/8 );
	this.setTimeout("animate()", 30);
}
