function calc()
{
	if($('amount'))
	{   amount = $F('amount').replace(",",".");
		amount = parseFloat(amount); 
	}
	if (isNaN(amount))
	{
		amount = 1;
		$('amount').value = amount;
	}
	var k1 = $F('k1');
	var k2 = $F('k2');
	
	$("wk1").update(number_format(amount,2,",","."));
	$("wk2").update(number_format(amount*k1,4,",","."));
	$("wk21").update(number_format(amount*k2,4,",","."));
	$("wk11").update(number_format(amount,2,",","."));
}
function berechne ()
{
	var w1 = $F('waehrungs1_id');
	if($('amount'))
	{   amount = $F('amount').replace(",",".");
		amount = parseFloat(amount); 
	}
	if (isNaN(amount))
	{
		amount = 1;
		$('amount').value = amount;
	}
	euro = parseFloat(wechselkurse["EUR"]);
	k1 = parseFloat(wechselkurse[w1])*euro;
	
	$$(".waehrungsrow").each(function(el)
	{
		k2 = wechselkurse[el.id]
		if (k2 != "undefined")
		{
			wert = _c(k2);	
			
			if (!isNaN(wert))
					wert2 = number_format(wert,2,",",".");
			else	wert2 = "-";
			el.update(wert2);
			
		}
	});
	
}


function _c (k2)
{
	if (!amount)
		amount=1;
	if (!k1)	
		return;
	return (k2/k1*euro)*amount;
}

 function number_format( number, decimals, dec_point, thousands_sep ) {
      // http://kevin.vanzonneveld.net
      // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
      // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
      // + bugfix by: Michael White (http://crestidg.com)
      // + bugfix by: Benjamin Lupton
      // + bugfix by: Allan Jensen (http://www.winternet.no)
      // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
      // * example 1: number_format(1234.5678, 2, '.', '');
      // * returns 1: 1234.57
      var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
      var d = dec_point == undefined ? "," : dec_point;
      var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
      var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
       
      return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
