// versao 1.1.1
// 18.ABR.2011 - FN_AMPLIAR_CONTEUDO - Alterado o Z-index máximo pra 102 e margin-top da janela calclulado pelo Scroll do Body;
// 23.MAR.2011 - FN_AMPLIAR_CONTEUDO - Corrigida a abertura da janela no primeiro clique
// 17.FEV.2011 - UPLOAD - Incluído o tamanho máximo limite e mensagem de erro do tamanho máximo
// 06.FEV.2011 - NOVO_COD - Adicionada
// 10.JAN.2011 - Criada a função FORM_CONTAR_CARACTERES
// 05.JAN.2011 - FN_AMPLIAR_CONTEUDO - Incluído o critério "local_anexo" caso dê erro ao anexar ao body
// 04.JAN.2011 - Corrigidas as funções SOMENTE_DECIMAL e SOMENTE_NUMEROS para aceitarem a tecla "Tab"
// 31.DEZ.2010 - Corrigida a função SOMENTE_DECIMAL para aceitar a tecla "enter"
// 16.DEZ.2010 - Corrigida a função EXECUTAR_AO_ENTER
// 15.DEZ.2010 - Incluídas as funções PORCENTAGEM, PORCENTAGEM_VALOR_PARCIAL, CORRIGE_VALOR_MOEDA e SOMAR_POR_ESTILO
// 09.DEZ.2010 - Incluída nova string no converte_encode
// 24.NOV.2010 - Incluída a função CONVERTE_ENCODE
// 15.NOV.2010 - Alterada FN_AMPLIAR_CONTEUDO
// 09.NOV.2010 - Alteradas FN_AMPLIAR_CONTEUDO, EXIBE_CORTE, OCULTA_CORTE
// 28.OUT.2010 - Corrigida a função FN_AMPLIAR_CONTEUDO para o posicionamento fixed
// 28.OUT.2010 - Corrigida a função FN_AMPLIAR_CONTEUDO para o .draggable("destroy")
// 11.AGO.2010 - Alterada a formatação da função FN_AMPLIAR_CONTEUDO
// 11.AGO.2010 - Corrigido erro na função carregaAjax na execução de função sem VARS
// 04.AGO.2010 - Incluidas as funções JS_LOAD e CSS_LOAD
// 26.JUN.2010 - atualizada a função carregaAjax

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

function novo_cod(tamanho){
	
	if(typeof tamanho=='undefined'){
							tamanho = 20;
							}
											
	var letras = "abcdefghijkmnopqrstuvxyz23456789";
	var limite = letras.length;
	var nova_senha='';
	
	for(i=0;i<tamanho;i++){
			var pos=Math.floor(Math.random()*(limite-1));
			nova_senha=nova_senha+letras.charAt(pos);
			}
			
	return nova_senha;
	}
	
//--->

function form_contar_caracteres(id_campo,limite,id_contador){
	
	//onKeyUp="form_contar_caracteres(this.id,250,'id_contador')"
	
	var campo = $("#"+id_campo);
	var tam_texto;
	var texto_cortado;
	var campo_contagem = $("#"+id_contador);
	var restante;
	var texto;
	
	tam_texto = $("#"+id_campo).val().length;

	if(tam_texto>limite){
		texto = $("#"+id_campo).val();
		texto_cortado = texto.substring(0,limite);
		$("#"+id_campo).val(texto_cortado);
		} else {
			restante = limite-tam_texto;
			campo_contagem.text(restante);
			}
	}

//---->

function cortar_texto(texto_original,tamanho){
	
	var texto_final = texto_original;
	var tamanho_original = texto_original.length

	if(tamanho_original>(tamanho+3)){
		texto_final = texto_original.substring(0,tamanho); 
		texto_final+='...';
		}
	
	return texto_final;
	
	}

//---->

function somar_pelo_estilo(alvo,valor_moeda,moeda){
	
	if(typeof moeda == 'undefined'){
								    moeda = 'R$';
									}
	total = $(alvo).length;

	valor_total = 0;
	for(var i=0;i<total;i++){
		valor = $(alvo+":eq("+i+")").text();
		
		if(valor_moeda=='s'){
			valor = corrige_valor_moeda(valor,moeda);
			}

		valor = parseFloat(valor);
		valor_total+= valor;
	
		}

	return valor_total;
	
	}

//---->

function corrige_valor_moeda(valor) {

	valor_correto='';
	ponto_encontrado=0;
	
	tamanho = valor.length;

	for(var ij=tamanho;ij>=0;ij--){
	
		if(valor.charCodeAt(ij)>47 && valor.charCodeAt(ij)<58){
			valor_correto=valor.charAt(ij)+valor_correto;
			}

		if(valor.charAt(ij)=="."){
				if(ij==(tamanho-3)){
					valor_correto=valor.charAt(ij)+valor_correto;
					ponto_encontrado=1;
					}
			}

		if(valor.charAt(ij)==","){
			ponto_encontrado=1;
			valor_correto=valor.charAt(ij)+valor_correto;
			}

		
		}

	valor_correto = substituir(valor_correto,',','.');

	if(ponto_encontrado==0){
		valor_correto=valor_correto+".00";
		}
	
	valor_correto = substituir(valor_correto,'..','.');
	
	return valor_correto;
}

//---->

function corrige_valor(valor,moeda){

	if(typeof moeda == 'undefined'){
									moeda = 'R$';
									}
	if(typeof valor == 'number'){
									valor = String(valor);
									}
	if(typeof valor == 'boolean'){
									valor = '0';
									}
	if(typeof valor == 'undefined'){
									valor = '0';
									}
	

	if(valor=='.00'){
		valor = '0.00';
		}

	var centavos='';
	var negativo='';
	var confere_negativo='';

	//verificando se é um texto
	contem_numero=0;
	size=valor.length;
	
	for(var i=0;i<size;i++){
		char = valor.charAt(i);
		cod = valor.charCodeAt(i);
		if(cod>=48 && cod<=57){
			contem_numero++;
			}
		}

	//REMOVE NEGATIVO
	confere_negativo=valor.substring(0,1);  
	if(confere_negativo=='-'){
		valor = valor.substr(1,size);
		negativo="-";
		}

	//REMOVE_CIFRÃO
	confere_cifrao=valor.substring(0,2);  
	if(confere_cifrao=='R$'){
		valor=valor.substring(2,size);
		}
		
	//REMOVE_CENTAVOS
	//CONFERE UMA CASA APÓS A VÍRGULA, TIPO 2,5
	ponto = valor.length; 
	ponto = ponto-2;
	confere_centavos=valor.charAt(ponto);
	
	if(confere_centavos==',' || confere_centavos=='.'){
		valor=valor+'0';
		}
	
	ponto = valor.length; 
	ponto = ponto-3;
	confere_centavos=valor.charAt(ponto);
	
	if(confere_centavos==',' || confere_centavos=='.'){
		ponto = ponto+1;
		centavos=valor.substring(ponto);
		valor=valor.substring(0,(ponto-1));
		}
	
	if(centavos==''){
		centavos='00';
		}


	size=valor.length;

	novo_valor='';
	if(size>3){
		contar=1;
		for(var i=(size-1);i>=0;i--){
			novo_valor=valor.charAt(i)+novo_valor;
	
			if((contar%3)==0){
				if(i!=size){
					if(i>0){
						novo_valor='.'+novo_valor;
						}
					}
				}
				
			contar++;
			}
		valor=novo_valor;
	} 
	
	valor=moeda+negativo+valor+','+centavos;
	valor = substituir(valor,'..','.');
	
	return valor;
}

//---->

function porcentagem(valor_total,valor_parcial,decimais){
	
	if(typeof decimais == 'undefined'){
					decimais = 2;
					}
	
	if((valor_total>0) && (valor_parcial>0)){
		retorno = (valor_parcial*100)/valor_total;
		retorno.toFixed(2);
		return retorno;
		} else {
		return false;
		}
	}

//---->

function porcentagem_valor_parcial(valor_total,porcentagem){
	
	if(typeof decimais == 'undefined'){
					decimais = 2;
					}
	
	if((valor_total>0) && (porcentagem>0)){
		retorno = (valor_total/100)*porcentagem;
		retorno.toFixed(2);
		return retorno;
		} else {
		return false;
		}
	}

//---->

function converte_encode(string) {
		
			string = substituir(string,"&agrave;","à");
			string = substituir(string,"&aacute;","á");
			string = substituir(string,"&Aacute;","Á");
			string = substituir(string,"&eacute;","é");
			string = substituir(string,"&Eacute;","É");
			string = substituir(string,"&iacute;","í");
			string = substituir(string,"&Iacute;","Í");			
			string = substituir(string,"&oacute;","ó");
			string = substituir(string,"&Oacute;","Ó");			
			string = substituir(string,"&uacute;","ú");
			string = substituir(string,"&Uacute;","Ú");
			string = substituir(string,"&atilde;","ã");
			string = substituir(string,"&Atilde;","Ã");
			string = substituir(string,"&otilde;","õ");
			string = substituir(string,"&Otilde;","Õ");
			string = substituir(string,"&acirc;","â");
			string = substituir(string,"&Acirc;","Â");
			string = substituir(string,"&ecirc;","ê");
			string = substituir(string,"&Ecirc;","Ê");
			string = substituir(string,"&ocirc;","ô");
			string = substituir(string,"&Ocirc;","Ô");
			string = substituir(string,"&ccedil;","ç");
			string = substituir(string,"&Ccedil;","Ç");
			
			return string;

			}

//---->

function js_load(url,funcao,vars){
    $.getScript(url, function(){
						if(funcao){
							exec = funcao;
							if(vars){
								exec(vars);
								} else {
								exec();	
								}
							}				
						 });
	}

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

function css_load(url){
    var lnk = document.createElement('link');
    lnk.setAttribute('type', 'text/css' );
    lnk.setAttribute('rel', 'stylesheet' );
    lnk.setAttribute('href', url );
    document.getElementsByTagName('head').item(0).appendChild(lnk);
	}

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

function substituir(texto,caractere_original,novo_caractere){
	while (texto.indexOf(caractere_original) != -1) {
 		texto = texto.replace(caractere_original,novo_caractere);
		}
	return texto;
	}

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

function trocaEstilo(alvo,lista){

	var array=lista.split(",");
	var total_itens = array.length;

	alvo = document.getElementById(alvo);
	
	for(i=0;i<total_itens;i++){
		if(alvo.className==array[i]){
			if(i==(total_itens-1)){
				alvo.className=array[0];	
				return;
				} else {
				alvo.className=array[i+1];				
				return;
				}
			} 
		}
	
	}

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

function focar_campo(campo){
	var alvo = document.getElementById(campo);
	alvo.focus();
	alvo.select();
	return false;
	}

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

function executarAoEnter(e,funcao,vars){
	<!--  onKeyPress="return executarAoEnter(event,funcao,'vars');" !-->
	
	if(typeof funcao=='undefined'){
							   	funcao = '';
								}
	if(typeof vars=='undefined'){
							   	vars = '';
								}
	
  if (e.keyCode) { // IE   
		tecla = e.keyCode;   
	  }  else if (e.which) { // Firefox   
		tecla = e.which;   
	  }  else { // Sei lá! :P   
		return false;   
	  }   
	
	if(tecla==13){
		if(funcao!=""){
				exec = funcao;
				if(vars!=''){
					exec(vars);
					} else {
					exec();
					}
				}
		return false;
		}
}

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

function arrastar(alvo){
	$("#"+alvo).draggable();
	}	
	
////////////////////////////////////////////////////		
	
function fn_ampliar_conteudo(url,largura,topo,funcao,vars,drag,local_anexo){
	
		if(typeof drag == 'undefined'){
		   	drag='s';
			}
		
		if(typeof topo == 'undefined'){
		   	topo=20;
			}
	
		if(typeof local_anexo == 'undefined'){
		   	local_anexo='body';
			}
	
		var n = $("#dv_ampliar").length;
		
		if(n==0){
					$('<style>\
					  		#dv_ampliar{ \
								position:absolute; \
								display: table; \
								left:0px; \
								top:0px; \
								width:100%; \
								height:100%; \
								z-index:100; \
								} \
							#dv_ampliar_fundo{ \
								position:fixed; \
								left:0px; \
								top:0px; \
								background-color:#000000; \
								width:100%; \
								height:100%; \
								z-index:101; \
								filter: Alpha(Opacity=40); \
								opacity: .4; \
								} \
							#dv_ampliar_palco{ \
								display:block; \
								position:absolute; \
								left:50%; \
								top:20px; \
								z-index:102; \
								width:200px; \
								} \
							#btn_fechar_ampliado{ \
								cursor:pointer;  \
								position:absolute;  \
								right:15px;  \
								top:15px;  \
								width:11px; \
								height:11px; \
								z-index:105; \
								} \
							#dv_ampliar_borda_top_esq, \
							#dv_ampliar_borda_top_dir, \
							#dv_ampliar_borda_top, \
							#dv_ampliar_borda_esq, \
							#dv_ampliar_borda_dir, \
							#dv_ampliar_borda_bot_esq, \
							#dv_ampliar_borda_bot_dir, \
							#dv_ampliar_borda_bot{ \
								position:absolute; \
								z-index:102; \
								background-repeat:repeat; \
								clear:both; \
								} \
							#dv_ampliar_borda_top_esq{ \
								left:0px; \
								top:0px; \
								background-image:url(imagens/ampliar/ampliar_top_esq.png); \
								width:20px; \
								height:20px; \
								} \
							#dv_ampliar_borda_top_dir{ \
								right:0px; \
								top:0px; \
								background-image:url(imagens/ampliar/ampliar_top_dir.png); \
								width:20px; \
								height:20px; \
								} \
							#dv_ampliar_borda_top{ \
								left:20px; \
								right:20px; \
								top:0px; \
								background-image:url(imagens/ampliar/ampliar_top.png); \
								height:20px; \
								} \
							#dv_ampliar_borda_esq{ \
								left:0px; \
								top:20px; \
								width:20px; \
								bottom:20px; \
								background-image:url(imagens/ampliar/ampliar_esq.png); \
								} \
							#dv_ampliar_borda_dir{ \
								right:0px; \
								top:20px; \
								width:20px; \
								bottom:20px; \
								background-image:url(imagens/ampliar/ampliar_dir.png); \
								} \
							#dv_ampliar_borda_bot_dir{ \
								right:0px; \
								bottom:0px; \
								background-image:url(imagens/ampliar/ampliar_bot_dir.png); \
								width:20px; \
								height:20px; \
								} \
							#dv_ampliar_borda_bot_esq{ \
								left:0px; \
								bottom:0px; \
								background-image:url(imagens/ampliar/ampliar_bot_esq.png); \
								width:20px; \
								height:20px; \
								} \
							#dv_ampliar_borda_bot{ \
								left:20px; \
								right:20px; \
								bottom:0px; \
								background-image:url(imagens/ampliar/ampliar_bot.png); \
								height:20px; \
								} \
							#dv_conteudo_ampliado{ \
								position:relative; \
								left:0px; \
								top:0px; \
								display:table; \
								z-index:102; \
								} \
							#dv_ampliar_conteudo_palco{ \
								position:relative; \
								left:0px; \
								top:0px; \
								display:table; \
								clear:both; \
								background-color:#FFFFFF; \
								z-index:102; \
								} \
							</style> \
							<div id="dv_ampliar"> \
								<div id="dv_ampliar_palco"> \
									<img id="btn_fechar_ampliado" src="imagens/icones/fechar.jpg"> \
									<div id="dv_ampliar_borda_top_esq"></div> \
									<div id="dv_ampliar_borda_top"></div> \
									<div id="dv_ampliar_borda_top_dir"></div> \
									<div id="dv_ampliar_borda_dir"></div> \
									<div id="dv_ampliar_borda_esq"></div> \
									<div id="dv_ampliar_borda_bot_esq"></div> \
									<div id="dv_ampliar_borda_bot"></div> \
									<div id="dv_ampliar_borda_bot_dir"></div> \
									<div id="dv_conteudo_ampliado"> \
										<div style="margin:20px;background-color:#FFFFFF;"> \
											<div id="dv_ampliar_conteudo_palco"></div> \
										</div> \
									</div> \
								</div> \
								<div id="dv_ampliar_fundo"></div> \
							<div id="dv_ampliar_carregando"></div> \
						</div>').appendTo(local_anexo);
				$("#dv_ampliar_fundo").click(function(event){
					ocultaCorte('dv_ampliar');
				 	});
				$("#btn_fechar_ampliado").click(function(event){
					ocultaCorte('dv_ampliar');
				 	});
				 
			} else {
			 exibe('dv_ampliar');
			}

		$("#dv_ampliar_palco").draggable();

		carregaAjax(url,'dv_ampliar_conteudo_palco','dv_ampliar_carregando',funcao,vars);

		//OCULTAR AO ESC
		$(document).one("keydown", function(event){
					if(event.keyCode==27){
						ocultaCorte('dv_ampliar');
						}
					});

		altura = $(document).height();
		if((largura=='') || (largura==undefined)){
			largura=780;
			}
		
		largura = largura+40;
		margem_esq = largura-(largura+(largura/2));
		
		if(drag!='s'){
			$("#dv_ampliar_palco").draggable('destroy');	
			}
		
		$("#myDiv").animate({ scrollTop: $("#myDiv").attr("scrollHeight") }, 3000);
		
		distancia = $("body").scrollTop();
		topo+=distancia;
		
		$("#dv_ampliar").css("height",altura+"px");
		$("#dv_ampliar_palco").css("width",largura+"px");
		$("#dv_ampliar_palco").css("margin-left",margem_esq+"px");
		$("#dv_ampliar_palco").css("top",topo+"px");
		
		}
		
////////////////////////////////////////////////////		

function confereCaractere(char,campo){
	
	var alvo = document.getElementById(campo);
	var conteudo = alvo.value;
	
		if(conteudo.indexOf(char,0) == -1){
			return false;
			} else {
			return true;
			}
			
	}

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

function corrige_pos_800_600(){

	base = document.getElementsByTagName('body');
	total = base[0].childNodes.length;
	
	for(i=0;i<total;i++) {
		if(base[0].childNodes[i].id){
			var nome_alvo = base[0].childNodes[i].id;
			var alvo_busca = document.getElementById(nome_alvo);	
			if(alvo_busca){
				var alvo = $('#'+nome_alvo);
				var posicao = alvo.offset();
				if(posicao.left<0){
					largura = (alvo.width()/2)+5;
					alvo_busca.style.left=largura+'px';

					}
				}
			}
		}
	}

////////////////////////////////////////////////////	
	
function fade(alvo,velocidade,alpha,funcao,vars){
	var alvo = document.getElementById(alvo);
	if(alvo){
		$(alvo).fadeTo(velocidade,alpha,function(){
												 if(funcao!=undefined){
													exec = funcao;
													exec(vars);
													}
												 });
		}
	}
	
////////////////////////////////////////////////////	

function menuDrop(alvo_menu,estilo_on,estilo_off,alvo_div_subs){
	
	if(typeof(alvo_menu)=='string'){
		alvo_menu = document.getElementById(alvo_menu);
		}
		
	if(alvo_menu.className==estilo_on){
			alvo_menu.className=estilo_off;
			ocultaCorte(alvo_div_subs);
		} else {
			alvo_menu.className=estilo_on;
			exibeCorte(alvo_div_subs);
		}
	
	}

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

function upload(id_alvo,arquivo_alvo,funcao,vars,swf,img_cancel,max_size,max_size_msg_erro){

	if(typeof(id_alvo)=='string'){
		id_alvo = document.getElementById(id_alvo);
		}
	if(typeof swf == 'undefined'){
		 swf = 'swf/uploader.swf';
		}
	if(typeof img_cancel == 'undefined'){
		img_cancel = 'imagens/icones/cancel_upload.png';
		}
	if(typeof max_size== 'undefined'){
		 max_size = 100000000; //(100mb)
		}
	if(typeof max_size_msg_erro== 'undefined'){
		 max_size_msg_erro = 'Tamanho do arquivo acima do máximo permitido.';
		}
	
	$(document).ready(function() {
		$(id_alvo).fileUpload({
		'uploader'  : swf,
		'script'    : arquivo_alvo,
		'cancelImg' : img_cancel,
		'auto'      : true,
		'sizeLimit' : max_size,
		
		// 'folder'    : diretorio,
		'onCancel'   : function(){
							alert('Upload cancelado!');
							},

		'onError'   : function (event,ID,fileObj,errorObj) {
			  		if(errorObj.type == 'File Size'){
						alert(max_size_msg_erro);
						}
				},
		'onComplete': function(){
							if(funcao!=undefined){
								exec = funcao;
								if(funcao!=undefined){
									exec(vars);
									}else{
									exec();	
									}
								}
							}
		});
	});	
}

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

function mascara(alvo,formato,e){
		//L = letras
		//9 = números
		//onKeyPress="return mascara(this.id,'LLL-9999',event);"
		
		if (e.keyCode) { 
			 tecla = e.keyCode;   
		  }  else if (e.which) { 
			 tecla = e.which;   
		  }  else {    
			 return false;   
		  }
	
		if(tecla==8 || tecla==9 || tecla==46 || tecla==37 || tecla==39){
			return true;
			}
	
		alvo = document.getElementById(alvo);
		texto = alvo.value;
		
		tamanho_texto = texto.length;
		tamanho_formato = formato.length;
		
		if(tamanho_texto>(tamanho_formato-1)){
			return false;
			}
		
		charAtual = String.fromCharCode(tecla);
		
		i=tamanho_texto;
		formatoAtual = formato.charAt(i);
		formatoProximo = formato.charAt((i+1));
			
			if(formatoAtual!='L' && formatoAtual!='9'){
					alvo.value = texto+formatoAtual;
					formatoAtual = formatoProximo;
					}
			
			if(formatoAtual=='L'){
				
					busca=/[a-zA-Z]/;
					if(charAtual.search(busca)==-1){
						return false;
				  		} 
				
				} else if (formatoAtual=='9'){
				
					busca=/\d/;
					if(charAtual.search(busca)==-1){
						return false;
				  		}
				
				} else {
					return false;
				}
		
		return true
	
	}

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

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==""){
			alternaEstilo(campo,'borda_erro');
			alvo.focus();
			alert('Preencha o campo selecionado!');
			return false;
			} else {
			alternaEstilo(campo,'');	
			}
		}

	}
	
////////////////////////////////////////////////////	

function somenteDecimal(e){
	
	<!--  onKeyPress="return somenteDecimal(event);" !-->
	
  if (e.keyCode) { // IE   
    tecla = e.keyCode;   
  }  else if (e.which) { // Firefox   
    tecla = e.which;   
  }  else { // Sei lá! :P   
    return false;   
  }   

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

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

  if(tecla==13 || tecla==9 || (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(alvo){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop=document.body.scrollTop;
	
	exibe("dv_zoom");
	carregaAjax(alvo,dv_palco_zoom,dv_carregando_zoom);
	}

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

function ampliarFoto(foto,legenda,credito){
	
	pos_zoom = document.getElementById("dv_zoom");
	pos_zoom.style.marginTop='0px';

	transparencia = document.getElementById('dv_transparente');
	transparencia.style.height = $(document).height()+'px';
	transparencia.style.top = '0px';
	
	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(typeof(funcao)!='undefined'){
					if(funcao!=''){
						
						exec = funcao;
						if(typeof(vars)!='undefined'){
							if(vars!=''){
								exec(vars);
								} else {
								exec();			
								}
							} else {
							exec();	
							}
						}
					}
				
				}
			}
		);
	}

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

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 alternaDisplayCorte(alvo,estiloExibe){
	
	if(typeof(alvo)=='string'){
		alvo = document.getElementById(alvo);
		}
	
	if(alvo.style.display=='none' || alvo.style.display==''){
			$(alvo).slideDown("fast");
		} else {
			$(alvo).slideUp("fast");			
		}

	}

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

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 exibeCorte(alvo,funcao,vars){
	
	if(typeof(alvo)=='string'){
		alvo = document.getElementById(alvo);
		}
	if(alvo!=null){
		$(alvo).slideDown("fast",function(){
									 if(funcao!=undefined){
										exec = funcao;
										exec(vars);
										}
									 });
		}
	}
	
/////////////////////////////////////////////////////

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

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

function ocultaCorte(alvo,funcao,vars){
	
	if(typeof(alvo)=='string'){
		alvo = document.getElementById(alvo);
		}
	
	if(alvo!=null){
		$(alvo).slideUp("fast",function(){
									 if(funcao!=undefined){
										exec = funcao;
										exec(vars);
										}
									 });
		}
	}
	
/////////////////////////////////////////////////////

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


