Function IsDuplicate(MyString, StrDUp)
	Dim DupCount
	For x = 1 to len(MyString)
		if Mid(MyString, x, 1) = StrDup Then
			DupCount = DupCount + 1
			if DupCount > 1 then
				IsDuplicate = True
				Exit Function
			end if
		end if
	Next
	IsDuplicate = False
End Function

Function IsEmail(EmailString)
	dim MsMsg
	MyMsg = "System cannot accept Invalid Email"

	if (InStrB(1,EmailString,"@")+1)/2 < 2 then
		Msgbox MyMsg
		IsEmail = false
		exit function
	end if
	if IsDuplicate(EmailString, "@") then
		Msgbox MyMsg
		IsEmail = false
		exit function
	end if
	'if IsDuplicate(EmailString, ".") then
	'	MsgBox MyMsg
	'	IsEmail = false
	'	exit function
	'end if
	'if (InStrB(1,EmailString,".")+1)/2 < (InStrB(1,EmailString,"@")+1)/2 then
	'	Msgbox MyMsg
	'	IsEmail = false
	'	exit function
	'end if
	if InStrB(1,EmailString," ") <> 0 then
		Msgbox MyMsg
		IsEmail = false
		exit function
	end if
	if (InStrB(1,EmailString,".")+1)/2 = len(EmailString) then
		MsgBox MyMsg
		IsEmail = false
		exit function
	end if
	IsEmail = True
End Function


Function CheckProduct(productcode)
	window.open "product.asp?productcode=" & productcode,"wdwProduct", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=550, height=550"
End Function

Function IsSpecial(strSpecial)

	strChar = Split("!_@_#_$_%_^_&_*_(_)_<_>_,_._?_/_'_;_:_{_}_[_]_|_\_-_=_+_`_~_" & chr(34),"_")
	for x = 0 to ubound(strChar)
		if InStrB(1,strSpecial, strChar(x)) <> 0 then
			IsSpecial = True
			exit function
		end if
	next
	IsSpecial = false
End Function

Function validatechangepass()
	with frmmember
		if len(.txtnewpassword.value) < 6 then
			msgbox "Please input at least 6 characters on new password"
			validatechangepass = false
			exit function
		end if
		if .txtnewpassword.value <> .txtconfirmpassword.value then
			msgbox "New password does not match with confirmation"
			validatechangepass = false
			exit function
		end if
	end with
	validatechangepass = true
End Function

Function validateme()
	with frmmember
		if trim(.txtusername.value) = empty then
			msgbox "Please input User Name"
			.txtusername.focus
			validateme = false
			exit function
		end if
		if trim(.txtfirstname.value) = empty then
			msgbox "Please input First Name"
			.txtfirstname.focus
			validateme = false
			exit function
		end if
		if trim(.txtlastname.value) = empty then
			msgbox "Please input Last Name"
			.txtlastname.focus
			validateme = false
			exit function
		end if
		if trim(.txtmi.value) = empty then
			msgbox "Please input Middle Initial"
			.txtmi.focus
			validateme = false
			exit function
		end if
		if .txtemail.value = empty then
			msgbox "Please input Email"
			.txtemail.focus
			validateme = false
			exit function
		end if
		if .cbogender.value = empty then
			msgbox "Please select Gender"
			.cbogender.focus
			validateme = false
			exit function
		end if
		if .cbomonth.value = empty then
			msgbox "Please select Month of Birth"
			.cbomonth.focus
			validateme = false
			exit function
		end if
		if .cboday.value = empty then
			msgbox "Please select Day of Birthday"
			.cboday.focus
			validateme = false
			exit function
		end if
		if .cboyear.value = empty then
			msgbox "Please select Year of Birth"
			.cboyear.focus
			validateme = false
			exit function
		end if
		if .txtpassword.value = empty then
			msgbox "Please input Password"
			.txtpassword.focus
			validateme = false
			exit function
		end if
		
		if .txtconfirm.value = empty then
			msgbox "Please confirm Password"
			.txtconfirm.focus
			validateme = false
			exit function
		end if
		if .cboaddress4.value = empty then
			msgbox "Please select Country"
			.cboaddress4.focus
			validateme = false
			exit function
		end if
		if .cbojoinmethod.value = empty then
			msgbox "Please tell us how you've learned about us"
			.cbojoinmethod.focus
			validateme = false
			exit function
		end if
		if .cbostatement.value = empty then
			msgbox "Please select Statement to answer"
			.cbostatement.focus
			validateme = false
			exit function
		end if
		if .txtanswer.value = empty then
			msgbox "Please input Answer to this Statement"
			.txtanswer.focus
			validateme = false
			exit function
		end if
		if .txtconfirmanswer.value = empty then
			msgbox "Please Confirm Answer to Statement"
			.txtconfirmanswer.focus
			validateme = false
			exit function
		end if
		if .chkagreement.checked = false then
			msgbox "We cannot process your Membership if you don't agree to the Terms and conditions"
			'.chkagreement.focus
			validateme = false
			exit function
		end if

		if instrb(1,.txtusername.value," ") <> 0 then
			msgbox "System cannot accept User Name with Spaces"
			.txtusername.focus
			validateme = false
			exit function
		end if
		if isspecial(.txtusername.value) then
			msgbox "System cannot accept User Name with Special Characters"
			.txtusername.focus
			validateme = false
			exit function
		end if
		if len(.txtusername.value) < 4 then
			msgbox "Please input at least 4 Characters for User Name"
			.txtusername.focus
			validateme = false
			exit function
		end if
		if not isdate(.cbomonth.value & "/" & .cboday.value & "/" & .cboyear.value) then
			msgbox "Please input valid Birth Date"
			.cbomonth.focus
			validateme = false
			exit function
		else
			if Year(.txtdate.value) - .cboyear.value < 18 then
				msgbox "Sorry, minors (below 18 years old) are not allowed to become members"&vbcrlf&"However, you can still view the online catalog and purchase at"&vbcrlf&"Bionic HQ located at 2nd flr Theatre Mall Greenhills"
				validateme = false
				exit function
			end if
		end if
		if IsEmail(.txtemail.value) = false then
			.txtemail.focus
			validateme = false
			exit function
		end if
		if instrb(1,.txtymid.value," ") <> 0 then
			msgbox "System cannot accept invalid Yahoo ID"
			.txtymid.focus
			validateme = false
			exit function
		end if
		if .txtpassword.value <> .txtconfirm.value then
			msgbox "Password does not match"
			.txtpassword.focus
			validateme = false
			exit function
		end if
		if len(.txtpassword.value) < 6 then
			msgbox "Please input at least 6 characters on Password"
			.txtpassword.focus
			validateme = false
			exit function
		end if
		if .txtanswer.value <> .txtconfirmanswer.value then
			msgbox "Answer to Statement does not match"
			.txtanswer.focus
			validateme = false
			exit function
		end if
	end with
	validateme = true
End Function

Function validateupdate()
	with frmmember
		if .txtfirstname.value = empty then
			msgbox "Please input First Name"
			.txtfirstname.focus
			validateupdate = false
			exit function
		end if
		if .txtlastname.value = empty then
			msgbox "Please input Last Name"
			.txtlastname.focus
			validateupdate = false
			exit function
		end if
		if .txtmi.value = empty then
			msgbox "Please input Middle Initial"
			.txtmi.focus
			validateupdate = false
			exit function
		end if
		if .cbogender.value = empty then
			msgbox "Please select Gender"
			.cbogender.focus
			validateupdate = false
			exit function
		end if
		if .cbomonth.value = empty then
			msgbox "Please select Month of Birth"
			.cbomonth.focus
			validateupdate = false
			exit function
		end if
		if .cboday.value = empty then
			msgbox "Please select Day of Birthday"
			.cboday.focus
			validateupdate = false
			exit function
		end if
		if .cboyear.value = empty then
			msgbox "Please select Year of Birth"
			.cboyear.focus
			validateupdate = false
			exit function
		end if
		if .cboaddress4.value = empty then
			msgbox "Please select Country"
			.cboaddress4.focus
			validateupdate = false
			exit function
		end if

		if not isdate(.cbomonth.value & "/" & .cboday.value & "/" & .cboyear.value) then
			msgbox "Please input valid Birth Date"
			.cbomonth.focus
			validateupdate = false
			exit function
		else
			if Year(.txtdate.value) - .cboyear.value < 18 then
				msgbox "Sorry, minors (below 18 years old) are not allowed to become members"&vbcrlf&"However, you can still view the online catalog and purchase at"&vbcrlf&"Bionic HQ located at 2nd flr Theatre Mall Greenhills"
				validateupdate = false
				exit function
			end if
		end if
		if instrb(1,.txtymid.value," ") <> 0 then
			msgbox "System cannot accept invalid Yahoo ID"
			.txtymid.focus
			validateupdate = false
			exit function
		end if
	end with
	validateupdate = true
End Function