// JavaScript Document

//DATA ATUALIZADA
var montharray=new Array("01","02","03","04","05","06","07","08","09","10","11","12")
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"

if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate=""+daym+"/"+montharray[month]+"/"+year+" | "+hours+":"+minutes;
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function info(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

//FOCUS DE CAMPOS
function Invalido(CAMPO)
{
	var Cor = '#cc0000';
	var CorFundo = '#F5E9E0';
	var Borda ='1px solid #cc0000';
	
	CAMPO.style.color = Cor;
  	CAMPO.style.backgroundColor = CorFundo;
  	CAMPO.style.border = Borda;	
}

function Valido(CAMPO)
{
	var Cor = '#000000';
	var CorFundo = '';
	var Borda ='1px solid #4E83B8';
	
	CAMPO.style.color = Cor;
  	CAMPO.style.backgroundColor = CorFundo;
  	CAMPO.style.border = Borda;	
	return true;
}


//VALIDA EMAIL
function valida_email( valor ) 
{
  if (valor.indexOf('@', 0) == -1 || valor.indexOf('.', 0) == -1) 
  { 
    return (false); 
  } else {
    return (true); 
  }
}  

function ValidaContato()
{
	var FORM = document.FormContato;
	
	if(FORM.Contato_Nome.value == "")
	{
		Invalido(FORM.Contato_Nome);
		alert("Fale Conosco\n ------------------------------------------------\n Preencha o campo com seu Nome\n");
		FORM.Contato_Nome.focus();
	}
	else if((Valido(FORM.Contato_Nome)) && (FORM.Contato_Email.value == ""))
	{
		Invalido(FORM.Contato_Email);
		alert("Fale Conosco\n ------------------------------------------------\n Preencha o campo com seu E-mail\n");
		FORM.Contato_Email.focus();
	}
	 else if ((Valido(FORM.Contato_Email)) && ((FORM.Contato_Email.value.indexOf('@', 0) == -1) || (FORM.Contato_Email.value.indexOf('.', 0) == -1)))
   {   
		Invalido(FORM.Contato_Email);
		alert("Fale Conosco\n ------------------------------------------------\n Seu E-mail não é um E-Mail Válido\n");
		FORM.Contato_Email.focus();
   }
   else if((Valido(FORM.Contato_Email)) && (FORM.Contato_Assunto.value == ""))
  {
		Invalido(FORM.Contato_Assunto);
		alert("Fale Conosco\n ------------------------------------------------\n Preencha o campo Assunto\n");
		FORM.Contato_Assunto.focus();
	}
	else if((Valido(FORM.Contato_Assunto)) && (FORM.Contato_Mensagem.value == ""))
  {
		Invalido(FORM.Contato_Mensagem);
		alert("Fale Conosco\n ------------------------------------------------\n Preencha o campo Mensagem\n");
		FORM.Contato_Mensagem.focus();
	}
   else
   {
	   Valido(FORM.Contato_Mensagem);
	   if(confirm("Fale Conosco\n ------------------------------------------------\n Enviar Mensagem?\n"))
	   {
		 	var URL = "?Secao=faleconosco&MsGSended=OK&Contato_Nome="+FORM.Contato_Nome.value+"&Contato_Email="+FORM.Contato_Email.value+"&Contato_Assunto="+FORM.Contato_Assunto.value+"&Contato_Mensagem="+FORM.Contato_Mensagem.value;
			window.location= URL;
	   }
   }
}

//CADASTRO INFORMATIVO
function CadastroNewsletter()
{
	var FORM = document.FormNewsletter;
	
	if(FORM.Newsletter_Nome.value == "")
	{
		Invalido(FORM.Newsletter_Nome);
		alert("Cadastro para Newsletter\n ------------------------------------------------\n Preencha o campo com seu Nome\n");
		FORM.Newsletter_Nome.focus();
	}
	 else if((Valido(FORM.Newsletter_Nome)) && (FORM.Newsletter_Email.value.indexOf('@', 0) == -1 || FORM.Newsletter_Email.value.indexOf('.', 0) == -1))
   {   
   		Invalido(FORM.Newsletter_Email);
		alert("Cadastro para Newsletter\n ------------------------------------------------\n Seu E-mail não é um E-Mail Válido\n");
		FORM.Newsletter_Email.focus();
   }
   else
   {
	   	Valido(FORM.Newsletter_Nome);
	   	Valido(FORM.Newsletter_Email);
	   
		var width = 200;
		var height = 120;
																	
		var left = ((screen.width-width)/2);
		var top = ((screen.height-height)/2);
																	   
		var URL = "newsletter.php?nome="+FORM.Newsletter_Nome.value+"&email="+ FORM.Newsletter_Email.value;
		
		Janela = window.open(URL, 'Newsletter', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
		Janela.focus();
   }
}

function ValidaBusca()
{
	var KEYWORD = document.FormBusca.PalavraChave;
  	
	if((KEYWORD.value == "") || (KEYWORD.value.length < 3))
	{
		alert("BUSCAR NOTÍCIA\n ------------------------------------------------\n Informe uma palavra-chave com no mínimo 3 caracteres.\n");
		KEYWORD.focus();
	}
	else
   {
	  var URL = "?Secao=noticias&Keywords="+KEYWORD.value;
										   
		window.location= URL;
   }
}

function ValidaBuscaGalerias()
{
	var KEYWORD = document.FormBusca.PalavraChave;
  	
	if((KEYWORD.value == "") || (KEYWORD.value.length < 3))
	{
		alert("BUSCAR GALERIA\n ------------------------------------------------\n Informe uma palavra-chave com no mínimo 3 caracteres.\n");
		KEYWORD.focus();
	}
	else
   {
	  var URL = "?Secao=galerias&Keywords="+KEYWORD.value;
										   
		window.location= URL;
   }
}

//JANELA DE ZOOM
function FotosNews(itemid, id)
{
	var width = 660;
	var height = 520;
								
	var left = ((screen.width - width)/2);
	var top = ((screen.height - height)/2);
				
	var URL = "popups/zoom.php?Tipo=1&ItemId="+itemid+"&FotoId="+id;
				   
	var Janela = window.open(URL,'PopupZoom', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
	Janela.focus();
}

//JANELA DE ZOOM
function FotosGaleria(itemid, id)
{
	var width = 660;
	var height = 520;
								
	var left = ((screen.width - width)/2);
	var top = ((screen.height - height)/2);
				
	var URL = "popups/zoom.php?Tipo=2&ItemId="+itemid+"&FotoId="+id;
				   
	var Janela = window.open(URL,'PopupZoom', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
	Janela.focus();
}

//JANELA DE IMPRESSAO
function Imprimir(itemid, tipo)
{
	var width = 625;
	var height = 500;
								
	var left = ((screen.width - width)/2);
	var top = ((screen.height - height)/2);
				
	var URL = "popups/imprimir.php?Tipo=1&ItemId="+itemid;
				   
	var Janela = window.open(URL,'Imprimir', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
	Janela.focus();
}

//JANELA DE INDICAÇÂO
function IndicarNews(titulo, id)
{
	var width = 450;
	var height = 300;
								
	var left = ((screen.width - width)/2);
	var top = ((screen.height - height)/2);
				
	var URL = "popups/indicar.php?Titulo="+titulo+"&Id="+id+"&Tipo=1";
	var Janela = window.open(URL,'Imprimir', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
	Janela.focus();
}

//VALIDAR INDICAR A AMIGO
function ValidaIndicacao()
{
	var FORM = document.FormIndicar;
	
	if(FORM.Indica_Nome.value == "")
	{
		alert("Indicar a um(a) Amigo(a)\n ------------------------------------------------\n Preencha o campo Seu Nome\n");
		FORM.Indica_Nome.focus();
	}
	 else if (FORM.Indica_EMail.value.indexOf('@', 0) == -1 || FORM.Indica_EMail.value.indexOf('.', 0) == -1) 
   {   
		alert("Indicar a um(a) Amigo(a)\n ------------------------------------------------\n Seu E-mail não é um E-Mail Válido\n");
		FORM.Indica_EMail.focus();
   }
   else if(FORM.Indica_Nome_Amigo.value == "")
	{
		alert("Indicar a um(a) Amigo(a)\n ------------------------------------------------\n Preencha o campo Nome do(a) Amigo(a)\n");
		FORM.Indica_Nome_Amigo.focus();
	}
	 else if (FORM.Indica_EMail_Amigo.value.indexOf('@', 0) == -1 || FORM.Indica_EMail_Amigo.value.indexOf('.', 0) == -1) 
   {   
		alert("Indicar a um(a) Amigo(a)\n ------------------------------------------------\n E-mail do(a) Amigo(a) não é um E-Mail Válido\n");
		FORM.Indica_EMail_Amigo.focus();
   }
   else
   {
	  	if(confirm("Indicar a um(a) Amigo(a)\n ------------------------------------------------\n "+FORM.Indica_Nome.value+",\n pressione OK se deseja realmente enviar a indicação para "+FORM.Indica_Nome_Amigo.value+"?\n"))
		{
			FORM.submit();								
		}
		else
		{
			FORM.Indica_Nome.focus();
		}
   }
}

//JANELA DA ENQUETE
function Enquete(ACAO)
{
	var width = 470;
	var height = 450;
								
	var left = ((screen.width - width)/2);
	var top = ((screen.height - height)/2);
				
	var URL = "popups/enquete.php?Acao="+ACAO;
				   
	var Janela = window.open(URL,'Enquete', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, maximize=no');
			
	Janela.focus();
}

//JANELAS PERSONALIZADAS
function CentraNetWindow(URL) 
{
	var Nome = "CentraNet";
	var Atributos = "toolbar=yes,location=none,status=yes,menubar=none,scrollbars=yes,resizable=yes";
	Janela = window.open(URL,Nome,Atributos);
	Janela.focus();
}

//Salvar Dissídio
function SalvarDissidio(FILE) 
{
	var URL = "../files/dissidios/salvar.php?file="+FILE;
	window.location=URL;
}

//Salvar Documento RS
function SalvarDocumentoRS(FILE) 
{
	var URL = "../files/regionalsul/salvar.php?file="+FILE;
	window.location=URL;
}

//LIMITE DE CARACTERES
var lim=500;
function limite(texto,total)
{
	if (texto.value.length > lim)
	{
		event.keyCode=0;
		texto.value = texto.value.substring(0,lim);
		Total.innerHTML = lim - texto.value.length;
		//document.form1.texto.disabled=true;
		alert("Esta caixa está limitada em "+lim+" caracteres.");
		return;
	}
	Total.innerHTML = lim - texto.value.length + " caracteres restantes.";
}

function FechaDHtml()
	{
		document.getElementById("DHtmlSwf").style.display = "none";	
	}

function MostraDHtml()
{
	document.getElementById("DHtmlSwf").style.display = "block";	
}