function emailcheck(email) {

	var str = String(email);

	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length - 1;
	var ldot=str.indexOf(dot);

	//must be an @ and .
	if (lat == -1 || ldot == -1) {
		return false;
	}

	//@ is not first or last
	if (lat==0 || lat==lstr){
		return false;
	}

	//. is not first or last
	if (ldot==0 || ldot==lstr){
		return false;
	}

	//only one @
	if (str.indexOf(at,(lat+1))!=-1){
		return false;
	}

	//. not just before or just after @
	if (str.charAt(lat-1)==dot || str.charAt(lat+1)==dot){
		return false;
	}

	//at least one . after the @
	if (str.indexOf(dot,(lat+1))==-1){
		return false;
	}

	//no spaces
	if (str.indexOf(" ")!=-1){
		return false;
	}

	return true;
}

