// JavaScript Document

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function horas()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds()
	
	if (hours <=9)
		hours="0"+hours;
		
	if (minutes<=9)
		minutes="0"+minutes;
		
	if (seconds<=9)
		seconds="0"+seconds;
		
	var cdate= hours+":"+minutes+":"+seconds; 
	clock.innerHTML= cdate;
	setTimeout("horas()",1000);
}

function util_apenasNumeros(e) 
{
	var key = window.event ? e.keyCode : e.which;
	return (key==8 || (key >= 48 && key <=57));
}

function util_validarCPF(cpf)
{
   
   cpf = remove(cpf, ".");
   cpf = remove(cpf, "-");
    
   if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
	  cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
	  cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
	  cpf == "88888888888" || cpf == "99999999999")
   {
	  return false;
   }

   soma = 0;
   for(i = 0; i < 9; i++)
   	 soma += parseInt(cpf.charAt(i)) * (10 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(9)))
   {
	 return false;
   }
   soma = 0;
   for(i = 0; i < 10; i ++)
	 soma += parseInt(cpf.charAt(i)) * (11 - i);
   resto = 11 - (soma % 11);
   if(resto == 10 || resto == 11)
	 resto = 0;
   if(resto != parseInt(cpf.charAt(10)))
   {
	 return false;
   }
   return true;
 }
 
function remove(str, sub) 
{
 	i = str.indexOf(sub);
 	r = "";
 	if (i == -1) return str;
 	r += str.substring(0,i) + remove(str.substring(i + sub.length), sub);
 	return r;
}

function util_enviarEmail(codigoNoticia)
{
	window.open("indicarMateria.php?cod="+codigoNoticia,'','scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,height=280,width=400,top=100,left=250');  
}

function util_imprimirPDF(codigoNoticia)
{
	window.open("imprimirPDF.php?codPost="+codigoNoticia,'','');
}

function util_imprimir(codigoNoticia)
{
	window.open("imprimirPost.php?codPost="+codigoNoticia,'','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,height=250,width=700,top=600,left=250');  
}
