/*
**     JavaScript Source Code
**     Created by Kalin Ganev
**     <KalinGanev [AT] Gmail (DOT) com>
**     Date Created:  2007-03-17
**     Last Modified: 2010-03-06
*/





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


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


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


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

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


		// All input data are OK.
		// Disabling "Submit" button (if exists):
		if (window.disableButtonSubmit) {
			window.disableButtonSubmit();
		}
	}
	return true;
}


window.onload = focus1stField;

