// INICIO

function inicio(){
	var isVentajas = false;
	$('#ventajas_ext h2')
		.attr('title', 'mostrar')
		.css({'background-position':'0 0', 'cursor':'pointer'})
		.toggle(
			function(){
				$(this).css('background-position','0 -50px');
				$(this).attr('title', 'ocultar');
			},
			function(){
				$(this).css('background-position','0 0');
				$(this).attr('title', 'mostrar');
			}
		)
		.click(function(){
			$('#ventajas').slideToggle(300);
		});
	$('#ventajas').hide();
}

function carrusel(){
	/*over sobre img carrusel*/
	$('#carrusel div').each(function(i){
		$(this).hover(
			function(){
				$('#nav li:eq('+(i+1)+') a').removeClass('curr').addClass('hover');
			},
			function(){
				$('#nav li:eq('+(i+1)+') a').removeClass('hover').addClass('curr');
			}
		)
	});
	/*over sobre href navegacion*/
	$('#nav li a').each(function(i){
		if(i > 0){
			$(this).hover(
				function(){
					$('#nav li a').removeClass('curr')
					$(this).addClass('hover');
					$('#carrusel').cycle('pause');
					$('#carrusel').cycle((i-1), false);
				},
				function(){
					$(this).removeClass('hover');
					$('#carrusel').cycle('resume');
				}
			);
		}
	});
	$('#carrusel').cycle({
		speed: 500,
		timeout: 3000,
		pause: true,
		after: function(curr, next, opts){
			if(!$('#nav li:eq('+((opts.currSlide+1))+') a').hasClass('hover')){
				$('#nav li a').removeClass('curr');
				$('#nav li:eq('+((opts.currSlide+1))+') a').addClass('curr');
			}
		}
	});
}

$(document).ready(function(){
	inicio();
	carrusel();
});