	
	$(document).ready(function() {
			
			//Arrow up
			
			if(!$.browser.msie){
				$("#nav_up").fadeOut(1);
			}
			$(document).scroll(function(){
				
				if (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop>1){
					$("#nav_up").fadeIn(500);
				}
				else if (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop<=1){
					$("#nav_up").fadeOut(500);
				}
			});
			
			$('#nav_up').click(
				function (e) {
					$('html, body').animate({scrollTop: '0px'}, 800);
				}
			)
			
			//Menu
			
			//Calculamos el padding entre las columnas
			
			total = 0;
			$('#menu ul').each(function() {
			    
			    total = total + $(this).width();
			   
			  });
			  
			padding=parseInt((930-total)/6);
			padding= parseInt(padding + (padding/5));
			$('#menu ul').css("paddingRight",padding);
			$('#menu ul.last').css("paddingRight",0);
			

		
			//Posición flecha activa
			
			if ($(".menuActivo").size()>0){
				var $arrow = $('#arrow-nav');
				$arrow
					.width($(".menuActivo").width())
					.css("left", $(".menuActivo").position().left)
					.data("origLeft", $arrow.position().left)
					.data("origWidth", $arrow.width());
			} else {
				
				var $arrow = $('#arrow-nav');
				$arrow
					.css("opacity","0")
					.data("origLeft",$arrow.position().left)
					.data("origWidth", $arrow.width());
				
			}
	 		
		
			//Movimiento flecha
		
			$('#menu ul').live('mouseover', function() {
			
				$el = $(this);
		        leftPos = $el.position().left;
		        newWidth = $el.width();
		        $arrow.stop().animate({
		            left: leftPos,
		            width: newWidth,
					opacity:1
		        });
		        
			});
			
			$('#menu ul').live('mouseout', function() {
													
				$arrow.stop().animate({
		            left: $arrow.data("origLeft"),
		            width: $arrow.data("origWidth")
		        }, function () {
					if ($(".menuActivo").size()==0 && $arrow.position().left == 0) 
						$arrow.css("opacity","0")
				
				});
				
				
				
			});
			
			
	});


	function muestraLigh(imagen, w, h){
		$.fancybox({
			'href': imagen,
        	'autoDimensions'	: false,
			'width'         		: w,
			'height'        		: h,
			'type': 'iframe'

		});
	}
	
	
	function muestraLighImg(imagen, w, h){
		$.fancybox({
			'href': imagen,
        	'autoDimensions'	: false,
			'width'         		: w,
			'height'        		: h

		});	
	}
	
	function desplegable(object){
		
		$des = $(object).next(".desplegable");
		
				if ($($des).is(":hidden")) {
       				 $($des).slideDown("slow");

      			} else {
	  				$($des).slideUp("slow");
			
      			} 
	}
	function desplegableUnico(object){
		
		$(".desplegable").slideUp("fast");
		$des = $(object).next(".desplegable");
		
				if ($($des).is(":hidden")) {
       				 $($des).slideDown("slow");

      			} else {
	  				$($des).slideUp("slow");
			
      			} 
	}
	
	$(function(){$('a[href][rel*=external]').each(function(i){this.target = "_blank";});});
	



