
//// --------------------------------- /////


function popup(url, nome, largura, altura, rolagem) {
 
if (!rolagem) { scrolling = 'auto' }
	
var lateral = (screen.width - largura) / 2;
var topo = (screen.height - altura) / 2;
	
ImprimiNoticia = window.open(url,nome,'width='+largura+',height='+altura+',scrollbars=yes,toolbar=no,location=no,status=no,menubar=no,resizable=no,left='+lateral+',top='+topo+'');
}



////-----------------------------------/////

function LimitarCaracter(campo, contador, Limite) {

Campo = document.getElementById(campo);
Display = document.getElementById(contador);
Caracteres = Limite - Campo.value.length;
Display.innerHTML = Caracteres;
if(Campo.value.length >= Limite){
Campo.value = Campo.value.substring(0, Limite);
}
}

//// ----------------------------------////

function formatar(mascara, documento){
  var i = documento.value.length;
  var saida = mascara.substring(0,1);
  var texto = mascara.substring(i)
  
  if (texto.substring(0,1) != saida){
	documento.value += texto.substring(0,1);
  }
  
}


//// --Função para mostrar SWF flash-- ////

function SWF(arquivo,largura,altura,bg,wmode,quality,variaveis){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
document.write('<param name="movie" value="' + arquivo + '">');
document.write('<param name="Flashvars" value="' + variaveis + '">');
document.write('<param name="BGCOLOR" value="#' + bg + '">');
document.write('<param name="wmode" value="' + wmode + '">');
document.write('<param name="menu" value="false"><param name="quality" value="' + quality + '">');
document.write('<embed src="' + arquivo + '" Flashvars="' + variaveis + '"  width="' + largura + '" height="' + altura + '" wmode="' + wmode + '"  quality="' + quality + '"  pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" bgcolor="#' + bg + '"></embed>');
document.write('</object>');
}

//// -----Função para fechar divs----- ////

function Fechar(div, este){

   document.getElementById(div).style.display="none";
   document.getElementById(este).style.display="none";

}

//// ---Função para executar ajax---- ////

var campo = null;

function Abre(arquivo, metodo, alvo, div_load, div_fecha){
try {
xmlhttp = new XMLHttpRequest();}
catch(ee){
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){
try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch(E) {xmlhttp = false;}
}
}

campo      = alvo;
div_load2  = div_load;
div_fecha2 = div_fecha;

if(metodo == "GET")
{
xmlhttp.onreadystatechange = Mostra;
xmlhttp.open("GET",arquivo);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
xmlhttp.send(null);
}
else
{
xmlhttp.onreadystatechange = Mostra;
xmlhttp.open("POST", arquivo);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
//xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
//xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
//xmlhttp.setRequestHeader("Pragma", "no-cache");
xmlhttp.send(arquivo);
}
}

//// -Função para mostrar divs ajax- ////

function Mostra() {
if (xmlhttp.readyState < 4){
document.getElementById(campo).style.display="none";
document.getElementById(div_load2).style.display="inline";
document.getElementById(div_fecha2).style.display="none";
}
else {
if (xmlhttp.status == 200) {
document.getElementById(campo).style.display="inline";
document.getElementById(campo).innerHTML = xmlhttp.responseText;
document.getElementById(div_load2).style.display="none";
document.getElementById(div_fecha2).style.display="inline";
}
else
{
document.getElementById(campo).style.display="inline";
document.getElementById(campo).innerHTML = "404 - Página não encontrada<br>";
document.getElementById(div_load2).style.display="none";
document.getElementById(div_fecha2).style.display="inline";
}
}
}

//// ------------------------------- ////


function verificaCampos() {

//pessoa
if (document.form.meu_nome.value == "") {
	alert("Digite seu nome!");
	document.form.meu_nome.focus();
	return;}
email = document.form.meu_email.value;
if ( email == "") {
	alert("Digite seu e-mail!");
	document.form.meu_email.focus();
	return;}
if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1) || (email.length < 7)) {
	alert("Seu e-mail é inválido!");
	document.form.meu_email.focus();
	return;}
	
//amigo
if (document.form.amigo_nome.value == "") {
	alert("Digite o nome de seu amigo!");
	document.form.amigo_nome.focus();
	return;}

email2 = document.form.amigo_email.value;
if ( email2 == "") {
	alert("Digite o e-mail do seu amigo!");
	document.form.amigo_email.focus();
	return;}
if ((email2.indexOf("@") == -1) || (email2.indexOf(".") == -1) || (email2.length < 7)) {
	alert("O e-mail do seu amigo é inválido!");
	document.form.amigo_email.focus();
	return;}

//mensagem
if (document.form.mensagem.value == "") {
	alert("Digite uma mensagem!");
	document.form.mensagem.focus();
	return;}

else {
	document.form.submit();
	document.getElementById('bt_envia').disabled='disabled'; 
}
}