/**
 * @author Diego
 */


$(document).ready(function()
{
	$('body').removeClass('nojQuery');
	$elementosMenu = $('#mainMenu li');
	$elementosMenu.bind('mouseenter',encimaElemento);
	$elementosMenu.bind('mouseleave',fueraElemento);
	
	$botones = $('a.link');
	$botones.live('mouseenter', encimaBoton);
	$botones.live('mouseleave', fueraBoton);
	
	$botonesForm = $('input.link');
 	$botonesForm.live('mouseenter', encimaBoton);
  	$botonesForm.live('mouseleave', fueraBoton);
	
});

function encimaElemento(e)
{
	e.preventDefault();
	if (!$('a:first', this).hasClass('actual')) 
	{
		$('a:first', this).css({
			'backgroundColor': '#2B2D33'
		});
		$('a:first span', this).delay(100).queue(function(){
			$(this).css({
				'backgroundPosition': '0 -9px'
			});
			$(this).dequeue();
		});
		$('a:first', this).stop().animate({
			'background-color': '#E34119',
			'color': '#fff',
			'borderBottomColor': '#CC2800'
		}, 200);
	}
	if ($('a:first', this).hasClass('dropdown'))
	{
		$('a:first', this).next().slideDown(150);
	}
	return false;
}

function fueraElemento(e)
{
	e.preventDefault();
	if (!$('a:first', this).hasClass('actual'))
	{
		$('a:first', this).stop().animate({
			'background-color': '#2B2D33',
			'color': '#818699',
			'borderBottomColor': '#6F7584'
		}, 200, function(){
			if ($(this).parent().parent().hasClass('submenu')) {
				$(this).css({
					'background': 'none'
				});
			}
		});
		$('a:first span', this).delay(50).queue(function(){
			$(this).css({
				'backgroundPosition': '0 0'
			});
			$(this).dequeue();
		});
	}
	if ($('a:first', this).hasClass('dropdown'))
	{
		$('a:first', this).next().slideUp(150);
	}
	return false;
}

function encimaBoton(e)
{
	$(this).stop().animate({
		'padding-right': '50',
		'background-color' : '#E9451D'
	}, 200);
}

function fueraBoton(e)
{
	$(this).stop().animate({
		'padding-right': '40',
		'background-color' : '#D92C00'
	}, 200);
}

