//Compute the total of selected options

function ComputeTotalCost(objsel)

{

if(objsel != null)

{

var img=objsel.options[objsel.selectedIndex].getAttribute("img");

		if(img.length > 4) 

		{

		document.getElementById('otherimage').src = img;

		}

}



var colOptions;

var oOpt;

var oSelect;

var lTotalCost=attrjsbase;

var lTotalReg=attrjsreg;

var tQuan;

for (var lLoop2=1; lLoop2 < attrjsattr; lLoop2++)

{

colOptions=document.getElementsByName('Product_Attributes[' + lLoop2 + ']:value');

if(attrjstypes[lLoop2] == 'select')

{

for (var lLoop=0; lLoop < colOptions.length; lLoop++)

{

oSelect=colOptions.item(lLoop);

oOpt=oSelect.options.item(oSelect.selectedIndex);

lTotalCost += Number(oOpt.getAttribute('AttribCost'));

lTotalReg += Number(oOpt.getAttribute('RegPrice'));

}

}

else if(attrjstypes[lLoop2] == 'radio' || attrjstypes[lLoop2] == 'checkbox')

{

for (var lLoop=0; lLoop < colOptions.length; lLoop++)

{

oSelect=colOptions.item(lLoop);

if(oSelect.checked)

{

lTotalCost += Number(oSelect.getAttribute('AttribCost'));

lTotalReg += Number(oSelect.getAttribute('RegPrice'));

}

}

}

else if(attrjstypes[lLoop2] == 'text' || attrjstypes[lLoop2] == 'memo')

{

oSelect=colOptions.item(0);

if(oSelect.value)

{

lTotalCost += Number(oSelect.getAttribute('AttribCost'));

lTotalReg += Number(oSelect.getAttribute('RegPrice'));

}

}

}

tQuan=document.getElementsByName('Quantity');

lTotalCost=lTotalCost * Number(tQuan.item(0).value);

lTotalReg=lTotalReg * Number(tQuan.item(0).value);

document.getElementById('attrProdTotal').innerHTML='<b class="price">'+formatCurrency(lTotalCost)+'</b>';

}

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);

}