function getFocus(){
	this.email_obj.focus();
}

function EmailChecker(email_obj){
	this.email_obj = email_obj;
	email_str = email_obj.value;
	
	this.focus = getFocus;
	
	this.error_id = 0;
	
	error_messages = new Array();
	
	error_messages[0] = 0;
	error_messages[1] = "Email address is blank.";
	error_messages[2] = "Email address does not contain the '@' symbol";
	error_messages[3] = "Email address contains the '@' symbol more than once";
	error_messages[4] = "Email address cannot end with the '@' symbol";
	error_messages[5] = "Email address cannot start with the '@' symbol";
	error_messages[6] = "Email address cannot contain the symbol pairs '.@', '..' or '@.'";
	error_messages[7] = "Email address must contain an '.' symbol";
	error_messages[8] = "Email address cannot end with the '.' symbol";
	error_messages[9] = "Email address cannot start with the '.' symbol";
	error_messages[10] = "Email address contains an invalid symbol";
	
	if(email_str == ''){
		this.error_id = 1;
	}
	else if(email_str.indexOf("@") == -1){
		this.error_id = 2;
	}
	else if(email_str.split("@").length > 2){
		this.error_id = 3;
	}
	else if(email_str.charAt( (email_str.length - 1) ) == "@"){
		this.error_id = 4;
	}
	else if(email_str.charAt(0) == "@"){
		this.error_id = 5;
	}
	else if(email_str.indexOf(".@") >=0 | email_str.indexOf("..") >=0 | email_str.indexOf("@.") >=0 ){
		this.error_id = 6;
	}
	else if(email_str.indexOf(".") == -1){
		this.error_id = 7;
	}
	else if(email_str.charAt( (email_str.length - 1) ) == "."){
		this.error_id = 8;
	}
	else if(email_str.charAt(0) == "."){
		this.error_id = 9;
	}
	
	if (this.error_id == 0){
		var regex = /^([a-zA-Z0-9_\-])+([a-zA-Z0-9_\.\-])*\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
		var found_regex = regex.exec(email_str);
	
		if(found_regex == null){
			this.error_id = 10;
		}
	} //end if this.error_id == 0
	
	this.error_msg = error_messages[this.error_id];
	
} //end EmailChecker()
