function doLogin(userNameId, passwordId, facebookmode){
	dojo.xhrPost({
		url: "/names.nsf?login",
		content: {
			username: dojo.byId(userNameId).value, 
			password: dojo.byId(passwordId).value, 
			redirectto: dbPath + "/username.txt?open&rnd=" + Math.random()
		},
		load: function(data) {
			try {
				if( data.indexOf("Anonymous") == -1) { 
					dojo.byId("loginMsg").style.display = "block";
					dojo.byId("loginMsg").style.color = "green";
					dojo.byId("loginMsg").style.backgroundColor = "transparent"; 
					dojo.byId("loginMsg").innerHTML = jslogindologinpleasewait;
					if(location.href.indexOf("register.xsp") > -1){
						location.href = dbPath;
					}else{
						if (facebookmode == true){
							window.opener.location.href = window.opener.location.href;
							window.close(); 
						}else{
							if (window.location.href.indexOf("#") > -1){
								window.location.replace( strLeft(window.location.href, "#") );
							}else{
								window.location.replace( window.location.href );
							}
						}
					}
				} else { 
					dojo.byId("loginMsg").style.display = "block";
					dojo.byId("loginMsg").style.color = "red"; 
					dojo.byId("loginMsg").style.backgroundColor = "transparent";
					if ( dojo.cookie('DomAuthSessId') != null || dojo.cookie('LtpaToken') != null ) { 
						dojo.byId("loginMsg").innerHTML = jslogindologinnotauth;
					} else { 
						dojo.byId("loginMsg").innerHTML = jslogindologinwrongpassword; 
					} 
				}
			}catch(e){
				alert(e);
				console.error ('Error: ', error);
			}
		},
		error: function(data) {
			alert(e);
			console.error ('Error: ', error); 
		} 
	});
}
