function ready(){

	Cufon.replace('.lubalXLT, .lubalMd, .lucida',{autoDetect:true,letterSpacing:"-1px", hover: {color: '#fff'}});

	Cufon.now();

	

	if($.browser.msie) var ie=1;

	if($.browser.msie && $.browser.version<=7) var ie7=1;

	

	if(ie7==1) $(".rotating").text("");

	$(".rotating").prepend("<span />").each(function(){

		var img = $(this).css("background-image");

		var span = $(">span", this).css("background-image",img).width($(this).width()).height($(this).height());

		$(this).hover(function(){

			span.stop().animate({opacity:0},400);

		},function(){

			span.stop().animate({opacity:1}, 1000);

		});

	});



	$("#menu li").each(function(){$(this).prepend('<p class="p1">&nbsp;</p>').append('<p class="p2">&nbsp;</p>').css("padding","0");});

	$("#menu ul li .p1").css("background-position","16px 0px");

	$("#menu ul li .p2").css("background-position","-16px 0px");

	$("#menu ul li a").hover(

		function(){

			$(this).parent().find(".p1").animate({"background-position":"4px 0px"},{duration:200,queue:false});

			$(this).parent().find(".p2").animate({"background-position":"0px 0px"},{duration:200,queue:false});

		},

		function(){

			$(this).parent().find(".p1").animate({"background-position":"16px 0px"},{duration:200,queue:false});

			$(this).parent().find(".p2").animate({"background-position":"-16px 0px"},{duration:200,queue:false});

		}

	);

	

	if($("#works").length){

		

		$("#workList article").each(function(i){

				if(ie && i%4 == 0) $(this).addClass("alpha");

				if(ie && i%4 == 3) $(this).addClass("omega");

				var ss = $(this).find(".ss");

				var im = $(this).find(".innerMask");

				var launch = $(this).find(".launch");

				var imDh = im.height();

				

				

				$(this).hover(

					function(){

						ss.animate({marginTop:"-=140px"},{queue:false});

						im.animate({height:"282px"},{queue:false});

					},

					function(){

						ss.animate({marginTop:"0px"},{queue:false});

						im.animate({height:imDh+"px"},{queue:false});

					}

				);

				

				launch.css("background-position","60px 4px");

				launch.hover(

					function(){

						$(this).animate({backgroundPosition:"65px 4px"},{duration:200, queue:false});

					},

					function(){

						$(this).animate({backgroundPosition:"60px 4px"},{duration:600,queue:false});

					}

				);

			}

		);

		

		$(".mask>.tags").each(function(){

			$(this).css("margin-top",105-$(this).height()+"px");

			$(this).parent().find(".innerMask .tags:first").html($(this).html());

		});

		

		

		$("#workList .innerMask .tags a").click(function(){

				var text = $(this).text().toLowerCase();

				

				

				$("#workList article").each(function(){

						var text2 = $(this).find(".innerMask").text().toLowerCase();

						if(text2.indexOf(text)<0 && !ie) $(this).stop(true).animate({opacity:0.3},{duration:300}).animate({opacity:0.3},{duration:5000}).animate({opacity:1},{duration:300}); else $(this).stop().animate({opacity:1},{duration:300});

					}

				);

				

				return false;

			}

		);

		$(".launch").click(function(){
			var href = $(this).attr("href");
			$("#getSite").attr("src",href);
			$("body").addClass("oyh");
			$("#back").fadeIn();
			$("#getSite").fadeIn();
			return false;
		});
		
		$("#back a").click(function(){
			$("#getSite").fadeOut();
			$("#back").fadeOut();
			$("#getSite").attr("src","");
			$("body").removeClass("oyh");
			return false;
		});

	}


	

	

	$("#info .arr").animate({height:"205px"},"slow");

	



	$("#contactForm p > *").focus(function(){$(this).prev().stop().fadeOut();if($(this).val() == $(this).attr("title")) $(this).val("");}).blur(function(){if($(this).val() == "") $(this).val($(this).attr("title"));});

	

	var sent=0;

	var loader = $("#contactForm #loader");

	$("#contactForm .submit").click(function(){$("#contactForm").submit();return false;});

	$("#contactForm").submit(function(){

		if(!sent){

			window.error=0;

			window.contactData = "act=contactForm";

			loader.animate({opacity:1});

			$("#contactForm [name=subject]").checkField();

			$("#contactForm [name=name]").checkField();

			$("#contactForm [name=email]").checkField("email");

			$("#contactForm [name=msg]").checkField();

			if(window.error==0){sent=1;$.ajax({type:"POST",url:"/ajax.php",data:window.contactData,success: function(msg){

				$("#contactForm").animate({height:"60px"},function(){

					$(this).html("<p id='sent' class='lubalMd'>Thanks for writing. I'll be in touch.</p>");

					Cufon.refresh('.lubalXLT, .lubalMd, .lucida');

				});

			

			}});}

			loader.animate({opacity:0});

			return false;

		}

		

	});

	

	

	if($("#home").length){

	

	/*Begin JSON */

	

		/* Begin get last tweet */

		$.getJSON('http://twitter.com/statuses/user_timeline/goxel.json?callback=?', 

			function(data){

				var html = "<b><a href='http://twitter.com/goxel/statuses/"+data[0].id+"'>"+relative_time(data[0].created_at)+"</a></b> "+ linkify(data[0].text);

				$("#twitterPost article").html(html);

			}

		);

		/* End get last tweet */

		

		/* Begin get posts from blog */

		$.getJSON('http://geryit.com/blog/feed/?feed=json&jsonp=?', 

			function(data){

				var html = "";

				for(i=0;i<3;i++){

					var title = data[i].title;

					if(title.length>35) title = title.substr(0,35)+ "...";

					html +='<dd><a href="/blog/?p='+data[i].id+'">'+title+'</a> / '+data[i].date+'</dd>';

				}

				$("#blogPosts article").html('<dl>'+html+'</dl>');

			}

		);

		/* End get posts from blog */

		

	/*End JSON */

		

	}






	
	

}

/////////////////////////////////////////////////////



jQuery.fn.checkField = function(type){

	var error=0;

	$(this).prev().fadeOut();

	if($(this).val().length<3 || $(this).val() == $(this).attr("title")){error=1;}

	else if(type=="email" && ($(this).val().length<7 || $(this).val().indexOf("@")<1 || ($(this).val().indexOf("@")+2)>$(this).val().lastIndexOf(".") || $(this).val().lastIndexOf(".")>($(this).val().length-2))){error=1;}

	if(error==1){window.error=1;$(this).prev().fadeIn().delay(3000).fadeOut();}

	window.contactData += "&"+$(this).attr("name")+"="+$(this).val();

}



function linkify(txt){

	var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;  

	return txt.replace(regexp,'<a href="$1">$1</a>');

}  



function relative_time(time_value) {

	var values = time_value.split(" ");

	time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];

	var parsed_date = Date.parse(time_value);

	var relative_to = (arguments.length > 1) ? arguments[1] : new Date();

	var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);

	delta = delta + (relative_to.getTimezoneOffset() * 60);

	

	var r = '';

	if (delta < 60) {

	r = 'a minute ago';

	} else if(delta < 120) {

	r = 'couple of minutes ago';

	} else if(delta < (45*60)) {

	r = (parseInt(delta / 60)).toString() + ' minutes ago';

	} else if(delta < (90*60)) {

	r = 'an hour ago';

	} else if(delta < (24*60*60)) {

	r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';

	} else if(delta < (48*60*60)) {

	r = '1 day ago';

	} else {

	r = (parseInt(delta / 86400)).toString() + ' days ago';

	}

	

	return r;

}













	

	

	