	//Disadvantage: WWW server roundtrip is still done
		//attention: the order of the currencies *must* be the same
		//in *all* (currently 4) arrays!

		/* some global vars*/
		g_ccyInx = 0;	//index into currency selection
		g_ccyAmt = 1;	//amount
		g_factor = 1;	//currency/EUR; e.g. 1 for EUR, 0.51113 for DEM
		g_setVarsDone = 0;	//needed to postpone document.write() until setVars has been called

		//freezed EURO rates
		g_rates = new Array(13);
		g_rates[0] = 1;			//EUR
		g_rates[1] = 13.7603;		//ATS
		g_rates[2] = 40.3399;		//BEF
		g_rates[3] = 1.95583;		//DEM
		g_rates[4] = 166.386;		//ESP
		g_rates[5] = 5.94573;		//FIM
		g_rates[6] = 6.55957;		//FRF
		g_rates[7] = 340.750;		//GRD
		g_rates[8] = 0.787564;		//IEP
		g_rates[9] = 1936.27;		//ITL
		g_rates[10] = 40.3399;		//LUF
		g_rates[11] = 2.20371;		//NLG
		g_rates[12] = 200.482;		//PTE

		//positions after decimal point
		g_padp = new Array(13);
		g_padp[0] = 2;				//EUR
		g_padp[1] = 2;				//ATS
		g_padp[2] = 2;				//BEF
		g_padp[3] = 2;				//DEM
		g_padp[4] = 2;				//ESP
		g_padp[5] = 2;				//FIM
		g_padp[6] = 2;				//FRF
		g_padp[7] = 2;				//GRD
		g_padp[8] = 2;				//IEP
		g_padp[9] = 2;				//ITL
		g_padp[10] = 2;				//LUF
		g_padp[11] = 2;				//NLG
		g_padp[12] = 2;				//PTE

		/* Sets the needed hidden variables so that the calculations can use them on reload()
		 *
		 * @param valuesFromForm:		int: if 1: the values from the form should be used; otherwise
		 *								from the arguments
		 */
		function setVars (valuesFromForm) {
			//defaults
			ccyInx = g_ccyInx;			//index into currency selection array
			ccyAmt = g_ccyAmt;			//amount

			frm = get_form_by_name('calcFormId');
			if (valuesFromForm) {
				ccyInx = frm.ccySelect.options[frm.ccySelect.selectedIndex].value;
				ccyAmt = frm.amount.value;
			} else {
				/* if parameters are available from last submit, use them instead of the ones in the form*/
				nvPairs = getUrlNvPairs();
				nvl = nvPairs.length;
				names = new Array(nvl);
				values = new Array(nvl);
				i = 0;
				/* extract names and values*/
				while (i< nvl) {
					nv = nvPairs[i];
					eqInx = nv.indexOf('=');
					names[i] = nv.slice(0, eqInx);
					values[i] = nv.slice(eqInx+1);
					i++;
				}
				i = 0;
				/* assign index and amount*/
				while (i< nvl) {
					if (names[i] == 'ccyInx') ccyInx = values[i];
					else if (names[i] == 'ccyAmt') ccyAmt = values[i];
					i++;
				}
			}
			/* update global vars*/
			g_ccyInx = ccyInx;
			g_ccyAmt = ccyAmt;
			g_factor = 1/g_rates[g_ccyInx];
			/* update form vars*/
			frm.amount.value = ccyAmt;
			frm.ccySelect.selectedIndex = ccyInx;
			g_setVarsDone = 1;			//set flag that init is done
		}/*setVars*/

		/* Checks if setVars has already been called. If not; calls it.
		 * This functions must be called before every document.write if the results depend
		 * on the global variables g_*
		 */
		function checkSetVars () {
			if (!g_setVarsDone) setVars();
		}/*checkSetVars*/

		/* Returns the name-value pairs of the URL parameters. If the convert button has been
		 * pressed, the parameters ccyInx and ccyAmt from the form are appended to the URL and
		 * must therefore be retrieved
		 */
		function getUrlNvPairs () {
			search = location.search;
			if (search == "") {
				return new Array(0);
			} else {
				pureSearch = unescape(search.slice(1));		//get rid of the '?' at start; %26 -> &
				return pureSearch.split("&");
			}
		}/*getUrlNvPairs*/

		/* Reloads the page*/
		function reloadPage () {
			frm = get_form_by_name('calcForm');
			href = location.href;
			pathname = location.pathname;
			// %26 = '&'; '&' is incorrect HTML
			new_href = window.location.pathname + '?ccyInx=' + g_ccyInx + '%26ccyAmt=' + g_ccyAmt;
			location.replace(new_href);
		}/*reloadPage*/

		/* Calculates the value for the currency speficied with @param inx, and formats the
		 * corresponding positions after the decimal point.
		 *
		 * @param inx: int: index of currency in currency array
		 */
		function calcValue (inx) {
			var floatVal = g_ccyAmt * g_factor * g_rates[inx];
			var rawVal =  String(floatVal);
			var padp = g_padp[inx];			//positions after decimal point

			//round
			var powVal = Math.round(floatVal * Math.pow(10, padp));
			var roundedVal = String(powVal * Math.pow(10, -padp));
			//adjust decPt - could be +1 after rounding
			decPt = roundedVal.indexOf(".");
			var decPt = roundedVal.indexOf(".");
			if (decPt< 0)
				decPt = roundedVal.length;

			//add missing "0" before "."
			if (roundedVal.substr(0, 1) == ".") {
				roundedVal = "0" + roundedVal;
				decPt += 1;
			}

			//separation of the thousands
			var minSign = roundedVal.indexOf("-");
			var finalVal = roundedVal.substr(0, minSign+1);
			var preDotStr = roundedVal.substr(minSign+1, decPt);
			var curPos = preDotStr.length % 3;
			finalVal += preDotStr.substr(0, curPos);

			while (curPos< preDotStr.length) {
				if (curPos != 0)
					finalVal += "'";
				finalVal += preDotStr.substr(curPos, curPos+3);
				curPos += 3;
			}

			// positions after decimal point
			if (padp == 0) padp = -1;			//make decimal point disappear
			var tail = roundedVal.substr(decPt, padp+1);
			//append as many "0" as necessary; the '=' because to catch
			//cases like 0.20 =>tail would be '.2' =>padp=2 =>no final '.20'
			if (tail.length<= padp) {
				if (tail.length == 0)
					tail = ".";
				for (var i=tail.length; i<=padp; i++)
					tail += "0";
			}
			finalVal += tail;
			return finalVal;
		}/*calcValue*/
		
		/* The following functions were copied from default.js of dn5 in order to make the calculator script work */
		
		function domCompliance ()
		{
		    if (document.all) return 3;
		    if (document.getElementById) return 1;
		    if (document.layers) return 2;
		    return -1;
		}
		
		function get_form_by_name (the_name) {					
			return get_form_by_name_and_win(window, the_name);
		}

		function get_form_by_name_and_win (win, the_name)
		{
		    if (domCompliance() == 3)
		    {
			// probably Internet Explorer
//			return win.document.all[the_name];
			return win.document.getElementById(the_name);
		    }
		    else if (domCompliance() == 2)
		    {
			// Netscape Navigator
			for (l=0; l<win.document.layers.length; l++) {
			    doc = win.document.layers[l].document;
			    for (f=0; f<doc.forms.length; f++) {
				the_form = doc.forms[f];
//				if (the_form.name == the_name) {
				if (the_form.id == the_name) {
				    return the_form;
				}
			    }
			}
			// if no layers defined, use this code
			for (f=0; f<win.document.forms.length; f++) {
			    the_form = win.document.forms[f];
//			    if (the_form.name == the_name) {
				if (the_form.id == the_name) {
					return the_form;
			    }
			}
		    }
		    else if (domCompliance() == 1)
		    {
			// DOM1-compliant
			if (win.document.getElementById(the_name))
			    return win.document.getElementById(the_name);
			else
			{
			    //shouldn't happen, but did happen e.g. with mozilla 1.1/Solaris
			    for (f=0; f<win.document.forms.length; f++) {
				the_form = win.document.forms[f];
//				if (the_form.name == the_name) {
				if (the_form.id == the_name) {
				    return the_form;
				}
			    }
			}
		    }
		    else
		    {
			// browser not supported or element not found
			alert('Sorry, your browser version is not supported (error getting form)');
			return 0;
		    }
		}
