$(document).ready(function(){

	initPortada();

	//Control de bloques	
	$("H1.desplegado").click(function(){
		$(this).toggleClass("desplegado");
		$(this).toggleClass("plegado");
		
		var bloque = $(this).next();
		toogleBloque(bloque);
	});
	
	$("H1.plegado").click(function(){
		$(this).toggleClass("plegado");
		$(this).toggleClass("desplegado");			
		
		var bloque = $(this).next();
		toogleBloque(bloque);
	});
	
	//Proyectos
	$('ul.slideList li').hover(function(){
		//$(this).find('img').animate({left:'405px'},{queue:false,duration:500});
		$(this).find('img').fadeOut('slow');
		},		
		function(){
			//$(this).find('img').animate({left:'0px'},{queue:false,duration:500});
			//$(this).find('img').show('fast');
			$(this).find('img').fadeIn('slow');
			
		});
 });	



function toogleBloque(bloque){	
	if($(bloque).is(':visible')){
		$(bloque.slideUp('slow'))
	}
	else{
		$(bloque.show())
	}
}

function toogleBloqueInicial(bloque){	
	if($(bloque).is(':visible')){
		$(bloque.hide())
	}
	else{
		$(bloque.show())
	}
}

function initPortada(){
	$("H1.plegado").each(function(){
		var bloque = $(this).next();
		 toogleBloqueInicial(bloque);
	});
}
