

$(document).ready(function(){

	// Margenes
	margin = 0;
	$('.wrap').each(function(index) {
		$(this).css("margin-left",margin+"%");
		margin = (margin + 100);
	});

  // Scroll
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().left;
				$('html,body').animate({scrollLeft: targetOffset}, 1000, 'easeOutBack');
				return false;
			}
		}
	});


  // Menu
  $("#nav li a").click(function() {
    $("#nav li").removeClass("sel");
    $(this).parent().addClass("sel");
   });

  // Iconitos
  $("ul.links li.item").hover(function() {
    $(this).removeClass("item");
    $("ul.links li.item a").stop();
    $("ul.links li.item a").fadeTo("fast", 0.2);
  },function(){
    $(this).addClass("item");
    $("ul.links li.item a").stop();
    $("ul.links li.item a").fadeTo("fast", 1.0);
  });

	// Enlaces con historial
	$(".items li").each( function (index) {
		$(this).fadeTo("slow", (1-index/10) );
		$(this).hover (
			function () { $(this).fadeTo("normal", 1); },
			function () { $(this).fadeTo("normal", (1-index/10) ); }
		);
	});

  // Paleta
  $("#paleta li").mouseover(function(){
    $(this).animate({width: "200px"});
  }).mouseout(function(){
    $(this).animate({width: "10px"});
  });

  // Mostrar foto
  $("#detalles").mouseover(function(){
    $("#contenedor, #paleta, #nav").css('visibility','hidden');
  }).mouseout(function(){
    $("#contenedor, #paleta, #nav").css('visibility','visible');
  });


});
