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 ValidateForm(){		
	var contentName = document.buyForm.name.value;
	var emailID= document.buyForm.email;
	var contentPhone = document.buyForm.phone.value;
	var contentMessage = document.buyForm.textToFill.value;
	if(contentName == "" || emailID == "" || contentPhone =="" || contentMessage== ""){
		alert("Please fill out all the fields");
		return false;
	}
	if(isNaN(contentPhone))
	{ 
		alert("Invalid data format.\n\nOnly numbers are allowed."); 
		document.buyForm.phone.focus();
		return false; 
	}

	if ((emailID.value==null)||(emailID.value=="")){
	alert("Please Enter your Email ID")
	document.buyForm.email.focus();
	return false;
	}
	if (echeck(emailID.value)==false){
	emailID.value="";
	document.buyForm.email.focus();
	return false; 
	}
	return true;
}
function ValidateFormSell(){
	
	var contentName = document.sellForm.name.value;
	var emailID= document.sellForm.email;
	var contentPhone = document.sellForm.phone.value;
	var contenttitle = document.sellForm.title.value;
	var contentlocation = document.sellForm.location.value;
	var contentarea = document.sellForm.area.value;
	var contentprice = document.sellForm.price.value;
	
	if(contentName == "" || emailID == "" || contentPhone =="" || contenttitle== "" || contentlocation== "" || contentarea== "" || contentprice== ""){
		alert("Please fill out all the fields");
		return false;
	}
	if(isNaN(contentPhone))
	{ 
		alert("Invalid data format.\n\nOnly numbers are allowed."); 
		document.sellForm.phone.focus();
		return false; 
	}

	if ((emailID.value==null)||(emailID.value=="")){
	alert("Please Enter your Email ID")
	document.sellForm.email.focus();
	return false;
	}
	if (echeck(emailID.value)==false){
	emailID.value="";
	document.sellForm.email.focus();
	return false; 
	}
	return true;
}