' VB Script Document
sub CheckForm()
	if Len(Trim(ContactForm.fname.value))=0 then
		alert "Ten ban khong duoc bo trong"
		ContactForm.fname.focus
		exit sub
	end if
			
	Dim email
	email=ContactForm.femail.value
	if Len(Trim(email))=0 then
		alert "Dia chi email khong duoc bo trong"
		ContactForm.femail.focus
		exit sub
	else		
		If Not InStr(email,"@")>0 then
			alert "Email khong co dau '@'"
			ContactForm.femail.focus
			Exit sub
		end if
		if Not InStr(email,".")>0 then
			alert "Email khong co dau '.'"
			ContactForm.femail.focus
			exit sub
		else
			if InStr(email,".")<InStr(email,"@") then
				alert "Dau '.' phai o phia sau ky tu '@'"
				ContactForm.femail.focus
				exit sub
			end if			
		end if
		if Len(Left(email,InStr(email,"@")-1))<=3 then
			alert "Dia chi dung truoc ky tu '@' qua ngan"
			ContactForm.femail.focus
			exit sub
		end if
		emailx=Mid(email,InStr(email,"@")+1,Len(email))
		if Len(Left(emailx,InStr(emailx,".")-1))<=2 then
			alert "Dia chi dung truoc dau '.' qua ngan"
			ContactForm.femail.focus
			exit sub
		end if
		if Len(Right(email,Len(email)-InStr(email,".")))<=1 then
			alert "Dia chi dung sau dau '.' qua ngan"
			ContactForm.femail.focus
			exit sub
		end if
	end if	
	if Len(Trim(ContactForm.fcomment.value))=0 then
		alert "Noi dung email khong duoc de trong"
		ContactForm.fcomment.focus
		exit sub
	end if
	
	Call ContactForm.submit()
end sub

sub MailAlert(Flag)	
	if Flag = "t" then
		alert "Thong tin lien lac cua ban da duoc gui cho chung toi. Cam on!"
		exit sub
	else
		if Flag = "f" then
			alert "Thong tin lien lac cua ban chua gui duoc. Xin vui long gui lai."
			exit sub
		end if
		exit sub
	end if
end sub