function loginGest(content, fieldFocus, destination){
	if(content == 'errore'){
		msg = "Accesso fallito!";
		msg += ' Nome utente o password errati.<br>';
		msg += 'Controllare i dati inseriti e ritentare.';
	} else {
		msg = "Accesso all'amministrazione in corso...";
		window.setTimeout("loadAdmin('" + destination + "', '" + content + "')", 1000);
	}
	getElement('loginResult').innerHTML = msg;
	mostra('loginResult');
	//resetForm('', fieldFocus);
	getElement(fieldFocus).focus();
	window.setTimeout("nascondi('loginResult')", 4500);
}

function loadAdmin(destinazione, dbname){
	frm = getElement('adminLogin');
	setParam('DBName', dbname)
  setParam('adminpwd', '9543');
	frm.action = destinazione;
	frm.method = 'post';
	frm.submit();
}

function serverLoginGest(content, fieldFocus, destination){
	aContent = content.split("|");
	if(aContent[0] == 'errore'){
		msg = "Accesso fallito!";
		msg += ' Nome utente o password errati.<br>';
		msg += 'Controllare i dati inseriti e ritentare.';
	} else if(aContent[0] == 'ok'){
		msg = "Accesso all'amministrazione server in corso...";
		window.setTimeout("loadServerAdmin('" + content + "', '" + destination + "')", 2000);
	}
	getElement('loginResult').innerHTML = msg;
	mostra('loginResult');
	getElement(fieldFocus).focus();
	window.setTimeout("nascondi('loginResult')", 4500);
}

function loadServerAdmin(content, destinazione){
	$aContenr = content.split("|");
	frm = getElement('serverAdminLogin');
	setParam('DBName', 'admincommerce');
	frm.action = destinazione;
	frm.method = 'post';
	frm.submit();
}

function onkeypress_login(btn, e){
	if(getKeyPressed(e) == 'INVIO'){ 
		getElement(btn).onclick();
	} 
}

function onLoadLogin(){
	var utente = getElement('utenteAdmin');
	if(utente) utente.focus();
}

function adjustLogin(){
	var login = getElement('loginBox');
	var header = getElement('loginHeader');
	var footer = getElement('loginFooter');
	if(login && header && footer){
		var top = header.offsetTop + header.offsetHeight;
		var bottom = footer.offsetTop;
		login.style.position = 'absolute';
		login.style.top = ((top + bottom) - login.offsetHeight) * 0.43 + "px";
	}
}