function Recalc(){
var objHidden;
var objControl;
var objLabel;
var n = 0;
var nRetail = 0;
var sName;
var sPrice = "";
var sSymbol = "";
var sRetailPrice = "";
var iQty = 1;
var iOptionQty = 0;
var e = document.getElementsByName("hdnPrice");
var e2;
var nCount = e.length
var j
for (var i = 0, len = nCount; i < len; i++){ 
		if(e[i].parentNode.tagName.toLowerCase()=="label"){ 
				sName = e[i].parentNode.attributes["for"].value;
				objControl = document.getElementById (sName);
				if (objControl.checked==true){
					n = n + Number(e[i].value);
					nRetail = nRetail + Number(e[i].attributes["retailprice"].value);
					}
		}
		else
		{
			j=i+2;
			e2 = document.getElementsByName("CtlConfigurator1:gFeatures:_ctl" + j + ":iFeatureQuantity");
			if (e2.length>0){
				if (Number(e2[0].attributes["bcid"].value)==Number(e[i].attributes["bcid"].value)){
					iOptionQty = Number(e2[0].value);
					n=n + (Number(e[i].value) * iOptionQty);	
					nRetail = nRetail + Number(e[i].attributes["retailprice"].value * iOptionQty);
				}
			}
		}
	}
	if(!isNaN(document.getElementById("CtlConfigurator1_iQuantity").value)==false){
	
	}
	if (e.length == 0){
		e = document.getElementsByName("CtlConfigurator1:hdnPriceNotConfigured");
		if (e.length != 0){
			n = Number(e[0].value);
		}
		e = document.getElementsByName("CtlConfigurator1:hdnBasePriceNotConfigured");
		if (e.length != 0){
			nRetail = Number(e[0].value);
		}
	}
	iQty = document.getElementById("CtlConfigurator1_iQuantity").value
	if (!isNaN(iQty)==false){iQty=1;}
	if (iQty < 1){iQty=1;}
	if(!isNaN(iQty)==true){
	n = n * Number(iQty);
	nRetail = nRetail * Number(iQty);
	}
	sPrice = formatCurrency(n);
	document.getElementById ("CtlConfigurator1_mextPrice").innerHTML = sPrice ;
	if (nRetail > 0){
		sRetailPrice = formatCurrency(nRetail);
		sSymbol = document.getElementById ("CtlConfigurator1_chCurrencySymbol").innerHTML;	
		}
	document.getElementById ("CtlConfigurator1_mExtBasePrice").innerHTML = sRetailPrice ;
	document.getElementById ("CtlConfigurator1_lblRetailCurrencySymbol").innerHTML = sSymbol;
};

function formatCurrency(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);
}

function RecalcCP(){
	var iQty = 1;
	var n = 0;
	var sPrice = "";
	var e = document.getElementsByName("CtlConfiguratorCP1:hdnPriceNotConfigured")
	iQty = document.getElementById("CtlConfiguratorCP1_iQuantity").value
	if (e.length != 0){
		n = Number(e[0].value);
	}
	if (!isNaN(iQty)==false){iQty=1;}
	if (iQty < 1){iQty=1;}
	if(!isNaN(iQty)==true){
	n = n * Number(iQty);
	}
	sPrice = formatCurrency(n);
	document.getElementById ("CtlConfiguratorCP1_mextPrice").innerHTML = sPrice ;
}
