

function newPriceChange(option, originalPrice, regularPrice, discountPercent){

	// new
	///////////////
	// BEGIN code to change price on screen with selection
	///////////////
	
	//option.id = dropdown's ID
	//opiton.value = <selected item's ID>_<selected item's name>
	//		aka: for dropdown 545, selection 7, with name "coffee choice 1 (+$20)" we get
	//		"7_coffee choice 1 (+$20)"

string = option.value;	

	//get the id to know which option you have
	id_first = string.indexOf("_");
	id = string.substring(0,id_first);		
	
	//get the price to add
	first = string.indexOf("$");
	last = string.lastIndexOf(")");	
	priceAdd = string.substring(first+1,last);
	
	
	if(originalPrice.indexOf("$") != -1){
		originalPrice = originalPrice.substr(1);
	}
	
	originalPrice = originalPrice * 1;		

	priceAdd = priceAdd * 1;

	if (discountPercent == 0) { // Old method (used for non % discounts)
		finalPrice = originalPrice + priceAdd;
		finalPrice = finalPrice.toFixed(2);	
		document.getElementById(option.id + "_priceRegular").style.visibility="hidden";
	}
	else { // Used for % discounts
		finalPrice = (regularPrice+priceAdd)*(1-discountPercent);
		finalPrice = finalPrice.toFixed(2);	
		document.getElementById(option.id + "_priceRegular").style.visibility="visible";		
	}
	
	document.getElementById(option.id + "_price").innerHTML = "$" + finalPrice;
	
	normalPrice = regularPrice + priceAdd;
	normalPrice = normalPrice.toFixed(2);
	document.getElementById(option.id + "_priceRegular").innerHTML = "$" + normalPrice;	
	///////////////
	// END code to change price on screen with selection
	///////////////
	
	///////////////
	// BEGIN code to add proper attribute select to Buy button
	///////////////
	hrefID = option.id + "_attribute_add";

	document.getElementById(hrefID).href = document.getElementById(hrefID) + "&attribute=" + id;
	///////////////
	// END code to add proper attribute select to Buy button
	///////////////
}

