$(document).ready(function(){
// Efecto pestanyas menuPrincipal
$("#menuPrincipal a").eq(pesta-1).addClass('select');

// Efecto acordeon menu productos
		$("#cabeceraApartado dd").hide();

	q=document.location.toString().split('/');
	q=q[q.length-1].split('?');
	$("#cabeceraApartado a[href='"+q[0]+"']").parent().parent().parent().parent().prev().find('a').addClass('cerrado');
	$("#cabeceraApartado a[href='"+q[0]+"']").parent().parent().parent().parent().show();
	$("#cabeceraApartado a[href='"+q[0]+"']").addClass('select');
//		$("dd .select").show();


		$("dt a").click(function(){
			$("#cabeceraApartado dd:visible").slideUp("fast");
			$(this).parent().next().slideDown("fast");
			return false;
		});

//Efecto plegar/desplegar imagen
			//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
				$("div#contenidoInfo:hidden").slideDown("fast");
				//quito clase cerrado
				$("dl#cabeceraApartado dt a").addClass("cerrado");
				w.removeClass("cerrado");
			}else{
				//abro
				$("div#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:eq(0)").hover(function(){$(this).attr("src", "img/point.gif");},function(){$(this).attr("src", "img/point_grey.gif");});
		$(".scrollbutton img:eq(1)").hover(function(){$(this).attr("src", "img/point_downh.gif");},function(){$(this).attr("src", "img/point_down.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);}});



});





