
var DockBar = Class.create (
{
	initialize: function()
	{
		this.dockBar = $('dockBar');
		this.dockBarHotSpot = $('dockBarHotSpot');
		
		if (!this.dockBar) return;
		
		Event.observe(document, 'mousemove', this.onMouseMove.bindAsEventListener(this));
		this.mouseX = 0;
		this.mouseY = 0;		
		this.mouseOver = false;		
		this.status = 'shown';	
	},
	
	onMouseMove: function(event)
	{
		this.mouseX = event.pointerX();
		this.mouseY = event.pointerY();
		this.isMouseOver();
	},
	isMouseOver: function()
	{
		var co = this.dockBarHotSpot.cumulativeOffset();	
		var dim = this.dockBarHotSpot.getDimensions();
		if (co.left <= this.mouseX && (co.left + dim.width) >= this.mouseX
			&& co.top <= this.mouseY && (co.top + dim.height) >= this.mouseY)
		{
			
			if (!this.mouseOver)
			{
				//dispatch event
				this.onMouseOver();
			}
			this.mouseOver = true;
			return true;
		}
		else
		{
			
			if (this.mouseOver)
			{
				//dispatch event
				this.onMouseOut();
			}
			this.mouseOver = false;
			return false;
		}
	},
	
	onMouseOver:function()
	{
		this.show.bind(this).delay(0.2);
	},
	
	onMouseOut:function()
	{
		this.hide.bind(this).delay(0.9);
	},
	hide:function()
	{
		if (this.status == 'hidden' || this.status == 'moving' || this.mouseOver) return;
		this.status = 'moving';
		Effect.BlindUp(this.dockBar,{ duration: 0.6, afterFinish: function() {
				  //basketAnimation = false;
				  this.status = 'hidden';		
				  }.bind(this)});
	},
	show:function()
	{
		if (this.status == 'shown' || this.status == 'moving'|| !this.mouseOver) return;
		this.status = 'moving';
		Effect.BlindDown(this.dockBar,{ duration: 0.7, afterFinish: function() {
				   this.status = 'shown';				
				  }.bind(this)});
	}
});

var dockBar;


Event.observe(window, 'load', function() 
	{
	
		dockBar = new DockBar();
	}
);
