//イージングサンプル：http://semooh.jp/jquery/cont/doc/easing/
//イージングサンプル：http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js
jQuery.easing.easeOutExpo = function (x, t, b, c, d) {
	return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
};  
jQuery(function($) {
	//var myurl = "http://" + location.hostname + location.pathname;
	$("a[href*='#']").click(function () {
		var id = this.href.substring(this.href.indexOf('#'),this.href.length);
		var hrefUrl = this.href.split(id);
//		if(hrefUrl[0] == myurl) {
			var targetOffset = $(id).offset().top;
			$('html,body').animate({ scrollTop: targetOffset}, 600,'easeOutExpo');
			return false;
//		}
	});
	
	$("#menu_home").hover(function(){
		resetMenu("menu_home","on");
	},function(){
		resetMenu("menu_home","off");
	});
	$("#menu_about").hover(function(){
		resetMenu("menu_about","on");
	},function(){
		resetMenu("menu_about","off");
	});
	$("#menu_service").hover(function(){
		resetMenu("menu_service","on");
	},function(){
		resetMenu("menu_service","off");
	});
	$("#menu_contact").hover(function(){
		resetMenu("menu_contact","on");
	},function(){
		resetMenu("menu_contact","off");
	});
	$("button.submit01").hover(function(){
		$(this).css({backgroundPosition: "0 -19px"});
	},function(){
		$(this).css({backgroundPosition: "0 0"});
	});
	$("button.submit02").hover(function(){
		$(this).css({backgroundPosition: "0 -19px"});
	},function(){
		$(this).css({backgroundPosition: "0 0"});
	});
	function resetMenu(myid,mymode) {
		if (mymode == "on") {
			var bp = "5px -20px";
			var toid = myid;
		} else {
			var bp = "5px 0";
			if (baseid == undefined) var toid = "";
			else var toid = baseid;
		//	alert(baseid);
		}
		if (toid == "menu_home") {
			$("#menu-liner").stop().animate({width: "50px",marginLeft: "316px"},600,'easeOutExpo');//366-50
		} else if (toid == "menu_about") {
			$("#menu-liner").stop().animate({width: "97px",marginLeft: "366px"},600,'easeOutExpo');//463-97
		} else if (toid == "menu_service") {
			$("#menu-liner").stop().animate({width: "86px",marginLeft: "463px"},600,'easeOutExpo');//549-86
		} else if (toid == "menu_contact") {
			$("#menu-liner").stop().animate({width: "86px",marginLeft: "549px"},600,'easeOutExpo');//630-86+5
		} else {
			$("#menu-liner").stop().animate({width: "1px",marginLeft: "1px"},600,'easeOutExpo');
		}
		$("#"+myid).css({backgroundPosition: bp});
	}
	resetMenu(baseid,"on");
	$("input[@type=text],textarea").focus(function(){
		$(this).css({backgroundColor: '#F7F2EC'});
	}).blur(function(){
		$(this).css({backgroundColor: '#FFFFFF'});
	});
	
});
