//<![CDATA[

/** The main menu visual effect
 *
 * Copyright (C) 2010-2011 Nikolay Nemshilov
 */
function move_zing()
{
	var zing = $('zing');
	var main = $('main-menu');
	var current = $$("#main-menu .current")[0];

	if(current)
	{
		if(zing.getStyle('width').toInt() == 0)
		{
			current.setStyle('border-color: transparent');
			zing.setStyle({
				width : current.size().x + 'px',
				left : (current.position().x - main.position().x) + 'px'
			});
		}

		if(move_zing._timer)
		{
			move_zing._timer.cancel();
			move_zing._timer = null;
		}

		zing.stop().morph(
		{
			width : this.size().x + 'px',
			left : (this.position().x - main.position().x) + 'px'
		}, 
		{
			transition : 'Log',
			engine : 'javascript'
		});
	}
}

function roll_back()
{
	var current = $$("#main-menu .current")[0];
	if(current && !move_zing._timer)
	{
		move_zing._timer = move_zing.bind(current).delay(800);
	}
}

"#main-menu a".on({mouseover: move_zing, mouseout: roll_back});
$(window).on({load : move_zing, blur: roll_back, resize: roll_back});

$(document).onReady(function() 
{
	$$('.me-lb').each(function(e, i)
	{
		e.set('rel', 'lightbox[roadtrip]');
	});
});
//]]>

