function cambiarTrasCambiarCampos(id){ 
    
    if (document.getElementById('radOrdinaria').checked==true){
        document.getElementById("precio").innerHTML='47&euro;';
    } else if (document.getElementById('radFamGeneral').checked==true){
        document.getElementById("precio").innerHTML='23,50&euro; (50% de bonificaci&oacute;n)';
    } else {
        document.getElementById("precio").innerHTML='Matr&iacute;cula gratuita';
    }    
/*if ((id == 'checkFamGeneral')){
        if (document.getElementById(id).checked==true){
            document.getElementById("precio").innerHTML='23,50&euro; (50% de bonificaci&oacute;n)';
        }
    }else{    
        if (document.getElementById(id).checked==true){
            document.getElementById("precio").innerHTML='Matricula gratuita';
        }        
    }
    if (document.getElementById(id).checked==false){
        document.getElementById("precio").innerHTML='47&euro;';
    }  */
}
function aviso(tipo, e){ 
    //alert(document.getElementById(e.id).checked);
    if (document.getElementById(e.id).checked==true){
        document.getElementById(tipo).innerHTML='Debe presentar el documento original en el centro o enviar por correo una fotocopia compulsada antes del 11 de junio';
    } else {
        document.getElementById(tipo).innerHTML='';
    }
}

function avisoTituloMusica(tipo, e){
    if (document.getElementById(e.id).checked==true){
        document.getElementById(tipo).innerHTML='Debe presentar el documento original en el centro o enviar por correo una fotocopia compulsada antes del 15 de junio<br />Si se va a obtener el t&iacute;tulo durante junio de este a&ntilde;o, a&ntilde;adir una nota a mano indic&aacute;ndolo en el impreso de solicitud, y enviarlo posteriormente';
    } else {
        document.getElementById(tipo).innerHTML='';
    }
}

function poneravisoestrajero(tipo, e){ 
    if (document.getElementById(e.id).checked==true){
        document.getElementById(tipo).innerHTML='<p>Si no tienes cuenta en espa&ntilde;a el pago se realizara mediente ingreso en cuenta.</p>'
    +'<p>N&uacute;mero de cuenta: 2086 0000 24 0700946949.'
    +'<br/>El c&oacute;digo IBAN asociado: ES30 2086 0000 2407 0094 6949'
    +'<br/>BIC/SWIFT correspondiente a Caja Inmaculada es: CECAESMM086</p>'
    +'<p>Si tienes cuenta en espa&ntilde;a el pago se realizara mediente domiciliaci&oacute;n bancaria.</p>';
    }
}
function quitaravisoestrajero(tipo, e){ 
    if (document.getElementById(e.id).checked==true){
        document.getElementById(tipo).innerHTML='';
    }
}
function estrajero(){ 
    var p=document.getElementById("divNacionalidad2");
    p.innerHTML='<label for="txtNacion2" class="etiqueta_formulario_datos_aspirante">Residencia</label>'
+ '<html:radio  property="radNacion2" styleClass="margin_top_8px" value="España" onclick="avisoestrajero(pagoExtranjero, this)"/>' 
+ '<label for="txtNacion2" class=" margenIzquierdoMenos2px margin_top_8px">Espa&ntilde;a</label>'
+ '&nbsp;&nbsp;&nbsp;'
+ '<html:radio  property="radNacion2" styleClass="margin_top_8px" value="Fuera" onclick="avisoestrajero(pagoExtranjero, this)"/>'
+ '<label for="txtNacion2" class="margin_top_8px">Fuera de España</label>"'
}
function comprobarCreditosOptativosPosibles(creditosPosi){
    
    var top= document.getElementById("tabOp1");
    var creditosOptativosPosibles = document.getElementById("creditosOptTotMatr");

    //var creditosPosi = document.getElementById("creditosPosibles");
    var totalCreditos = 0.0;

    alert(top.rows[1].cells[2].innerHTML);
    for (var j=1;j<top.rows.length;j++) {
        
        totalCreditos=totalCreditos + parseFloat(top.rows[j].cells[2].innerHTML);
    }

    creditosOptativosPosibles=creditosPosi - totalCreditos;
    return creditosOptativosPosibles;

}

function comprobarCreditos(ele){
    
    var creditosPosibles = document.getElementById("creditosPosibles");
    var creditosOptativosPosibles = document.getElementById("creditosOptTotMatr");
    
    /*Calcula la suma de los creditos de los check seleccionados*/
    var lstoptativas = document.getElementsByName("lstOptativas");
    var texto ="credOp";
    for (x=0;x<lstoptativas.length;x++){
        if (lstoptativas[x].value != -1){
            if (lstoptativas[x].checked ){
                texto = texto+lstoptativas[x].value;
                var cre2 = document.getElementById(texto);
                creditosOptativosPosibles.value = creditosOptativosPosibles.value - parseFloat(cre2.innerHTML);
                texto ="credOp";
            }
        }
    }
    /*Fin del calculo*/
    if (creditosOptativosPosibles.value < 0){
        ele.checked=false;
        window.alert('El n\u00famero m\u00e1ximo de cr\u00e9ditos optativos en los que se puede matricular es de '+creditosPosibles.value);
    }
    
    creditosOptativosPosibles.value = creditosPosibles.value;//vuelvo a retomar el valor total de creditos
}


//function comprobarCreditos(cred, ele){
//
//    var creditosPosibles = document.getElementById("creditosPosibles");
//    var creditosOptativosPosibles = document.getElementById("creditosOptTotMatr");
//    var cre = document.getElementById(cred);
//    //var credPosibles = comprobarCreditosOptativosPosibles(creditosPosibles.value);
//
//    //    if (credPosibles > 0){
//    if(ele.checked){
//        if (creditosOptativosPosibles.value > 0){
//            creditosOptativosPosibles.value = creditosOptativosPosibles.value - parseFloat(cre.innerHTML);
//        }else{
//            ele.checked=false;
//            window.alert('El n\u00famero m\u00e1ximo de cr\u00e9ditos optativos en los que se puede matricular es de '+creditosPosibles.value);
//        }
//    }else{
//        if (creditosOptativosPosibles.value <= creditosPosibles.value){
//
//            var credPos = 0.0;
//            credPos = parseFloat(creditosOptativosPosibles.value);
//
//            var cr = 0.0;
//            cr = parseFloat(cre.innerHTML);
//
//            var sumaCred = 0.0;
//
//
//            sumaCred = credPos + cr;
//
//            creditosOptativosPosibles.value = sumaCred;
//
//        //            creditosOptativosPosibles.value = creditosOptativosPosibles.value + parseFloat(cre.innerHTML);
//        }
//    }
