
function CuentaLetras()
{

 document.datos.comen.value = 129 - document.datos.mensaje.value.length;

}

function borra_espacios(str)
    {
        var newstr = '';
        var borrar = false;
        var start = 0;
                        
        if (str.length > 0)
            while (start < str.length && str.charAt(start) == ' ')
                start++;
            
        for (var i = start ; i < str.length ; i++)
        {
            char1 = str.charAt(i);
            if (char1 == ' ') {
                if (!borrar)
                {
                    newstr += char1;
                    borrar = true;
                }
            }
            else
            {
                newstr += char1;
                borrar = false;
            }
        }
        if (borrar)
            return newstr.substr(0,newstr.length-1);
        else
            return newstr;

     }

function send()
        {   document.datos.mensaje.value = borra_espacios(document.datos.mensaje.value);
            var contador=0;
            contador = document.datos.mensaje.value.length;
            //alert(contador);

            if (document.datos.celu.value.length != 10 || isNaN(parseInt(document.datos.celu.value))){
                alert('El número de Celular debe ser numérico y de 10 caracteres. \n');
		document.datos.celu.focus();
            }else if(contador>130){
                alert('El cuerpo del mensaje no puede superar los 130 caracteres. \n');
		document.datos.mensaje.focus();
            }else{
                document.datos.submit();
            }
        }

function popup(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=485,height=285');");
}
