// JavaScript Document
/***********************************************************************************
*	(c) Firecast Web Solutions 2003 version 1.01 28 February 2003	          *
*	For info write to info@firecast.co.uk		          *
*	You may remove all comments for faster loading	          *		
***********************************************************************************/
function validateForm(form)
{ 
//var emailID = form.email.value;
//alert(Card_ExpMon);
//alert(expyr);
//alert(nowMonth);
//alert(nowYear);
//alert(Card_CardType);

	if (form.txt_telephonenumber.value == "")
	{ 
	   alert("Please enter your telephone number."); 
	   form.txt_telephonenumber.focus( ); 
	   return false; 
	}
	else if ((form.txt_emailaddress.value==null)||(form.txt_emailaddress.value=="")){
		alert("Please enter your email address")
		form.txt_emailaddress.focus()
		return false
	}
	else if (echeck(form.txt_emailaddress.value)==false){
		form.txt_emailaddress.value=""
		form.txt_emailaddress.focus()
		return false
	}
	else if (form.security_code.value == "")
	{ 
	   alert("Please enter the security code."); 
	   form.security_code.focus( ); 
	   return false; 
	}
}

//email validation function, called from within above validateForm function
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("The E-mail that you have entered is not valid")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("The E-mail that you have entered is not valid")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("The E-mail that you have entered is not valid")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("The E-mail that you have entered is not valid")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("The E-mail that you have entered is not valid")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("The E-mail that you have entered is not valid")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("The E-mail that you have entered is not valid")
		    return false
		 }
		 return true					
	}