/*
function formatCurrencyChangePrice(num) {num = num.toString().replace(/\$|\,/g,'');if(isNaN(num))num = "0";sign = (num == (num = Math.abs(num)));num = Math.floor(num*100+0.50000000001);cents = num%100;num = Math.floor(num/100).toString();if(cents<10)cents = "0" + cents;for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));return (((sign)?'':'-') + '$' + num + '.' + cents);}
*/

Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function changePrice()
{

//try {
	price = cleanUpPrice(document.getElementById("currentPrice").innerHTML);
//} catch(e) {
	//*** IGNORE
//}

var tempOut;
var tempOut2;
var tempOut3;
var tempOut4;
var numberOption;
var newTotal=0;
var tempValue;
var accValue=0;
var f=parseFloat(price);

for (m=0; m<document.forms.length; m++)
{
	for (i=0; i<document.forms[m].elements.length; i++)
 	 {
	    if(document.forms[m].elements[i].type=="select-one")
  		  {
   		   tempValue=document.forms[m].elements[i].value;

                   accValue=accValue + tempValue;
                   tempOut=tempValue.split("+");
				   
				   
				   if(tempOut.length > 1)
				   {
					   tempOut2=tempOut[1];
					   tempOut3=tempOut2.split(")");
					   tempOut4=tempOut3[0];
					   try {
					   	numberOption=parseFloat(cleanUpPrice(tempOut4));
					   } catch(e) {
					    numberOption=parseFloat(tempOut4);
					   }
					   f=f+numberOption;
					   newTotal=Math.round(parseFloat(f) * 100) / 100;
					}
					
    
       		  }
 	 }

}

	$("#NewPrice").text("");
	if(newTotal !=0) {
	
		if(isWholesaleLoggedIn == true) {
			$("#NewPrice").append("<div class=priceWithOptionsText style='display:inline;'>Institutional Price With Options: </div><div class=priceWithOptionsPrice style='display:inline;'>"+formatCurrency(newTotal, true)+"</div>");
		} else {
			$("#NewPrice").append("<div class=priceWithOptionsText style='display:inline;'>Price With Options: </div><div class=priceWithOptionsPrice style='display:inline;'>"+formatCurrency(newTotal, true)+"</div>");
		}
		
		try {document.getElementById("youSavePrice").style.display = "none";} catch(e) {}
		try {document.getElementById("pdMyAccountPrice").className = "pdMyAccountPriceLessEmphasis";} catch(e) {}
		try {document.getElementById("orderSalePrice").className = "pdMyAccountPriceLessEmphasis";} catch(e) {}
		try {document.getElementById("ourPriceValue").className = "pdMyAccountPriceLessEmphasis";} catch(e) {}
	}
}