function load(id_product, id_hole, id_spec, variable, constant) 
{
   var textTarget = '?pid='+id_product+'&id_hole='+id_hole+'&id_spec='+id_spec+'&variable='+variable+'&constant='+constant;
   var load = window.open('/order/stonesetting.php'+textTarget,'','scrollbars=1,menubar=no,height=650,width=750,resizable=yes,toolbar=no,location=no,status=no');
}

function updateStoneSetting(target, value, variable, constant, width)
{
	variable = parseFloat(variable);
	constant = parseFloat(constant);
	width = parseFloat(width);
	var frm = document.prod_spec;
	if (target == 's16_0') {
		frm.s16_0.value = value;
		upd(document.prod_spec.s16_0, 'sp16_0');
		if (variable != 0) {
			frm.s2.value = parseFloat((width * variable) + constant);
			document.getElementById("sp2").innerHTML = frm.s2.value;
		}
	}
	if (target == 's16_1') {
		frm.s16_1.value = value;
		upd(document.prod_spec.s16_1, 'sp16_1');
	}
	if (target == 's16_2') {
		frm.s16_2.value = value;
		upd(document.prod_spec.s16_2, 'sp16_2');
	}
	if (target == 's16_3') {
		frm.s16_3.value = value;
		upd(document.prod_spec.s16_3, 'sp16_3');
	}
	if (target == 's16_4') {
		frm.s16_4.value = value;
		upd(document.prod_spec.s16_4, 'sp16_4');
	}
	if (target == 's16_5') {
		frm.s16_5.value = value;
		upd(document.prod_spec.s16_5, 'sp16_5');
	}
	if (target == 's16_6') {
		frm.s16_6.value = value;
		upd(document.prod_spec.s16_6, 'sp16_6');
	}
}

function updateSE(target, value, price, txt)
{
	var frm = document.prod_spec;
	if (target == 'st0') {
		frm.st0_text.value = txt;
		frm.st0.value = value;
		upd_price('st0', 'stp0', price);
	}
	if (target == 'st1') {
		frm.st1_text.value = txt;
		frm.st1.value = value;
		upd_price('st1', 'stp1', price);
	}
	if (target == 'st2') {
		frm.st2_text.value = txt;
		frm.st2.value = value;
		upd_price('st2', 'stp2', price);
	}
	if (target == 'st3') {
		frm.st3_text.value = txt;
		frm.st3.value = value;
		upd_price('st3', 'stp3', price);
	}
	if (target == 'st4') {
		frm.st4_text.value = txt;
		frm.st4.value = value;
		upd_price('st4', 'stp4', price);
	}
	if (target == 'st5') {
		frm.st5_text.value = txt;
		frm.st5.value = value;
		upd_price('st5', 'stp5', price);
	}
	if (target == 'st6') {
		frm.st6_text.value = txt;
		frm.st6.value = value;
		upd_price('st6', 'stp6', price);
	}
}


function total()
{
	var amount = 0;
	for(var i in item_price) 
	{
		amount+=item_price[i];
	}
	return amount;
}

function updateWidth(objForm, variable, constant)
{
	if (!(variable == 0 && constant == 0))
	{
		width = width_list[ objForm.s16_0.value ];
		objForm.s2.value = parseFloat((width * variable) + constant);
		if (document.getElementById("sp2"))
			document.getElementById("sp2").innerHTML = objForm.s2.value;
	}
}

function upd_price(objName, objPriceName, mprice)
{
	item_price[objName] = mprice;
	document.getElementById(objPriceName).innerHTML = mprice.toFixed(2);
	
	var totalPrice = 0;
	for(var i in item_price) {
		totalPrice += item_price[i];
	}
	document.getElementById("total").innerHTML = totalPrice.toFixed(2);
}

function ___upd(obj, span_object)
{
	item_price[obj.name] = prices[obj.name][obj.value];
	document.getElementById(span_object).innerHTML = prices[obj.name][obj.value].toFixed(2);
	document.getElementById("total").innerHTML = total().toFixed(2);
}

