function nullField(q) {  
    for ( i = 0; i < q.length; i++ ) {  
        if ( q.charAt(i) != " " ) { return false; }  
    } return true;  
}

function checkFields(form) {
	var nombre = document.getElementById('nombre'), valNombre = false;
	var apellidos = document.getElementById('apellidos'), valApellidos = false;
	var sexo1 = document.getElementById('sexo1'), valSexo = false;
	var sexo2 = document.getElementById('sexo2');
	var edad = document.getElementById('edad'), valEdad = false;
	var experiencia = document.getElementById('experiencia'), valExperiencia = false;
	var estudios = document.getElementById('estudios'), valEstudios = false;
	var puesto_actual = document.getElementById('puesto'), valPuestoActual = false;
	var localidad = document.getElementById('ciudad'), valLocalidad = false;
	var provincia = document.getElementById('provincia'), valProvincia = false;
	var email = document.getElementById('email'); valEmail = false;
	var telefono = document.getElementById('telefono'), valTelefono = false;
	var sesionInformativa1 = document.getElementById('sesion-informativa1'), valSesionInformativa = false;
	var sesionInformativa2 = document.getElementById('sesion-informativa2');
	var condiciones = document.getElementById('condiciones'), valCondiciones = false;
	
	if(!nullField(nombre.value)&&(nombre.value.length > 1)) {
		document.getElementById('nombre').style.borderColor = '#CCCCCC'; document.getElementById('nombre').style.backgroundColor = '#FFFFFF';
		valNombre = true;
	} else { document.getElementById('nombre').style.borderColor = '#F60000'; 
					 document.getElementById('nombre').style.backgroundColor = '#FFE6E6'; }
	
	if(!nullField(apellidos.value)&&(apellidos.value.length > 1)) {
		document.getElementById('apellidos').style.borderColor = '#CCCCCC'; document.getElementById('apellidos').style.backgroundColor = '#FFFFFF';
		valApellidos = true;
	} else { document.getElementById('apellidos').style.borderColor = '#F60000'; 
					 document.getElementById('apellidos').style.backgroundColor = '#FFE6E6'; }
	
	if(sexo1.checked||sexo2.checked) {
		valSexo = true;
		document.images["tick1"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/green.gif";
	} else { document.images["tick1"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/red.gif"; }
	
	if(!nullField(edad.value)&&(/^[0-9]+$/.test(edad.value))) {
		document.getElementById('edad').style.borderColor = '#CCCCCC'; 
		document.getElementById('edad').style.backgroundColor = '#FFFFFF';
		valEdad = true;
	} else { document.getElementById('edad').style.borderColor = '#F60000'; 
					 document.getElementById('edad').style.backgroundColor = '#FFE6E6'; }

	if(!nullField(experiencia.value)&&(/^[0-9]+$/.test(experiencia.value))) {
		document.getElementById('experiencia').style.borderColor = '#CCCCCC'; 
		document.getElementById('experiencia').style.backgroundColor = '#FFFFFF';
		valExperiencia = true;
	} else { document.getElementById('experiencia').style.borderColor = '#F60000'; 
					 document.getElementById('experiencia').style.backgroundColor = '#FFE6E6'; }

	if(!nullField(estudios.value)&&(estudios.value.length > 2)) {
		document.getElementById('estudios').style.borderColor = '#CCCCCC'; 
		document.getElementById('estudios').style.backgroundColor = '#FFFFFF';
		valEstudios = true;
	} else { document.getElementById('estudios').style.borderColor = '#F60000'; 
					 document.getElementById('estudios').style.backgroundColor = '#FFE6E6'; }
	
	if(!nullField(puesto_actual.value)&&(puesto_actual.value.length > 1)) {
		document.getElementById('puesto').style.borderColor = '#CCCCCC'; 
		document.getElementById('puesto').style.backgroundColor = '#FFFFFF';
		valPuestoActual = true;
	} else { document.getElementById('puesto').style.borderColor = '#F60000'; 
					 document.getElementById('puesto').style.backgroundColor = '#FFE6E6'; }
	
	if(!nullField(localidad.value)&&(localidad.value.length > 2)) {
		document.getElementById('ciudad').style.borderColor = '#CCCCCC'; 
		document.getElementById('ciudad').style.backgroundColor = '#FFFFFF';
		valLocalidad = true;
	} else { document.getElementById('ciudad').style.borderColor = '#F60000'; 
					 document.getElementById('ciudad').style.backgroundColor = '#FFE6E6'; }

	if(!nullField(provincia.value)&&(provincia.value.length > 2)) {
		document.getElementById('provincia').style.borderColor = '#CCCCCC'; 
		document.getElementById('provincia').style.backgroundColor = '#FFFFFF';
		valProvincia = true;
	} else { document.getElementById('provincia').style.borderColor = '#F60000'; 
					 document.getElementById('provincia').style.backgroundColor = '#FFE6E6'; }
	
	if(/(^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*)@([0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3})$/.test(email.value)) {
		document.getElementById('email').style.borderColor = '#CCCCCC'; 
		document.getElementById('email').style.backgroundColor = '#FFFFFF';
		valEmail = true;
	} else { document.getElementById('email').style.borderColor = '#F60000'; 
					 document.getElementById('email').style.backgroundColor = '#FFE6E6';	}
	
	if(/^[9,6]{1}\d{8}$/.test(telefono.value)) {
		document.getElementById('telefono').style.borderColor = '#CCCCCC'; 
		document.getElementById('telefono').style.backgroundColor = '#FFFFFF';
		valTelefono = true;
	} else { document.getElementById('telefono').style.borderColor = '#F60000'; 
					 document.getElementById('telefono').style.backgroundColor = '#FFE6E6';	}
	
	if(sesionInformativa1.checked||sesionInformativa2.checked) {
		valSesionInformativa = true;
		document.images["tick3"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/green.gif";
	} else { document.images["tick3"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/red.gif"; }
	
	if(condiciones.checked) {
		valCondiciones = true;
		document.images["tick2"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/green.gif";
	} else { document.images["tick2"].src = "http://images.cyberclick.es/viavip/msite-tokio-img/red.gif"; }
	
	validForm = (valNombre)&&(valApellidos)&&(valSexo)&&(valEdad)&&(valExperiencia)&&(valEstudios)&&(valPuestoActual)&&
	            (valLocalidad)&&(valProvincia)&&(valEmail)&&(valTelefono)&&(valSesionInformativa)&&(valCondiciones);
}
