
function change_color(cordefundo,corsecundaria){
var
mudarcor = cordefundo;
mudarcorsecundaria = corsecundaria;

document.bgColor = mudarcor;
document.getElementById('topo').style.backgroundColor = mudarcorsecundaria;
document.getElementById('menu_lateral').style.backgroundColor = mudarcorsecundaria;
document.getElementById('enquete').style.backgroundColor = mudarcorsecundaria;
document.getElementById('enquete_rodape').style.backgroundColor = mudarcorsecundaria;
document.getElementById('acessibilidade').style.backgroundColor = mudarcorsecundaria;
document.getElementById('rodape').style.backgroundColor = mudarcorsecundaria;

}

function showMap(regiao,isClose) {

			for (i=1; i<6; i++) {
				details = document.getElementById(i);
				details.style.visibility = 'hidden';
			}
			
			details = document.getElementById(regiao);
			
         if (isClose == '1') {
         details.style.visibility = 'hidden';
         } else {
         details.style.visibility = 'visible';
         }
}

function abrirPopUp(popup, name, largura, altura) {
alert(popup);
alert(largura);
alert(altura);
window.open(popup, "publique",  "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500");
}

function openBlank(popup)
{
	window.open(popup);
}

function loadXMLDoc(url, tipo, email)	{

	setCookie("email", email);
	
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange
	 	
	 	xmlhttp.open(tipo,url,true)
	 	
	 	xmlhttp.setRequestHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT");
 		xmlhttp.setRequestHeader("Pragma", "no-cache");
		xmlhttp.setRequestHeader("Cache-control", "no-cache");
	  		  
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  
	  	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    
	    xmlhttp.onreadystatechange=xmlhttpChange
			
			xmlhttp.open(tipo,url,true)
			xmlhttp.setRequestHeader('Expires', 'Thu, 01 Dec 1994 16:00:00 GMT');
	 		xmlhttp.setRequestHeader('Pragma', 'no-cache');
			xmlhttp.setRequestHeader('Cache-control', 'no-cache');	    
	    xmlhttp.send()
			    									    	
										    } 
				}
}
			
			
function xmlhttpChange()	{
		
	if (xmlhttp.readyState==4)	{
	  	
	  	
		  if (xmlhttp.status==200)	{	
	  		
	  		div = document.getElementById("msg");
	  		
	  		resposta = trim(xmlhttp.responseText);
	  		
	  		
	  		if (String(resposta).substring(0,2) == "[(") {
	  				
	  				valor = resposta.substring(2,resposta.length);
	  				tamanho = valor.length
	  				valor = valor.substring(0, tamanho-2);
	  				document.getElementById("boletim_msg").innerHTML = valor;	  				
	  			
	  			
	  		}
	  		else	{
	  				reg = /(<[^>]*>)?([^>]*)/;
	  		
			  		resultado = resposta.match(reg);
			  		valor     = resultado[1];
			  		
			  		resultado = resultado[2];
			  		
			  		valor = String(valor).substring(1,String(valor).length-1);
	  				
	  				if (div == null)	{
	  						
	  						resultado = trim(resultado)
	  						
	  						if (resultado == "Cadastrado com sucesso") {
	  							window.fale_email.envia_email(Get_Cookie("email"));
				  				document.getElementById("boletim_msg").innerHTML = resultado;
				  			}
	  						
			  				setCookie("boletim", valor);
			  				
			  				//redirect_boletim();
	  						  				
			  		}
				  	else	{
				  		
				  			resposta = trim(xmlhttp.responseText);
				  			document.getElementById("msg").innerHTML = resposta;
				  			
				  			if (resposta == "Cadastrado com sucesso") {
				  					//comunicacao@redejovem.org.br
				  					//window.fale_email.envia_email();
			
				  			}	
				  	}			  	
	  		}		
	  	}
	}
}				

function setCookie(name, value, expires, path, domain, secure) {
         var curCookie = name + "=" + escape(value) +
         ((expires) ? "; expires=" + expires.toGMTString() : "") +
         ((path) ? "; path=" + path : "") +
         ((domain) ? "; domain=" + domain : "") +
         ((secure) ? "; secure" : "");
         document.cookie = curCookie;
 }
  
function Get_Cookie( name ) {
					var start = document.cookie.indexOf( name + "=" );
					var len = start + name.length + 1;
					if ( ( !start ) &&
					( name != document.cookie.substring( 0, name.length ) ) )
					{
					return null;
					}
					if ( start == -1 ) return null;
					var end = document.cookie.indexOf( ";", len );
					if ( end == -1 ) end = document.cookie.length;
					return unescape( document.cookie.substring( len, end ) );
			}
  
 function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}


function log() {
//	baseURL = "HTTP://www.redejovem.net/";
//	pubURL = "/cgi/private/cgilua.exe/sys/reader/htm/checklogin.htm";
//	blogname = document.form_user.blogname.value;
	document.form_cadastro.action = "start.htm?tpl=w_check_blog&user=reader";
	document.form_cadastro.submit;
}

function boletim_apaga_email()
{
	atual_email = document.boletim.email.value;
	if (atual_email == "Digite seu e-mail")	{
		
		document.boletim.email.value = "";
	}
	
}

function envia_boletim()
{
		atual_email = document.boletim.email;
		antigo_email = document.boletim.antigo_email;
		
		if (antigo_email.value != "") {
			
			if (antigo_email.value == atual_email.value)	{
				alert("E-mail encontra-se cadastrado.")
				return false;
			}	
		}
		
		if (atual_email.value == "")	{
			
  		 alert("Por favor, informe o seu e-mail.");
  	   atual_email.focus();	
  	   return false;
  	}
  
	var patr = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

  	if (!patr.test(atual_email.value)) 		{
  		
  		 alert("E-mail inválido!");
  		 atual_email.focus();
  		 return false;
  	}
	
	document.boletim.antigo_email.value = atual_email.value;
	document.getElementById("boletim_msg").innerHTML = "enviando...";
	params = "?email="+atual_email.value;
	loadXMLDoc("../../cad_boletim/cad_boletim.htm"+params, "GET", atual_email.value);
				
	return false;	
}

function enterPress()
{
	if (event && event.which == 13)
	{
		envia_boletim();
		return false;
	}
	else
	{	
		return false;
	}
}

function publique() {
  window.open("start.htm?tpl=section_publicar", "publique",  "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500");
}

// Início do código de Aumentar/ Diminuir a letra
 
// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
 
var tagAlvo = new Array('p','div'); //pega todas as tags p//
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '10px','11px','12px','13px','14px','15px' );
var tamanhoInicial = 1;
 
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}
// Fim do código de Aumentar/ Diminuir a letra

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Endereço de email inválido")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Endereço de email inválido")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Endereço de email inválido")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Endereço de email inválido")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Endereço de email inválido")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Endereço de email inválido")
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    alert("Endereço de email inválido")
	    return false
	 }

	 return true					
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function checkmailfield() {
	if (document.fale.blogname.value == "")
	{
		alert("Coloque o nome do blog.");
		document.fale.blogname.focus();
		return false
	}
	if (document.fale.blogname.value.match(/[^A-Za-z0-9]/) !== null)
	{
		alert("O nome do blog contém caracteres inválidos. Utilize somente letras e números.");
		document.fale.blogname.focus();
		return false
	}
  if (echeck(document.fale.email.value)==false)
  {
		document.fale.email.focus();
		return false;
	}
	else
	{
	  document.fale.submit();
	}
}


function post()
{
	if (document.esqueci.blogname.value == "")
	{
		alert("Digite o nome do Blog.");
		document.esqueci.blogname.focus();
		return false;
	}
	if (document.esqueci.name.value == "")
	{
		alert("Digite seu nome.");
		document.esqueci.name.focus();
		return false;
	}
	if (document.esqueci.email.value == "")
	{
		alert("Digite seu e-mail.");
		document.esqueci.email.focus();
		return false;
	}
	return true;
}

function SendForm(){
        /* Validando o campo NOME */
        if(document.fale.name.value == ""){
                alert("Por favor, preencha o campo nome.");
                document.fale.name.focus();
                return;
        }

        /* Validando o campo E-MAIL */
        if(document.fale.email.value == ""){
                alert("Por favor, preencha o campo e-mail.");
                document.fale.email.focus();
                return;
        }

        /* Validando o campo MENSAGEM */
        if(document.fale.mensagem.value == ""){
                alert("Por favor, preencha o campo mensagem.");
                document.fale.mensagem.focus();
                return;
        }

                /* Submit no formulário */
        document.fale.submit();
}

function clearFormMail(form){
  var form = form;
  form.submit();
  form.reset();
}
