function validate_html_tags(field, alerttxt)
{
	with (field)
	{
		lessthanindex = value.indexOf("<")
		greaterthanindex = value.indexOf(">")
		
		if ( lessthanindex >= 0 || greaterthanindex >= 0 ) 
  		{
  			alert(alerttxt);
  			return false
  		}
		else{return true}
	}
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789";
     var IsNumber = true;
     var Char;

     for(i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      		Char = sText.charAt(i); 

     		 if (ValidChars.indexOf(Char) == -1) 
         	 {
         		IsNumber = false;
         	 }
      }

   	return IsNumber;
}

function validate_email(field, alerttxt)
{
	with (field)
	{
		apos = value.indexOf("@")
		dotpos = value.lastIndexOf(".")
		
		if ( apos < 1 || ((dotpos - apos) < 2) ) 
  		{
  			alert(alerttxt);
  			return false
  		}
		else{return true}
	}
}

function validate_zip_length(field, alerttxt)
{
	var isValid = false;
	
	with (field)
	{
		
		if( value != null && value.length == 5 )
		{
			isValid = true;
		}
		else
		{
			alert(alerttxt);
		}
	}
	
	return isValid;
}

function validate_isZipNumeric(field, alerttxt)
{
	var isValid = false;
	
	with (field)
	{
		
		if( value != null && IsNumeric(value) )
		{
			isValid = true;
		}
		else
		{
			alert(alerttxt);
		}
	}
	
	return isValid;
}




function validate_required(field, alerttxt)
{
	with (field)
	{
		if (value == null || value == "")
  		{
			alert(alerttxt);
			return false
		}
		else 
		{
			return true
		}
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
	
		if ( validate_required(txtFirstName,"First name is required!") == false)
  		{  			
			txtFirstName.focus();
			return false
		}
		
		if (validate_html_tags(txtFirstName,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtFirstName.focus();
			return false
		}
		
		if ( validate_required(txtLastName,"Last name is required!") == false)
  		{
			txtLastName.focus();
			return false
		}

		if (validate_html_tags(txtLastName,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtLastName.focus();
			return false
		}

		if (validate_html_tags(txtAgency,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtAgency.focus();
			return false
		}

		if (validate_html_tags(txtAddress1,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtAddress1.focus();
			return false
		}

		if (validate_html_tags(txtAddress2,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtAddress2.focus();
			return false
		}

		if (validate_html_tags(txtCity,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtCity.focus();
			return false
		}

		if (validate_html_tags(txtLastName,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			txtLastName.focus();
			return false
		}
	
		if ( validate_zip_length(txtPostal,"Zip code must contain 5 characters!") == false)
  		{
			txtPostal.focus();
			return false
		}
		
		if ( validate_isZipNumeric(txtPostal,"Zip code must contain numeric values only!") == false)
  		{
			txtPostal.focus();
			return false
		}


		if (validate_required(email,"Email field is required!") == false)
  		{
			email.focus();
			return false
		}
		
		if (validate_email(email,"Email address is invalid!") == false)
  		{
			email.focus();
			return false
		}

		if (validate_html_tags(email,"The usage of '<' and '>' characters is not allowed! ") == false)
		{
			email.focus();
			return false
		}

		if (validate_html_tags(txtQuestion,"The usage of '<' and '>' characters is not allowed! ") == false)
  		{
			txtQuestion.focus();
			return false
		}

	}
}