

var numberFormat = new NumberFormat(0);
numberFormat.setPlaces(2);
numberFormat.setCurrencyValue('&euro;');
numberFormat.setCurrency(true);



function setPrecioCompartido(resp) {
    var total = 'j_total'+resp;
    var capa1 ='j_res'+resp+'_1';
    var cantidad1 = eval ("document.formRes.pasajeros_"+resp+".selectedIndex")+1;
    cantidad1 = cantidad1 * getCochePrecio(resp);

    numberFormat.setNumber(cantidad1);
    writit(total,numberFormat.toFormatted());
    writit(capa1,numberFormat.toFormatted());    

} 
                                
function setPrecios (resp) {

    var total = 'j_total'+resp;
    var capa1 ='j_res'+resp+'_1';
    var capa2 ='j_res'+resp+'_2';
    var capa3 ='j_res'+resp+'_3';
    var capa4 ='j_res'+resp+'_4';

    var roundtrip = 1;
    if (isRoundtrip(resp)) roundtrip =2;

    var cantidad1 = eval ("document.formRes.coches_"+resp+".selectedIndex")+1;
    cantidad1 = cantidad1 * getCochePrecio(resp);

    var cantidad2 = eval ("document.formRes.equipaje_"+resp+".selectedIndex");
    cantidad2 = cantidad2 * document.formRes.equipaje_precio.value * roundtrip;

    var cantidad3 = eval ("document.formRes.sillas_"+resp+".selectedIndex");
    cantidad3 = cantidad3 * document.formRes.silla_precio.value * roundtrip;

    var cantidad4 = eval ("document.formRes.elevadores_"+resp+".selectedIndex");
    cantidad4 = cantidad4 * document.formRes.elevador_precio.value * roundtrip;

    numberFormat.setNumber(cantidad1);
    writit(capa1,numberFormat.toFormatted());

    numberFormat.setNumber(cantidad2);
    writit(capa2,numberFormat.toFormatted());

    numberFormat.setNumber(cantidad3);
    writit(capa3,numberFormat.toFormatted());

    numberFormat.setNumber(cantidad4);
    writit(capa4,numberFormat.toFormatted());

    numberFormat.setNumber(cantidad1+cantidad2+cantidad3+cantidad4);
    writit(total,numberFormat.toFormatted());

}

 function writit(id,text) {
        if (document.getElementById) {
            x = document.getElementById(id);
            x.innerHTML = '';
            x.innerHTML = text;
        } else if (document.all) {
            x = document.all[id];
            x.innerHTML = text;
        } else if (document.layers) {
            x = document.layers[id];
            x.document.open();
            x.document.write(text);
            x.document.close();
        }
     }


    function getCochePrecio(resp) {
        var coche = eval("document.formRes.coche_precio_"+resp);
        for (i=0;i<3;i++) {
            if (coche[i].checked) return (coche[i].value);
        }
    }

    function isRoundtrip(resp) {
        var coche = eval("document.formRes.coche_precio_"+resp);
        return (coche[2].checked);
    }

    function getTrayecto(resp) {
        var coche = eval("document.formRes.coche_precio_"+resp);
        for (i=0;i<3;i++) {
            if (coche[i].checked) return i;
        }
    }