// JavaScript Document

function checkEmail (thisString) {
    var at="@"
	var dot="."
	var lat=thisString.indexOf(at)
	var lstr=thisString.length
	var ldot=thisString.indexOf(dot)

		if (thisString.indexOf(at) == -1 )
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if  (thisString.indexOf(at) == -1 || thisString.indexOf(at) == 0
	    		|| thisString.indexOf(at) == lstr)
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if  (thisString.indexOf(dot) == -1 || thisString.indexOf(dot) == 0
	     		|| thisString.indexOf(dot) == lstr)	
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if (thisString.indexOf(at, (lat+1)) != -1)
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if (thisString.substring(lat-1, lat) == dot || thisString.substring (lat+1, lat+2) == dot )		
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if (thisString.indexOf(dot, (lat+2)) == -1)
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		if  (thisString.indexOf(" ") != -1)
				{
				alert('The e-mail address has not been entered or is invalid')
				return false;
				}
		return true
}

function checkFormSubmit (thisForm)
{ 
	if (thisForm.cftitle.value == '' || thisForm.cftitle.value == null ) 
	 		{
	 		 alert('Please enter your title');
	 		 return false;
			 }
    if (thisForm.cffirstname.value == '' || thisForm.cffirstname.value == null ) 
	 		{
	 		 alert('Please enter your first name');
	 		 return false;
			 }
	if (thisForm.cfsurname.value == '' || thisForm.cfsurname.value == null ) 
	 		{
	 		 alert('Please enter your surname name');
	 		 return false;
			 }
	if (thisForm.cfphone.value == '' || thisForm.cfphone.value == null ) 
	 		{
	 		 alert('Please enter your telephone number');
	 		 return false;
			 }		 
	if (thisForm.cfemail.value != ' ' && checkEmail (thisForm.cfemail.value) == false)
	       		{	
		   		thisForm.cfemail.value = ""
				thisForm.cfemail.focus()
				return false;
				}			
	if (thisForm.cfrequest.value == '' || thisForm.cfrequest.value == null ) 
	 		{
	 		 alert('Please enter your request');
			return false;
			 }			  								
	return true;		 
}
