$(document).ready(function(){var n=1500;function k(B){image=new Image();$("section#"+B+" img").each(function(D){var C=$(this).attr("src");if(C&&C.length>0){image.src=C}});var A=$("section#"+B+".heading").css("background-image");if(A&&A.length>0){image.src=A}}setTimeout(function(){$("nav#navigation ul li").each(function(A){if(!$(this).hasClass("selected")){var B=$(this).attr("id");k(B)}})},n);var m=$("#conveyor");var u=$("#conveyor .scrolling figure");var j=u.length;var t=j*220;function d(){var A=m.outerWidth();var B=Math.ceil(A/t);if(B<2){B=2}for(i=0;i<B;i++){$(u).clone().appendTo("#conveyor .scrolling")}$("#conveyor .scrolling").width(t*(B+2))}function z(A){$(A).each(function(B){$(this).load(function(){var C=$(this).width();if(C!=0){$(this).css({left:"50%","margin-left":"-"+C/2+"px"})}})})}if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/)){z($("#conveyor .scrolling figure img"))}else{d();z($("#conveyor .scrolling figure img"));if(navigator.userAgent.match(/iPad/i)){return}var p=0;setInterval(function(){if(p<j){m.scrollTo("+=220px",800);p++}else{p=1;m.scrollTo(0,0);m.scrollTo("220px",800)}},2500)}if(window.location.hash){var s=window.location.hash.substring(3,window.location.hash.length);if($("section#"+s).length>0){a(s,false);$("nav#navigation ul li#"+s).addClass("selected")}}$("nav#navigation ul li").click(function(){if($(this).hasClass("selected")){return}$("nav#navigation ul li").removeClass("selected");$(this).addClass("selected");var A=$(this).attr("id");a(A,true);if(typeof(_gaq)!="undefined"){_gaq.push(["_trackPageview","/"+A])}});function a(C,B){window.location.hash="!/"+C;document.title=$("nav#navigation ul li#"+C+" h2").html()+" — Matías Martínez";var A=$("section#"+C);$("section").css("z-index","");$(A).css("z-index","1337").fadeIn(200);$("section").not(A).hide();if(g){$("body").scrollTo("nav#navigation",200)}}var g=true;if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/)||navigator.userAgent.match(/iPad/)){g=false}var f={beforeSubmit:e,success:l};$("#contact_form").ajaxForm(f);var b=$("#envelope");var w=$("#catcher");var q=false;function e(C,B,A){if(q){return false}b.addClass("sending");q=true;c(true);w.slideUp("fast");return true}function l(B,C,D,A){if(B!="SENT_SUCCESS"||C!="success"){b.removeClass("sending");c(false);w.html(B);w.slideDown("slow")}else{y()}q=false}var o={lines:12,length:7,width:4,radius:10,color:"#fff",speed:1,trail:60,shadow:true};var r=$("#spinner");var v=document.getElementById("spinner");var h=new Spinner(o);function c(A){if(A){$("section#contacto").css("position","relative");h.spin(v);r.fadeIn(100)}else{$("section#contacto").css("position","");h.stop();r.fadeOut(100)}}var x=$(".envelope-overlay");function y(){c(false);var B=$("input#name").val();if(B.length==0){B=$("input#email").val()}if(B.length>0){$(".envelope-overlay .content").html("<p>De: "+B+"</p> <p>Para: Matías Martínez</p>")}else{$(".envelope-overlay .content").html("<p>De: Anónimo</p> <p>Para: Matías Martínez</p>")}var A=x.css("height");x.css("bottom","-"+A);x.show();x.animate({bottom:"0px"},1000,function(){b.animate({"margin-top":"1000px"},1000,function(){b.hide();x.delay(100).animate({bottom:"-"+A},1000,function(){x.hide();$("figure.notice").fadeIn(500)})})})}$("section .yourturn, ul.social a.contact").click(function(){$("nav#navigation ul li#contacto").click()});$("section#software article figure").click(function(){document.location=$(this).parent().find("a.getapp").attr("href")})});
