// JavaScript Document

function conductorPpal () {
	if (document.proyectov.conductor.checked == true) {
		document.proyectov.fnacimientopr.value = document.proyectov.fnacimientop.value
		document.proyectov.fcarnetpr.value = document.proyectov.fcarnetp.value
		document.proyectov.sexopr.value = document.proyectov.sexop.value
	} else {
		document.proyectov.fnacimientopr.value = ""
		document.proyectov.fcarnetpr.value = ""
		document.proyectov.sexopr.options[0].selected = true
	}
}
// checkFor is the id from the checkbutton
// whenChecked == true|false then do
// actionOn == id from elemebt to chnage
function disableChecked(checkFor,whenChecked,actionOn){
	if (document.getElementsByName(checkFor)[0].checked == whenChecked) {
		document.getElementsByName(actionOn)[0].disabled = false;
	} else {
		document.getElementsByName(actionOn)[0].disabled = true;
		document.getElementsByName(actionOn)[0].value = "";
	}
}

function totalCalc(idName, arr) {
	total = 0;
	for(i=0;i<=arr.length-1;i++) {
		total += parseFloat(document.getElementsByName(arr[i])[0].value) || 0;
	}
	document.getElementsByName(idName)[0].value = total;
}

function chkOff(arr) { // take of all checked make on ths part
	for(i=0;i<=arr.length-1;i++) {
		document.getElementsByName(arr[i])[0].checked = false;
	}
}

var privacidad = null;
function abrir_ventana(pagina,ancho,alto) {
	if (privacidad != null && !privacidad.closed) privacidad.close();
	privacidad=window.open (pagina,'wndpriv','toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width='+ancho+',height='+alto+'');
}


function conductorPpal () {
	if (document.getElementsByName("conductor")[0].checked == true) {
		document.getElementsByName("fnacimientopr")[0].value = document.getElementsByName("fnacimientop")[0].value
		document.getElementsByName("fcarnetpr")[0].value = document.getElementsByName("fcarnetp")[0].value
		document.getElementsByName("sexopr")[0].options[document.getElementsByName("sexop")[0].selectedIndex].selected = true;
	} else {
		document.getElementsByName("fnacimientopr")[0].value = ""
		document.getElementsByName("fcarnetpr")[0].value = ""
		document.getElementsByName("sexopr")[0].options[0].selected = true
	}
}

function comprobarBonificacion(){
	if (document.getElementsByName("bonificacion")[0].options[document.getElementsByName("bonificacion")[0].selectedIndex].value == "1") {
		document.getElementsByName("bonidni")[0].disabled = false
		document.getElementsByName("bonicia")[0].disabled = false
		document.getElementsByName("bonipoliza")[0].disabled = false
				showHide('divBoni','show');
		} else {
		document.getElementsByName("bonidni")[0].disabled = true
		document.getElementsByName("bonicia")[0].disabled = true
		document.getElementsByName("bonipoliza")[0].disabled = true
				showHide('divBoni','hide');
		}
}

function comprobarNacionalidad(){
	if (document.proyectov.espanol.options[document.proyectov.espanol.selectedIndex].value == "2") {
		document.proyectov.nacionalidad.disabled = false;
		document.proyectov.permiso.disabled = false;
		} else {
		document.proyectov.nacionalidad.disabled = true;
		document.proyectov.permiso.disabled = true;
		}
}

