function Login()
{
	this.oAjax = new sack();
	this.resetAjax();
}

Login.prototype = {
	init : function()
	{
	},

	resetAjax : function()
	{
		this.oAjax.resetData();
		this.oAjax.requestFile = "index.php";
		this.oAjax.method = "POST";
		this.oAjax.Synchron = false;
		this.oAjax.setVar('module', 'Login');
		this.callBackFunction = "";
	},

	showForgetPasswordPopup : function()
	{
		this.resetAjax();
		this.oAjax.setVar('event', 'on_LoginShowForgetPasswordPopup');
		this.oAjax.runAJAX();

		oThis = this;
		onCompletionAJAX = function () {
			oThis.callBackFunction = oThis.sendNewPassword;
			oThis.writeOutput(oAJAX.responseText);
		};
	},

	sendNewPassword : function()
	{
		this.resetAjax();
		this.oAjax.setVar('event', 'on_LoginConfirmForgetPassword');
		this.addFormValuesToAjax("forget_password");
		this.oAjax.runAJAX();

		oThis = this;
		onCompletionAJAX = function () {
			oThis.callBackFunction = oThis.sendNewPassword;
			oThis.writeOutput(oAJAX.responseText);
		};
	},

	writeOutput : function(sResponse)
	{
		var oResponse = eval(sResponse);

		// show popup
		try {
			if (oResponse.aPopup != "" && oResponse.aPopup != undefined) {
				if (oResponse.aPopup.sHeadline != undefined && oResponse.aPopup.sContent != undefined) {
					if (oResponse.aPopup.iWidth != "" && oResponse.aPopup.iWidth != undefined) {
						iWidth = oResponse.aPopup.iWidth;
					}
					if (oResponse.aPopup.iHeight != "" && oResponse.aPopup.iHeight != undefined) {
						iHeight = oResponse.aPopup.iHeight;
					}
					
					if (oResponse.aPopup.sButtons == "CLOSE") {
						oThis.callBackFunction = "";
					}

					if (document.popup == null) document.popup = new isPopup();
					document.popup.show(oResponse.aPopup.sButtons, oResponse.aPopup.sHeadline, iWidth, iHeight, oResponse.aPopup.sContent, oThis);
				}
			}
		} catch (e) {
		}
	},

	addFormValuesToAjax : function(sFormID)
	{
		var oForm = _gel(sFormID);
		if (oForm) {
			var i, oElement;
			for (i=0; i<oForm.elements.length; i++) {
				var oElement = oForm.elements[i];
				// get input fields values
				if (oElement.type=="text" || oElement.type=="hidden" || oElement.type=="password" || oElement.type=="select-one" || oElement.type=="textarea") {
					this.oAjax.setVar(oElement.name, oElement.value);
				}

				if (oElement.type=="radio" || oElement.type=="checkbox") {
					if (oElement.checked == true) {
						this.oAjax.setVar(oElement.name, oElement.value);
					}
				}

				if (oElement.type=="select-multiple") {
					for (var j = 0; j < oElement.options.length; j++) {
						sName = oElement.name + '[' + j + ']';
						if (oElement.options[j].selected || oElement.name == "aSelectedClasses") {
							this.oAjax.setVar(sName, oElement.options[j].value);
						}
					}
				}
			}
		}
	}
}