function loadCidade(id_estado,tmp_eval,idcampo,divloding){
	resetCity(idcampo,divloding);
	if(id_estado != ""){
		var a = new Ajax();
		a.onLoad = function(){
			var s = document.getElementById(idcampo);
			var arr = this.html.split("###");//separa por registro
			var arraux = new Array();
			for(x=0;x<arr.length;x++){
				arraux[x] = arr[x].split("...");
				var option = document.createElement('option');
				option.value = arraux[x][0];
				option.text = arraux[x][1];
				
				try {//outros navegadores
					s.add(option,null);
				} catch(ex) {//para IE
					s.add(option);
				}
			}
			if(tmp_eval){
				eval(tmp_eval);
			}
			if (divloding != '') {
				var span = document.getElementById(divloding);
				span.innerHTML = "";
			}
		}
		a.get('site/inc/routines/routines.php?routine=load_cidade&id_estado='+id_estado);
	}
}
function popMessage(width,height,msg){
	var p = new Popup(width,height);
	p.template = 2;
	p.overflow = "hidden";
	var message = '';
	if(msg){
		message = '?msg='+msg;
	}
	p.open("site/inc/popup/message.php"+message);
}
pop_copiarLink = function(link){
	var p = new Popup(400,90);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/copiar_link.php?link="+link);
}
function swapM(m,focus,welcome){
	var prefix = '';
	if(welcome){
		prefix = 'welcome_';
	}
	
	var td_left = document.getElementById(prefix+'td_left_'+m);
	var td_center = document.getElementById(prefix+'td_center_'+m);
	var td_right = document.getElementById(prefix+'td_right_'+m);
	
	if(focus){
		td_left.className = prefix+"td_esq";
		td_center.className = prefix+"td_center";
		td_right.className = prefix+"td_dir";
	} else {
		td_left.className = prefix+"td_vazio_esq";
		td_center.className = prefix+"td_vazio_center";
		td_right.className = prefix+"td_vazio_dir";
	}
}
function swapI(obj,focus){
	if(focus){
		if(obj.value == obj.attributes["label"].value){
			obj.value = "";
		}
	} else {
		if(obj.value.trim() == ""){
			obj.value = obj.attributes["label"].value;
		}
	}
}
function swapP(obj,focus){
	if(focus){
		var pass = document.getElementById(obj.attributes["parent"].value);
		if(pass){
			obj.innerHTML = "";
			pass.focus();
		}
	} else {
		if(obj.value == ""){
			var div = document.getElementById("div"+obj.id);
			if(div){
				div.innerHTML = obj.attributes["label"].value;
			}
		}
	}
}
function swapImg(obj,src,src_over,focus){
	if(focus){
		obj.src = src_over;
	} else {
		obj.src = src;
	}
}
function changeClass(tmp_class,tmp_idelemento,tmp_valorelemento,tmp_valorpadrao) {
	if (tmp_valorelemento != tmp_valorpadrao) {
		$(tmp_idelemento).className = tmp_class;
	}
}
function imprimirRedacao(tmp_id) {
	window.open('site/inc/routines/routines.php?routine=print_redacao&id='+tmp_id,'IMPRIMIR','width=50,height=50');
}
function enviarRedacao(id_redacao){
	var p = new Popup(400,310);
	p.template = 5;
	p.overflow = "hidden";
	p.position = "absolute";
	p.ownTop = 150;
	p.ownLeft = 500;
	p.align = "";
	p.valign = "";
	p.open("site/inc/popup/enviar_redacao.php?id="+id_redacao);
}
function enviarTwitter(id_redacao, nome){
	var p = new Popup(400,250);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/enviar_twitter.php?id="+id_redacao+"&nome="+nome);
}
function inserirevento(id_estabelecimento){
	var p = new Popup(600,480);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/insere_evento.php?id="+id_estabelecimento);
}
function selectAll(obj){
	obj.select();
}
function somaClique(tmp_id) {
	var a = new Ajax();
	a.onLoad = function() { }
	a.get('site/inc/routines/routines.php?routine=someClique&id='+tmp_id);
}
function somaCliqueCanal(tmp_id) {
	var a = new Ajax();
	a.onLoad = function() { }
	a.get('site/inc/routines/routines.php?routine=someCliqueCanal&id='+tmp_id);
}
function somaCliqueRelacao(tmp_id,tmp_url) {
	var a = new Ajax();
	a.onLoad = function() { parent.window.location = tmp_url; }
	a.get('site/inc/routines/routines.php?routine=someCliqueRelacao&id='+tmp_id);
}
function somaCliquePublicidade(tmp_id) {
	var a = new Ajax();
	a.onLoad = function() { }
	a.get('site/inc/routines/routines.php?routine=someCliquePublicidade&id='+tmp_id);
}
function sendSelectFiltro(pagina,nomecampo,valorcampo) {
	window.location = pagina+'?'+nomecampo+'='+valorcampo;
}
function alterLine(x,value){
	var obj = document.getElementById("ativo"+x);
	if(obj){
		if(value.trim() != ""){
			obj.checked = true;
		} else {
			obj.checked = false;
		}
	}
}
function pop_mapAgenda(id_estabelecimento){
	var p = new Popup(500,450);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/mapa.php?id="+id_estabelecimento);
}
function linksDownload(id_artista){
	var p = new Popup(500,450);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/sets.php?id="+id_artista);
}
function seguirDj(tmp_iddj,is_logado) {
	if (is_logado) {
		var a = new Ajax();
		a.onLoad = function() {
			if (this.html == 1) { // OK
				seguidores = $('span_numeroseguidores').innerHTML;
				seguidores++;
				$('span_numeroseguidores').innerHTML = seguidores;
				$('div_botaoseguirdj').style.display = 'none';
				$('div_botaodeixarseguirdj').style.display = '';
			} else {
				if (this.html == 2) {
					alert('Você já esta seguindo este DJ');
				}	
			}
		}
		a.get('site/inc/routines/routines.php?routine=seguirDj&id='+tmp_iddj);
	} else {
		alert('Você precisa estar logado para seguir o DJ!');	
	}
}
function deixarDeSeguirDj(tmp_iddj) {
	var a = new Ajax();
	a.onLoad = function() {
		seguidores = $('span_numeroseguidores').innerHTML;
		seguidores--;
		$('span_numeroseguidores').innerHTML = seguidores;
		$('div_botaodeixarseguirdj').style.display = 'none';
		$('div_botaoseguirdj').style.display = '';
		alert('Vínculo excluido com sucesso.');
	}
	a.get('site/inc/routines/routines.php?routine=deixarDeSeguirDj&id='+tmp_iddj);
}
function seguirEstabelecimento(tmp_idestabeleciemnto,is_logado) {
	if (is_logado) {
		var a = new Ajax();
		a.onLoad = function() {
			if (this.html == 1) { // OK
				seguidores = $('span_numeroseguidores').innerHTML;
				seguidores++;
				$('span_numeroseguidores').innerHTML = seguidores;
				$('div_botaoseguirestabelecimento').style.display = 'none';
				$('div_botaodeixarseguirestabelecimento').style.display = '';
			} else {
				if (this.html == 2) {
					alert('Você já esta seguindo este estabelecimento');
				}	
			}
		}
		a.get('site/inc/routines/routines.php?routine=seguirEstabelecimento&id='+tmp_idestabeleciemnto);
	} else {
		alert('Você precisa estar logado para seguir o estabelecimento!');	
	}
}
function deixarDeSeguirEstabelecimento(tmp_idestabeleciemnto) {
	var a = new Ajax();
	a.onLoad = function() {
		seguidores = $('span_numeroseguidores').innerHTML;
		seguidores--;
		$('span_numeroseguidores').innerHTML = seguidores;
		$('div_botaodeixarseguirestabelecimento').style.display = 'none';
		$('div_botaoseguirestabelecimento').style.display = '';
		alert('Vínculo excluido com sucesso.');
	}
	a.get('site/inc/routines/routines.php?routine=deleteSeguirEstabelecimento&id='+tmp_idestabeleciemnto);
}
function pop_enviaremail(email){
	var p = new Popup(400,320);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/enviar_emaildj.php?email="+email);
}
function pop_enviarvideo(idartista,secao,idusuario){
	if (idusuario > 0) {
		var p = new Popup(400,155);
		p.template = 2;
		p.overflow = "hidden";
		p.open("site/inc/popup/enviar_video.php?id="+idartista+"&secao="+secao);
	} else {
		alert('Você deve estar logado para enviar um vídeo');	
	}
}
function pop_zoomVideo(idvideo,secao) {
	var p = new Popup(515,415);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/ver_video.php?id="+idvideo+"&secao="+secao);
}
function indicacaoVideo(idvideo,secao) {
	Popup_atual.close();
	var p = new Popup(426,407);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/indicar_video.php?id="+idvideo+"&secao="+secao);
}
function pop_enviarfoto(id_relacionado,tipo,idusuario){
	if (idusuario > 0) {
		var p = new Popup(400,310);
		p.template = 2;
		p.overflow = "hidden";
		
		switch(tipo) {
			case 'artista':
					p.open("site/inc/popup/enviar_foto.php?id_dj="+id_relacionado);
				break;
	
			case 'estabelecimento':
					p.open("site/inc/popup/enviar_foto.php?id_estabelecimento="+id_relacionado);
				break;
					
			case 'foto':
					p.open("site/inc/popup/enviar_foto.php?id_galeria="+id_galeria);
				break;

		}
	} else {
		alert('Você deve estar logado para enviar uma foto');	
	}
}
function pop_zoomImagem(idimagem,idartista,nome,width,height) {
	if (nome != '') {
		height += 30;
	}
	var p = new Popup(width+120,height+100);
	p.template = 2;
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("site/inc/popup/ver_imagem.php?id="+idimagem+"&idartista="+idartista+"&titulo="+nome);
}
function pop_flyer(titulo,pasta,id,w,h){
	if (titulo != '') {
		h += 30;
	}
	var p = new Popup(w+120,h+100);
	p.template = 2;
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("site/inc/popup/ver_flyer.php?id="+id+"&titulo="+titulo+"&pasta="+pasta);
}
function pop_zoomFlyer(idflyer,nome,width,height) {
	if (nome != '') {
		height += 30;
	}
	var p = new Popup(width+120,height+100);
	p.template = 2;
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("site/inc/popup/ver_flyer.php?id="+idflyer+"&titulo="+nome);
}
function pop_zoomFlyer2(idflyer,nome,width,height) {
	if (nome != '') {
		height += 30;
	}
	var p = new Popup(width+120,height+100);
	p.template = 2;
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("site/inc/popup/ver_flyer.php2?id="+idflyer+"&titulo="+nome);
}
function pop_enviarflyer(idrelacionado,tipo,idusuario){
	if (idusuario > 0) {
		var p = new Popup(400,310);
		p.template = 2;
		p.overflow = "hidden";
		p.open("site/inc/popup/enviar_flyer.php?idrelacionado="+idrelacionado+"&tipo="+tipo);
	} else {
		alert('Você deve estar logado para enviar um Flyer');	
	}
}
function mudaPaginaRedacao(tmp_pagina,tmp_nome) {
	var a = new Ajax();
	a.onLoad = function() {
		$('div_noticiaartista').innerHTML = this.html;
	}
	a.get('site/inc/routines/routines.php?routine=listar_noticiasartista&pagina='+tmp_pagina+'&nome='+tmp_nome);
}
function mudaPaginaAgenda(tmp_rotina,tmp_pagina,tmp_indicedata,tmp_div) {
	var a = new Ajax();
	a.onLoad = function() {
		$(tmp_div).innerHTML = this.html;
		this.runJS(this.html);
	}
	a.get('site/inc/routines/routines.php?routine='+tmp_rotina+'&pagina='+tmp_pagina+'&data='+tmp_indicedata);
}
function forgotPass(){
	var p = new Popup(400,200);
	p.template = 2;
	p.overflow = "hidden";
	p.position = "fixed";
	p.open("site/inc/popup/esqueci_senha.php");
}
function ingressoFacil(tmp_value){
	if(tmp_value != ""){
		var arr = tmp_value.split("###");
		var a = new Ajax();
		a.onLoad = function() { }
		a.get('site/inc/routines/routines.php?routine=someCliqueIngressoFacil&id='+arr[0]);
		window.open(arr[1]);
	}
}
function denuncie(id, secao){
	var a = new Ajax();
	a.onLoad = function() {
		alert('Denunciado com sucesso!!!!');
	}
	a.get('site/inc/routines/routines.php?routine=denunciarVideo&id='+id+'&secao='+secao);	
}
function openWelcome(){
	abilitaOverflow(false);
	
	var p = new Popup(780,456);
	p.template = 2;
	p.overflow = "hidden";
	p.bg_alpha = 99;
//	p.position = "fixed";
	p.open("site/inc/popup/welcome.php");
}
function prossegue(){ // Fecha POPUP (Welcome) inicial do site.
	document.getElementById('flashInicial').style.display = 'none';
	document.getElementById('menuInicial').style.display = 'none';
	document.getElementById('floater').style.display = '';
   	document.body.style.background = '#FFFFFF';
	document.getElementById('table_principal').style.display = '';
	document.getElementById('flashInicial').innerHTML = '';
	document.getElementById('menuInicial').innerHTML = '';
	
	abilitaOverflow(true);
}
function abilitaOverflow(status) {
	if (status) {
		document.body.style.overflow = "auto";
	} else {
		document.body.style.overflow = "hidden";
	}
}
function relateDjFlyer(id_dj){
	if(id_dj != ""){
		var span = document.getElementById('spanRelateFlyerDj');
		if(span){
			span.innerHTML = 'Relacionando...';
		}
		var frm = document.getElementById('frmRelacionaDj');
		frm.submit();
	}
}
function gerenciarPromoters(tmp_id,tmp_tipo,tmp_quantidade){
	h = 230;
	if(tmp_quantidade){
		h = h + (tmp_quantidade * 25);
	}
	var p = new Popup(500,h);
	p.template = 2;
	p.overflow = "hidden";
	p.open("site/inc/popup/promoters.php?id="+tmp_id+"&tipo="+tmp_tipo);
}
function site_flickr(idusuario){
	if (idusuario == 0) {
		alert('Por favor, faça seu Login.');
	} else {
		window.open("http://www.flickr.com/fbnfotos", "_blank");
	}
}

function fechaPopUp()
{
	document.getElementById("floater").style.display = "none";
}