Math.roundFloat=function(b,a){return Math.round(b*Math.pow(10,a))/Math.pow(10,a)};var $box,$presentation,$header,$items,$scroller,$close,$projects,$lab,$left,$right,$name,$data,opened=false,running=false,duration=500,scrollOffset=300,scroll=false,scrollOver=false,multiplier=0,mouse={x:0,y:0};
$(function(){$("a#e").text("e"+"m"+"a"+"i"+"l"+":"+" k"+"o"+"n"+"t"+"a"+"k"+"t"+"@"+"m"+"i"+"c"+"h"+"a"+"l"+"h"+"a"+"l"+"a"+"s"+"."+"p"+"l").attr("href",$("a#e").text().replace("email: ","mail:"));
$("a#s").text("s"+"k"+"y"+"p"+"e"+":"+" m"+"i"+"c"+"h"+"a"+"l"+"h"+"a"+"l"+"a"+"s"+"."+"p"+"l").attr("href",$("a#s").text().replace("skype: ","call:"));
$box=$("div#box");$presentation=$("div.presentation"),$header=$("div.presentation h2.header"),$items=$("div.presentation div.items"),$scroller=$("div.presentation div.items div.scroller"),$close=$("div.presentation a.close"),$projects=$("div#projects"),$lab=$("div#lab"),$left=$("div#left");
$right=$("div#right"),$name=$("div#name"),$data=$("div#data");$box.css({width:$(window).outerWidth()+"px",height:$(window).outerHeight()+"px"});$presentation.css({top:"0px",left:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px",height:$(window).outerHeight()+"px"});
$items.css({height:$presentation.outerHeight()-$header.outerHeight()-$close.outerHeight()+"px"});$close.css({top:$presentation.outerHeight()-$close.outerHeight()+"px"});
$left.css({top:($(window).outerHeight()/2)-($left.outerHeight()/2)+"px",left:"0px",width:($(window).outerWidth()/2)+"px"});$right.css({top:($(window).outerHeight()/2)-($right.outerHeight()/2)+"px",left:($(window).outerWidth()/2)+"px",width:($(window).outerWidth()/2)+"px"});
$name.css({top:($(window).outerHeight()/2)-($name.outerHeight()/2)+"px",left:$left.outerWidth()-$name.outerWidth()+"px"});$data.css({top:($(window).outerHeight()/2)-($data.outerHeight()/2)+"px",left:$left.outerWidth()+"px"});
setInterval(function(){$box.css({width:$(window).outerWidth()+"px",height:$(window).outerHeight()+"px"});$presentation.css({top:"0px",left:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px",height:$(window).outerHeight()+"px"});
$items.css({height:$presentation.outerHeight()-$header.outerHeight()-$close.outerHeight()+"px"});$close.css({top:$presentation.outerHeight()-$close.outerHeight()+"px"});
if(!running){if(!opened){$left.css({top:($(window).outerHeight()/2)-($left.outerHeight()/2)+"px",left:"0px",width:($(window).outerWidth()/2)+"px"})}else{$left.css({top:($(window).outerHeight()/2)-($left.outerHeight()/2)+"px",left:"0px",width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px"})
}if(!opened){$right.css({top:($(window).outerHeight()/2)-($right.outerHeight()/2)+"px",left:($(window).outerWidth()/2)+"px",width:($(window).outerWidth()/2)+"px"})
}else{$right.css({top:($(window).outerHeight()/2)-($right.outerHeight()/2)+"px",left:($(window).outerWidth()/2)+($presentation.outerWidth()/2)+"px",width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px"})
}$name.css({top:($(window).outerHeight()/2)-($name.outerHeight()/2)+"px",left:$left.outerWidth()-$name.outerWidth()+"px"});$data.css({top:($(window).outerHeight()/2)-($data.outerHeight()/2)+"px",left:$right.offset().left+"px"})
}if(opened){$left.css({height:$(window).outerHeight()+"px"});$right.css({height:$(window).outerHeight()+"px"})}},100);$("a#e, a#s",$box).mouseenter(function(){$(this).stop().animate({opacity:0.8})
}).mouseleave(function(){$(this).stop().animate({opacity:1})});$("a#toggle-projects").click(function(a){a.preventDefault();if(!running){if(opened){if(opened&&$projects.css("display")=="none"){change($projects)
}else{close()}}else{open($projects)}}});$("a#toggle-lab").click(function(a){a.preventDefault();if(!running){if(opened){if(opened&&$lab.css("display")=="none"){change($lab)
}else{close()}}else{open($lab)}}});$("a.close").click(function(a){a.preventDefault();close()});$("div.items a.item").item();$(window).mouseover(function(){scroll=true
}).mouseout(function(){scroll=false}).mousemove(function(c){mouse={x:c.pageX,y:c.pageY};if(opened){var d=c.pageY,b=0,a=$(window).outerHeight();minMax=scrollOffset,maxMin=a-minMax;
multiplier=0;if(d>=b&&d<=minMax){multiplier=1-((d*100)/minMax/100)}if(d>=maxMin&&d<=a){multiplier=-((d-maxMin)*100)/minMax/100}multiplier=Math.roundFloat(multiplier,2)
}});$items.items();setInterval(function(){if(opened&&scroll&&scrollOver&&multiplier!=0&&$scroller.outerHeight()>$items.outerHeight()){var c=(5*multiplier),f=parseInt($scroller.css("top"))+c,a=$scroller.outerHeight()-$items.outerHeight(),e=$("a.item-show"),d=$("a.item-to-follow"),b=d.offset();
if(f>0){f=0}if(-f>a){f=-a}$scroller.css({top:f+"px"});if(b){e.css({top:b.top+"px"})}}},10);$("a.menu-item").mouseenter(function(){var b=$(this),a=$("div",b);
a.stop().animate({top:"-18px"},{duration:200})}).mouseleave(function(){var b=$(this),a=$("div",b);a.stop().animate({top:"0px"},{duration:200})})});jQuery.fn.items=(function(a){return function(b){return this.each(function(){var d=a(this),c=false;
setInterval(function(){var e=d.offset();if(opened&&(mouse.y>=e.top&&mouse.y<=(e.top+d.outerHeight())&&mouse.x>=e.left&&mouse.x<=(e.left+d.outerWidth()))){scrollOver=true;
if(!c){c=true}}else{c=false;scrollOver=false}},10);return this})}})(jQuery);jQuery.fn.itemShow=(function(a){return function(b){return this.each(function(){var e=a(this),f=b.original.offset(),c=false,d=setInterval(function(){var h=e.offset(),l=e.outerHeight(),k=e.outerWidth(),g=$items.offset(),i=$items.outerHeight(),j=$items.outerWidth();
h.right=h.left+k;h.bottom=h.top+l;if(h.top<g.top){h.top=g.top}if(h.left<g.left){h.left=g.left}if(h.top+l>g.top+i){h.bottom=g.top+i}if(mouse.y<h.top||mouse.y>h.bottom||mouse.x<h.left||mouse.x>h.right){scrollOver=false;
if(c){b.original.removeClass("item-to-follow").css("visibility","visible");clearInterval(d);e.remove()}}else{scrollOver=true;if(!c){c=true}}},10);b.original.addClass("item-to-follow").css("visibility","hidden");
e.addClass("item-show").css({top:f.top+"px",left:f.left+"px"});return this})}})(jQuery);jQuery.fn.item=(function(a){return function(){return this.each(function(){var d=a(this),c=a("img",d),b=false;
setInterval(function(){var e=c.offset();if(opened&&(mouse.y>=e.top&&mouse.y<=(e.top+c.outerHeight())&&mouse.x>=e.left&&mouse.x<=(e.left+c.outerWidth()))){if(!b){b=true;
a("a.item").removeClass("item-to-follow");var f=d.clone();f.itemShow({original:d}).appendTo(document.body)}}else{b=false}},10);return this})}})(jQuery);
function change(a){running=true;$left.animate({width:($(window).outerWidth()/2)+"px"},{duration:duration,step:function(b,c){if(c.prop=="width"){$name.css({left:b-$name.outerWidth()+"px"})
}},complete:function(){$presentation.hide();a.show();$left.animate({width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px"},{duration:duration,easing:"easeInOutQuad",step:function(b,c){if(c.prop=="width"){$name.css({left:b-$name.outerWidth()+"px"})
}},complete:function(){running=false}});$right.animate({width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px",left:($(window).outerWidth()/2)+($presentation.outerWidth()/2)+"px"},{duration:duration,easing:"easeInOutQuad",step:function(b,c){if(c.prop=="left"){$data.css({left:$right.offset().left+"px"})
}},complete:function(){running=false}})}});$right.animate({width:($(window).outerWidth()/2)+"px",left:($(window).outerWidth()/2)+"px"},{duration:duration,step:function(b,c){if(c.prop=="left"){$data.css({left:$right.offset().left+"px"})
}}})}function close(){running=true;$left.animate({width:($(window).outerWidth()/2)+"px"},{duration:duration,easing:"easeOutQuad",step:function(a,b){if(b.prop=="width"){$name.css({left:a-$name.outerWidth()+"px"})
}},complete:function(){$presentation.hide();$left.stop().animate({top:($(window).outerHeight()/2)-($left.data("height")/2)+"px",height:$left.data("height")+"px"},{duration:duration,easing:"easeOutQuad",complete:function(){opened=false;
running=false}})}});$right.animate({width:($(window).outerWidth()/2)+"px",left:($(window).outerWidth()/2)+"px"},{duration:duration,easing:"easeOutQuad",step:function(a,b){if(b.prop=="left"){$data.css({left:$right.offset().left+"px"})
}},complete:function(){$right.stop().animate({top:($(window).outerHeight()/2)-($right.data("height")/2)+"px",height:$right.data("height")+"px"},{duration:duration,easing:"easeOutQuad",complete:function(){opened=false;
running=false}})}})}function open(a){running=true;$left.data("height",parseInt($left.height())).stop().animate({top:"0px",height:$(window).outerHeight()+"px"},{duration:duration,easing:"easeOutQuad",complete:function(){$scroller.css("top","0px");
a.show();$left.animate({width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px"},{duration:duration,easing:"easeOutQuad",step:function(b,c){if(c.prop=="width"){$name.css({left:b-$name.outerWidth()+"px"})
}},complete:function(){opened=true;running=false}})}});$right.data("height",parseInt($right.height())).stop().animate({top:"0px",height:$(window).outerHeight()+"px"},{duration:duration,easing:"easeOutQuad",complete:function(){$right.animate({width:($(window).outerWidth()/2)-($presentation.outerWidth()/2)+"px",left:($(window).outerWidth()/2)+($presentation.outerWidth()/2)+"px"},{duration:duration,easing:"easeOutQuad",step:function(b,c){if(c.prop=="left"){$data.css({left:b+"px"})
}},complete:function(){}})}})};
