$(document).ready(function(){

// Efecto mostrar contenido
	$('#mostrarInfo').animate({left:'420px'},300);
	
	$('#menuPrincipal a').click(function(){
		a=parseInt($('#menuPrincipal a').index(this))+1;
		if($('#contWrapper').children('div').index($('#contWrapper').children('div:visible'))!=a){
			$('#contWrapper').children('div:visible').animate({left:'780px'},500,function(){
				$(this).hide();
				$('#contWrapper').children('div').eq(a).show().animate({left:'420px'},500);
			});
		}
		return false;
	});


// Efecto fade de imagen de fondo
		$('ul#imagenFondo').innerfade({
			speed: 1000,
			timeout: 5000,
			type: 'sequence',
			containerheight: '500px'
		});
		
		$('.fade').innerfade({
			speed: 1000,
			timeout: 6000,
			type: 'random_start',
			containerheight: '1.5em'
		});

//Efecto acordeon
	$("#mostrarInfo3 dd:not(:first)").hide();
		$("dt a").click(function(){
			$("#mostrarInfo3 dd:visible").slideUp("fast");
			$(this).parent().next().slideDown("fast");
			return false;
		});

//Efecto plegar/desplegar imagen en acordeon
			//Aqui asignamos el click al elemento a
			$("dl#cabeceraApartado a.openClose").click(function(){
			w=$(this);
			var t = $("dl#cabeceraApartado dt a");
			if(w.hasClass('cerrado')) {
				//cierro
				$("dd#contenidoInfo:hidden").slideDown("fast");
				//quito clase cerrado
				$("dl#cabeceraApartado dt a").addClass("cerrado");
				w.removeClass("cerrado");
			}else{
				//abro
				$("dd#contenidoInfo:visible").slideUp("fast");
				//pongo clase cerrado
				$("dl#cabeceraApartado dt a").removeClass("cerrado");
				w.addClass("cerrado");
			}
			});

// Scroll de imagenes 
$("#buttondown").hover(function(){ 
			c=$(".scrolling").parents("div").height();
			m=0-($(".scrolling").height())+c-50;
			a=($(".scrolling").height()/c)*3000;			
			if(c<$(".scrolling").height())$(".scrolling").animate({top: m+'px'},a);
		},function(){$(".scrolling").stop();});

		$("#buttonup").hover(function(){ 
			c=$(".scrolling").parents("div").height();
			a=($(".scrolling").height()/c)*3000;			
			if(c<$(".scrolling").height())$(".scrolling").animate({top: '0px'},a);
		},function(){$(".scrolling").stop();});

		$(".scrollbutton>img").hover(function(){$(this).attr("src", "img/point.gif");},function(){$(this).attr("src", "img/point_grey.gif");});
		

		$("#buttondown").click(function(){ 
			c=$(".scrolling").parents("div").height();
			m=0-($(".scrolling").height())+c-50;
			if(c<$(".scrolling").height())$(".scrolling").stop().animate({top: m+'px'}, 300);
		});		

		$("#buttonup").click(function(){if(c<$(".scrolling").height()){$(".scrolling").stop().animate({top: '0px'}, 300);}});

// Lightbox
	$(function() {
        $('#gallery a').lightBox();
    });

});




