// JavaScript Document

/*

 * Verifica si es un email valido

 */



function isMail(_email) {

     var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i

     return emailReg.test(_email);

  }



function isTelefono(_telefono) {

     var telefonoReg = /^[0-9]+$/

     return telefonoReg.test(_telefono);

  }


function contarPalabras(e,valor){
	var palabras = 41;
	var unicode = e.keyCode ? e.keyCode : e.charCode;
	var tam;
	var temp;
	if(unicode == 32 || unicode == 13 || unicode == 8){
		tam = valor.value.split(" ").length;
		$("resto").innerHTML = palabras - tam;		
	}
	if(palabras - tam == -1){
		temp = valor.value.split(" ");
		temp[temp.length-2] = "";
		temp[temp.length-1] = "";
		temp = temp.join(" ");
		temp[temp.length-1] = "";
		valor.value = temp.strip();
		$("resto").innerHTML = palabras - valor.value.split(" ").length;
		
	}
}