$(document).ready(function() {
	
	jQuery.easing.def = "easeOutBack";
	
	
	$("#mode a").hover(function () {
		 $('#contact #modes img').css ("margin-left", "10px");
	 }
	);
	
	$("#meta").click(function (e) {
		 e.preventDefault();
		 $('#meta').fadeOut(200);
		 $('.meta').slideDown(600);
							   	 });
	
	$("#related").click(function (e) {
		 e.preventDefault();
		 $('#related').fadeOut(200);
		 $('#relatedposts').slideDown(600);
							   	 });	
	$("#more").click(function (e) {
		 e.preventDefault();
		 $('#more').slideUp(600);
		 $('.more').slideDown(600);
							   	 });
	
	
	$("#resume_thumb").hover(
	function () {
		if ($("#resume_preview").is(":hidden")) {
			$("#resume_preview").slideDown(1600);
		}
	});
	
	//search
	
	$("#search a").click(function (e) {
		 e.preventDefault();
		 $('#search a').hide();
		 $('#search span').show();
		 $('#search #s').focus();
							   	 });
	$("#tryanother").click(function (e) {
		 e.preventDefault();
		 $('#search a').hide();
		 $('#search span').show();
		 $('#search #s').focus();
							   	 });
	//contact form
	
	$("#namae").focus(
	function () {
		if ($("#meeru").is(":hidden")) {
			$("#meeru").slideDown(400);
		}
	});
	
	$("#meeru").focus(
	function () {
		if ($("#renraku").is(":hidden")) {
			$("#renraku").slideDown(400);
		}
	});
	
	$("#renraku").focus(
	function () {
		if ($("#himon").is(":hidden")) {
			$(".contact div").css('display','block');
			$("#himon").slideDown(400);
			$("#himonimg").fadeIn(500);
		}
	});
		
	$("#himon").focus(
	function () {
		if ($("#send").is(":hidden")) {
			$("#send").fadeIn(400);
		}
	});
	
	$('#contact_form').submit(function() {
			var himon;
			var himonf = $("#himon").val().toLowerCase();
			switch ($("#simgnum").val()) {
				case '1' : himon = "animate"; break;
				case '2' : himon = "robot"; break;
				case '3' : himon = "sushi"; break;
				case '4' : himon = "colors"; break;
				case '5' : himon = "rhythm"; break;
				case '6' : himon = "raster"; break;
				case '7' : himon = "vector"; break;
				case '8' : himon = "pixel"; break;
			  }				
									   
			if (himonf == himon) {
			$("input").attr('disabled', 'true');
			$("textarea").attr('disabled', 'true');
			$('#send').val('sending');
			var namae = $("#namae").val();
			var meeru = $("#meeru").val();
			var renraku = $("#renraku").val();
			var dataString = 'namae='+ namae + '&meeru=' + meeru + '&renraku=' + renraku;
			$.ajax({
				type: "POST",
				url: "/post.php",
				data: dataString,
				success: function() {
					$('#contact_form').html("<span id='msg'></span>");
					$('#msg').html("<h2>Your message has been sent.</h2>")
					.append("<p>I will contact you soon. Thank you!</p>")
					.hide()
					.fadeIn(1500, function() {
					//$('#message').append("<img id='checkmark' src='images/check.png' />");
					});
				}
			});
			return false;
			}
			else {
			$('#himonchigaimasu').show(200);
			$('#himon').focus();
			return false;}
			}
		);

	//		image animation
	
	$('#content img.hover').animate({width:'180px',height:'180px'},250, function(){ $(this).animate({width:'200px',height:'200px'},250);} );
	$('#content img.hover').hover(
								  function () {
									  			$(this).animate({width:'180px',height:'180px'},250, function(){ $(this).animate({width:'200px',height:'200px'},250);} );
												});

	//MENU
	var ftime = 360;
	
	$("#web").hover(
  function () {
    $("#web img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#web img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#threeD").hover(
  function () {
    $("#threeD img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#threeD img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#image").hover(
  function () {
    $("#image img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#image img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#animation").hover(
  function () {
    $("#animation img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#animation img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#contact").hover(
  function () {
    $("#contact img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#contact img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#resume").hover(
  function () {
    $("#resume img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#resume img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#viewdemoreel").hover(
  function () {
    $("#viewdemoreel img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#viewdemoreel img").stop().animate({"opacity": "1"}, ftime);
  }
	);
	
	$("#viewdrawings").hover(
  function () {
    $("#viewdrawings img").stop().animate({"opacity": "0"}, ftime);
  }, 
  function () {
    $("#viewdrawings img").stop().animate({"opacity": "1"}, ftime);
  }
	);});


	// end MENU


