var aat=0
var pt=0

function soushin() {
	var ff=document.mapo.mail.value
	var sf=0
	
	ff=trim01(ff)

	if ( ff=="" ) {
		alert("メールアドレスを入力してください")
		document.mapo.mail.focus()
		sf=1
	}

	if ( (document.mapo.mail.value != ff) && (sf==0) ) {
		alert("スペースが含まれています")
		document.mapo.mail.value=ff
		document.mapo.mail.focus()
	} else {
		if ( ff != "") {
			if ( aat == 0 ) {
				alert("@が含まれていません")
				document.mapo.mail.value=ff
				document.mapo.mail.focus()
			} else {
				if ( aat > 1 ) {
					alert("@が" + aat + "個含まれています")
					document.mapo.mail.value=ff
					document.mapo.mail.focus()
				} else {
					if ( pt == 0 ) {
						alert(". が含まれていません")
						document.mapo.mail.value=ff
						document.mapo.mail.focus()
					} else {
						var a01=document.mapo.mail1.value
						var a02=document.mapo.mail.value
						if (a01!=a02) {
							alert("メールアドレスがあっていません。")
							document.mapo.mail.focus()
						} else {
							document.mapo.submit()
						}
					}
				}
			}
		}
	}
}	

function trim01(bb) {
    var sl=0
    var i=0
    var j=1

	i=bb.length
	aat=0
	if ( i == 0 ) {
    return ""
	}
	else {
		for (j=0; j<i; j++) {
			if ( bb.substring(j,j+1) == " " ) {
				bb= bb.substring(0,j) + bb.substring(j+1,i)
				i--
				j--
			}
			if ( bb.substring(j,j+1) == "@" ) {
				aat++
			}
			if ( bb.substring(j,j+1) == "." ) {
				pt++
			}
		}
	}
	return bb
}


