

//==============================================================================
// Login
//==============================================================================
function loginbtn_onclick() {
    ClearMsg();
    Login("chatportal.php");
}

function Login(nexturl)
{
	try
	{
		var username = escape("" + document.getElementById("logusername").value);
		var password = escape("" + document.getElementById("logpassword").value);
		var url = "logintry.php"+"?sessid=" + sessid + "&username=" + username + "&password=" + password;
		var ajaxlogin = new AjaxCall(url, LoginResponseCall, nexturl, "A");

		SetCtrlEnable("loginbtn", false);
		ajaxlogin.Exec();
		SetCtrlEnable("loginbtn", true);
		return;
	}
	catch (e)
	{
		MyError1("Login Fout 1: " + e.description);
	}
	SetCtrlEnable("loginbtn", true);
}

function LoginResponseCall(txt, _this)
{
	var txtarr = txt.split(" ");
	var first = txtarr.shift();

	try
	{
		if (first == "true")
		{
		    MyError("");
		    MyError1("");
		    document.getElementById("logpassword").value = "";
		    FullscreenPopUp(_this.nexturl, 191); 
		}
		else
		{
		    MyError1( "Niet ingelogd (" + txt + ")");
		    document.getElementById("logpassword").value = "";
		}
	}
	catch (e)
	{
		MyError1("Login Fout 2: " + e.description);
}
    MyError("");
	SetCtrlEnable("loginbtn", true);
}
 
function LimitText(field, maxlen)
{
	if (field.value.length > maxlen)
	{
		field.value = field.value.substring(0, maxlen);
		// alert('your input has been truncated!');
	}
} 
  