function changeprice(f,c,decimals) {
	var i, pr, base
	base = Math.round(parseFloat(f.base.value)*exponencial(10,decimals))
	var attr = parseInt(f.att_num.value)
	for (i=1;i<=attr;i++) {
		pr = eval('f.itm_'+i.toString()+'.value.split("#",2)')
		base += Math.round(parseFloat(pr[1])*exponencial(10,decimals))
	}
	document.getElementById("price").innerHTML = addCommas((base/exponencial(10,decimals)).toString())
	pr = c[c.selectedIndex].value.split("#",5)
	if (pr[2] != '0')
		ajaxpage('item.asp?ID='+pr[2],'subprod'+pr[3])
	else
		document.getElementById("subprod"+pr[3]).innerHTML = pr[4]
	hideddrivetip()
	pr = window.location.href.split("#",1)
	window.location.href = pr[0]+'#product'
}

function attr_init() {
	var c, pr
	var f = document.formproduct
	if (! f.att_num) return
	var attr = parseInt(f.att_num.value)
	for (i=1;i<=attr;i++) {
		c = eval('f.itm_'+i.toString())
		pr = c[c.selectedIndex].value.split("#",5)
		if (pr[2] != '0')
			ajaxpage('item.asp?ID='+pr[2],'subprod'+pr[3])
		else
			document.getElementById("subprod"+pr[3]).innerHTML = pr[4]
	}	
}

function exponencial(base,exponente) {
		if (exponente == 0)
			base = 1
		for (var i=2;i<=exponente;i++)
			base *= base
		return(base)
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
