/****************SOLICITUD VALIDA_CONTACTO****************************/
function valida_frm_contacto()
{
	var e_name,e_email,e_comment;
	var name=document.frm_contacto.name.value;
	var email=document.frm_contacto.email.value;
	var comment=document.frm_contacto.comment.value;
	
	document.getElementById("error_name").innerHTML='&nbsp;';
	document.getElementById("error_email").innerHTML='&nbsp;';
	document.getElementById("error_comment").innerHTML='&nbsp;';
	
	if(name.length>2)
	{
		e_name=false;
	}
	else
	{
		e_name=true;
		document.getElementById("error_name").innerHTML='El Nombre debe ser mayor a tres letras';
	}
	if (validaMail(email))
	{
		e_email=false;
	}
	else
	
	{
		e_email=true;
	document.getElementById("error_email").innerHTML+='Escribir un Email Valido!!';	
	}
	
	if(comment.length>5)
	{
		e_comment=false;
	}
	else
	{
		e_comment=true;
		document.getElementById("error_comment").innerHTML='Favor de Escribir un Comentario';
	}
	
	if (e_name==false && e_email==false && e_comment==false )
	{
		document.frm_contacto.submit();
	}
	else
	{
		alert("Favor de corregir los siguientes errores");
	}		
}
/*********************************************************************/

/*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 validaMail(Objeto)
  {  

     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Objeto)){	   
    return (true)
     } else {

			return (false);}
  }

