jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(h,f,e,g,a){return jQuery.easing[jQuery.easing.def](h,f,e,g,a)},easeOutQuad:function(h,f,e,g,a){return -g*(f/=a)*(f-2)+e},easeInOutExpo:function(h,f,e,g,a){if(f==0){return e}if(f==a){return e+g}if((f/=a/2)<1){return g/2*Math.pow(2,10*(f-1))+e}return g/2*(-Math.pow(2,-10*--f)+2)+e}});(function(c){var a=c.scrollTo=function(d,f,e){c(window).scrollTo(d,f,e)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};a.window=function(d){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){var f=this,d=!f.nodeName||c.inArray(f.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return f}var e=(f.contentWindow||f).document||f.ownerDocument||f;return c.browser.safari||e.compatMode=="BackCompat"?e.body:e.documentElement})};c.fn.scrollTo=function(d,f,e){if(typeof f=="object"){e=f;f=0}if(typeof e=="function"){e={onAfter:e}}if(d=="max"){d=9000000000}e=c.extend({},a.defaults,e);f=f||e.speed||e.duration;e.queue=e.queue&&e.axis.length>1;if(e.queue){f/=2}e.offset=b(e.offset);e.over=b(e.over);return this._scrollable().each(function(){var g=this,h=c(g),l=d,m,i={},j=h.is("html,body");switch(typeof l){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(l)){l=b(l);break}l=c(l,this);case"object":if(l.is||l.style){m=(l=c(l)).offset()}}c.each(e.axis.split(""),function(n,u){var p=u=="x"?"Left":"Top",o=p.toLowerCase(),s="scroll"+p,r=g[s],t=a.max(g,u);if(m){i[s]=m[o]+(j?0:r-h.offset()[o]);if(e.margin){i[s]-=parseInt(l.css("margin"+p))||0;i[s]-=parseInt(l.css("border"+p+"Width"))||0}i[s]+=e.offset[o]||0;if(e.over[o]){i[s]+=l[u=="x"?"width":"height"]()*e.over[o]}}else{var q=l[o];i[s]=q.slice&&q.slice(-1)=="%"?parseFloat(q)/100*t:q}if(/^\d+$/.test(i[s])){i[s]=i[s]<=0?0:Math.min(i[s],t)}if(!n&&e.queue){if(r!=i[s]){k(e.onAfterFirst)}delete i[s]}});k(e.onAfter);function k(n){h.animate(i,f,e.easing,n&&function(){n.call(this,d,e)})}}).end()};a.max=function(f,j){var e=j=="x"?"Width":"Height",h="scroll"+e;if(!c(f).is("html,body")){return f[h]-c(f)[e.toLowerCase()]()}var d="client"+e,i=f.ownerDocument.documentElement,g=f.ownerDocument.body;return Math.max(i[h],g[h])-Math.min(i[d],g[d])};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery);(function(d){var c=location.href.replace(/#.*/,"");var b=d.localScroll=function(e){d("body").localScroll(e)};b.defaults={duration:1000,axis:"y",event:"click",stop:true,target:window,reset:true};b.hash=function(f){if(location.hash){f=d.extend({},b.defaults,f);f.hash=false;if(f.reset){var e=f.duration;delete f.duration;d(f.target).scrollTo(0,f);f.duration=e}a(0,location,f)}};d.fn.localScroll=function(e){e=d.extend({},b.defaults,e);return e.lazy?this.bind(e.event,function(h){var g=d([h.target,h.target.parentNode]).filter(f)[0];if(g){a(h,g,e)}}):this.find("a,area").filter(f).bind(e.event,function(g){a(g,this,e)}).end().end();function f(){return !!this.href&&!!this.hash&&this.href.replace(this.hash,"")==c&&(!e.filter||d(this).is(e.filter))}};function a(m,g,f){var j=g.hash.slice(1),h=document.getElementById(j)||document.getElementsByName(j)[0];if(!h){return}if(m){m.preventDefault()}var k=d(f.target);if(f.lock&&k.is(":animated")||f.onBefore&&f.onBefore.call(f,m,h,k)===false){return}if(f.stop){k.stop(true)}if(f.hash){var i=h.id==j?"id":"name",l=d("<a> </a>").attr(i,j).css({position:"absolute",top:d(window).scrollTop(),left:d(window).scrollLeft()});h[i]="";d("body").prepend(l);location=g.hash;l.remove();h[i]=j}k.scrollTo(h,f).trigger("notify.serialScroll",[h])}})(jQuery);function nowebversion(){alert("I am currently working on a web version of my resume. This will be avaiable very soon.\nMeanwhile, please refer to the PDF-version.\n\n/Mickel")}var ME={};Date.prototype.toRelativeTime=function(b){var c=new Date()-this;b=parseInt(b,10);if(isNaN(b)){b=0}if(c<=b){return"Just now"}var d=null;var e={millisecond:1,second:1000,minute:60,hour:60,day:24,month:30,year:12};for(var a in e){if(c<e[a]){break}else{d=a;c=c/e[a]}}c=Math.floor(c);if(c!==1){d+="s"}return[c,d,"ago"].join(" ")};Date.fromString=function(a){return new Date(Date.parse(a))};noProject=function(a){alert("Sorry, no link for this project yet.\nContact me if you want more information about "+a+".")};ME.Mode={Layout:false,Offline:false};ME.Utils={RxEmail:/(?:[a-z0-9_\-\.\+])+\@(?:[a-z0-9_\-\.])+\.(?:[a-z]{2,4})/ig,ValidateEmail:function(b){var a=ME.Utils.RxEmail.match(b);return a.length==1&&a[0]==b},GetEmailAddresses:function(a){return a.match(ME.Utils.RxEmail)},HasEmail:function(a){return ME.Utils.GetEmailAddresses(a)!=null},Linkify:function(a){var b=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;return a.replace(b,"<a href='$1'>$1</a>")},Enablify:function(b,d,c){var a=function(){var e="disabled";c(b,d);if(this.value.length>2){d.removeClass(e)}else{d.addClass(e)}};b.keypress(a).keyup(a).keyup()}};ME.API={Twitter:{Recent:"/API/RecentTweets"},Blog:{Recent:"/API/RecentBlogs"},LastFm:{TopTracks:"/API/TopTracks",RecentTracks:"/API/RecentTracks",NowPlaying:"/API/NowPlaying"},Flickr:{RecentPhotos:"/API/RecentPhotos"},Mail:{SendEmail:"/API/SendEmail"},Facts:{RandomFacts:"/API/RandomFacts"}};ME.AJAX=function(b){var a=b.dataType||"json";$.ajax({type:b.type,url:b.url,data:b.data,dataType:a,beforeSend:function(){if(typeof b.beforeSend==="function"){b.beforeSend()}},success:function(c){if(typeof b.success==="function"){b.success(c)}},error:function(c,e,d){if(typeof b.error==="function"){b.error(c,e,d)}}})};ME.CallService=function(a,b){b.url=a;b.type="post";ME.AJAX(b)};ME.Templating={Wrap:{Track:function(a){return'<li><a href="'+a.URL+'">'+a.Artist+" - "+a.Title+"</a></li>"},NiceTrack:function(a){if(a.Title.length>30){a.Title=a.Title.substring(0,30)+"..."}if(a.Artist.length>30){a.Artist=a.Artist.substring(0,30)+"..."}return'<a href="'+a.URL+'"><strong>'+a.Title+"</strong>, by "+a.Artist+"</a>"},RecentTrack:function(a){return'<li><a href="'+a.URL+'">'+a.Title+"<span>"+a.Artist+"</span></li>"},RecentPhoto:function(a){return"<li style=\"background-image: url('"+a.ThumbnailUrl+'\')"><a href="'+a.WebUrl+'" title="'+a.Title+'">'+a.Title+"</a></li>"},Tweet:function(a){return"<li>"+ME.Utils.Linkify(a.Text)+"<span>"+new Date(a.CreatedAt).toRelativeTime()+"</span></li>"},Blog:function(a){return'<li><a href="'+a.Url+'">'+a.Title+"</a></li>"},Tracks:function(a){return ME.Templating.Wrap.Each(a,ME.Templating.Wrap.Track)},RecentTracks:function(a){return ME.Templating.Wrap.Each(a,ME.Templating.Wrap.RecentTrack)},RecentPhotos:function(a){return ME.Templating.Wrap.Each(a,ME.Templating.Wrap.RecentPhoto)},Tweets:function(a){return ME.Templating.Wrap.Each(a,ME.Templating.Wrap.Tweet)},Blogs:function(a){return ME.Templating.Wrap.Each(a,ME.Templating.Wrap.Blog)},Each:function(c,a){var b="";$.each(c,function(d,e){b+=a(e)});return b}}};ME.GUI={lastTrack:"",trackTimeoutTimer:null,trackPingTimer:null,lastFact:-1,NewFact:function(e,d){var a="active";if(d.hasClass(a)){return}d.addClass(a);var b=function(){d.removeClass(a)};ME.CallService(ME.API.Facts.RandomFacts,{data:{take:1,not:ME.GUI.lastFact},success:function(c){b();if(!c||c.length==0){return}var c=c[0];e.fadeOut(100,function(){e.html(c.Content);e.fadeIn(100)});ME.GUI.lastFact=c.Id},error:function(f,g,h){b()}})},RecentTweets:function(a){ME.CallService(ME.API.Twitter.Recent,{data:{take:7},success:function(b){if(!b){return}a.append(ME.Templating.Wrap.Tweets(b)).slideDown()},error:function(b,d,c){a.append('<li class="error">Ooops! Failed to fetch recent Tweets.<br />Visit <a href="http://twitter.com/miickel">Miickel @ Twitter</a> instead.</li>')}})},RecentBlogs:function(a){ME.CallService(ME.API.Blog.Recent,{data:{take:5},success:function(b){if(!b){return}a.append(ME.Templating.Wrap.Blogs(b)).slideDown()},error:function(b,d,c){a.append('<li class="error">Ooops! Failed to fetch recent blog posts.<br />Visit <a href="http://blog.mickel.me">blog.mickel.me</a> instead.</li>')}})},TopTracks:function(a){ME.CallService(ME.API.LastFm.TopTracks,{data:{take:10},success:function(b){if(!b){return}a.append(ME.Templating.Wrap.Tracks(b)).slideDown()}})},RecentTracks:function(a){ME.CallService(ME.API.LastFm.RecentTracks,{data:{take:5},success:function(b){if(!b){return}a.html(ME.Templating.Wrap.RecentTracks(b))}})},NowPlaying:function(f,g){try{var d=$("#npc");var b=function(){setTimeout(function(){ME.GUI.NowPlaying(f,g)},6000)};var a=function(){ME.GUI.RecentTracks($("#recent-tracks"))};ME.CallService(ME.API.LastFm.NowPlaying,{success:function(c){if(!c){if(f.is(":visible")){if(ME.GUI.trackTimeoutTimer!=null){b();return}ME.GUI.trackTimeoutTimer=setTimeout(function(){d.slideDown();f.slideUp();ME.GUI.StartTrackPolling(f,g);a()},10000)}else{ME.GUI.StartTrackPolling(f,g)}}else{if(ME.GUI.trackTimeoutTimer!=null){clearTimeout(ME.GUI.trackTimeoutTimer)}clearTimeout(ME.GUI.trackPingTimer);var e=function(){g.html(ME.Templating.Wrap.NiceTrack(c))};if(c.Title!=ME.GUI.lastTrack){a();g.fadeOut(function(){e();g.fadeIn()});ME.GUI.lastTrack=c.Title}else{e()}if(!f.is(":visible")){f.slideDown();d.slideUp()}b()}}})}catch(h){}},StartTrackPolling:function(b,a){if(ME.GUI.trackPingTimer!=null){return}ME.GUI.trackPingTimer=setInterval(function(){ME.GUI.NowPlaying(b,a)},10000)},RecentPhotos:function(a){ME.CallService(ME.API.Flickr.RecentPhotos,{data:{take:21},success:function(b){if(!b){return}var d=new Array();for(var c=0;c<b.length;c++){d[c]=document.createElement("img");d[c].setAttribute("src",b[c].ThumbnailUrl)}a.html(ME.Templating.Wrap.RecentPhotos(b))}})},};ME.Contact={LastBlock:null,FocusOnPageLoaded:false,Init:function(a){ME.Contact.LastBlock=a.find("li:last");maxWidth=615;minWidth=0;a.find("li").click(function(){var b=$(this);if(b.find("h3").hasClass("active")){return}ME.Contact.LastBlock.find("div.c").animate({width:minWidth+"px"},{queue:false,duration:200}).fadeOut().parent().find("h3").removeClass("active");b.find("div.c").animate({width:maxWidth+"px"},{queue:false,duration:200,complete:function(){if(!ME.Contact.FocusOnPageLoaded){ME.Contact.FocusOnPageLoaded=true;return}$(this).find("textarea:first").focus()}}).fadeIn().parent().find("h3").addClass("active");ME.Contact.LastBlock=b});a.find("li.email").click()}};ME.Web={DOM_Loaded:function(){var g=$("#tweets");var a=$("#blogs");var c=$("#top-tracks");var j=$("#recent-tracks");var d=$("#now-playing");var e=$("#fm-status");var f=$("#recent-photos");var m=$("#contact ul");var p=$("#nav");var i=new Array();$.each($("a",p),function(s,u){u=u.toString();u=$(u.substring(u.lastIndexOf("#")));var r=u.offset().top;i.push({target:u.attr("id"),top:r,bottom:r+u.height()})});$(window).scroll(function(r){var s=$(window).scrollTop()+5;$.each(i,function(u,v){if(s>=v.top&&s<v.bottom){$("a",p).removeClass("active");$('a[href="#'+v.target+'"]',p).addClass("active")}})});p.localScroll({duration:1000});if(ME.Mode.Layout){ME.GUI.TopTracks(c);ME.GUI.RecentTracks(j);ME.GUI.NowPlaying(d,e);ME.GUI.RecentPhotos(f);ME.GUI.RecentTweets(g);ME.Contact.Init(m)}else{if(ME.Mode.Offline){ME.Contact.Init(m)}else{ME.GUI.RecentTweets(g);ME.GUI.RecentBlogs(a);ME.GUI.TopTracks(c);ME.GUI.RecentTracks(j);ME.GUI.NowPlaying(d,e);ME.GUI.RecentPhotos(f);ME.Contact.Init(m)}}jQuery.easing.def="easeInOutExpo";var k=function(){var r=$(this);if(r.hasClass("disabled")){return}r.parent().find("span.discreet").hide()};var q=function(r){r.parent().find("span.discreet").fadeIn()};var l=$("#tweet-me");var b=$("#send-tweet");ME.Utils.Enablify(l,b,function(s,t){var u=s.val().length;var v=131-u;var r=$("#notif-t");r.html(v);if(v<0){r.addClass("error")}else{r.removeClass("error")}});b.click(function(){if(l.val().length<3){return}$(".twitterStatus").slideUp(function(){$(this).html('<p class="ciao">Connecting Twitter...</p>').slideDown(function(){window.location.href="http://twitter.com/home?source=Miickel&status=@Miickel"+encodeURI(" "+l.val())})})});var n=$("#send-email");var o=$("#email-me");ME.Utils.Enablify(o,n,function(r,v){if(o.val().length<3){return}var w=r.val();var s=$("#notif-e");var u=s.parent().find("span.discreet");var t=ME.Utils.GetEmailAddresses(w);if(t==null){s.hide().empty();u.fadeIn();return}s.html("My reply will be sent to "+t[0]).fadeIn();u.hide()});n.click(function(){var v=o.val();if(v.length<3){return}var u=ME.Utils.GetEmailAddresses(v);var s=$(this);var r=function(){s.addClass("disabled").parent().addClass("active").parent().find("textarea").attr("disabled",true)};var t=function(){s.blur().removeClass("disabled").parent().removeClass("active").parent().find("textarea").removeAttr("disabled").focus()};r();ME.CallService(ME.API.Mail.SendEmail,{data:{message:v,sender:u!=null?u[0]:null},success:function(w){t();if(w.MailSent){$(".mailStatus").slideUp(function(){var x=$(this);x.html('<p class="ciao">Thanks! Your email has been sent.</p>').slideDown()})}else{alert(w.Error+"\n\nDetails:\n"+w.ErrorDetails)}},error:function(w,x,y){alert("Unable to send your email. Please verify your connection to the Internet.");t()}})});$("a.btn").mousedown(k).click(k).blur(function(){var r=$(this);if(r.parent().find("span[id^=notif]").not(":empty").length!=0){return}q(r)});var h=$("div#info");$("div#random").click(function(){ME.GUI.NewFact($("#random-fact"),h)}).mousemove(function(t){var s=t.pageX;var r=t.pageY;h.css({position:"absolute",top:r,left:s+20}).html("Click for more facts!").show()}).mouseleave(function(){h.hide()})}};$(ME.Web.DOM_Loaded);