$(document).ready(function(){ 	
/* alterna les capes del submenú del curriculum */

	
	var paginaActual = $("div#biografia");

	$("a#link_biografia").click(function(event) { 
		event.preventDefault();
		if (paginaActual.attr("id") != $("div#biografia").attr("id")){
			paginaActual.fadeOut(function() {
				$("div#biografia").fadeIn();	
			});
			paginaActual = $("div#biografia");
		}
	});
	$("a#link_especialidades").click(function(event) {
		event.preventDefault();
		if (paginaActual.attr("id") != $("div#especialidades").attr("id")){
			paginaActual.fadeOut(function() {
				$("div#especialidades").fadeIn();	
			});
			paginaActual = $("div#especialidades");
		}
	});
	$("a#link_bibliografia").click(function(event) {
		event.preventDefault();
		if (paginaActual.attr("id") != $("div#bibliografia").attr("id")){
			paginaActual.fadeOut(function() {
				$("div#bibliografia").fadeIn();	
			});
			paginaActual = $("div#bibliografia");
		}
	});



/* alterna les imatges abans/despres fent una dissolució (sense funció callback) */


	$("a#a_enlace_despres").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#a_enlace_abans").css("background-color","#202020");
		$("div#a_abans").fadeOut();
		$("div#a_despres").fadeIn();
	});
	$("a#a_enlace_abans").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#a_enlace_despres").css("background-color","#202020");
		$("div#a_abans").fadeIn();
		$("div#a_despres").fadeOut();
	});

	$("a#b_enlace_despres").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#b_enlace_abans").css("background-color","#202020");
		$("div#b_abans").fadeOut();
		$("div#b_despres").fadeIn();
	});
	$("a#b_enlace_abans").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#b_enlace_despres").css("background-color","#202020");
		$("div#b_abans").fadeIn();
		$("div#b_despres").fadeOut();
	});

	$("a#c_enlace_despres").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#c_enlace_abans").css("background-color","#202020");
		$("div#c_abans").fadeOut();
		$("div#c_despres").fadeIn();
	});
	$("a#c_enlace_abans").click(function(event) {
		event.preventDefault();
		$(this).css("background-color","#f66");
		$("a#c_enlace_despres").css("background-color","#202020");
		$("div#c_abans").fadeIn();
		$("div#c_despres").fadeOut();
	});
	

/* Valida formulari amb jquery */

    $('#form_miquel').validate({
        rules: {
            nom: {required: true},
            correo_e: {required: true, email: true},
            comentari: {required: true}
        },
        messages: {
            nom: {required: "Introduce un nombre"},
            correo_e: {required: "Introduce un correo", email: "Introduce una dirección de correo válida"},
            comentari: {required: "Introduce un mensaje"}
        }
    });

/* fa scroll segons l'enllaç clicac */

/*
	var primerBloc = $('#noticies').offset().top - 150;	
	var segonBloc = $('#curriculum').offset().top - 150;
	var tercerBloc = $('#cursos').offset().top - 150;
	var quartBloc = $('#feines').offset().top - 150;
	var cinqueBloc = $('#articles').offset().top - 150;
	var siseBloc = $('#contacte').offset().top - 150;
*/

	$('.aNoticies').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:0}, 'slow', 'swing');
		return false;
	});		
	$('.aCurriculum').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:$('#curriculum').offset().top - 150}, 'slow', 'swing');
		return false;
	});		
	$('.aCursos').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:$('#cursos').offset().top - 150}, 'slow', 'swing');
		return false;
	});		
	$('.aFeines').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:$('#feines').offset().top - 150}, 'slow', 'swing');
		return false;
	});		
	$('.aArticles').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:$('#articles').offset().top - 150}, 'slow', 'swing');
		return false;
	});		
	$('.aContacte').click(function(evento){ 
		evento.preventDefault(); 
		$('html, body').animate({scrollTop:$('#contacte').offset().top - 150}, 'slow', 'swing');
		return false;
	});		
	
	
	$("#article1").click(function(evento){ 
		evento.preventDefault(); 
		$("#cargando").css("display", "inline");
		$("#article").load("arxius/article1.php", function(){	/* Cargar artículos mediante ajax */
			$("#cargando").css("display", "none");
			$('#article').fadeIn();
			$("#final_article").css("display", "block");
		});
	});
	
	$("#article2").click(function(evento){ 
		evento.preventDefault(); 
		$("#cargando").css("display", "inline");
		$("#article").load("arxius/article2.php", function(){	/* Cargar artículos mediante ajax */
			$("#cargando").css("display", "none");
			$('#article').fadeIn();
			$("#final_article").css("display", "block");
		});
	});

	$("#article3").click(function(evento){ 
		evento.preventDefault(); 
		$("#cargando").css("display", "inline");
		$("#article").load("arxius/article3.php", function(){	/* Cargar artículos mediante ajax */
			$("#cargando").css("display", "none");
			$('#article').fadeIn();
			$("#final_article").css("display", "block");
		});
	});
	
	$(".cerrar_articulo").click(function(evento){ 
		evento.preventDefault(); 
		$("#final_article").css("display", "none");
		$('#article').fadeOut();
		$('html, body').animate({scrollTop:$('#articles').offset().top - 150}, 'slow', 'swing');
	});

/* adaptar l'alçada de la columna "protesis dental removible" a l'alçada de la pantalla */

	$('#imatge_columna_fixed').height($(window).height());
	$('#imatge_columna_fixed').css("display","block");
	$(window).bind("resize", function() {
		$('#imatge_columna_fixed').height($(window).height());
	});
	
	
	
/* Fin	 */
	
	
	
	
	
});



