function toDecimalPlaces(x, n)

{

	if (n < 1 || n > 14) return false;
	var e = Math.pow(10, n);
	var k = (Math.round(x * e) / e).toString();
	if (k.indexOf('.') == -1) k += '.';
	k += e.toString().substring(1);
	return k.substring(0, k.indexOf('.') + n+1);

}



function currencyToOSC(str)

{

	var decimal_point = ',';
	var decimal_places = 2;
	var thousands_point = '.';
	str = toDecimalPlaces(str,decimal_places);
	var predecimal_part = str.substring(0,str.length-decimal_places-1);
	var decimal_part = str.substr(str.length-decimal_places,decimal_places);
	if(thousands_point != "" && predecimal_part.length > 3){
		var predecimal_temp = predecimal_part;
		var predecimal_part = "";
		for(j = 3; j < predecimal_temp.length ; j+=3){
		  var extrakt = predecimal_temp.slice(predecimal_temp.length - j, predecimal_temp.length - j + 3);
		  predecimal_part = thousands_point + extrakt +  predecimal_part + "";
		}
		var str_first = predecimal_temp.substr(0, (predecimal_temp.length % 3 == 0)?3:(predecimal_temp.length % 3));
		predecimal_part = str_first + predecimal_part;
	  }
	return predecimal_part + decimal_point + decimal_part;

}



function currencyToJavaScript(str)

{

	var decimal_places = 2;
	var thousands_point = '.';
	str = str.toString()
	var predecimal_part = str.substring(0,str.length-decimal_places-1);
	var decimal_part = str.substr(str.length-decimal_places,decimal_places);
	if(thousands_point != "" && predecimal_part.length > 3)
		predecimal_part = predecimal_part.replace(eval('/\\'+thousands_point+'/g'),'');
	return Number(predecimal_part + '.' + decimal_part);

}
