/*
 * www.impel.gr - init.js
 * author: Giotis Aggelos
 * last modified: 18/10/2011
 */
$.browser.msie&&parseInt($.browser.version)<9?(max=-$(window).height()+"px",max_left="-500px",zero=0,half=$(window).width()/2+"px"):(max_left=max="-100%",zero="0%",half="50%");
var o=
{
	init:function()
	{
		this.fullscreen.init();
		this.blank();
		this.menu.open();
		this.menu.close();
		this.social.hover();
		this.skills.draw()
	},
	helper:function(a)
	{
		$(a).append($("<span />").addClass("helper"))
	},
	blank:function()
	{
		$(".blank, .social a, .side li a").attr("target","_blank")
	},
	fullscreen:
	{
		data:
		{
			width:1600,height:1010,bgID:"#background",
			callback:function()
			{
				$(o.fullscreen.data.bgID).css({visibility:"visible"})
			}
		},
		init:function()
		{
			$.fn.fullscreenr(o.fullscreen.data)
		}
	},
	menu:
	{
		open:function()
		{
			$(".menu").find("a").click(function()
			{
				var a=$(this);$(".menu").find("a");var b=$("body"),a=a.attr("rel"),c=$(".slide").filter("#"+a),
				d={block:c.find(".main"),all:$(".main")},e={block:c.find(".side"),all:$(".side")},a=$(".home"),f={home:a.width(),window:$(window).width()},h={window:$(window).height()},g=f.home/f.window*100;d.block.css({height:h.window-140+"px"});b.hasClass("active")?(e.all.animate({top:max},400),setTimeout(function()
				{
					d.all.animate({top:max},400,
					function(){c.css({left:g+"%"});e.block.animate({top:zero},400,function(){d.block.animate({top:zero},400)})})
				},
				200)):(d.block.css({top:zero}),c.animate({left:g+"%"},400),setTimeout(function(){e.block.animate({top:zero},400)},200),a.animate({left:zero,marginLeft:0},400),b.addClass("active"));return!1
			})
		},
		close:function()
		{
			$(".close").click(function(){$(this);var a=$(".home"),b=$(".slide"),c=b.find(".side"),d=$("body");c.animate({top:max},400);setTimeout(function(){b.animate({left:max_left},400).dequeue();a.animate({left:half,marginLeft:"-160px"},400)},200);d.removeClass("active");return!1})
		}
	},
	social:
	{
		hover:function()
		{
			$(".social").find("a").bind("mouseover mouseleave",function(a){var b=$(this).next("span"),c=$(".social").find("span");$.browser.msie&&parseInt($.browser.version)<9?a.type=="mouseover"?b.show():c.hide():a.type=="mouseover"?b.fadeIn():c.fadeOut()})
		}
	},skills:
	{
		draw:function(){$(".skills").find("li").each(function(){var a=$(this),b=a.find("span"),c=b.text().split("%")[0];b.wrap($("<div />").addClass("percent"));b=a.find(".percent").find("span");b.css({width:c+"%"})})}
	},twitter:
	{get:function()
		{
			var a=[],b=$(".tweets");$.getJSON("http://twitter.com/status/user_timeline/marcinmobily.json?count=4&callback=?",function(c)
			{
				$.each(c,function(b,c){a.push('<div class="post">');a.push(c.text);a.push("</div>")});c=a.join("");b.html(c);$(".tweets").find(".post").eq(0).show();o.twitter.rotate.start();b.fadeIn()
			})
		}
	}
};
$(function(){o.init()});
