YPTripsBox = 
{
	el : null,
	positionLeft : null,

	init : function()
	{
		YPTripsBox.el = $('TripsBox');
		YPTripsBox.positionLeft = YPTripsBox.el.cumulativeOffset().left;
	
		Event.observe(YPTripsBox.el, 'focus', YPTripsBox.handleFocus);
		Event.observe(YPTripsBox.el, 'click', YPTripsBox.handleClick);
		Event.observe(YPTripsBox.el, 'mousemove', YPTripsBox.handleOver);	
	},
	
	handleFocus : function(e)
	{
		YPTripsBox.el.value = '';		
		Event.stopObserving(YPTripsBox.el, 'focus');		
	},
	
	handleClick : function(e)
	{
		if (e.pointerX() - YPTripsBox.positionLeft > 120)
		{
			YPTripsBox.el.up('form').submit();
		}
	},
	
	handleOver : function(e)
	{	
		if (e.pointerX() - YPTripsBox.positionLeft > 120)
		{
			YPTripsBox.el.setStyle({
				'cursor': 'pointer'
			});
		}
		else
		{
			YPTripsBox.el.setStyle({
				'cursor': 'text'
			});
		}
	}
}

Event.observe(window, 'load', YPTripsBox.init);
