

$(function(){
// begin //

$("form").submit(function(){
	$("p.err").remove();
	$(":text,textarea").removeClass("errborder");
	
	$("textarea[name='INQ_BODY']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#INQ").after("<p class='err'>※入力してください。</p>");
		}
	});
	
	$("input[name='NAME2']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#NAME").after("<p class='err'>※名を入力してください。</p>");
		}
	});
	
	$("input[name='NAME1']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#NAME").after("<p class='err'>※姓を入力してください。</p>");
		}
	});
	
	$("input[name='NAME_KANA2']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#NAME_KANA").after("<p class='err'>※名を入力してください。</p>");
		}
	});
	
	$("input[name='NAME_KANA1']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#NAME_KANA").after("<p class='err'>※姓を入力してください。</p>");
		}
	});
	
	$("input[name='TEL3']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#TEL").after("<p class='err'>※番号入力してください。</p>");
		}
	});
	
	$("input[name='TEL2']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#TEL").after("<p class='err'>※市内局番入力してください。</p>");
		}
	});
	
	$("input[name='TEL1']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#TEL").after("<p class='err'>※市外局番を入力してください。</p>");
		}
	});
	
	$("input[name='ZIP2']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#ZIP").after("<p class='err'>※4桁を入力してください。</p>");
		}
	});
	
	$("input[name='ZIP1']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#ZIP").after("<p class='err'>※3桁を入力してください。</p>");
		}
	});
	
	$("select[name='PREF_NAME']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#PREF").after("<p class='err'>※入力してください。</p>");
		}
		if($(this).val()!=""){
		$(this).removeClass("errborder");
		}
	});
	
	$("input[name='ADDRESS1']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#CITY").after("<p class='err'>※入力してください。</p>");
		}
	});
	
	$("input[name='ADDRESS2']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#TOWN").after("<p class='err'>※入力してください。</p>");
		}
	});
	
	$("input[name='email']").each(function(){
		if($(this).val()==""){
		$(this).addClass("errborder");
		$("#E-Mail").after("<p class='err'>※入力してください。</p>");
		}
		if($(this).val() && !$(this).val().match(/.+@.+\..+/g)){
		$(this).addClass("errborder");
		$("#E-Mail").after("<p class='err'>※正しく入力してください。</p>");
		}
	});
	
	if($("p.err").size() > 0){
		$('html,body').animate({ scrollTop: $(".errborder:first").offset().top-40 }, 'slow');
		$("form .errborder:first").focus();
		// $("p.error").parent().addClass("error");
		return false;
	}
});




// first-childをIE6で有効にする
if($.browser.msie && $.browser.version<7){
	$("body#Location .LifeInfoList:first-child").css("margin","0px 26px 0px 4px;");
	$("body#Location .LifeInfoList h3:first-child").css("margin","30px 0px 0px 0px");
}


// リンクの点線を消す
$("a").focus(function(){
	this.blur();
});


// ロールオーバー　オーバー時の画像名に_ovを付ける
$(".rollover").mouseover(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
}).mouseout(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
}).mousedown(function(){
	$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
}).each(function(){
	$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
});


var basesrc = $("html script[src*='common']").attr("src");　// 101207修正
var path = basesrc.substr(0, basesrc.lastIndexOf('common'));
var spacegif = path+"common/img/space.gif";

// pngロールオーバー　オーバー時の画像名に_ovを付ける
$("img.pngrollover").each(function(){
	$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
});

if($.browser.msie && $.browser.version<7){
	$("img.pngrollover").each(function(){
		$(this)
			.data("src",$(this).attr("src"))
			.attr("src",spacegif)
			.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	}).mouseover(function(){
		$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2")+"',sizingMethod='scale')");
	}).mouseout(function(){
		$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	});
	
}else{
	$("img.pngrollover").mouseover(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_ov$2"));
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
	}).mousedown(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_ov(\.[a-z]+)$/, "$1$2"));
	});
}


// pngロールオーバーなし　imgクラス名png
if($.browser.msie && $.browser.version<7){
	$(".png").each(function(){
		$(this)
			.data("src",$(this).attr("src"))
			.attr("src",spacegif)
			.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
	});
}


// ページトップへほかアンカーリンクスクロール
$("a[href^='#'],area[href^='#']").click(function(){
if($.browser.msie && $.browser.version<7){
	$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top-15},"slow","swing");
	return false;
}else{
	$('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top},"slow","swing");
	return false;
}
});

// end //
});




