function updateImg(img, src) { 
	img.src = 'images/' + src;
}

function updateGlobalImg(img, src) { 
	img.src = src;
}

String.prototype.trim = function() {
	var x = this;
	x = x.replace(/^\s*(.*)/, "$1");
	x = x.replace(/(.*?)\s*$/, "$1");
	return x;
}

function validateLogin(strng1, msg) {
	var error = "";
	
	if (strng1 == "") {
		error = msg;
	}
	else if (strng1 != "") {
		for (var i = 0; i < strng1.length; i++) {   
			var c = strng1.charAt(i);
		
			if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')))) {
				error = msg;
			}
		}
	}

	return error;
}

function submitLoginFaculty() {
	var message = "Please check your user name and password and try again. Possible errors include: incorrect capitalization or using a space between words.";
	var errors = validateLoginFaculty();
	
	if (errors != "") {
		alert(message);
	}
	else {
		document.loginFormFaculty.submit();
	}
}

function validateLoginFaculty() {
	var errors = "";
	
	errors += validateLogin(document.loginFormFaculty.loginUserNameFaculty.value.trim(), "* User name\n");
	errors += validateLogin(document.loginFormFaculty.loginPasswordFaculty.value.trim(), "* Password\n");
	
	return errors;
}

function submitLoginStudent() {
	var message = "Please check your user name and try again. Possible errors include: incorrect capitalization or using a space between words.";
	var errors = validateLoginStudent();
	
	if (errors != "") {
		alert(message);
	}
	else {
		document.loginFormStudent.submit();
	}
}

function validateLoginStudent() {
	var errors = "";
	
	errors += validateLogin(document.loginFormStudent.loginUserNameStudent.value.trim(), "* User name\n");
	
	return errors;
}
