// JavaScript Document
SlideMenu = function(element,travelDistance)
{
	this._menu = element;
	//Assume Menu Starts Open
	//Get the initial position of the menu
	this._menu.style.left = "0px";
	 this.openingX_num = parseInt(this._menu.style.left);
	 this.closingX_num = this.openingX_num - travelDistance;
	 this.closing = false;
	 this.opening = false;
	 this.stepSize = 4;
	 this.alerted = 0;
}
SlideMenu.prototype._directions = {"closing":-1, "opening":1};
SlideMenu.prototype.close = function()
{
	if(this.closing) return;
	this.opening = false;
	this.closing = true;
	var direction = "closing";
	this.closingIntervalID = 
		setInterval(Utils.createDelegate(this,this._animate,direction),10);
}
SlideMenu.prototype.open = function()
{
	if(this.opening) return;
	//alert('trying to open');
	this.opening = true;
	this.closing = false;
	var direction = "opening";
	this.openingIntervalID = 
		setInterval(Utils.createDelegate(this,this._animate,direction),10);
}

SlideMenu.prototype._animate = function(direction_str)
{
	//alert(this._menu.style.left);
	var posX_num = parseInt(this._menu.style.left);

	if(posX_num == this[direction_str + "X_num"] || !this[direction_str]) 
	{
		clearInterval(this[direction_str + "IntervalID"]);
		this[direction_str] = false;

		return;
	}
	var direction_num = this._directions[direction_str];
	var menuPos_str = "";
	posX_num += this.stepSize*direction_num;
	var posX_str = posX_num + "px";
	this._menu.style.left = posX_str;
	var leftClip_str = -posX_num + "px";
	this._menu.style.clip = "rect(0 auto auto " + leftClip_str +")";
}
