<!---Added to prevent an error if check box is empty--->
<cfparam name="url.all" default="">
<cfparam name="FORM.allst" default="">
<cfparam name="FORM.all" default="no">
<!--- Remember this forms email address if captcha is wrong only--->
 <cfif isDefined("FORM.toAddress")>
 <cfset SESSION.address = FORM.toAddress>
 <cfset toAddressPreFill = FORM.toAddress>
 
<!--- Pre fill to address form after captcha is wrong --->
<cfelseif isDefined("SESSION.address")>
 <CFSET toAddressPreFill = SESSION.address>
 
<!--- Show empty string the first visit --->
<cfelse>
 <cfset toAddressPreFill = "">
</cfif>
<!---End  --->
 
<!--- Remember this forms subject if captcha is wrong only--->
<cfif isDefined("FORM.subject")>
  <cfset SESSION.subject = FORM.subject>
 <cfset subjectPreFill = FORM.subject>
 
<!--- Pre fill subject form after captcha is wrong --->
 <cfelseif isDefined("SESSION.subject")>
 <CFSET subjectPreFill = SESSION.subject>
 
<!--- Show empty string the first visit --->
<cfelse>
 <cfset subjectPreFill = "Request A Quote For Mailing List">
</cfif>
<!---End  --->
 
<!--- Remember this forms message if captcha is wrong only--->
<cfif isDefined("FORM.messageBody")>
  <cfset SESSION.message = FORM.messageBody>
 <cfset messageBodyPreFill = FORM.messageBody>
 
<!--- Pre fill message body form after captcha is wrong --->
  <cfelseif isDefined("SESSION.message")>
 <CFSET messageBodyPreFill = SESSION.message>
 
<!--- Show empty string the first visit --->
<cfelse>
  <cfset messageBodyPreFill = "">
</cfif>
<!---End  --->
 
<!---<!--- Remember this forms email address if captcha is wrong only--->
 <cfif isDefined("FORM.all")>
 <cfset SESSION.add = FORM.all>
 <cfset PreFill = FORM.all>
 
<!--- Pre fill to address form after captcha is wrong --->
<cfelseif isDefined("SESSION.add")>
 <CFSET PreFill = SESSION.add>
 
<!--- Show empty string the first visit --->
<cfelse>
 <cfset PreFill = "">
</cfif>
<!---End  --->--->
 
<!---Get all US states that are active--->
<cfquery name="allStates" datasource="#request.dsn#" username="#request.un#" password="#request.pw#">
SELECT	statename
FROM	states
WHERE	IsActive = 1
		AND CountryID = 1
</cfquery>
    <div class='featurebox_left'>
 
<!---Added captcha test here--->
 
<cffunction name="makeRandomString" returnType="string" output="false">
   <cfset var chars = "23456789ABCDEFHJKMNPRS">
   <cfset var length = randRange(2,4)>
   <cfset var result = "">
   <cfset var i = "">
   <cfset var char = "">
 
   <cfscript>
   for(i=1; i <= length; i++) {
      char = mid(chars, randRange(1, len(chars)),1);
      result&=char;
   }
   </cfscript>
 
   <cfreturn result>
</cffunction>
 
<cfset showForm = true>
 
<cfparam name="form.captcha" default="">
<cfparam name="form.captchaHash" default="">
 
<cfif isDefined("form.send")>
   <cfset errors = "">
 
   <cfif hash(ucase(form.captcha)) neq form.captchaHash>
      <cfset errors = errors & "You Did Not Enter The Right Text Below.">
   </cfif>
 
   <cfif errors is "">
      <!--- do something here --->
      <cfset showForm = false>
   </cfif>
 
</cfif>
 
<cfif showForm>
 
   <cfset captcha = makeRandomString()>
   <cfset captchaHash = hash(captcha)>
   <cfoutput>
<!---End captcha test--->
 <!--- Provide simple form for recipient and message --->
 
 <cfform action="#cgi.script_name#" method="post">
 
 <table width="100%"  border="0" align="center" cellpadding="2"cellspacing="2">
 <!--- Table row: Input for Email Address --->
 <tr>
 <td> </td>
 <td>
<!--- Display Error Message--->
    <cfif isDefined("errors")>
   <img src="graphics/warning.png" hspace="5" vspace="5" align="absmiddle" /><strong>#errors#</strong>
   </cfif></td>
 </tr>
 <tr>
 <th valign="top">Email:</th>
 <td>
     <cfinput type="text"
     name="toAddress"
     value="#toAddressPreFill#"
     message="You must provide an email address (example@gmail.com)"
     validateat="onSubmit,onServer"
     validate="email"
     required="yes"
     size="50"> </td>
 </tr>
 
 <!--- Table row: Input for E-mail Subject --->
 <tr>
 <th valign="top">Subject:</th>
 <td>
     <cfinput type="text"
     name="subject"
     value="#subjectPreFill#"
     required="yes"
     size="50" maxlength="100"
     message="You must provide a subject for the email. (Maximum 100 characters)"> </td>
 </tr>
 
 <!--- Table row: Input for actual Message Text --->
 <tr>
 <th valign="top">Your Message:</th>
 <td>
     <cftextarea name="messageBody"
     cols="50"
     rows="5"
     wrap="hard"
     required="yes"
     value="#messageBodyPreFill#"
     maxlength="1000"
     message="You must provide a message body. (Maximum 1000 characters)" /> </td>
 </tr>
    <!---Table row: check box for all states --->
 <tr>
 <td><!---Howdy #session.name#---></td>
 <td valign="top">
 
<!---<cfinput type="checkbox" name="all" checked="no"> All 50 States--->
<cfinput type="checkbox"
name="all"
checked="#isDefined('form.all')#"> All 50 States
 
</td>
 </tr>
<tr>
  <td> </td>
  <td>
  <cfloop query="allstates">
  <input type="checkbox" name="allst" value="#statename#"> #statename#<br />
  </cfloop>
  </td>
</tr>
  <!--- Table row: Input for captcha text --->
<tr>
  <td valign="top"> </td>
  <td>Enter Text Below: 
      <cfinput type="text"
      name="captcha"
      required="yes"
      size="10"
      message="Please type the letters and numbers below.">
      </td>
</tr>
 <!--- Table row: Display Captcha Image --->
<tr>
<td> </td>
     <td>
     <cfimage action="captcha" width="300" height="75" text="#captcha#">
     <cfinput type="hidden"
     name="captchaHash"
     value="#captchaHash#">     </td>
</tr>
 <!--- Table row: Submit button to send message --->
 <tr>
 <td valign="top"> </td>
 <td>
     <cfinput type="submit"
     name="send"
     validate="submitonce"
     value="Send Message Now"> </td>
 </tr>
 <tr>
   <td colspan="2" valign="top"> </td>
   </tr>
 </table>
 </cfform>
    </cfoutput>
 
<cfelse>
<!---Go to here if captcha is correct--->
 
  <!--- We do not want ColdFusion to suppress whitespace here --->
  <cfprocessingdirective suppressWhitespace="No">
 
<!--- Send the mail message, based on form input --->
<cfmail
 subject="#FORM.subject#" type="html"
 from='#FORM.toAddress#'
 to="webmaster@firefightingnews.com"
 bcc="mcconaghey@vzw.blackberry.net"
  replyto="#FORM.toAddress#"
>
<b>This is a message from request a quote from our fire department mailing list page on FireFightingNews.com:</b>
<p></p>
#FORM.messageBody#
<p></p>
#FORM.all#
<p></p>
#FORM.allst#
<br />
</cfmail>
 
  </cfprocessingdirective>
<!---Clear all fields if email was successful--->
 <cfscript>
   StructClear(Session);
</cfscript>
<!---End--->
 
 <!--- Display "success" message to user --->
<cfinclude template="email_ok.cfm">
 
</cfif>
</div>