function valida()
{
	
	/********************************DEFINE VARIABLES Y LIMPIA DIVS****************************/
	var e_sel,e_name,e_mail,e_tel,e_fax,e_dir,e_comment;
	
	document.getElementById("td_name").innerHTML='';
	document.getElementById("td_mail").innerHTML='';
	document.getElementById("td_tel").innerHTML='';
	document.getElementById("td_fax").innerHTML='';
	document.getElementById("td_dir").innerHTML='';
	document.getElementById("td_comment").innerHTML='';
	

/*********************************VALIDA NOMBRE***************************************************/
if (document.getElementById('Name').value.length > 3)
{
	e_name=false;
}
else
{
	document.getElementById("td_name").innerHTML+='Error Nombre Incorrecto!!';
	e_name=true;
}


/*******************************VALIDA MAIL*********************************************************/

if (validaMail(document.getElementById('Mailx').value))
{
e_mail=false;	

}
else
{
	document.getElementById("td_mail").innerHTML+='Error Direccion Email Incorrecta!!';
	e_mail=true;
	
}

/*************************VALIDA TELEFONO***********************************************************/

if (isPhoneNumber(document.getElementById('Telephone').value))
{
e_tel=false;	
}
else
{
	document.getElementById("td_tel").innerHTML+='Error Telefono Incorrecto!!';
	e_tel=true;
}

/**************************   VALIDA FAX    *****************************************************/


if (isPhoneNumber(document.getElementById('Fax').value))
{
e_fax=false;
}
else
{
	document.getElementById("td_fax").innerHTML+='Error Fax Incorrecto!!';
	e_fax=true;
}

/***************************  VALIDA DIRECCION   **********************************************/

if (document.getElementById("Address").value.length>5)
{
	e_dir=false;
}
else
{
	document.getElementById("td_dir").innerHTML+='Error Direccion  Incorrecta!!';
	e_dir=true;
}

	
/****************************    VALIDA COMENTARIO ******************************************/
if (document.getElementById("Comments").value.length >5)
{
e_comment=false;

}
else
{
	document.getElementById("td_comment").innerHTML+='Error Comentario Incorrecto!!';
	e_comment=true;
}
/*********************** VALIDA VARIABLES DE ERROR **************************************************/

	if ( e_name==false && e_mail==false  && e_tel==false && e_fax==false && e_dir==false && e_comment==false)
	{
		document.form1.submit();
	}
	else
	{
		alert("Favor de Revisar los Siguientes Errores!!");
	}
				
}

function validaMail(my_val)
  {
//var my_val=document.getElementById('Mailx').value;	  


     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(my_val)){	   
    return (true)
     } else {
			//alert("Direccion de e-mail invalida!!");
			return (false);}
  }



/*funciones para validar numero de telefono */

var defaultEmptyOK = false
var phoneChars = "()-+ ";
function isPhoneNumber (s)
{   var modString;
    if (isEmpty(s)) 
       if (isPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isPhoneNumber.arguments[1] == true);
    modString = stripCharsInBag( s, phoneChars );
    return (isInteger(modString))
}
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
function isInteger (s)
{   var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if( i != 0 ) {
            if (!isDigit(c)) return false;
        } else { 
            if (!isDigit(c) && (c != "-") || (c == "+")) return false;
        }
    }
    return true;
}
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";

    // Buscar por el string, si el caracter no esta en "bag", 
    // agregarlo a returnString
    
    for (i = 0; i < s.length; i++)
    {   var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function show(val)
{
	if (val==0)
	{
	document.getElementById("div_f").style.display='none';
	
	}
	else
	{
	document.getElementById("div_f").style.display='block';
	
	}

}