function es_vacio(campo)
{
	campo.style.borderWidth = "2px";
	campo.style.borderStyle = "solid";

    if (campo.value == "")
    {
	campo.style.borderColor = "Darkred";
	campo.style.color = "Darkred";

	//Aqui quitamos la imagen
	
	//y luego la añadimos
	//campo.parent.createElement("img");
    }
    else
    {
	//Aqui quitamos la imagen
	campo.style.borderColor = "Darkgreen";
	campo.style.color = "Darkgreen";
	
	//Y luego la añadimos
	//campo.parent.createElement("img");
    }
}


function validar_medioambiental()
{
    var errores = "";

    errores = comprobar_campos();
    errores += comprobar_adjuntos();
    if (errores == "")
    {
	document.getElementById("form_seguro_resp_medioambiental").submit();
    }
    else
    {
	alert (errores);
	
    }
}

function comprobar_campos()
{

    var hay_errores = false;
    var f = document.getElementById("form_seguro_resp_medioambiental");
    if (f.razon_social.value==""){
	hay_errores = true;
	f.razon_social.focus();
	pintar_error (f.razon_social);	
    }
    if (f.contacto.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.contacto.focus();
	    }
	pintar_error(f.contacto);
    }
    if (f.direccion.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.direccion.focus();
	    }
	pintar_error (f.direccion);
    }
    if (f.facturacion.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.facturacion.focus();
	    }
	pintar_error(f.facturacion);
    }
    if (f.pregunta_1.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_1.focus();
	    }
	pintar_error(f.pregunta_1);
    }
    if (f.pregunta_3.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_3.focus();
	    }
	pintar_error(f.pregunta_3);
    }
    if (f.pregunta_4.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_4.focus();
	    }
	pintar_error(f.pregunta_4);
    }
    if (f.pregunta_5.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_5.focus();
	    }
	pintar_error(f.pregunta_5);
    }
    if (f.pregunta_6.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_6.focus();
	    }
	pintar_error(f.pregunta_6);
    }
    if (f.pregunta_7.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_7.focus();
	    }
	pintar_error(f.pregunta_7);
    }
    if (f.pregunta_8.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_8.focus();
	    }
	pintar_error(f.pregunta_8);
    }
    if (f.pregunta_17.value == "")
    {
	if (!hay_errores)
	    {
		hay_errores = true;
		f.pregunta_17.focus();
	    }
	pintar_error(f.pregunta_17);
    }


    if (hay_errores)
	{
	    var aux = "Se han encontrado errores";
	    aux += "\n- Todos los campos son obligatorios";
	    return aux;
	}
	else
	    {
		return "";
	    }
}

function comprobar_adjuntos()
{
    var errores = "";
     var rd2 = document.getElementById("pregunta_2_si").checked;
     var rd18 = document.getElementById("pregunta_18_si").checked;
     var f = document.getElementById("form_seguro_resp_medioambiental");
     if (rd2 && f.adjunto_pregunta_2.value == "")
     {
	 errores += "\n- Debe agregar el adjunto en la pregunta 2";
     }
     if (rd18 && f.adjunto_pregunta_18.value == "")
     {
	 errores += "\n- Debe agregar el adjunto en la pregunta 18";
     }

     return errores;2
     
}

function pintar_error (campo)
{
    campo.style.borderWidth = "2px";
    campo.style.borderStyle = "solid";
    campo.style.borderStyle = "solid";
    campo.style.borderColor = "Darkred";
    campo.style.color = "Darkred";    
}






