function indique(){
	var nome_dest = document.getElementById('nome_destinatario_indique');
	var email_dest = document.getElementById('email_destinatario_indique');
	var nome_rem = document.getElementById('nome_remetente_indique');
	var email_rem = document.getElementById('email_remetente_indique');
	var msg = document.getElementById('mensagem_adicional_indique');
	
	if(nome_dest.value==''){
		alert('Informe o nome do destinatário');
		nome_dest.focus();
		return false
		}
	if(email_dest.value==''){
		alert('Informe o email do destinatário');
		email_dest.focus();
		return false
		}
	if(nome_rem.value==''){
		alert('Por favor preencha seu nome');
		nome_rem.focus();
		return false
		}
	if(email_rem.value==''){
		alert('Por favor preencha seu email');
		email_rem.focus();
		return false
		}
	
	carregaAjax('php/indique_insere.php?nome_destinatario='+nome_dest.value+'&email_destinatario='+email_dest.value+'&nome_remetente='+nome_rem.value+'&email_remetente='+email_rem.value+'&mensagem_adicional='+msg.value,'dv_indique','dv_indique_carregando');
	
	nome_dest.value='';
	email_dest.value='';
	nome_dest.focus();

	}

////////////////////////////////////////////////////	

function load_foto(id){
	carregaAjax('php/galeria_foto.php?id_busca='+id,'dv_gal_exibe','dv_gal_exibe_carregando');
	}

////////////////////////////////////////////////////

function foto_reduz(id){
	cor_borda(id,'#000000');
	alvo = document.getElementById(id);	
	$(alvo).animate(
									  {
										  width:"90px",
										  height:"90px"
										}, 300);
	}

////////////////////////////////////////////////////

function foto_amplia(id){
	cor_borda(id,'#FF6600');
	alvo = document.getElementById(id);	
	$(alvo).animate(
									  {
										  width:"110px",
										  height:"110px"
										}, 300);
	}

////////////////////////////////////////////////////

function move_album_dir(){
	var x = $("#lista_fotos");
	var position = x.position();
	var largura = x.width();
	var limite = largura - (largura*2) + 500;
	//alert('Left: '+position.left+' Larg: '+largura+' limite: '+limite);
	if(position.left>limite){
		$("#lista_fotos").animate({"left": "-=500px"}, 2000);
		}
	}

////////////////////////////////////////////////////

function move_album_esq(){
	var x = $("#lista_fotos");
	var position = x.position();
	if(position.left<0){
		$("#lista_fotos").animate({"left": "+=500px"}, 2000);
		}
	}

////////////////////////////////////////////////////

function load_galeria(id){
	carregaAjax('php/galeria_exibe.php?id_busca='+id,'album_exibe','album_exibe_carregando');
	}

////////////////////////////////////////////////////

function carrega_calendario(mes,ano){
	carregaAjax('php/agenda_calendario.php?mes_busca='+mes+'&ano_busca='+ano,'agenda_calendario','agenda_calendario_carregando');
	}

////////////////////////////////////////////////////
	
function load_pg(arquivo){
		oculta('dv_loja');
		if(arquivo=='agenda'){
			carregaAjax('php/'+arquivo+'.php','dv_palco','dv_palco_carregando',iniciar_agenda);
			} else if(arquivo=='loja'){
			
				oculta('dv_palco');
				exibe('dv_loja');
			
			}	else {
			carregaAjax('php/'+arquivo+'.php','dv_palco','dv_palco_carregando');
			}
	}

////////////////////////////////////////////////////

function agenda_detalhes(id){
	carregaAjax('php/agenda_detalhes.php?id_busca='+id,'agenda_detalhes','agenda_detalhes_carregando');
	}

////////////////////////////////////////////////////

function iniciar_agenda(){
	carregaAjax('php/agenda_calendario.php','agenda_calendario','agenda_calendario_carregando');
	carregaAjax('php/agenda_lista.php','agenda_lista','agenda_lista_carregando');
	}

////////////////////////////////////////////////////

function fade(alvo,velocidade,alpha){
	if(alvo){
		$(alvo).fadeTo(velocidade,alpha);
		}
	}

////////////////////////////////////////////////////

function calendario(alvo){
		var local = document.getElementById(alvo);
		$(function() {
			$(local).datepicker({ });
			});
		}

////////////////////////////////////////////////////	

function cadastro_newsletter(){
	var nome = document.getElementById('newsletter_nome');
	var email = document.getElementById('newsletter_email');
	
	if(nome.value==''){
		alert('Por favor preencha seu nome');
		nome.focus();
		return false
		}
	if(email.value==''){
		alert('Por favor preencha seu email');
		email.focus();
		return false
		}
	
	carregaAjax('php/newsletter_insere.php?nome_insere='+nome.value+'&email_insere='+email.value,'dv_newsletter','dv_newsletter_carregando');

	
	}

////////////////////////////////////////////////////	

function cor_borda(alvo,cor) {
	var alvo = document.getElementById(alvo);
	alvo.style.borderColor = cor
}

////////////////////////////////////////////////////	

function confere_form(lista){
	var array=lista.split(",");
	for(i=0;i<array.length;i++){
		var campo=array[i];
		var alvo = document.getElementById(campo);
		if(alvo.value==""){
			alert('Preencha o campo selecionado!');
			alternaEstilo(campo,'borda_erro');
			alvo.focus();
			return false;
			} else {
			alternaEstilo(campo,'');	
			}
		}

	}
	
////////////////////////////////////////////////////	
	
function somenteNumeros(e){
	
  if (e.keyCode) { // IE   
    tecla = e.keyCode;   
  }  else if (e.which) { // Firefox   
    tecla = e.which;   
  }  else { // Sei lá! :P   
    return false;   
  }   

  if(tecla > 43 && tecla < 58) // numeros de 0 a 9
    return true;
  else {
      if (tecla != 8) // backspace
        return false;
      else
        return true;
    }
}


/////////////////////////////////////////////////////

function confirma_url(msg,url){
	if(confirm(msg)){
					document.location.href=url;
				  } 
	
	}

/////////////////////////////////////////////////////

function ampliarConteudo(tipo,id){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop=document.body.scrollTop;
	
	exibe("dv_zoom");
	carregaAjax('php/exibe_conteudo.php?tipo='+tipo+'&id_busca='+id,dv_palco_zoom,dv_carregando_zoom);
	}

/////////////////////////////////////////////////////

function ampliarFoto(foto,legenda,credito){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop=document.body.scrollTop;

	exibe("dv_zoom");
	carregaAjax('php/exibe_foto.php?foto='+foto+'&legenda='+legenda+'&credito='+credito,dv_palco_zoom,dv_carregando_zoom);
	}

/////////////////////////////////////////////////////

function fechar_zoom(){
	oculta("dv_zoom");
	}

/////////////////////////////////////////////////////
	
function cookie(name,value,hours){
	var path='/';
	if (hours){
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+escape(value)+expires+"; path="+path;
}

/////////////////////////////////////////////////////

function lerCookie(name){   
	var nameEQ = name + "=";
   var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' '){
			c = c.substring(1,c.length);
			}
      if (c.indexOf(nameEQ) == 0){
   		return unescape(c.substring(nameEQ.length,c.length));
   		}
	}
	return null;
}

/////////////////////////////////////////////////////

function limparCookie(name,path){
	var path = '/';
	var mac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
	if(mac){
		createCookie(name,"",0.001,path);
 	}else{
		createCookie(name,"",-1,path);
	}
}

/////////////////////////////////////////////////////

function carregaAjax(url,alvo,carregando,funcao,vars){

	if(typeof(alvo)=='string'){
		alvo = document.getElementById(alvo);
		}
	if(typeof(carregando)=='string'){
		carregando = document.getElementById(carregando);
		}

	$.ajax(
		{
		  url: url,
		  cache: false,
		  beforeSend: function(){
			  	if((carregando!=undefined) && (carregando!='')){
		  			$(carregando).show();
					}
				if((alvo!=undefined) && (alvo!='')){	
					$(alvo).hide();
					}
		  		},
		  success: function(html){
		  		if((carregando!=undefined) && (carregando!='')){
					$(carregando).hide();
					}
				if((alvo!=undefined) && (alvo!='')){	
					$(alvo).show();
					$(alvo).html(html);
					}
				
				if(funcao!=undefined){
					exec = funcao;
					exec(vars);
					}
				
				}
			}
		);
	}

/////////////////////////////////////////////////////

function mudaImagem(alvo,imagem){
	alvo = document.getElementById(alvo)
	alvo.src=imagem;
	}
	
/////////////////////////////////////////////////////

function alternaImagens(alvo,imagem1,imagem2){
	
	alvo = document.getElementById(alvo);
	if(alvo.src.indexOf(imagem1)!=-1){
		alvo.src=imagem2;
		} else {
		alvo.src=imagem1;
		}
	}
	
/////////////////////////////////////////////////////

function alternaDisplay(alvo,estiloExibe){
	if(estiloExibe==undefined){
		estiloExibe = 'block';
		}
	alvo = document.getElementById(alvo)
	if(alvo.style.display==estiloExibe){
		alvo.style.display="none";
		} else {
		alvo.style.display=estiloExibe;
		}
	}

/////////////////////////////////////////////////////

function alternaEstilo(alvo,estilo1,estilo2){
	alvo = document.getElementById(alvo);
	if(alvo.className==estilo1){
			alvo.className=estilo2;
		} else {
			alvo.className=estilo1;
		}
	}

/////////////////////////////////////////////////////

function estilo(alvo,estilo){
	alvo = document.getElementById(alvo);
	alvo.className=estilo;
	}
   
/////////////////////////////////////////////////////   

function exibe(alvo){	
	alvo = document.getElementById(alvo)
	alvo.style.display="block"
	}

/////////////////////////////////////////////////////   	

function oculta(alvo){
	alvo = document.getElementById(alvo)
	alvo.style.display="none"
	}
	
/////////////////////////////////////////////////////   	