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("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	
	
function validate(x) {

    //var theMessage = "Please enter the following details: \n----------------------------------------\n";
    //var noErrors = theMessage

    // make sure field is not blank
   	if (x.name.value=="") {
	alert("Enter the Full name");
	x.name.focus();
	return false;
	//theMessage = theMessage + "\n -> Full Name";
    }
	if (x.address.value=="") {
	alert("Enter the Address");
	x.address.focus();
	return false;
    //theMessage = theMessage + "\n -> Address";
    }
	if (x.postcode.value=="") {
	alert("Enter the postcode");
	x.postcode.focus();
	return false;
    //theMessage = theMessage + "\n -> Postcode";
    }
	if (x.phone.value=="") {
	alert("Enter the phone");
	x.phone.focus();
	return false;
    //theMessage = theMessage + "\n -> Contact Telephone Number";
    }
	if (x.phone1.value=="") {
	alert("Enter the alternate phone");
	x.phone1.focus();
	return false;
    //theMessage = theMessage + "\n -> Alternate Telephone Number";
    }
	if (x.email.value=="")
	{
    alert("Enter the email");
	x.email.focus();
	return false;
	//theMessage = theMessage + "\n -> Email address";
	}
	if (echeck(x.email.value)==false)
	{
		x.email.value=""
		x.email.focus();
		return false
	}
	
  if (x.types.value=="") {
	alert("Select the types of mortgage");
	x.types.focus();
	return false;
    //theMessage = theMessage + "\n -> Types of Mortgage";
    }
	if (x.amtmort.value=="") {
    alert("Enter the amount mortgage");
	x.amtmort.focus();
	return false;
	//theMessage = theMessage + "\n -> Amount of Mortgage Required";
    }
	if((x.badcredit[0].checked== false) && (x.badcredit[1].checked== false) )
	{
	alert("Choose the bad credit/ccj's");
	x.badcredit[0].focus();
	return false;
	}	
    //theMessage = theMessage + "\n -> Any Bad credit or CCJ's";
    
	if (x.besttime.value=="") {
    alert("Enter the time to call");
	x.besttime.focus();
	return false;
	//theMessage = theMessage + "\n -> Best time to call";
    }
	
    // If no errors, submit the form
   /* if (theMessage == noErrors) {
    return true;

    } else {

    // If errors were found, show alert message
    alert(theMessage);
    return false;
    }*/
	
	}
	
function numbersonly(e)
{
var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8)
	{ //if the key isn't the backspace key (which we should allow)
		if (unicode<48||unicode>57) //if not a number
		return false //disable key press
	}
}

