
	
//Validate Email Addresses	
function validate(reqform,email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['reqform'].elements['email'].value;
   if(reg.test(address) == false) {
      alert('You Have Entered An Invalid Email Address.  Email example: user@domain.com');
      return false;
   }
}

//Reset the entire form	
	function restart()
		 { alert("Please Start Over By Completing Step 1.")
		 document.location.reload(true)
		 }

var okToSend = true

function openwindow(help)
{
   window.open(help + ".htm","my_new_window","toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=400,top=100,left=375")
}



function isemail(obj,okToSend) {
    if (obj.value.length != 0) {
	   if (obj.value.indexOf('@')==-1) {
		  alert("You entered an invalid email address!")
                  document.reqform.email.value = ""
		  okToSend=false
	   }
	}
   
}

function isinteger(obj,okToSend) {
    if (okToSend) {
	   var currchar="", decimalcount=0, filteredstring="", i=0
	   
	   fieldval=obj.value
	   
	   /* scan the string, char by char */
	   for (var i=0; i<fieldval.length; i++) {
	   
	      currchar=fieldval.substring(i,i+1)
		  
		  /* look for valid characters */
		  if ((currchar >= "0" && currchar <= "9") || (currchar=="." || currchar=="," || currchar=="-")) {
		     if (currchar!=",") {
			    filteredstring+=currchar
			 }
			 if (currchar=="-" && i > 0) { /* neg sign only allowed as first character */
			    okToSend=false
		     }
		     if (currchar==".") { /* no decimal point allowed */
			    decimalcount++
				if (decimalcount > 0) {
				   okToSend=false
				}
			 }
		  }
		  else {
		       okToSend=false
		  }
       } 
       /* replace the inputted string with a filtered string */
	   if (okToSend) {
	      obj.value=filteredstring
	   }
	   else {
	      alert("Invalid Zip Code.")
              okToSend = false
              document.reqform.zip.value = ""
	   }
	}   
	
}   
	
function isbetween(obj,minval,maxval,okToSend) {
   if (okToSend) { 
      if (obj.value.length > 0) {
         if (!(parseFloat(obj.value) >= minval && parseFloat(obj.value) <= maxval)) {
         okToSend=false
         alert("Bad input: Number must be between "+minval+" and "+maxval)
         document.reqform.zip.value = ""
                  }
      }
   }
   
}

// This function will call the other subfunctions when the user hits the submit button


function checkWholeForm(reqform)  {   
      
      checkDataEntry()
	  submitForm()
      
}







//This function checks if the name, address, city, zip, or phone fields are empty

function checkDataEntry(){

var why = ""
why += missingline()
why += checkName()
why += checkAddress()
why += checkCity()
why += checkZip()
why += checkPhone()
why += checkEmail()
why += checklocation()
why += checkDirection()
why += checkidlocCity()
why += checkidlocCS()
why += checklocationDD()
why += checkIDComment()
    if (why != "") {
        alert (why)
		document.reqform.name.focus()
        okToSend = false}
	else {okToSend = true}
}

//The following functions will check if the user entered something in the required fields

function missingline(){
  var error = ""
  var strng = ((document.reqform.name.value) && (document.reqform.address.value) && (document.reqform.city.value) && (document.reqform.zip.value) && (document.reqform.phone.value) && (document.reqform.email.value) && (document.reqform.idloc.value) && (document.reqform.IDlocdd.selectedIndex) && (document.reqform.IllDcomment.value))
  if (strng == "") {
    error = "Please fill in the following fields: \n"}
return error
}

function checkName(){
  var error = ""
  var strng = (document.reqform.name.value)
  if (strng == "") {
    error = "- Please enter your name.\n"}
return error
}

function checkAddress() {
  var error = ""
  var strng = (document.reqform.address.value)
  if (strng == "") {
    error = "- Please enter your address.\n"}
return error
}

function checkCity() {
  var error = ""
  var strng = (document.reqform.city.value)
  if (strng == "") {
    error = "- Please enter your city.\n"}
return error
}

function checkZip() {
  var error = ""
  var strng = (document.reqform.zip.value)
  if (strng == "") {
    error = "- Please enter your zip.\n"}
return error
}

function checkPhone() {
  var error = ""
  var strng = (document.reqform.phone.value)
  if (strng == "") {
    error = "- Please enter your phone number.\n"}
return error
}
function checkEmail() {
  var error = ""
  var strng = (document.reqform.email.value)
  if (strng == "") {
    error = "- Please enter your email address.\n"}
return error
}

function checklocation() {
  var error = ""
  var strng = (document.reqform.idloc.value)
  if (strng == "") {
    error = "- Please enter the location of the Illegally Dumped items.\n"}
return error
}

function checkDirection() {
  var error = ""
  var strng = (document.reqform.direction.selectedIndex)
  if (strng == "") {
    error = "- Please select a direction for the illegally dumped items.\n"}
return error
}

function checkidlocCity() {
  var error = ""
  var strng = (document.reqform.idlocCity.value)
  if (strng == "") {
    error = "- Please enter the city (community) of the illegally dumped items.\n"}
return error
}

function checkidlocCS() {
  var error = ""
  var strng = (document.reqform.idlocCS.value)
  if (strng == "") {
    error = "- Please enter the cross-street of the Illegally Dumped items.\n"}
return error
}

function checklocationDD() {
  var error = ""
  var strng = (document.reqform.IDlocdd.selectedIndex)
  if (strng == "") {
    error = "- Please select a location from the drop down list.\n"}
return error
}

function checkIDComment() {
  var error = ""
  var strng = (document.reqform.IllDcomment.value)
  if (strng == "") {
    error = "- Please enter the list of Illegally Dumped items.\n"}
return error
}


			

//This function checks if it is ok to send the form.

function submitForm() {

   if (okToSend == true) {

        document.reqform.submit()
        alert ("Form is processing. Thank you!")
}
}





