// フロートナビ

	$(function(){
		$("#container").floater({
			marginTop: 30,
			marginBottom: 80,
			speed: 600,
			agility: 0
		});
	}); 


// スムーススクロール

$(function(){
   // #で始まるアンカーをクリックした場合に処理
   $('a, map area[href*=#]').click(function() {
      // スクロールの速度
      var speed = 700;// ミリ秒
      // アンカーの値取得
      var href= $(this).attr("href");
      // 移動先を取得
      var target = $(href == "#" || href == "" ? 'html' : href);
      // 移動先を数値で取得
      var position = target.offset().top;
      // スムーススクロール
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'easeInOutExpo');
      return false;
   });
});

//メールフォーム

$(function(){
	$("form").submit(function(){
	
		//エラーの初期化
		$("p.error").remove();
		$("dl dd").removeClass("error");
		
		$(":text,textarea").filter(".validate").each(function(){
			
			//必須項目のチェック
			$(this).filter(".required").each(function(){
				if($(this).val()==""){
					$(this).parent().prepend("<p class='error'>必須項目です</p>")
				}
			})
			
			//数値のチェック
			$(this).filter(".number").each(function(){
				if(isNaN($(this).val())){
					$(this).parent().prepend("<p class='error'>数値のみ入力可能です</p>")
				}
			})
			
			//メールアドレスのチェック
			$(this).filter(".mail").each(function(){
				if($(this).val() && !$(this).val().match(/.+@.+\..+/g)){
					$(this).parent().prepend("<p class='error'>メールアドレスの形式が異なります</p>")
				}
			})
			
			//メールアドレス確認のチェック
			$(this).filter(".mail_check").each(function(){
				if($(this).val() && $(this).val()!=$("input[name="+$(this).attr("name").replace(/^(.+)_check$/, "$1")+"]").val()){
					$(this).parent().prepend("<p class='error'>メールアドレスと内容が異なります</p>")
				}
			})
			
		})
		
		//エラーの際の処理
		if($("p.error").size() > 0){
				$('html,body').animate({ scrollTop: $("p.error:first").offset().top-40 }, 'slow');
				
				$("p.error").parent().addClass("error");
				return false;
		}
	})
})

//リダイレクト


