// Esta funcion es valida solo para el grupo de ficheros de Presupuestos


function Validar(){
    var txt = "Error en los siguientes campos: \n\n";
	msg_f = txt.length;

if (document.ValidarPresupuesto.nombre.value == "")
	{
	 document.ValidarPresupuesto.nombre.style.backgroundColor = "#C3C3C3"
	 txt+="\tNombre\n";
	}


if (document.ValidarPresupuesto.empresa.value == "")
	{
	document.ValidarPresupuesto.empresa.style.backgroundColor = "#C3C3C3"
	 txt+="\tEmpresa\n";
	}

if (document.ValidarPresupuesto.direccion.value == "")
	{
	document.ValidarPresupuesto.direccion.style.backgroundColor = "#C3C3C3"
	 txt+="\tDirección\n";
	}

if (document.ValidarPresupuesto.telefono.value == "")
	{
	 document.ValidarPresupuesto.telefono.style.backgroundColor = "#C3C3C3"
	 txt+="\tTelefono\n";
	}



if ( TestMail(document.ValidarPresupuesto.correo.value) == false )
	{
	 document.ValidarPresupuesto.correo.style.backgroundColor = "#C3C3C3"
	 txt+="\tE-Mail\n";
	}

/*

if (document.ValidarPresupuesto.fax.value == "")
	{
	 document.ValidarPresupuesto.fax.style.backgroundColor = "#C3C3C3"
	 txt+="\tFax\n";
	}

if (document.ValidarPresupuesto.movil.value == "")
	{
	 document.ValidarPresupuesto.movil.style.backgroundColor = "#C3C3C3"
	 txt+="\tMóvil\n";
	}

 if (document.ValidarPresupuesto.web.value == "")  
	{
 document.ValidarPresupuesto.web.style.backgroundColor = "#C3C3C3"
	 txt+="\tWeb\n";
	}
	*/
	
if (document.ValidarPresupuesto.referido.selectedIndex == 0)
	{
	 document.ValidarPresupuesto.referido.style.backgroundColor = "#C3C3C3"
	 txt+="\tReferido\n";
	}
	


/* DATOS DEL PEDIDO */

if (document.ValidarPresupuesto.TipoInstalacion.selectedIndex == 0)
	{
	document.ValidarPresupuesto.TipoInstalacion.style.backgroundColor = "#C3C3C3"
	 txt+="\tTipo de Instalación\n";
	}

if (document.ValidarPresupuesto.tipoLocal.selectedIndex == 0)
	{
	 document.ValidarPresupuesto.tipoLocal.style.backgroundColor = "#C3C3C3"
	 txt+="\tTipo de Local\n";
	}
	
if (document.ValidarPresupuesto.Comentario.value == "")
	{
	 document.ValidarPresupuesto.Comentario.style.backgroundColor = "#C3C3C3"
	 txt+="\tBreve descripción del trabajo\n";
	}

if(document.ValidarPresupuesto.aceptarCondiciones.checked == false )
	{
	document.ValidarPresupuesto.aceptarCondiciones.style.backgroundColor = "#C3C3C3"
	txt+="\tAceptar Condiciones de Uso\n";
	}
	
	

if (msg_f != txt.length){
	alert(txt);
	return false;
	}else{
		return true;
	}
}




function TestMail(texto)
{
  var correcto=true;
  if ((texto.indexOf("@")<1) || (texto.indexOf("@")>8))
    { correcto=false; }
  if ( (texto.indexOf(".com")<0) &&  (texto.indexOf(".do")<0) && (texto.indexOf(".cu")<0) && (texto.indexOf(".cl")<0) && (texto.indexOf(".br")<0) && (texto.indexOf(".ch")<0) && (texto.indexOf(".pt")<0) && (texto.indexOf(".it")<0) && (texto.indexOf(".uk")<0) && (texto.indexOf(".mx")<0) && (texto.indexOf(".ar")<0) && (texto.indexOf(".de")<0) && (texto.indexOf(".fr")<0) && (texto.indexOf(".biz")<0) && (texto.indexOf(".info")<0) && (texto.indexOf(".net")<0) && (texto.indexOf(".es")<0)  && (texto.indexOf(".org")<0) &&  (texto.indexOf(".edu")<0) )
    { correcto=false; }
  
return correcto;
}

