function swapimg(obj) {
	if(obj.src.match(/_f2.(jpg|gif|png)/)) {
		obj.src = obj.src.replace('_f2', '');
	} else {
		obj.src = obj.src.replace(/\.(jpg|gif|png)$/, "_f2.$1");
	}
}
function isMaxlength(obj){
  var mlength = obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
  if (obj.getAttribute && obj.value.length > mlength)
    obj.value = obj.value.substring(0,mlength);
}

function isValid(){
	var errs = 0;
	$("p.CPCaution1").remove();
	$("form input:hidden[value='_must_']").each(function(){
		var mustchk = 0;
		$("form input:visible[name="+$(this).attr("name")+"], textarea[name="+$(this).attr("name")+"], select[name="+$(this).attr("name")+"]").each(function() {
			var val = $.trim($(this).val());
			if (val == '') mustchk = 1;
		});
		errs += mustchk;
		if(mustchk == 1) $(this).closest("td").append('<p class="CPCaution1 red">入力されていません</p>');
	});
	if ($("form #email").val() != $("form #email2").val()) {
		$("form #email,form #email2").closest("td").append('<p class="CPCaution1 red">E-MailとE-Mail（確認）が一致しません</p>');
		return false;
	}
	if (errs > 0) {
		alert('入力された内容にエラーがあります。\nご確認ください。');
		return false;
	}
	return true;
}
