function CheckEmail(sEmail){
	str = document.getElementById(sEmail).value;
	var Errors = false;
	var Emailerrors = false;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if(str == ""){
		Emailerrors = true;	
	}
	if (str.indexOf(at)==-1){
	  Emailerrors = true;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   Emailerrors = true;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		Emailerrors = true;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		Emailerrors = true;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		Emailerrors = true;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		Emailerrors = true;
	 }
	
	 if (str.indexOf(" ")!=-1){
		Emailerrors = true;
	 }
	 if(Emailerrors){
		return false;
	 }else{
		return true;	 
	 }
}
function quote_form_mandatory() {
	
	var msg = '';
	if(document.getElementById('firstname').value == '') {
		msg += '\r\nFirst Name is required.';
	}
	if(document.getElementById('lastname').value == '') {
		msg += '\r\nSurname is required.';
	}
	if(document.getElementById('telephone').value == '') {
		msg += '\r\nTelephone is required.';
	}
	var email = document.getElementById('email').value;
	if(email == '') {
		msg += '\r\nEmail is required.';
	}
	else if(!CheckEmail('email')) {
		msg += '\r\nEmail is invalid.';
	}
	if(msg != '') {
		alert('Please complete the form:\r\n' + msg);
		return false;
	}
	
	return true;
}
