function number_format(nb, afterPrice)
{
	nb = nb.toString();
	if (nb.length > 3
		&& nb.charAt(nb.length - 1) == '0' 
		&& nb.charAt(nb.length - 2) == '0' 
		&& nb.charAt(nb.length - 3) == '.')
	{
		nb = nb.substr(0, nb.length - 3);
	}
	else if (nb.length > 4
		&& nb.charAt(nb.length - 1) == '0' 
		&& nb.charAt(nb.length - 2) == '0' 
		&& nb.charAt(nb.length - 3) == '0' 
		&& nb.charAt(nb.length - 4) == '.')
	{
		nb = nb.substr(0, nb.length - 4);
	}
	else if (nb.length > 5
		&& nb.charAt(nb.length - 1) == '0' 
		&& nb.charAt(nb.length - 2) == '0' 
		&& nb.charAt(nb.length - 3) == '0' 
		&& nb.charAt(nb.length - 4) == '0' 
		&& nb.charAt(nb.length - 5) == '.')
	{
		nb = nb.substr(0, nb.length - 5);
	}
	else if (nb.length > 6
		&& nb.charAt(nb.length - 1) == '0' 
		&& nb.charAt(nb.length - 2) == '0' 
		&& nb.charAt(nb.length - 3) == '0' 
		&& nb.charAt(nb.length - 4) == '0' 
		&& nb.charAt(nb.length - 5) == '0' 
		&& nb.charAt(nb.length - 6) == '.')
	{
		nb = nb.substr(0, nb.length - 6);
	}
	else if (nb.length > 7
		&& nb.charAt(nb.length - 1) == '0' 
		&& nb.charAt(nb.length - 2) == '0' 
		&& nb.charAt(nb.length - 3) == '0' 
		&& nb.charAt(nb.length - 4) == '0' 
		&& nb.charAt(nb.length - 5) == '0' 
		&& nb.charAt(nb.length - 6) == '0' 
		&& nb.charAt(nb.length - 7) == '.')
	{
		nb = nb.substr(0, nb.length - 7);
	}

	


	var str = nb.replace('.', ',').toInt().toString();
	var cropWith = (typeof(priceThousands) != 'undefined' && priceThousands.length) ? priceThousands : '.';
	var get = '';
	for (var i = 0; i < str.length; i++)
	{
		if (((str.length - i) % 3) == 0)
		{
			if (i != 0)
			{
				get += cropWith;
			}
		}
		get += str.charAt(i);
	}
	
	if (!afterPrice)
	{
		afterPrice = LANGS.configurator.afterprice
	}
	
	if	(LANGS.configurator.beforepricespecial)
	{
		return (LANGS.configurator.beforepricespecial + ' ' + get + ' ' + afterPrice);
	}
	else
	{
		return (get + ' ' + afterPrice);
	}
}

function convert_local_price(price)
{
	price = price.toInt();
	price *= localPriceConvert;
	price = Math.round(price, 2);
	return (number_format(price, localPriceUnit));
}
