function frmLogin_onSubmit()
	dim thisForm : set thisForm = document.frmLogin
	if thisForm.txtUserName.value = "" then
		msgbox "Username is required." & chr(13) & "Please enter a username.", 16
		thisForm.txtUserName.focus()
		frmLogin_onSubmit = false
		exit function
	elseif thisForm.txtPassword.value = "" then
		msgbox "Password is required." & chr(13) & "Please enter a password.", 16
		thisForm.txtPassword.focus()
		frmLogin_onSubmit = false
		exit function
	end if
end function


sub requestPW(strEmail)
	if trim(strEmail) = "" then
		strEmail = inputbox("Please enter your email address."&vbcrlf&vbcrlf&"Your password will be emailed to your mailbox.","Enter your email address")
	end if
	if trim(strEmail) = "" then
		exit sub
	else
		window.location="/SuperiorCourt/AttorneyCalendar/processing.asp?txtDoWhat=emailPassword&txtEmail="&strEmail
	end if
end sub

sub txtEmail_onBlur()
	dim strEmail : strEmail = trim(document.frmUserInfo.txtEmail.value)
	dim intAtPos: intAtPos = instr(strEmail, "@")
	if intAtPos < 2 or instr(intAtPos+1, strEmail, "@") > 0 then
		msgbox "This is not a valid email address"&chr(13)&chr(13)&"A valid email address is in the form user@domain."&chr(13)&"For example: qadams@superiorcourt.maricopa.gov",16
'		document.frmUserInfo.txtEmail.focus()
		exit sub
	end if
	
	strUsername = left(strEmail, intAtPos-1)
	document.frmUserInfo.txtUsername.value = strUsername
end sub

function frmUserInfo_onSubmit()
	dim errorBln: errorBln=false: dim errorStr: errorStr="": dim elementObj
	dim thisForm : set thisForm = document.frmUserInfo
	if errorBln=false and trim(thisForm.txtFirstName.value)="" then
		errorBln=true: errorStr="First Name is required.": set elementObj=thisForm.txtFirstName
	end if
	if errorBln=false and trim(thisForm.txtLastName.value)="" then
		errorBln=true: errorStr="Last Name is required.": set elementObj=thisForm.txtLastName
	end if
	if errorBln=false and trim(thisForm.txtEmail.value)="" then
		errorBln=true: errorStr="Email is required.": set elementObj=thisForm.txtEmail
	end if
	if errorBln=false and trim(thisForm.txtBarID.value)="" then
		errorBln=true: errorStr="Your bar number is required.": set elementObj=thisForm.txtBArID
	end if
	
	
	if errorBln=true then
		call show("An error has occurred:"&vbcrlf&vbcrlf&errorStr,vbCritical)
		elementObj.focus()
		frmUserInfo_onSubmit = false
		exit function
	end if
	if thisForm.txtDoWhat.value="addUser" then
		thisForm.txtPassword.value=genpass("a",6)
	end if
end function

function show(msgStr,buttonsStr)
	show = msgBox(msgStr,buttonsStr)
end function

sub showNgo(msgStr,buttonsStr,loc)
	call show(msgStr,buttonsStr)
	if lcase(left(loc,4)) = "back" then
		if len(loc) > 4 then
			window.history.go("-" & mid(loc,5))
		else
			window.history.back()
		end if
	else
		window.location = loc
	end if
end sub