$(document).ready(function(){
	
	/* FUNCIONES DEL MENU */
	var menuIndex;
	var navIndex;
	var reelIndex = 0;
	var bannerClinicaIndex = 0;
	var eventosGalIndex = 0;
				
	$('.menuDesplegable:eq(0)').css('left' , '5px');
	$('.menuDesplegable:eq(1)').css('left' , '158px');
	$('.menuDesplegable:eq(2)').css('left' , '296px');
	$('.menuDesplegable:eq(3)').css('left' , '390px');
	$('.menuDesplegable:eq(4)').css('left' , '485px');
	$('.menuDesplegable:eq(5)').css('left' , '652px');
	$('.menuDesplegable:eq(6)').css('left' , '770px');
	
	$('.menu').stop().animate({"opacity" : 1}, 200);
	
	$('.menu').hover(function(){
		$(this).css({"color" : "#DDDDDD"});
		menuIndex = $('.menu').index(this);
		$('.menuDesplegable:eq('+ menuIndex +')').show();
		$('.menuDesplegable:lt('+ menuIndex +')').hide();
		$('.menuDesplegable:gt('+ menuIndex +')').hide();
		$('.menu:lt('+ menuIndex +')').css({"color" : "#FFFFFF"});
		$('.menu:gt('+ menuIndex +')').css({"color" : "#FFFFFF"});
	}, function(){
		if ((menuIndex == 3)||(menuIndex == 5)||(menuIndex == 6)){
			$(this).css({"color" : "#FFFFFF"});
		}
	});
	
	$('.menuDesplegable').hover(function(){
		menuIndex = $('.menuDesplegable').index(this);	
	}, function(){
		$(this).hide();
		$('.menu:eq('+ menuIndex +')').stop().animate({"opacity" : 1}, 200);
	});
	
	$('body').click(function(){
		$('.menuDesplegable:eq(' + menuIndex + ')').stop().hide();	
		$('.menu:eq(' + menuIndex + ')').stop().animate({"opacity" : 1}, 200);			
	});
	
	/*FIN DE LAS FUNCIONES DEL MENU */
	/* FUNCIONES DEL REEL */
		
	$('#reel .nav').stop().animate({"opacity" : 0.7}, 0);
	$('#reel .fondoitem').animate({"opacity" : 0}, 0);
	
	$('#reel .nav').hover(function(){
		$(this).stop().animate({"opacity" : 1}, 100);
	}, function(){
		$(this).stop().animate({"opacity" : 0.7}, 100);
	});
		
	$('#reel .nav').click(function(){
		if (($('#reel .nav').index(this) == 1) && reelIndex < ($('#reel .reelitem').length - 5)){
			reelIndex++;
			$('#reel #contenedor').animate({"left" : (170 * -reelIndex)}, 400);
		}
		if (($('#reel .nav').index(this) == 0) && reelIndex > 0){
			reelIndex--;
			$('#reel #contenedor').animate({"left" : (170 * -reelIndex)}, 400);
		}
	});
		
	$('#reel .reelitem').hover(function(){
		$(this).find('.fondoitem').stop().animate({"opacity" : 1}, 300);
	}, function(){
		$(this).find('.fondoitem').stop().animate({"opacity" : 0}, 300);
	});
	
	/*FIN DE LAS FUNCIONES DEL REEL */
	/* FUNCIONES DEL BANNERCLINICAS */
	
	$('#bannerClinicas #bcContenido ul li').animate({"opacity" : 0}, 0);
	$('#bannerClinicas #bcContenido ul li:eq(0)').animate({"opacity" : 1}, 0);
	$('#bannerClinicas #bcMenus #bcFondoMenu').stop().animate({ "top": (0) }, 300);
	
	$('#bannerClinicas #bcMenus #bcMenuContenedor ul li').hover(function(){
		var index = $('#bannerClinicas #bcMenus #bcMenuContenedor ul li').index(this);
		$('#bannerClinicas #bcMenus #bcFondoMenu').stop().animate({"top" : (23*index)}, 300);
		$('#bannerClinicas #bcContenido ul li:eq('+index+')').stop().animate({"opacity" : 1}, 300);
		$('#bannerClinicas #bcContenido ul li:lt('+index+')').stop().animate({"opacity" : 0}, 100);
		$('#bannerClinicas #bcContenido ul li:gt('+index+')').stop().animate({"opacity" : 0}, 100);
	}, function(){
		
	});
	
	/*FIN DE LAS FUNCIONES DEL BANNERCLINICAS */
	/* FUNCIONES DE EVENTOS */
	$('#eventosGal .imagenGal').animate({"opacity" : 0}, 0);
	$('#eventosGal .imagenGal:eq(0)').animate({"opacity" : 1}, 300);
	
	$('#eventosGal .imagenMin').hover(function(){
		$(this).stop().animate({"opacity" : 0.7}, 100);
	}, function(){
		$(this).stop().animate({"opacity" : 1}, 300);
	});
	
	$('#eventosGal .imagenMin').click(function(){
		eventosGalIndex = $('#eventosGal .imagenMin').index(this);
		$('#eventosGal .imagenGal').stop().animate({"opacity" : 0}, 100);
		$('#eventosGal .imagenGal:eq(' + eventosGalIndex + ')').stop().animate({"opacity" : 1}, 300);
	});
	
	/*FIN DE LAS FUNCIONES DE EVENTOS */
	/* FUNCIONES DE MATERNIDAD INSTALACIONES*/
	$('#maternidadGaleria .imagenMin').hover(function(){
		$(this).animate({"opacity" : 0.8}, 100);
	}, function(){
		$(this).animate({"opacity" : 1}, 300);
	});
	
	$('#maternidadGaleria .imagenGrande').click(function(){
		$(this).fadeOut();
	});
	
	$('#maternidadGaleria .imagenMin').click(function(){
		var index = $('#maternidadGaleria .imagenMin').index(this) + 1;
		$('#maternidadGaleria .imagenGrande').fadeIn();
		$('#maternidadGaleria .imagenGrande').css('top', pageYOffset + ((window.outerHeight/2) - 300) );
		$('#maternidadGaleria .imagenGrande').css('left', pageXOffset + ((window.outerWidth/2) - 300) );
		$('#maternidadGaleria .imagenGrande').attr('src' , 'img/img-habitacion-gde-' + index + '.jpg');
	});
	/*FIN DE LAS FUNCIONES DE MATERNIDAD */
});
