function valida_contacto()
{
	//valido la opcion
	for (x=0;x<=4;x++)
	{
		valor  = document.frmcontacto.optPara[x].checked;
		if (x >= 4 && valor == false)
		{
			alert("Seleccione una opción de contacto.");
			document.frmcontacto.optPara[0].focus();
			return false;
		}
		else if (valor == true)
		{			
			valor2 = document.frmcontacto.para.value;
			if (x==4 && (valor2 == null || valor2.length == 0 || /^\s+$/.test(valor2)))
			{
				alert("Escriba la opción");
				document.frmcontacto.para.focus();
				return false;
			}
			x=4;
		}

	}	
	
	//valido el nombre
	valor = document.frmcontacto.nombre.value;
	if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) 
	{
		alert("Tiene que escribir su nombre.");
		document.frmcontacto.nombre.focus();
		return false;
	}
	
	valor = document.frmcontacto.cia.value;
	if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) 
	{
		alert("Tiene que escribir el nombre de su compañia.");
		document.frmcontacto.cia.focus();
		return false;
	}	
	
	//Valida el e-mail
	valor = document.frmcontacto.mail.value;
	if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) 
	{
		alert("Tiene que escribir su e-mail.");
		document.frmcontacto.mail.focus();
		return false;
	}
	else
	{	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmcontacto.mail.value))
		{	//alert("La dirección de email " + valor    + " es correcta.")
		   	//return (true)
		}
		else
		{	alert("La dirección de e-mail es incorrecta.");
			document.frmcontacto.mail.focus();
		   	return (false);
		}
		/*
		//expresion regular
	    var correo=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/

	    //comentar la siguiente linea si no se desea que aparezca el alert()
	    //if (correo)
	    if(correo.test(document.frmregistro.email))
		{	alert("e-mail " + (correo.test(document.frmregistro.email)?"":"no ") + "válido.")
			return false;
	    }
	    //devuelve verdadero si validacion OK, y falso en caso contrario
	    return correo.test//(email)
	    */
	}
	
	valor=document.frmcontacto.telefono.value;
    valor = validarEntero(valor)
    document.frmcontacto.telefono.value=valor;
    if( valor == null || valor.length == 0 || /^\s+$/.test(valor) )
    {    alert("Tiene que introducir un número entero en el campo teléfono.")
        document.frmcontacto.telefono.focus()
        return false;
    }    
	
		
	valor = document.frmcontacto.comentarios.value;
	if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) 
	{
		alert("Escribir su comentario.");
		document.frmcontacto.comentarios.focus();
		return false;
	}	
	
	return true;
	
}

function validarEntero(valor)
{
      //intento convertir a entero.
     //si era un entero no le afecta, si no lo era lo intenta convertir
     valor = parseInt(valor)
      //Compruebo si es un valor numérico
      if (isNaN(valor))
	  {
            //entonces (no es numero) devuelvo el valor cadena vacia
            return ""
      }
	  else
	  {
            //En caso contrario (Si era un número) devuelvo el valor
            return valor
      }
}
