/*
	Code written by Eric Chodelka
	Copyright Interpro Development
*/

var error_title = "The following error(s) has occured:\n\n";

function login(form){
	var error_message = "";
	

	if (isEMail(form.u.value) == -1){
		error_message += "E-Mail address is invalid.\n";
	}

	form.p.value = removeChars(form.p.value);
	if(isPassword(form.p.value) == -1){
		error_message += "Password length must be greater than 8 characters.\n";
	}

	if(error_message == ""){
		return true;
	}else{
		display_message(error_title + error_message);
		return false;
	}
}

function removeChars(str){
	var newstr = "";
  	for (i = 0; i < str.length; i++) {
    		if (str.charAt(i) != '\n' && str.charAt(i) != '\r' && str.charAt(i) != ' ') {
    	  		newstr += str.charAt(i);
		}
	}
	return newstr;
}

function display_message(str){
	alert(str);
}
