
jQuery( function($) {
	var mySelect = $('select.product_attributes');
	var changeTarget = $('b.productSpecialPrice');
	var changeTargetColor = changeTarget.css('color');
	
	function getCurrentPrice(priceSelect) {
		
		var currentText = priceSelect.find('option:selected').text();
		
		// Get everything after the last ( and before the last )
		var pieces = currentText.split('(');
		var lastPiece = pieces[pieces.length - 1];
		pieces = lastPiece.split(')');
		var price = pieces[0];
		
		//console.log(price);
		return price
	}
	
	function updatePrice() {
		var newPrice = getCurrentPrice(mySelect);
		changeTarget.text(newPrice);
	}
	
	function updatePriceAndAnimate() {
		updatePrice();
		changeTarget.stop(true).css('background-color', '#f0d582'); //.css('color', '#e5ab44')
		changeTarget.animate({backgroundColor: 'white'}, 2000);
	}
	
	if (mySelect.length) {
		mySelect.change(updatePriceAndAnimate);
		updatePrice();
	}		

});