jQuery(function($) {
						   
	$("#website").hide();				   
	$("#other").hide();	
	$("#user").hide	();
	$("#midashi03").hide();
	$("#contact_bt").hide();
	$("#title01").change(function () {
		
		//セレクトによって切り替える処理
        var selectedObj = $(this).children("option:selected");
		$("#website").hide();				   
		$("#other").hide();	
		$("#user").hide	();
		$("#midashi03").hide();
		$("#contact_bt").hide();

        if(selectedObj.val() == 1){
			
			titleNo01();
			$subject = selectedObj.text();
		}
		else if(selectedObj.val() == 2){
			titleNo02();
			$subject = selectedObj.text();
		}
		else if(selectedObj.val() == 3){
			titleNo02();
			$subject = selectedObj.text();
		}		
		
		
		//種別がWebサイト制作だったときの表示
		function titleNo01(){
			$("#midashi03").show();		
			$("#website").show();
			$("#user").show();
			$("#contact_bt").show();
			$("div #website .NullCheck").removeClass("NChide");
			$("div #other .NullCheck").addClass("NChide");			
		}


		//種別がパートナー＆その他だったときの表示
		function titleNo02(){
			$("#midashi03").show();		
			$("#other").show();
			$("#user").show();
			$("#contact_bt").show();
			$("div #other .NullCheck").removeClass("NChide");
			$("div #website .NullCheck").addClass("NChide");			
		}
	}).change();
	
	
	
	  //----------------------------------------------
	  //
	  //  リアルタイムエラーチェック処理ここから
      //
      //-----------------------------------------------
		
		
		// *必須項目のチェック処理
		$(".errmsg").hide();
		$(".NullCheck").blur( function () {
			if($(this).val() == ""){
				$(this).nextAll().filter("span").hide();
				$(this).nextAll().filter("span").text($(this).attr("alt"));
				$(this).nextAll().filter("span").fadeIn("slow");
			}
			if($(this).val() != ""){
				
				$(this).nextAll().filter("span").fadeOut("slow");		
				
			}
		} );
		

		// *メールアドレス形式のチェック処理
		$(".EmailCheck").blur( function () {
										 						 
			txt = $(this).val();
			data = txt.match(/^\S+@\S+\.\S+$/);
			
			if($(this).val() == ""){
				$(this).nextAll().filter("span").hide();
				$(this).nextAll().filter("span").text("　！メールアドレスをご入力ください");
				$(this).nextAll().filter("span").fadeIn("slow");
			}
			
			if($(this).val() != ""){
				
				if(!data){
					$(this).nextAll().filter("span").hide();
					$(this).nextAll().filter("span").text($(this).attr("alt"));
					$(this).nextAll().filter("span").fadeIn("slow");
				}
				else{
					
				$(this).nextAll().filter("span").fadeOut("slow");
				
				}				
				
			}
			
			} );
		
		
		//----------------------------------------------
		//
		//  送信ボタンを押した際のアクションここから
		//
		//-----------------------------------------------

		$("#lastCheck").submit( function () {
			var emailflg = 0;
			var nullflg  = 0;
			nck();							  
			eck();							  
			if(nullflg == 1  && emailflg == 1){

			}
			else{
	
			alert("入力内容をご確認ください。");
			return false;
			}
			
			//ここでNullチェックをします
			function nck(){
				
			var cnt = $('.NullCheck').length;
			

			for (i = 0; i < $('.NullCheck').length; i++) {

				if($(".NullCheck").eq(i).not(".NChide").val() == ""){
					$(".NullCheck").eq(i).nextAll().filter("span").hide();					
					$(".NullCheck").eq(i).nextAll().filter("span").text($(".NullCheck").eq(i).attr("alt"));
					$(".NullCheck").eq(i).nextAll().filter("span").fadeIn("slow");
				}
				else{

					$(".NullCheck").eq(i).nextAll().filter("span").fadeOut("slow");
					cnt -= 1;
				}

				if(cnt == 0){
					nullflg = 1;
				}
			}
			
			
			
			}
			
			//ここでEmailチェックをします *Eメール入力欄が1つ以上あるときはこれでは不可なので注意
			function eck(){
				
			txt = $(".EmailCheck").val();
			data = txt.match(/^\S+@\S+\.\S+$/);
			
			if($(".EmailCheck").val() == ""){
				$(".EmailCheck").nextAll().filter("span").hide();
				$(".EmailCheck").nextAll().filter("span").text("　！メールアドレスを入力してください");
				$(".EmailCheck").nextAll().filter("span").fadeIn("slow");
				
			}
			else{
				
				if(!data){
					$(".EmailCheck").nextAll().filter("span").hide();
					$(".EmailCheck").nextAll().filter("span").text($(".EmailCheck").attr("alt"));
					$(".EmailCheck").nextAll().filter("span").fadeIn("slow");

				}
				else{
					
				$(".EmailCheck").nextAll().filter("span").fadeOut("slow");
				emailflg = 1;
				
				}				
				
			}
			return false;
			
			}			

		});
		


		
	  
});





	  
