/****************************************************************************************************
* Description:
* This file includes the javascript code implemented for the registration tool plugin
*
* Notice:
* - There are no Umlaute and special characters allowed.
* - Use the given Prefixs for naming the variables (str, arr, flag, int etc.)
* - If possible do layout without using padding (IE box modell error)
* - German names for css-classes etc. are used in respect to English key words, which are reservated
*
* Versions:
* 0.1				09. Maerz 2009				Beat Schilbach (Steckborn)
****************************************************************************************************/



/****************************************************************************************************
* sendAnmeldung()
* theButton		button name of calling element
* theTarget		target step ID
* theLanguage	currently chosen website language
*
* This function decides with the help of the button name, what is loaded next
****************************************************************************************************/
function sendAnmeldung(theButton,theAction,theControl,theTarget,theLanguage)

{
	// function variables
	var stepID = document.anmeldungForm.intStep.value;
	var confirmTxtDe = "Es gehen alle bisher eingegebenen Daten verloren. Soll der Anmeldevorgang wirklich abgebrochen werden?";
	var confirmTxtFr = "All already entered data will be deleted. Do you really want to cancel the registration process?";
	var confirmTxtEn = "All already entered data will be deleted. Do you really want to cancel the registration process?";
	var tmpConfirmTxt = confirmTxtDe;

	// control
	switch (theAction)
	{
		case "cancelAction":
			
			if(theLanguage == "en") tmpConfirmTxt = confirmTxtEn;
			if(theLanguage == "fr") tmpConfirmTxt = confirmTxtFr;
			
			if(confirm(tmpConfirmTxt))
			{
				stepID = 0;
				document.anmeldungForm.buttonAction.value = theAction;
				document.anmeldungForm.intStep.value = stepID;
				document.anmeldungForm.intControlStep.value = stepID;
				document.anmeldungForm.submit();
			}
			break;
		case "stepBack":
			stepID = 0;
			document.anmeldungForm.intStep.value = theTarget;
			document.anmeldungForm.buttonAction.value = theAction;
			if(theControl != "none") stepID = theControl;
			document.anmeldungForm.intControlStep.value = stepID;
			document.anmeldungForm.submit();
			break;
		case "stepNext":
			document.anmeldungForm.buttonAction.value = theAction;
			document.anmeldungForm.intStep.value = theTarget;
			document.anmeldungForm.submit();
			break;
		default:
			stepID = 0;
			document.anmeldungForm.intStep.value = theTarget;
			document.anmeldungForm.buttonAction.value = theAction;
			if(theControl != "none") stepID = theControl;
			document.anmeldungForm.intControlStep.value = stepID;
			document.anmeldungForm.submit();
			break;
			break;
	}
	
}


/****************************************************************************************************
* euro_chf()
*
* This function changes the entry fee from EUR to CHF and other way.
****************************************************************************************************/
function euro_chf(theBasicCHF,theBasicEUR)
{
	var wahrung = document.getElementById('tWahrung').value;
	var tmp = document.getElementById('tBetrag').value;
	tmp = parseInt(tmp);
	basis1 = theBasicEUR;
	basis2 = theBasicCHF;
	if(wahrung == "EURO")
	{
		tmp = tmp - basis2;
		tmp = (tmp / 25) * 20;	// Preis der Sonderkarte(n)
		tmp = tmp + basis1;
	}
	else
	{
		tmp = tmp - basis1;
		tmp = (tmp / 20) * 25;
		tmp = tmp + basis2;
	}
	document.getElementById('tBetrag').value = tmp;
}


/****************************************************************************************************
* plus()
* 
* This function computes the value of the entry fee depending on the chosen value of 
* additional maps.
****************************************************************************************************/
function plus(theBasicCHF,theBasicEUR)
{
	var wahrung = document.getElementById('tWahrung').value;
	var basis;
	if(wahrung == "CHF")
	{
		basis = theBasicCHF;
		var tmp = document.getElementById('taSonderkarten').value;
		tmp = tmp * 25;
		tmp = basis + tmp;
	}
	if(wahrung == "EURO")
	{
		basis = theBasicEUR;
		var tmp = document.getElementById('taSonderkarten').value;
		tmp = tmp * 20;
		tmp = basis + tmp;
	}
	document.getElementById('tBetrag').value = tmp;
}


/****************************************************************************************************
* toggleDisplay()
* 
* This function toggles the visibility of the online payement information div-tag in step6.
****************************************************************************************************/
function toggleDisplay(theDiv)
{
	var div1 = document.getElementById(theDiv);
	
	if (div1.style.display == 'none')
	{
		div1.style.display = 'block';
	}
	else
	{
		div1.style.display = 'none';
	}
}

