﻿//set focus() on fist field in loginform
if (document.getElementById('loginform').elements.length) {
	document.getElementById('loginform').Name.focus();
}

function isblank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function check_empty(e)
{
	var msg;
	var textAll = "Por favor, especifique su e-mail y contraseña.";
	var textName = "";
	var textPassw = "";

	if ((e.Name.value == null) || (e.Name.value == "") || isblank(e.Name.value)) {
		textName = "Por favor, especifique su e-mail.\n";
	}
		if ((e.password.value == null) || (e.password.value == "") || isblank(e.password.value)) {
			textPassw = "Por favor, especifique su contraseña.";
		}
	if (e.Name.style) e.Name.style.backgroundColor = textName != "" ? '#FFCC66':'#FFFFFF';
	if (e.Name.style) e.password.style.backgroundColor = textPassw != "" ? '#FFCC66':'#FFFFFF';
		
	if ((textPassw == "") && (textName == "")) return true;
	if (textName && textPassw) {
		msg = textAll;
	} else {
		msg = textName + textPassw;
	}		
	alert(msg);
	return false;
}

