function popUp(src,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open(src);
	
}
function nothing(){
				
			}
function swapM(obj,focus){
	if(focus){
		obj.className = "tdMIS";
	} else {
		obj.className = "tdMI";
	}
}
function g(link){
	window.location = link;
}
function swapI(obj,focus){
	if(focus){
		if(obj.value == obj.defaultValue)
			obj.value = "";
	} else {
		if(obj.value == "")
			obj.value = obj.defaultValue;
	}
}
function swapB(obj,focus){
	if(focus){
		obj.className = obj.attributes["overclass"].value;
	} else {
		obj.className = "tblo";
	}
}
function swapC(obj,focus){
	if(focus){
		obj.className = obj.attributes["overclass"].value;
	} else {
		obj.className = "tblom2";
	}
}
function swap_pontos(obj,focus){
	if(focus){
		obj.className = obj.attributes["overclass"].value;
	} else {
		obj.className = "tb1om_cinza";
	}
}
function swapSub(menu,over){
	var sub = document.getElementById(menu);
	
	if(over){
		sub.style.display = "";
	} else {
		sub.style.display = "none";
	}
}
var aba_atual = "";
function swap_aba(aba){
	var atual;
	var tr;
	if(aba_atual != ""){
		atual = document.getElementById("aba_"+aba_atual);
		tr = document.getElementById("tr_"+aba_atual);
		if(atual){
			atual.className = "aba";
		}
		if(tr){
			tr.style.display = "none";
		}
	}
	
	atual = document.getElementById("aba_"+aba);
	tr = document.getElementById("tr_"+aba);
	if(atual){
		atual.className = "abaS";
	}
	if(tr){
		tr.style.display = "";
	}
		
	aba_atual = aba;
}
function pop(src,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open("../../inc/structure/pop.php?src="+src);
}
function popup(src,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open(src);
}
function popG(id,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open("../../inc/structure/popG.php?id="+id);
}
function popGVivendo(id,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open("../../inc/structure/popGVivendo.php?id="+id);
}
function popObras(id,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open("../../inc/structure/popObras.php?id="+id);
}
function popVideo(id,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("../../inc/structure/popVideo.php?id="+id);
}
function popMap(id,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("../../inc/structure/popMap.php?id="+id);
}
function popImagem(caminho,w,h){
	var p = new Popup(w,h);
	p.overflow = "hidden";
	p.open("../../inc/structure/popImagem.php?caminho="+caminho);
}
function setRanking(tmp_secao,tmp_ordem) {
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('div_ranking_'+tmp_secao).innerHTML = this.html;
	}
	
	a.get('../../inc/routines/routines.php?rotina=lista_ranking&secao='+tmp_secao+'&ordem='+tmp_ordem);
}
function mudaCalendario(tmp_mes,tmp_ano) {
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('div_calendario').innerHTML = this.html;
	}
	
	a.get('../../inc/routines/routines.php?rotina=calendario&mes='+tmp_mes+'&ano='+tmp_ano);
}
function somaVoto(tmp_id,voto,rand) {
	document.getElementById('avaliacao').value = voto;

	for(x=0;x<5;x++) {
		if (x < voto) {
			document.getElementById('div_estrelaavaliacao'+rand+'_'+tmp_id+'_'+x).className = 'avaliacao';
		} else {
			document.getElementById('div_estrelaavaliacao'+rand+'_'+tmp_id+'_'+x).className = 'avaliacaoOp';
		}
	}
}
function somaVotoAjax(tmp_secao,tmp_id,voto) {
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('div_avaliacaodinamica'+tmp_id).innerHTML = this.html;
		this.runJS(this.html);
	}
	
	a.get('../../inc/routines/routines.php?rotina=somavoto&secao='+tmp_secao+'&id='+tmp_id+'&voto='+voto);
}
function prePostAvaliacao(idfrm) {
	if (document.getElementById('avaliacao').value > 0) {
		f.send(idfrm);
	} else {
		alert('Faltou postar o voto na avaliação!');
		return false;
	}
}
function showUploadArquivo(tmp_valor,tmp_id) {
	for(x=0;x<=1;x++) {
		if (x!=tmp_valor) {
			document.getElementById(tmp_id+x).style.display = 'none';
		} else {
			document.getElementById(tmp_id+x).style.display = '';
		}
	}
}
function sendGaleria(idForm) {
	if ((document.getElementById('Procurar imagem_FIL0').value == '') && (document.getElementById('URL do YouTube_TXT0').value == '')) {
		alert('Você deve enviar uma imagem, audio ou cadastrar o link do vídeo do YouTube.');
	} else {
		if (document.getElementById('Autorizo a publicação_CHK0').checked) {
			f.send(idForm);
		} else {
			alert('Você deve autorizar a publicação da imagem ou vídeo.');	
			document.getElementById('Autorizo a publicação_CHK0').focus();
		}
	}
}
function PlayPause(id){
	var div = document.getElementById("audio"+id);
	var img = document.getElementById("audioimage"+id);
	if(div.attributes["play"].value == "0"){
		div.attributes["play"].value = 1;
		img.src = "../../img/common/stop.jpg";
		//play
		play(id);
	} else {
		div.attributes["play"].value = 0;
		img.src = "../../img/common/play.jpg";
		//stop
		stop(id);
	}
	//alert(div.attributes["play"].value);
}
function play(id){
	var b = document.getElementsByTagName('body')[0];
	var div = document.getElementById("audio"+id);
	
	var audio = document.createElement('div');
	audio.id = "audioIn"+id;
	audio.style.width = "1px";
	audio.style.height = "1px";
	//audio.innerHTML = "asdasdasdasdasd";
	//audio.style.position = "absolute";
	//audio.style.marginTop = "-10000px";
	
	b.appendChild(audio);
	
	//swf("../../swf/common/audio.swf", 1, 1, "audio=../../../upload/visitando_galeria/"+id+".mp3", "", "transparent","","asdasd");
	swf("../../swf/common/audio.swf", 1, 1, "audio=../../../upload/visitando_galeria/"+id+".mp3", "", "transparent","",audio.id);
	
	//adiciona visita
	var a = new Ajax();
	
	a.onLoad = function() {}
	
	a.get('../../inc/routines/routines.php?rotina=soma_visita&id='+id);
}
function stop(id){
	var audio = document.getElementById("audioIn"+id);
	if(audio){
		removeElement(audio);
	}
}
function mudaTipoGuia(tmp_valor,tmp_valordefault,tmp_width) {
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('td_selecttipo').innerHTML = this.html;
	}
		
	a.get('../../inc/routines/routines.php?rotina=carregartiposguia&secaoguia='+tmp_valor+'&valordefault='+tmp_valordefault+'&width='+tmp_width);
}
function mudaConteudo(id,nomemenu) {	
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('conteudo_principal').innerHTML = this.html;
	}
	
	a.get('../../inc/routines/routines.php?rotina=carregarconteudomenu&idmenu='+id);
	
	document.getElementById('div_titulo_menu').innerHTML = nomemenu;
	
	mudaClasseLink(id);
}
function mudaClasseLink(id) {
	document.getElementById('a_linkmenu_'+idmenuinicial).className = 'seta';
	document.getElementById('a_linkmenu_'+id).className = 'seta_over';

	idmenuinicial = id;
}
function preFiltroGuia(idForm,idCampo) {
	if (document.getElementById(idCampo).value == $(idCampo).defaultValue) {
		document.getElementById(idCampo).value = '';
	}
	
	f.send(idForm);
}

function mudaCategoria(tmp_valor,tmp_valordefault,tmp_width) {
	var a = new Ajax();
	
	a.onLoad = function() {
		document.getElementById('td_selectcategoria').innerHTML = this.html;
	}
		
	a.get('../../inc/routines/routines.php?rotina=carregartiposguia&secaoguia='+tmp_valor+'&valordefault='+tmp_valordefault+'&width='+tmp_width);
}
function abreMapa(idsecretaria) {
	popup('mapa.php?idsecretaria='+idsecretaria,425,350);
}

