function checkLogin() {
	form = document.forms[0];
	password = MD5(form.clearPass.value);
	form.clearPass.value='';

	params = "authProvider=" + form.authProvider.value + "&authUser=" + form.authUser.value + "&authPass=" + password;

	// XHR request MUST be synchronous or popup
	// blocker will kill the new window...

	xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST", "/interface/UI/resources/login.php", false);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(params);

	if (xmlhttp.responseText == '1') {
		// Login successful
		document.getElementById("logininfo").innerHTML = '<img src="/interface/UI/resources/images/check.png" />Welcome to ProHealth Care EHR.';
		document.getElementById("logininfo").style.color = '#006400';

		newW = window.open('/interface/UI/overview/overview.php', '_blank', 'fullscreen=yes, menubar=no, toolbar=no, status=no, resizable=yes');
		//newW.resizeTo(screen.availWidth-(screen.availWidth * .1), screen.availHeight-(screen.availWidth * .1));
		//newW.moveTo(0, 0);
		window.open('', '_self', ''); window.close();
		setTimeout("window.open('', '_self', ''); window.close();", 0);
		setTimeout("window.open('', '_self', ''); window.close();", 100); // Some browsers don't behave properly

	} else {
		// Login failed
		document.getElementById("logininfo").style.color = '#FF0000';
		document.getElementById("logininfo").innerHTML = '<img src="/interface/UI/resources/images/x.png" />Invalid username or password.';
		document.getElementById("sendbtn").disabled = false;
	}
}

function doLogin() {
	document.getElementById("logininfo").style.color = '#000000';
	document.getElementById("logininfo").innerHTML = '<img src="/interface/UI/resources/images/ajax_loading.gif" />Verifying...';
	document.getElementById("sendbtn").disabled = true;

	setTimeout('checkLogin();', 0);

	return false;
}

