function TLogin(pvHtmlElId, pvSSL, pvSSLDomain, pvLoggedIn, pvFocusUserName)
{
	this.htmlel = getEl(pvHtmlElId);
	this.ssl = pvSSL;
	this.ssldomain = pvSSLDomain;
	this.loggedin = pvLoggedIn;
	var lvEl = this;

	if (!this.loggedin)
	{
		this.usernamefield = getEl(pvHtmlElId + "_usn");
		this.passwordfield = getEl(pvHtmlElId + "_pwd");
		this.messagecell = getEl(pvHtmlElId + "_msg");
		attachEvt(getEl(pvHtmlElId + "_li"), "click", function(event) { return lvEl.login(event); });
		var lvFocusEl = pvFocusUserName ? this.usernamefield : this.passwordfield;

		//Check if the login is visible, otherwise we will get an error in IE when trying to focus
		if (this.htmlel.style.display.toLowerCase() != "none" && this.htmlel.parentNode.style.display.toLowerCase() != "none")
		{
			attachEvt(window, "load", function()
			{
				lvFocusEl.focus();
				lvFocusEl.select();
			});
		}
	}
	else { attachEvt(getEl(pvHtmlElId + "_lo"), "click", function() { lvEl.switchSSL(); }); }
}

TLogin.prototype.login = function(evt)
{
	var lvResult = false;
	var lvFocusEl = this.usernamefield;
	if (this.usernamefield.value == "")
	{
		lvMessage = "Gebruikersnaam is een verplicht veld";
	}
	else
	{
		if (this.passwordfield.value == "")
		{
			lvMessage = "Wachtwoord is een verplicht veld";
			lvFocusEl = this.passwordfield;
		}
		else { lvResult = true; }
	}

	if (lvResult)
	{
		if (this.ssl) { this.switchSSL(); }
		return true;
	}
	else
	{
		if (this.messagecell != null) { this.messagecell.innerHTML = lvMessage; }
		else { alert(lvMessage); }
		lvFocusEl.focus();
		return preventDefault(evt);
	}
}

TLogin.prototype.switchSSL = function()
{
	var lvForm = document.forms[0];
	var lvPath = lvForm.action;

	if (lvPath.indexOf("http") == -1)
	{
		lvPath = getCurrentPath() + lvPath;
	}

	if (lvPath.indexOf("//localhost") == -1 && lvPath.indexOf("//127.0.0.1") == -1)
	{
		lvPath = lvPath.replace("http:", "").replace("https:", "").replace("//", "");
		var lvPrefix = "http";
		if (!this.loggedin)
		{
			lvPrefix += "s";
			if (this.ssldomain != "") { lvPath = lvPath.replace(getServer(lvPath), this.ssldomain); }
		}
		lvPath = lvPrefix + "://" + lvPath;
		lvForm.action = lvPath;
	}
}