function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function fixPrices(){
	jQuery('.price').each(function(){
		if((!jQuery(this).parent('span').hasClass('total-code')) && !(jQuery(this).children('span').hasClass('p-fix'))){
			jQuery(this).html(jQuery(this).html().replace(/\./g, ','));
			jQuery(this).html(addCommas(jQuery(this).html()));
			var price = jQuery(this).html();
			jQuery(this).html(price.replace(price.substr(0, 1), '<span class="valpri">' + price.substr(0, 1) + '</span>'));
			// jQuery(this).html(jQuery(this).html().replace(/00$/, '- '));
			jQuery(this).html(jQuery(this).html().replace(/[,.]00$/, ',- '));
			jQuery(this).html('<span class="p-fix">' + jQuery(this).html() + '</span>');
		}
	});
	jQuery(".price").css('color', 'black');
}

jQuery(document).ready(function(){
	fixPrices();
	$$('.swatch').each(function(e){
		Event.observe(e, 'click', function(){
			setTimeout("fixPrices()", 1);
		});
	});
});
