function validation(valor)
{
	if(isEmpty(valor)) return false;
	if(isSpace(valor)) return false;
	return true;
}
function isEmpty(s)
{
	return ((s == null) || (s.length == 0)); }
	function isSpace(c)
	{ return ((c == "\n") || (c == " ") || (c == "\b") || (c == "\t")); }
	function isWhiteSpace(s)
	{ for(i=0; i<s.length; i++)
	if(!isSpace(s.charAt(i))) return false;
	return true;
}
function warning(f,s)
{
	f.focus();
	f.select();
	alert(s);
	return false;
}
function isEmail(email)
{
	if(isEmpty(email)) return false;
	if(isWhiteSpace(email)) return false;
	invalidChars = " /:,;";
	for(i=0; i<invalidChars.length; i++)
	{
	badChar = invalidChars.charAt(i);
	if(email.indexOf(badChar,0) > -1) return false; 
	}
	atPos = email.indexOf("@",1);
	if(atPos == -1) return false; 
	if(email.indexOf("@",atPos+1) > -1) return false; 
	periodPos = email.indexOf(".",atPos);
	if(periodPos == -1) return false; 
	if(periodPos+3 > email.length) return false; 
	return true;
}
function validar()
{
	var nombre = document.getElementById("name");
	var mail = document.getElementById("email");
	var comentarios = document.getElementById("comments");
	var captcha = document.getElementById("tmptxt");	
	
	if(!validation(nombre.value))
	{
		seekAttention("name");
		return false;
	}
	
	if(!isEmail(mail.value))
	{
		seekAttention("email");
		return false;
	}

	if(isEmpty(comentarios.value))
	{
		seekAttention("comments");
		return false;
	}

	if(isEmpty(captcha.value))
	{
		seekAttention("tmptxt");
		return false;
	}	
	
	return envialo();
}

function envialo()
{
	document.comentariosForm.submit()
}
function seekAttention(elem)
{
	$('#'+elem).seekAttention({container: '#newsComments',color: '#333',	pulseSpeed: 300});
}
