
	$(document).ready(function () {
		product_px = $('#price').text().replace(/[^0-9.]/g,''); // remove all non-price characters
		updatePx();
		$('#product select').change(function(){
			updatePx();
		}); 
	});

	function updatePx() {

		// Check for Options. If there are none, return.
		if ($('#product select').length == 0) { return; }
		
		// Go through all options and get the price of each
		var symbol_left = '$';
		var symbol_right = '';
		var px = product_px * 1;
		$('#product select :selected').each(function(i, selected){
			option_px = $(selected).text(); // get the contents of each selected option
			if (option_px.indexOf('-') > 0) { option_op = '-' } else { option_op = '+' }
			option_px = option_px.replace(/[\+-]/g,'#'); // create a common split reference
			option_px = option_px.replace(/[\+-]/g,'#'); // create a common split reference
			tmp = option_px.split('#'); // split the price from the text
			if (tmp.length > 1) {
				option_px = tmp[1].replace(/[^0-9.]/g,''); // remove all non-price characters
				option_px * 1;
				if (option_op == '-') {
					px -= (option_px * 1);
				} else {
					px += (option_px * 1);
				}
			}
		});
		
		// Update the main price with the new price.
		$('#price').fadeOut('normal', function() {
			$('#price').html(symbol_left+px.toFixed(2)+symbol_right); 
		});
		$('#price').fadeIn('normal');
		
	}

