function updateProductDetails()
{
	updateCartPrice();
}

function updateCartPrice()
{
	var _base = parseFloat(jQuery('#base_price').val());
	synchSelects();
	var _selects = jQuery('#product_item-details select[name^="options_"]'); //alert(_selects.length);
	var _m = /\$([0-9.]+)/;
	var _add = 0;
	
	_selects.each(function () {
		var _val = jQuery(this).val(); //alert(_val);
		if(_matches = _val.match(_m))
			_add += parseFloat(_matches[1]);
	});

	_new = parseFloat(_base + _add).toFixed(2);
	
	jQuery('#Cart66Price').hide();
	jQuery('#Cart66Price').text('$' + formatAsCurrency(_new));
	jQuery('#Cart66Price').show();
	
}

function synchSelects()
{
	var _h = jQuery('#product_item-details select[name^="options_"]');  
	var _s = jQuery('#product_item-details select[name^="viewopts_"]'); 
	
	for(var i = 0; i < _h.length; i++)
	{	
		//var _si = _s.eq(i).attr('selectedIndex'); //alert(_si);
		//_h.eq(i).attr('selectedIndex',_si);
		var _si = _s.eq(i).prop('selectedIndex');
		_h.eq(i).prop('selectedIndex',_si);
	}
}
	

function formatAsCurrency(_val)
{
	var reg = /(\d+)(\d{3})/;
	return String(_val).replace(/\d+/, function (w) {
		while(reg.test(w)) {
			w = w.replace(reg,'$1,$2');
		}
		return w;
	 });
}

function stripPrices()
{
	var _m = /\+[\s]*\$([0-9.]+)/;
	jQuery('#product_item-details select[name^="viewopts_"]').each(function() {
			jQuery('option', this).each(function() {
				var o = jQuery(this).text().replace(_m,''); //alert(_selects.length);
				jQuery(this).text(o);
			});
	});
}
