/*
**     JavaScript Source Code
**     Created by Kalin Ganev
**     <KalinGanev [AT] Gmail (DOT) com>
**     Date Created:  2008-05-29
**     Last Modified: 2009-05-07
*/





function /*void*/ focusUsername () {
	if (document.getElementById('username_login')) {
		document.getElementById('username_login').focus();
	}
}


function /*void*/ focusPassword () {
	if (document.getElementById('password_login')) {
		document.getElementById('password_login').focus();
	}
}


function /*void*/ focus1stField () {
	if (document.getElementById) {
		document.getElementById('username_login') && '' == document.getElementById('username_login').value
				? window.focusUsername() : window.focusPassword();
	}
}


function /*boolean*/ validateLoginForm () {
	if (document.getElementById) {
		if (document.getElementById('username_login')) {
			// Checking username:
			if ('' == document.getElementById('username_login').value) {
				window.alert(gstr_msgErrorUsername);
				window.focusUsername();
				return false;
			}
		}

		if (document.getElementById('password_login')) {
			// Checking password:
			if ('' == document.getElementById('password_login').value) {
				window.alert(gstr_msgErrorPassword);
				window.focusPassword();
				return false;
			}
		}

		// All input data are OK.
	}
	return true;
}


window.onload = focus1stField;

