function ajaxInit(){
	var xmlhttp ;
	try {
		xmlhttp = new XMLHttpRequest ();
	}catch (ee){
		try { 
			xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP");
		}catch( e ) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E) {
				xmlhttp= false ;
			}
		}
	}
	return xmlhttp ;
}

function busca(evt){
	var key_code = evt.keyCode  ? evt.keyCode  :
		evt.charCode ? evt.charCode :
			evt.which    ? evt.which    : void 0;
	if (key_code == 13){
		document.formBusca.action='?ac=busca';
		document.formBusca.submit();
	}
}
function buscaClique(){
	document.formBusca.action='?ac=busca';
	document.formBusca.submit();
}

function paginaBanner(cont,imagem,href){
	document.getElementById("DivImgBanner").innerHTML="<img src=imagens/carregando.gif>";
	var tam = document.getElementById("cont").value;
	for(i=1;i<=tam;i=i+1){
		if(i==cont){
			document.getElementById("Href"+i).setAttribute((document.all ? "className" : "class"), "linkBannerSel");
		}else{
			document.getElementById("Href"+i).setAttribute((document.all ? "className" : "class"), "linkBanner");
		}
	}
	document.getElementById("DivImgBanner").innerHTML="<a href="+href+"><img src=imagensUpload/"+imagem+"></a>";
}
function chamaBanner(links,count){
	for(i=1;i<=count;i++){
		window.setTimeout(links[i], 9000);
	}	
}
function contaVoto(id){
	document.formEnquete.action="?ac=contaVoto&idopcao="+id;
	document.formEnquete.submit();
}
function blocTexto(idpergunta,id,valor,quant){
	total = valor.length;
	if(total <= quant){
		resto = quant - total;
		document.getElementById('cont'+idpergunta).innerHTML = resto;
	}
	else{
		document.getElementById(id).value = valor.substr(0,quant);
	}
}
function blocTexto(id,valor,quant){
	total = valor.length;
	if(total <= quant){
		resto = quant - total;
		document.getElementById('cont').innerHTML = resto;
	}
	else{
		document.getElementById(id).value = valor.substr(0,quant);
	}
}
function pagina(id,limit,paginas){
	ajax=ajaxInit();
	document.getElementById("divImagensEsq").innerHTML="<img src=\"imagens/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','?ac=carregar_pagina&id='+id+'&limit='+limit+'&paginas='+paginas,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("divImagensEsq").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function carregarFoto(id){
	ajax=ajaxInit();
	document.getElementById("divImg").innerHTML="<img src=\"imagens/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','?ac=carregar_foto&id='+id,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("divImg").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function mascara(o,f){
	v_obj=o
	v_fun=f
	setTimeout("execmascara()",1)
}
function execmascara(){
	v_obj.value=v_fun(v_obj.value)
}
function logar(){
	if(document.formLogin.txtEmail.value==''){
		alert('Informe o seu e-mail');
		document.formLogin.txtEmail.focus();
	}
	else if(document.formLogin.txtSenha.value==''){
		alert('Informe sua senha');
		document.formLogin.txtSenha.focus();
	}
	else{
		document.formLogin.action="?ac=logar";
		document.formLogin.submit();
	}
}
function alteraSenha(){
	if(document.form.txtSenhaAntiga.value==''){
		alert('Informe sua senha Atual!');
		document.form.txtSenhaAntiga.focus();
	}
	else if(document.form.txtNovaSenha.value==''){
		alert('Informe sua nova Senha!');
		document.form.txtNovaSenha.focus();
	}
	else if(document.form.txtConfirmaSenha.value==''){
		alert('Informe sua nova Senha novamente!');
		document.form.txtConfirmaSenha.focus();
	}
	else if(document.form.txtNovaSenha.value!=document.form.txtConfirmaSenha.value){
		alert('Senhas não conferem!');
		document.form.txtNovaSenha.value='';
		document.form.txtConfirmaSenha.value='';
		document.form.txtNovaSenha.focus();
	}
	else{
		document.form.action="?ac=alteraSenha";
		document.form.submit();
	}
}
function atualizarDados(){
	document.form.action="?ac=atualizarDados";
	document.form.submit();
}

var tam = 13;
var tamT = 17;

function mudaFonte(tipo){
	if (tipo=="mais") {
		if(tam<24){
			tam+=1;
			tamT+=1;
		}
	} else {
		if(tam>10){
			tam-=1;
			tamT-=1;
		}
	}
	if(document.getElementById('DivCentral')!=null){
		document.getElementById('DivCentral').style.fontSize = tam+'px';
	}
}

function getImagemClass(id){
	ajax=ajaxInit();
	document.getElementById("DivImgClass").innerHTML="<img src=\"imagens/carregando.gif\" \>";
	if(ajax){
		ajax.open('GET','?ac=carregar_foto_class&id='+id,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivImgClass").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function enviarEmail(){
	var nome=document.formulario.txtNome.value;
	var email=document.formulario.txtEmail.value;
	var telefone=document.formulario.txtTelefone.value;
	var assunto=document.formulario.txtAssunto.value;
	var msg=document.formulario.txtMsg.value;

	if(nome==''){
		alert('Informe um nome!');
		document.formulario.txtNome.focus();
	}
	else if(email==''){
		alert('Informe um e-mail!');
		document.formulario.txtEmail.focus();
	}
	else if(telefone==''){
		alert('Informe um telefone!');
		document.formulario.txtTelefone.focus();
	}
	else if(assunto==''){
		alert('Informe um assunto!');
		document.formulario.txtAssunto.focus();
	}
	else if(msg==''){
		alert('Digite uma mensagem!');
		document.formulario.txtMsg.focus();
	}
	else{
		document.formulario.action='?ac=contato';
		document.formulario.submit();
	}
}
function reenviarSenha(){
	if(document.formLogin.txtEmail.value==''){
		alert('Informe seu E-mail');
		document.formLogin.txtEmail.focus();
	}
	else{
		document.formLogin.action="?ac=reenviarSenha";
		document.formLogin.submit();
	}
}
function click(id) {
	$.get('ban?ac=click&id='+id, function(conteudo) {
	});
}
function filie(){
	var nome=document.form.txtNome.value;
	var profissao=document.form.txtProfissao.value;
	var email=document.form.txtEmail.value;

	if(nome==''){
		alert('Informe um nome!');
		document.form.txtNome.focus();
	}
	else if(profissao==''){
		alert('Informe um telefone!');
		document.form.txtTelefone.focus();
	}
	else if(email==''){
		alert('Informe um e-mail!');
		document.form.txtEmail.focus();
	}
	else{
		document.form.action='?ac=filie';
		document.form.submit();
	}
}
