%
response.expires = 0
response.expiresabsolute = Now() - 1
response.addHeader "pragma","no-cache"
response.addHeader "cache-control","private"
response.buffer=true
%>
<%
Sub errorStr(errorString)
' Display an 'oops!' image and the error message supplied
%>

<%
Response.Write("" & errorString & "
")
End Sub
Sub showForm(fromError, focusObj)
'From error indicates the user had a problem filling in the form
if not fromError then
%>
Please forward all inquiries to: sales@airgun-shop.com
or use the form below.
<%
End If
%>
(Fields marked with a * are required.)
<%
if focusObj="" then focusObj = "name"
%>
<%
End Sub
Sub saveDetails()
Dim validSubmit, focus, mailObj
validSubmit = true
if len(Request.Form.Item("name")) < 5 then
errorStr("Please supply your name.")
validSubmit=false
else if len(Request.Form.Item("submit_by")) > 5 then
if InStr(Request.Form.Item("submit_by"), "@") < 1 then
errorStr("Please supply a valid e-mail address.")
focus="submit_by"
validSubmit=false
end if
else
errorStr("Please supply an e-mail address.")
focus="submit_by"
validSubmit=false
end if
end if
if not validSubmit then
call showForm(True, focus)
else
Response.Write("Thank-you, your submission has been accepted.")
emailStr = "Name: " & Request.form.item("name") & vbCrLf & vbCrLf
emailStr = emailStr + "Address: " & request.Form.item("address") & vbCrLf & vbCrLf
emailStr = emailStr + "Comments: " & request.Form.item("details")
Set mailObj = Server.CreateObject("SMTPsvg.Mailer")
mailObj.FromName = Request.form.item("name")
mailObj.FromAddress = Request.Form.Item("submit_by")
mailObj.RemoteHost = "smtp.vhost.co.uk"
mailObj.AddRecipient "Enquiry", "sales@brocock.co.uk"
mailObj.Subject = "Submission of contact form"
mailObj.BodyText = emailStr
mailObj.Priority = 5 ' Low
mailObj.Urgent = false
mailObj.SendMail
Set mailObj = Nothing
%>
<%
end if
End Sub
%>
<%=Application("engine")%>
<%
Session("page") = "contact.asp"
Session("string") = Request.ServerVariables("QUERY_STRING")
%>

<%
' Make refresh work
Session("page") = "contact.asp"
Session("string") = Request.ServerVariables("QUERY_STRING")
' Check if the user has just submitted the form
if Request.QueryString("save") = "yes" then
call saveDetails()
else
call showForm(false, "name")
end if
%>
<%Response.Flush%>