<!-- Validation -->
function validateinputs()

{
	if (document.theform.email_address.value == "")
  	{
    	alert("Please correct the following error: Please enter an email address.");
    	document.theform.email_address.focus();
    	return (false);
  	}
	
	if (document.theform.email_address.value != "")
  	{
     	if (!(isEmailAddr(document.theform.email_address.value)))
     		{
       			alert("Please correct the following error: Please enter valid email address");
		        document.theform.email_address.focus();
       			return (false);
     		}
    }
	
	
	
	if (document.theform.other_title.value != "")
		{
			replaceChars(document.theform.other_title.value);
			document.theform.other_title.value = temp;
		}
		
	if (document.theform.first_name.value != "")
		{
			replaceChars(document.theform.first_name.value);
			document.theform.first_name.value = temp;
		}
		
	if (document.theform.last_name.value != "")
		{
			replaceChars(document.theform.last_name.value);
			document.theform.last_name.value = temp;
		}

		if (document.theform.business_phone.value != "")
		{
			replaceChars(document.theform.business_phone.value);
			document.theform.business_phone.value = temp;
		}

	if (document.theform.mobile_phone.value != "")
		{
			replaceChars(document.theform.mobile_phone.value);
			document.theform.mobile_phone.value = temp;
		}

	 if (document.theform.postcode.value != "")
		{
			replaceChars(document.theform.postcode.value);
			document.theform.postcode.value = temp;
		}
        
    	if (document.theform.state.value != "")
		{
			replaceChars(document.theform.state.value);
			document.theform.state.value = temp;
		}

	if (document.theform.email_address.value != "")
		{
			replaceChars(document.theform.email_address.value);
			document.theform.email_address.value = temp;
		}

	
	
    if (document.theform.message_sender.value != "")
		{
			replaceChars(document.theform.message_sender.value);
			document.theform.message_sender.value = temp;
		}
    
    if (document.theform.summary_complaint.value != "")
		{
			replaceChars(document.theform.summary_complaint.value);
			document.theform.summary_complaint.value = temp;
		}
        
    if (document.theform.sender_id.value != "")
		{
			replaceChars(document.theform.sender_id.value);
			document.theform.sender_id.value = temp;
		}
        
    if (document.theform.mobile_provided.value != "")
		{
			replaceChars(document.theform.mobile_provided.value);
			document.theform.mobile_provided.value = temp;
		}
        
    if (document.theform.mobile_no.value != "")
		{
			replaceChars(document.theform.mobile_no.value);
			document.theform.mobile_no.value = temp;
		}        
     
    if (document.theform.date_email.value != "")
		{
			replaceChars(document.theform.date_email.value);
			document.theform.date_email.value = temp;
		} 
    
    if (document.theform.time_email.value != "")
		{
			replaceChars(document.theform.time_email.value);
			document.theform.time_email.value = temp;
		}
        
    if (document.theform.previous_association.value != "")
		{
			replaceChars(document.theform.previous_association.value);
			document.theform.previous_association.value = temp;
		}
        
    if (document.theform.previous_consent.value != "")
		{
			replaceChars(document.theform.previous_consent.value);
			document.theform.previous_consent.value = temp;
		}  
        
    if (document.theform.efforts_unsubscribe.value != "")
		{
			replaceChars(document.theform.efforts_unsubscribe.value);
			document.theform.efforts_unsubscribe.value = temp;
		}   
    
    if (document.theform.text_message.value != "")
		{
			replaceChars(document.theform.text_message.value);
			document.theform.text_message.value = temp;
		}   
    
    if (document.theform.txt_other.value != "")
		{
			replaceChars(document.theform.txt_other.value);
			document.theform.txt_other.value = temp;
		}   
        
    	document.theform.hidpost.value="post";
    	document.theform.submit();
  }

function isEmailAddr(email)
  {
    var result = false;
    var theStr = new String(email);
    var index = theStr.indexOf("@");
    if (index > 0)
    {
      var pindex = theStr.indexOf(".",index);
      if ((pindex > index+1) && (theStr.length > pindex+1))
	    result = true;
    }
    return result;
  }
  
function replaceChars(entry) 
{
	out = "<"; // replace this
	add = "&lt;"; // with this
	out2 = ">";
	add2 = "&gt;";
	temp = "" + entry; // temporary holder

	while (temp.indexOf(out)>-1) 
	{
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}

	while (temp.indexOf(out2)>-1) 
	{
		pos= temp.indexOf(out2);
		temp = "" + (temp.substring(0, pos) + add2 + 
		temp.substring((pos + out2.length), temp.length));
	}
	
	return temp;	
}



