
function Start()
{
	this.oAjax = new sack();
	this.resetAjax();
}

Start.prototype = {
	resetAjax : function()
	{
		this.oAjax.reset();
		this.oAjax.requestFile = "index.php";
		this.oAjax.method = "POST";
		this.oAjax.Synchron = false;
		this.oAjax.setVar("module", "Start");
		this.callBackFunction = "";
	},

	callBackFunction : function()
	{
	},

	orderActionCode : function()
	{
		this.resetAjax();
		this.addFormValuesToAjax("TestAccountForm");
		this.oAjax.setVar("event", "on_StartOrderActionCode");
		this.oAjax.runAJAX();

		oThis = this;
		onCompletionAJAX = function () {
			oThis.writeOutput(oAJAX.responseText);
		};
	},

	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);
					}
				}
			}
		}
	},
	
	writeOutput : function(sResponse)
	{
		var oResponse = eval(sResponse);

		var iWidth = 400;
		var iHeight = 150;

		if (oResponse.sErrors) {
			if (oResponse.sErrors != "" && oResponse.sErrors != undefined) {
				if (document.popup == null) document.popup = new isPopup();
				document.popup.show("OK", oResponse.sHeadline, 300, 230, oResponse.sErrors);
			}
		}

		if (oResponse.sContent) {
			if (oResponse.sContent != "" && oResponse.sContent != undefined) {
				oMessengerContent = _gel("TestAccount");
				if (oMessengerContent) {
					oMessengerContent.innerHTML = oResponse.sContent;
				}
			}
		}

		// check for popup
		if (oResponse.aPopup) {
			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 (document.popup == null) document.popup = new isPopup();
					document.popup.show(oResponse.aPopup.sButtons, oResponse.aPopup.sHeadline, iWidth, iHeight, oResponse.aPopup.sContent, oThis);
				}
			}
		}

		if (oResponse.aValues) {
			if (oResponse.aValues != "" && oResponse.aValues != undefined) {
				if (typeof(oResponse.aValues) == "object") {
					for (i in oResponse.aValues) {
						if (typeof(oResponse.aValues[i]) == 'object') {
							sID = oResponse.aValues[i]['sID'];
							sContent = oResponse.aValues[i]['sContent'];
							if (sID != "" && sID != undefined && sContent != "" && sContent != undefined) {
								if (sID == 'JavaScript') {
									eval(sContent);
								} else {
									oModuleValues = _gel(sID);
									if (oModuleValues) {
										oModuleValues.innerHTML = sContent;
									}
								}
							}
						}
					}
				}
			}
		}
	}
}