function MM_jumpMenu(selObj,restore)
{
	//v3.0
	switch(selObj.selectedIndex)
	{
		case 0:
			eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
			break;
		case 1:	
			eval("window.open('"+selObj.options[selObj.selectedIndex].value+"')");
			break;
		case 2:
			eval("window.open('"+selObj.options[selObj.selectedIndex].value+"')");
			break;
		case 3:
			eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
			break;
		case 4:
			eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
			break;
		case 5:
			eval("window.open('"+selObj.options[selObj.selectedIndex].value+"')");
			break;
		default:
			eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
			break;
	}
	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu2(selObj,restore)
{
	//v3.0
	eval("window.location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
function imprimir()
{
	print();
	window.close();
}

function abrirLinkPag(urlPagina,larPagina,altPagina,tipLink)
{
	if (tipLink == 1)
		window.location.href = urlPagina;
	else
		window.open(urlPagina,'','scrollbars=yes,width=' + larPagina + ',height=' + altPagina + '\'');
}
function valida_fale(){
	var Form
	Form = document.form_fale
	if (Form.pf_nome.value.length == 0 ) {
		alert('Por favor, informe seu nome completo.');
		Form.pf_nome.focus();
		return false;
    }
	if(Form.pf_email.value.indexOf("@")==-1 || Form.pf_email.value.indexOf(".")==-1 || Form.pf_email.value==''){
		alert(' Verifique se o digitou corretamente seu e-mail.')
		Form.pf_email.focus();
		return false;
	}
	return true
}

function valida_cad_simples(){
var Form
	Form = document.cadastrar;

	if (Form.pf_nome.value.length == 0 ) {
		alert('Por favor, informe seu nome para efetuar o cadastro.');
		Form.pf_nome.focus();
		return false;
    }
	if(Form.pf_email.value.indexOf("@")==-1 || Form.pf_email.value.indexOf(".")==-1 || Form.pf_email.value==''){
		alert('Verifique se o digitou corretamente seu e-mail.')
		Form.pf_email.focus();
		return false;
	}
	return true;
}

function Amplia_Imagem_Livre(img,winName,width,height,features) { 
//1.1 kadazuro kadazuro@kardouz.com
	if(window.screen){
		per_ancho=(width/screen.width)*100;//porcentaje screen-ancho
		per_alto=(height/width)*100;//porcentaje de ancho-alto
		win_ancho=(screen.width*per_ancho)/100;//ancho de la ventana
		win_alto=(win_ancho*per_alto)/100;//alto de la ventana
		x=(screen.width-win_ancho)/2;//centra x
		y=(screen.height-win_alto)/2;//centra y
	}else{// si el buscador es 4-- queda todo igual :(
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+",scrollbars=no");
	window.open("mostra_img_gd.asp?imagem="+img+"",winName,winfeatures);
}
function Amplia_Galeria(img,winName,width,height,features) { 
//1.1 kadazuro kadazuro@kardouz.com
	if(window.screen){
		per_ancho=(width/screen.width)*100;//porcentaje screen-ancho
		per_alto=(height/width)*100;//porcentaje de ancho-alto
		win_ancho=(screen.width*per_ancho)/100;//ancho de la ventana
		win_alto=(win_ancho*per_alto)/100;//alto de la ventana
		x=(screen.width-win_ancho)/2;//centra x
		y=(screen.height-win_alto)/2;//centra y
	}else{// si el buscador es 4-- queda todo igual :(
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+",scrollbars=no");
	window.open("mostra_galeria.asp?imagem="+img+"",winName,winfeatures);
}
function createXMLHTTP(){
		var ajax;
		try	{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");  //IE
		} 
		catch(e){
			try{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(ex){
				try{
					ajax = new XMLHttpRequest();
				} catch(exc) {
					 alert("Esse browser não tem recursos para uso do Ajax");
					 ajax = null;
				}
			}
		}
		return ajax;	
		   var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
							    "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
							    "Microsoft.XMLHTTP"];
		   for (var i=0; i < arrSignatures.length; i++){
				try{
					var oRequest = new ActiveXObject(arrSignatures[i]);
					return oRequest;
				} catch (oError)	{
			    }
		   }
		throw new Error("MSXML is not installed on your system.");
	}

// Função para troca de imagem sobre eveito do mouse
function IMG(elemento, URL){
	elemento.src= '../img/btn/menu/'+ URL + '.gif';	
}

// Montagem do cabeçalho Data
	hoje = new Date();
	dia = hoje.getDate();
	dias = hoje.getDay();
	mes = hoje.getMonth();
	ano = hoje.getFullYear();
		if (dia < 10)
			dia = "0" + dia;
		if (ano < 2000)
			ano = "19" + ano;
	
function CriaArray (n)
{
	this.length = n;
}
	
	NomeDia = new CriaArray(7);
	NomeDia[0] = "Domingo";
	NomeDia[1] = "Segunda-feira";
	NomeDia[2] = "Ter&ccedil;a-feira";
	NomeDia[3] = "Quarta-feira";
	NomeDia[4] = "Quinta-feira";
	NomeDia[5] = "Sexta-feira";
	NomeDia[6] = "S&aacute;bado";
	
	NomeMes = new CriaArray(12);
	NomeMes[0] = "janeiro";
	NomeMes[1] = "fevereiro";
	NomeMes[2] = "mar&ccedil;o";
	NomeMes[3] = "abril";
	NomeMes[4] = "maio";
	NomeMes[5] = "junho";
	NomeMes[6] = "julho";
	NomeMes[7] = "agosto";
	NomeMes[8] = "setembro";
	NomeMes[9] = "outubro";
	NomeMes[10] = "novembro";
	NomeMes[11] = "dezembro";

function RelogioDigital() {
	hoje = new Date();
	var hora = hoje.getHours();
	var minuto = hoje.getMinutes();
	var segundo = hoje.getSeconds();
	if (hora <= 9) {
		hora = '0' + hora;
	}
	if (minuto <= 9) {
		minuto = '0' + minuto;
	}
	if (segundo <= 9) {
		segundo = '0' + segundo;
	}
	document.getElementById('Relogio').innerHTML = " Manaus/AM - "  +  dia + " de " + NomeMes[mes] + " de " + ano;
}
//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div' );

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
	
	cEl.style.fontSize = szs[ sz ];
	
	for ( i = 0; i < tgs.length; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0; j < cTags.length; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

//Função para validar formulário Contato
function valida_Form_Contato(){

    if (document.getElementById('nome').value == ""){
		alert("O campo Nome deve ser preenchido!");
		document.getElementById('nome').focus();
		return false;
    }
	if (document.getElementById('email').value == ""){
		alert("O campo E-mail deve ser preenchido!");
		document.getElementById('email').focus();
		return false;
    }
	if (document.getElementById('cidade').value == ""){
		alert("O campo Cidade deve ser preenchido!");
		document.getElementById('cidade').focus();
		return false;
    }
	if (document.getElementById('estado').value == ""){
		alert("O campo Estado deve ser preenchido!");
		document.getElementById('estado').focus();
		return false;
    }
	if (document.getElementById('mensagem').value == ""){
		alert("O campo Mensagem deve ser preenchido!");
		document.getElementById('mensagem').focus();
		return false;
    }
			
	return true;
}
//Função para enviar contato
function enviar(){
	if(valida_Form_Contato()){
			var HTTP = createXMLHTTP();
							
					HTTP.open("POST","envia_contato.php",true);
					HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					HTTP.onreadystatechange=function(){
						if (HTTP.readyState==4){  //completo
							if (HTTP.responseText != ""){
								document.getElementById("retorno").innerHTML = HTTP.responseText;
							 } 
						}
					}    
					HTTP.send("nome=" + document.getElementById('nome').value+"&email="+document.getElementById('email').value+"&estado="+document.getElementById('estado').value+"&cidade="+document.getElementById('cidade').value+"&mensagem="+document.getElementById('mensagem').value);		
		}
}

//Função para mudar paginação
function ir_para(pag){
		window.location="?pagina="+pag+"&p="+document.getElementById('p').value;
}

//Comentários
//Função para carregar tela de login
function user_coment(x){
	if(document.getElementById("tela_comentario").style.display == "none"){
   		document.getElementById("tela_comentario").style.display = "inline";
	}	
	var HTTP = createXMLHTTP();
							
	HTTP.open("POST","tela_login.php",true);
	HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	HTTP.onreadystatechange=function(){
		if (HTTP.readyState==4){  //completo
			if (HTTP.responseText != ""){
				document.getElementById("tela_comentario").innerHTML = HTTP.responseText;
			} 
		}
	}    
	HTTP.send("f="+x);		
}

//Função para carregar tela de comentário
function tela_coment(){
	
	var HTTP = createXMLHTTP();
							
	HTTP.open("POST","tela_comentario.php",true);
	HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	HTTP.onreadystatechange=function(){
		if (HTTP.readyState==4){  //completo
			if (HTTP.responseText != ""){
				document.getElementById("tela_comentario").innerHTML = HTTP.responseText;
			} 
		}
	}    
	HTTP.send("nome=" + document.getElementById('nome').value+"&email="+document.getElementById('email').value);		
}

//Função para enviar comentário
function enviar_comentario(){
			var HTTP = createXMLHTTP();
							
			HTTP.open("POST","envia_comentario.php",true);
			HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			HTTP.onreadystatechange=function(){
				if (HTTP.readyState==4){  //completo
					if (HTTP.responseText != ""){
						document.getElementById("tela_comentario").innerHTML = HTTP.responseText;
					} else {
						document.getElementById("tela_comentario").innerHTML = "";	 
					} 
				}
			}    
			HTTP.send("cod_user=" + document.getElementById('cod_user').value+"&comentario="+document.getElementById('comentario').value+"&pagina="+document.getElementById('pagina').value+"&cod_texto="+document.getElementById('cod_texto').value);
}

//Função para cadastrar usuário para cometário
function cadastro_comentario(){
	
	var HTTP = createXMLHTTP();
							
	HTTP.open("POST","tela_cadastro.php",true);
	HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	HTTP.onreadystatechange=function(){
		if (HTTP.readyState==4){  //completo
			if (HTTP.responseText != ""){
				document.getElementById("tela_comentario").innerHTML = HTTP.responseText;
			} 
		}
	}    
	HTTP.send("pagina="+document.getElementById('pagina').value+"&cod_texto="+document.getElementById('cod_texto').value);		
}

//Função para enviar comentário
function enviar_cadastro(){
	if(valida_Form_User_Coment()){
			var HTTP = createXMLHTTP();
			
			if(document.getElementById('info1')){
				if(document.getElementById('info1').checked == true){
					var radio = document.getElementById('info1').value;	
				}
			}
	
			if(document.getElementById('info2')){
				if(document.getElementById('info2').checked == true){
					var radio = document.getElementById('info2').value;	
				}
			}
							
			HTTP.open("POST","envia_cadastro.php",true);
			HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			HTTP.onreadystatechange=function(){
				if (HTTP.readyState==4){  //completo
					if (HTTP.responseText != ""){
						user_coment("s");
					} else {
						user_coment("s");	 
					} 
				}
			}    
			HTTP.send("nome=" + document.getElementById('nome').value+"&email="+document.getElementById('email').value+"&cep="+document.getElementById('cep').value+"&naturalidade="+document.getElementById('naturalidade').value+"&profissao="+document.getElementById('profissao').value+"&info="+radio);
	}
}

//Função para fechar tela de comentário
function fechar_comentario(){
	if(document.getElementById("tela_comentario")){
		document.getElementById("tela_comentario").style.display = "none";		
	}
	if(document.getElementById("tela")){
		document.getElementById("tela").style.display = "none";		
	}
}

//Função para carregar tela de comentario
function mostrar_comentario(pagina){
	
	var HTTP = createXMLHTTP();
							
	HTTP.open("POST",pagina+".php",true);
	HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	HTTP.onreadystatechange=function(){
		if (HTTP.readyState==4){  //completo
			if (HTTP.responseText != ""){
				document.getElementById("comentarios").innerHTML = HTTP.responseText;
			} 
		}
	}    
	HTTP.send("pagina="+document.getElementById('pagina').value+"&cod_texto="+document.getElementById('cod_texto').value);		
}

//Função para validar formulário Comentário
function valida_Form_User_Coment(){

    if (document.getElementById('nome').value == ""){
		alert("O campo Nome deve ser preenchido!");
		document.getElementById('nome').focus();
		return false;
    }
	if (document.getElementById('email').value == ""){
		alert("O campo E-mail deve ser preenchido!");
		document.getElementById('email').focus();
		return false;
    }
	//validar email(verificao de endereco eletronico)
        parte1 = document.getElementById('email').value.indexOf("@");
        parte2 = document.getElementById('email').value.indexOf(".");
        parte3 = document.getElementById('email').value.length;
        if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
            alert("O campo E-mail deve conter um endereço eletrônico!");
            document.getElementById('email').focus();
            return false;
        }
	if (document.getElementById('cep').value == ""){
		alert("O campo CEP deve ser preenchido!");
		document.getElementById('cep').focus();
		return false;
    }
	if (isNaN(document.getElementById('cep').value)){
            alert("O campo CEP deve conter apenas numeros!");
            document.getElementById('cep').focus();
            return false;
    }
			
	return true;
}

//Função para enviar email
function enviar_email(){
	if(valida_Form_Enviaremail()){
			var HTTP = createXMLHTTP();

					HTTP.open("POST","envia_email.php",true);
					HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					HTTP.onreadystatechange=function(){
						if (HTTP.readyState==4){  //completo
							if (HTTP.responseText != ""){
								document.getElementById("retorno").innerHTML = HTTP.responseText;
							 } 
						}
					}    
					HTTP.send("nome_remetente=" + document.getElementById('nome_remetente').value+"&email_remetente="+document.getElementById('email_remetente').value+"&nome_destinatario="+document.getElementById('nome_destinatario').value+"&email_destinatario="+document.getElementById('email_destinatario').value+"&mensagem="+document.getElementById('mensagem').value+"&pagina="+document.getElementById('pagina').value+"&cod="+document.getElementById('cod').value);		
		}
}
//Função para validar formulário Contato
function valida_Form_Enviaremail(){

    if (document.getElementById('nome_remetente').value == ""){
		alert("O campo Seu Nome deve ser preenchido!");
		document.getElementById('nome_remetente').focus();
		return false;
    }
	if (document.getElementById('email_remetente').value == ""){
		alert("O campo Seu E-mail deve ser preenchido!");
		document.getElementById('email_remetente').focus();
		return false;
    }
	//validar email(verificao de endereco eletronico)
        parte1 = document.getElementById('email_remetente').value.indexOf("@");
        parte2 = document.getElementById('email_remetente').value.indexOf(".");
        parte3 = document.getElementById('email_remetente').value.length;
        if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
            alert("O campo E-mail deve conter um endereço eletrônico!");
            document.getElementById('email_remetente').focus();
            return false;
        }
	if (document.getElementById('nome_destinatario').value == ""){
		alert("O campo Nome Destinatário deve ser preenchido!");
		document.getElementById('nome_destinatario').focus();
		return false;
    }
	if (document.getElementById('email_destinatario').value == ""){
		alert("O campo E-mail Destinatário deve ser preenchido!");
		document.getElementById('email_destinatario').focus();
		return false;
    }
	//validar email(verificao de endereco eletronico)
        parte1 = document.getElementById('email_destinatario').value.indexOf("@");
        parte2 = document.getElementById('email_destinatario').value.indexOf(".");
        parte3 = document.getElementById('email_destinatario').value.length;
        if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
            alert("O campo E-mail deve conter um endereço eletrônico!");
            document.getElementById('email_destinatario').focus();
            return false;
        }
			
	return true;
}
//Função para cadastrar usuário
function cadastro(){
	if(document.getElementById("tela").style.display == "none"){
   		document.getElementById("tela").style.display = "inline";
	}
	var HTTP = createXMLHTTP();
							
	HTTP.open("GET","t_cadastro.php",true);
	HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	HTTP.onreadystatechange=function(){
		if (HTTP.readyState==4){  //completo
			if (HTTP.responseText != ""){
				document.getElementById("tela").innerHTML = HTTP.responseText;
			} 
		}
	}    
	HTTP.send(null);		
}
//Função para enviar comentário
function e_cadastro(){
	if(valida_Form_User_Coment()){
			var HTTP = createXMLHTTP();
			
			if(document.getElementById('info1')){
				if(document.getElementById('info1').checked == true){
					var radio = document.getElementById('info1').value;	
				}
			}
	
			if(document.getElementById('info2')){
				if(document.getElementById('info2').checked == true){
					var radio = document.getElementById('info2').value;	
				}
			}
							
			HTTP.open("POST","envia_cadastro.php",true);
			HTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			HTTP.onreadystatechange=function(){
				if (HTTP.readyState==4){  //completo
					if (HTTP.responseText != ""){
						document.getElementById("tela").innerHTML = "<span style='margin-left:50px; margin-top:2px;' class='texto_site'>Cadastro realizado com sucesso. Em breve você recebe novas notícias!!!</span>";
					}  
				}
			}    
			HTTP.send("nome=" + document.getElementById('nome').value+"&email="+document.getElementById('email').value+"&cep="+document.getElementById('cep').value+"&naturalidade="+document.getElementById('naturalidade').value+"&profissao="+document.getElementById('profissao').value+"&info="+radio);
	}
}
//Função para buscar por ano
function busca_ano(pagina){
		window.location="?pagina="+pagina+"&a="+document.getElementById('a').value;
}
