


//regexp de los inputs
var rx1 = /^chk_([\sa-z_A-Z\d]{1,})$/ // el checkbox
var rx2 = /^opt_([\sa-z_A-Z\d]{1,})$/ // el option
var rx3 = /^slc_([\sa-z_A-Z\d]{1,})$/ // el select multiple
var rx4 = /^frm_([\sa-z_A-Z\d]{1,})$/ // los datos de formulario

/* actualiza el div que contiene el precio final */
function updateTotal()
{
	var acumTotal = 0;
	
	if(document.SOMEFORM.service_urg[0])
		{
			if(document.SOMEFORM.service_urg[0].checked) acumTotal += parseFloat(document.SOMEFORM.opt_service.value);
		}
	

	
	// recorremos los elementos del formulario buscando los que nos interesan
	for(var i = 0; i < document.forms.SOMEFORM.length; i++)
	{
		
		var input = document.forms.SOMEFORM[i];
		
		if(rx1.test(input.name))
		{
			//window.alert('es un check');
			if(input.checked) acumTotal += parseFloat(input.value);
		}
		
		if(rx2.test(input.name))
		{
			if(input.checked) acumTotal += parseFloat(input.value);
		}
			
		if(rx3.test(input.name))
		{
			//window.alert('es un select');
			//tomamos el valor del option seleccinado
			var elValue = input[input.selectedIndex].value;
			
			//lo separamos por punto y coma para tomar el valor correspondiente
			var nDatos = elValue.split(";");
			
			if(nDatos[1]){
				acumTotal += parseFloat(nDatos[1]);
			}
		}
	}
	
	//tenemos el total, lo mostramos en el div
	document.getElementById('display_order_total').innerHTML = acumTotal;
	document.getElementById('total').value = acumTotal;
}


