// JavaScript Document

function carregaCombo(url, codigo, id) {
	//alert(url + "?tipo=" + tipo)
	$("#" + id).load(url + "?codigo=" + codigo)
}

function isInt(id)
{
   	element = document.getElementById(id)
	var str = /^\d+$/;
	return str.test(valor_text);
}


function formatar(id, mask)
{
	src = document.getElementById(id);
	var i = src.value.length;
  	var saida = mask.substring(0,1);
  	var texto = mask.substring(i)
	if (texto.substring(0,1) != saida)
  	{
    	src.value += texto.substring(0,1);
  	}
}
function formatarFone(id)
{
	src = document.getElementById(id);
	var i = src.value.length;
	if(i==1)
	{
		src.value = "(" + src.value;
	}
	if(i==3)
	{
		src.value = src.value + ") " 
	}
	if(i==9)
	{
		src.value = src.value + "-" 
	}
	
	
}
function formatarValor(id)
{
	obj = document.getElementById(id)
	valor_aux = obj.value;
	if( valor_aux != "")
	{
		if(isFloat(valor_aux) == true)
		{
			pos = valor_aux.search(",");
			if(pos != -1)
			{
				vet_valor = valor_aux.split(",");
				valor = vet_valor[0];
				valor= valor.replace(".","")
				valor= valor.replace(".","")
				valor= valor.replace(".","")
				valor= valor.replace(".","")
				valor= valor.replace(".","")
				valor = valor * 100;
				valor = valor / 100;
				valor = new String(valor);	
				if(valor != "")
				{
					if (vet_valor[1].length == 2)
					{
						valor = formataFloatPonto(valor) + "," + vet_valor[1];
						document.getElementById(id).value = valor;
					}
					else
					{
						if (vet_valor[1].length > 2)
						{
							vet_valor[1] = vet_valor[1].substring(0,2);	
							valor = formataFloatPonto(valor) + "," + vet_valor[1]
							document.getElementById(id).value = valor;
						}
						else
						{
							valor = formataFloatPonto(valor) + "," + vet_valor[1] + "0"	
							document.getElementById(id).value = valor;
						}
					}
				}
				else
				{
					valor = formataFloatPonto(valor) + ",00"; 
					document.getElementById(id).value = valor;
				}
			}
			else
			{
				valor_aux= valor_aux.replace(".","")
				valor_aux= valor_aux.replace(".","")
				valor_aux= valor_aux.replace(".","")
				valor_aux= valor_aux.replace(".","")
				valor_aux= valor_aux.replace(".","")
				obj = document.getElementById(id);
				obj.value = formataFloatPonto(valor_aux) + ",00"
				
			}
		}
	}
	
}
function formataFloatPonto(valorParam)
{
	valor = valorParam;	
	tam_vet = parseInt(valor.length / 3)
	var vet_aux = new Array();				
	cont = 0;
	contVet = 0
	if (valor != "")
	{
		if (valor.length > 3)
		{
				
			for(i=valor.length;i>0;i--)
			{
				if( ( cont % 3 == 0)  && (cont > 0) )
				{
					vet_aux[contVet] = i;
					contVet = contVet + 1;
				}	
				cont = cont + 1
			}
			for(i=0;i<vet_aux.length;i++)
			{
				valor = valor.substring(0,vet_aux[i]) + "." + valor.substring(vet_aux[i],valor.length);				
			}
			
		}
	}
	else
	{
		valor = "0";
	}
	return valor
}

function insNumeric(obj,event)
{
    if(obj.id == "cep1")
	{
		maxLengh = 4
		if( $.browser.msie )
		{
			setTimeout(function(){
				if( obj.value.length == 5)
				{
					document.getElementById("cep2").focus();	
				}
			},300)
			
		}
		else
		{		
			if( obj.value.length == maxLengh)
			{
				document.getElementById("cep2").focus();	
			}
		}
	}
	
	var tecla = event.charCode;
    var ie = event.keyCode;
    if (!event) event = window.event;
    var code;
    if (event.keyCode) code = event.keyCode;
    else if (event.which) code = event.which; // Netscape 4.?
//se nao for número nem parentesis ou espaço
    if ((code < 48 || code > 59) && (code != 8 ) && (code != 13 ) ){      
	  event.returnValue = false;
      if (event.which){
        event.preventDefault();
      }
      return false;
    }else{
      event.returnValue = true;
      return true;
    }
 }
function insFloat(obj,event)
{
    var tecla = event.charCode;
    var ie = event.keyCode;
    if (!event) event = window.event;
    var code;
    if (event.keyCode) code = event.keyCode;
    else if (event.which) code = event.which; // Netscape 4.?
//se nao for número nem parentesis ou espaço
    if ((code < 48 || code > 59) && (code != 8 ) & (code != 44) && (code != 13 )){
      event.returnValue = false;
      if (event.which){
        event.preventDefault();
      }
      return false;
    }else{
      event.returnValue = true;
      return true;
    }
} 
function mask(_mask, val) {
	var i, mki;
	var aux="";
	
	for(i=mki=0; i<val.length; i++, mki++) {
		if(_mask.charAt(mki)=='' || _mask.charAt(mki)=='#' || _mask.charAt(i)==val.charAt(i)) {
			aux+=val.charAt(i);
		} else {
			aux+=_mask.charAt(mki)+val.charAt(i);
			mki++;
		}
	}
	return aux;
}
function mascaraNumero(obj,event,_mask)
{
    var tecla = event.charCode;
    var ie = event.keyCode;
    if (!event) event = window.event;
    var code;
    if (event.keyCode) code = event.keyCode;
    else if (event.which) code = event.which; // Netscape 4.?
//se nao for número nem parentesis ou espaço
    var strCheck = '0123456789';
	rcode = code
    key=String.fromCharCode(rcode);
	
	
	  if( code != 8 && code != 9 && code != 46 && code != 39 && code !=37 && code !=116 && code !=13 ){
	//Not a valid key
		
		if( (strCheck.indexOf(key)==-1 || (obj.value.length >= _mask.length) ) )
		{
			return false;
		}
		aux=obj.value+key;
		//window.alert(aux);
		aux=mask(_mask,aux);
		//window.alert(aux);
		obj.value=aux;	
		return false;
	 }
	 else
	 {
		
		event.returnValue = true;
      	return true; 
	 }    


 }

function isFloat(valor)
{
	var valor_text = valor;
	var str = /^[+-]?((\d+|\d{1,3}(\.\d{3})+)(\,\d*)?|\,\d+)$/;
	return str.test(valor_text);
}

function pegarHora(campo){
	hora = new Date;
	wHora = hora.getHours();
	wMin = hora.getMinutes();
	if(wMin < 10){
		wMin = "0" + wMin;
	}
	wSec = hora.getSeconds();
	if(wSec < 10){
		wSec = "0" + wSec;
	}
	
	//wHoraF = wHora +":"+ wMin +":"+ wSec;
	wHoraF = wHora +":"+ wMin;
	
	document.getElementById(campo).innerHTML = wHoraF;
	
	setTimeout("pegarHora('"+campo+"')",1);
}
function pegarData(){
	var nomeDia;
	data = new Date;
	dia  = data.getDay();
	mes = data.getMonth();
	ano = data.getFullYear();
	
	switch(dia){
		case 0:
			nomeDia = "Domingo";
		case 1:
			nomeDia = "Segunda-feira";
		case 2:
			nomeDia = "Terça-feira";
		case 3:
			nomeDia = "Quarta-feira";
		case 4:
			nomeDia = "Quinta-feira";
		case 5:
			nomeDia = "Sexta-feira";
		case 6:
			nomeDia = "Sábado";
	}
	
	switch(mes){
		case 0:
			nomeMes = "janeiro";
		case 1:
			nomeMes = "fevereiro";
		case 2:
			nomeMes = "março";
		case 3:
			nomeMes = "abril";
		case 4:
			nomeMes = "maio";
		case 5:
			nomeMes = "junho";
		case 6:
			nomeMes = "julho";
		case 7:
			nomeMes = "agosto";
		case 8:
			nomeMes = "setembro";
		case 9:
			nomeMes = "outubro";
		case 10:
			nomeMes = "novembro";
		case 11:
			nomeMes = "dezembro";
	}
	
	campoData = document.getElementById("data_semana");
	campoData.innerHTML = nomeDia +", "+ dia +" de "+ nomeMes +" de "+ ano +".";	
}


function janelaBusca(url,id,idIns,IdDel,largura,altura)
{
	element = document.getElementById(id)
	extra = document.getElementById("extra")
	wurl = url + "&digitado="+ element.value + "&camposIns=" + idIns + "&camposApagar=" + IdDel	
	
	if( (extra) && (extra.value != "") )
	{
		vet_extra = extra.value.split("|");
		campoExtra = vet_extra[0];
		valorCampo = document.getElementById(vet_extra[1]);
		if (valorCampo)
		{
			wurl = wurl + "&campoExtra=" + campoExtra + "&valorExtra=" + valorCampo.value
		}
	}
	
	winDt = window.open(wurl,'','top=300,left=600,width='+ largura +',height='+ altura +',scrollbars=1,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0');
	winDt.focus();
}

function excluirReg(url)
{
	urlRetornoAlert=url;
	confirm("Deseja realmente excluir o registro?")
	
}
function fechar()
{
	close();
}
function salvar(id)
{
	document.getElementById(id).submit();	
}

function abrirMenu(wcontrole)
{	
	$("#"+wcontrole).slideToggle("normal")
}

function janelaRelatorio(wurl)
{
	var winDt = window.open(wurl,'','scrollbars=1,status=1,toolbar=1,location=0,menubar=1,directories=1,resizable=1');
	winDt.focus();
}


idCategoriaAnterior = ""
idSubCategoriaAnterior = ""
controleClickOpen = false
function iniciarFuncoes()
{
	//funcoes para o menu topo
	
	$(".submenu").hover(function(){
		
		$(this).find("a:eq(0)").css("background-position","0px -33px")
		$(this).find("ul").show()	
		$(".submenu ul li").css("background-position","0px 0px").css("color","#FFF")
		$(".submenu ul li").find("a").css("background-position","0px 0px").css("color","#FFF")
	}, 
	function() {
		$(this).find("a:eq(0)").css("background-position","0px 0px")
		$(this).find("ul").hide()
	});
	$(".submenu ul li").hover(function(){			
		$(this).stop().animate({
			backgroundPosition: "(0 -30px)"			
		}, 500,function(){ $(this).css("color","#01520F"); $(this).find("a").css("color","#01520F") })
								 
	}, 
	function() {
		 $(this).stop().animate({backgroundPosition:"(0px 0px)"},500,function(){ $(this).css("color","#FFF");$(this).find("a").css("color","#FFF") })
	});
	
	
	//fim funcoes menu
	
	// abrir link em outra janela
	$(".novaJanela").click(function(){

		wurl = $(this).attr("href")

		janelaExterna(wurl)

		return false

	})

	//Funcoes da exibição rotativa de nocias na home
				
	iniciarGaleria()
	
	$("#btnNoticiaEsq").click(function(){
		if( controleClick == true)
		{
			controleClick = false
			fotoAux = parseInt(foto_atual) - 1
			if( fotoAux < 0 )
			{
				fotoAux = $("#fotoNoticiaHome img").length-1	
			}
			mudar_foto(fotoAux)
		}
		
	})
	
	$("#btnNoticiaDir").click(function(){
		if( controleClick == true)
		{
			controleClick = false
			fotoAux = parseInt(foto_atual) + 1
			if( fotoAux == $("#fotoNoticiaHome img").length )
			{
				fotoAux = 0
			}
			mudar_foto(fotoAux)
		}
	})
	
	$("#btnNoticiaPause").toggle(
	  function () {
		$(this).attr("src","imagens/bt-pause2.png")
		clearInterval(intervalo);
		controlePause = true;
		
	  },
	  function () {
		$(this).attr("src","imagens/bt-pause.png")
		intervalo = setInterval(function(){
			mudar_fotoAuto()
		},4000);
		controlePause = false
	  }
	);
	
	
	intervalo = setInterval(function(){
		mudar_fotoAuto()
	},4000)
		
	//fim
	
	
	
	$(".linkVideos").click(function(){
		incluirFundo('fundoVideo','')
		
		
		wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat(31) ) / 2
		if (document.all)
		{
			var wtop = parseInt(document.documentElement.scrollTop)
		}
		else
		{
			var wtop = parseInt(window.scrollY)
		}
		wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat(31) ) / 2 )
		
		$("<img src='imagens/ajax-loader.gif' id='carregando' style='position:absolute;z-index:110px'>").css("left",wleft).css("top",wtop).css("position","absolute").css("z-index","1000").appendTo("body")
		$("<div id='caixaVideo'/>").appendTo("body").hide()
		index = $(".linkVideos").index($(this))
		$("#caixaVideo").load("carrega_video.asp?" + $(this).attr("href").split("?")[1],function(){
			setTimeout(function(){
				wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat($("#caixaVideo").innerWidth()) ) / 2
				if (document.all)
				{
					var wtop = parseInt(document.documentElement.scrollTop)
				}
				else
				{
					var wtop = parseInt(window.scrollY)
				}
				wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat($("#caixaVideo").innerHeight()) ) / 2 )
				$("#carregando").remove()
				$("#caixaVideo").css("left",wleft).css("top",wtop).show("normal")
				$("<img src='imagens/fechar_x.png' id='btnFecharVideo' class='btnFecharCaixa'>").appendTo("#caixaVideo")			
				$("#fundoVideo,#btnFecharVideo").click(function(){
					$("#caixaVideo").remove()
					$("#fundoVideo").remove()				
				})					
								
			},3000)
			
																	 
		})
		return false								  
	})
	
	//Funcao para exibir texto devocional
	$("#linkDevocional").click(function(){
		incluirFundo('fundoVideo','')
		
		
		wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat(31) ) / 2
		if (document.all)
		{
			var wtop = parseInt(document.documentElement.scrollTop)
		}
		else
		{
			var wtop = parseInt(window.scrollY)
		}
		wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat(31) ) / 2 )
		
		$("<img src='imagens/ajax-loader.gif' id='carregando' style='position:absolute;z-index:110px'>").css("left",wleft).css("top",wtop).css("position","absolute").css("z-index","1000").appendTo("body")
		$("<div id='caixaVideo'/>").appendTo("body").hide()
		$("#caixaVideo").html($("#textoDevocional").html())
		setTimeout(function(){
			wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat($("#caixaVideo").innerWidth()) ) / 2
			if (document.all)
			{
				var wtop = parseInt(document.documentElement.scrollTop)
			}
			else
			{
				var wtop = parseInt(window.scrollY)
			}
			wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat($("#caixaVideo").innerHeight()) ) / 2 )
			$("#carregando").remove()
			$("#caixaVideo").css("left",wleft).css("top",wtop).show("normal")
			$("<img src='imagens/fechar_x.png' id='btnFecharVideo' class='btnFecharCaixa'>").appendTo("#caixaVideo")			
			$("#fundoVideo,#btnFecharVideo").click(function(){
				$("#caixaVideo").remove()
				$("#fundoVideo").remove()				
			})					
							
		},1000)
		return false
	})
	
	//Trocar galeria de videos
	$(".tituloListaDocumentos").click(function(){
		$(".listaDocumentos").css("display","none")
		$("#cont_" + $(this).attr("id").split("_")[1]).css("display","block")	
		return false
	})
	
	
	//caixa de zoom nos documentos
	
	
	$(".zoomImg").click(function(){
				
		incluirFundo('fundoVideo','')


		wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat(31) ) / 2
		if (document.all)
		{
			var wtop = parseInt(document.documentElement.scrollTop)
		}
		else
		{
			var wtop = parseInt(window.scrollY)
		}
		wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat(31) ) / 2 )
		
		$("<img src='imagens/ajax-loader.gif' id='carregando' style='position:absolute;z-index:110px'>").css("left",wleft).css("top",wtop).css("position","absolute").css("z-index","1000").appendTo("body")
		
		$("#fundoVideo").click(function(){
			$("#carregando").remove()
			$("#fundoVideo").remove()				
		})	
		
		imgPreloader = new Image()	
		linkImagem = $(this).attr("href")
		
		$("<div id='caixaVideo'><img src='"+ $(this).attr("href") +"'></div>").appendTo("body").hide()
		imgPreloader.onload = function(){
			imgPreloader.onload = function(){}
			wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseFloat(imgPreloader.width) ) / 2
			if (document.all)
			{
				var wtop = document.documentElement.scrollTop
			}
			else
			{
				var wtop = window.scrollY
			}
			wtop = $(window).scrollTop()
			wtopCaixa = parseFloat(wtop) + 50
			heightImg = parseFloat(imgPreloader.height) + 50
			
			if (!$.browser.opera)
			{
				if( parseFloat(heightImg) < parseFloat($(window).height()) )
				{
					
					wtopCaixa = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat(heightImg) ) / 2 )
					if( parseFloat(wtopCaixa) < 50 )
					{
						wtopCaixa = wtop + 50
					}
				}
			}
			
			$("#carregando").remove()
			$("#caixaVideo").css("left",wleft).css("top",wtopCaixa).show("normal",function(){
				$("#fundoVideo").remove()
				incluirFundo('fundoVideo','')	
				$("<img src='imagens/fechar_x.png' id='btnFecharVideo' class='btnFecharCaixa'>").appendTo("#caixaVideo")			
				$("#fundoVideo,#btnFecharVideo").click(function(){
					$("#caixaVideo").remove()
					$("#fundoVideo").remove()				
				})	
			})
							
		}
		imgPreloader.src = linkImagem
		return false
	})
	
	
	
	
	$("#addFavorito").click(function(){
		var url  = location.href;
		var title  = $("title").text()
		
		if (!$.browser.opera) 
		{                
			
			if ($.browser.mozilla) {
					window.sidebar.addPanel(title, url, '');
					return false;
			} else if($.browser.msie) {  
					window.external.AddFavorite( url, title);
					return false;
			} else {
					var o = $('a.bookmark').offset();
					alert('Use as teclas CTRL + D para adicionar aos favoritos.');
			}
			return false
        }

		
	})
	
	
	//Exibição de imagens de animais
	
	$(".tituloListaAnimais").css("cursor","pointer")
	if( $(".categoriaSelecionada").length > 0 )
	{
		idCategoriaAnterior = $(".categoriaSelecionada").attr("id")
	}
	if( $(".subCategoriaSelecionada").length > 0 )
	{
		idSubCategoriaAnterior = $(".subCategoriaSelecionada").attr("id")
	}
	$(".tituloListaAnimais").click(function(){
		if( $(this).attr("id").split("_")[1] != "animais")
		{
			
			if( $(this).attr("id").split("_")[1] == "categ")
			{
				
				if( $(this).attr("id") != idCategoriaAnterior && idCategoriaAnterior != "")
				{
					
					if( controleClickOpen == false )
					{
						
						controleClickOpen = true
						idAtual = $(this).attr("id")
						altura = $("#cont_sub_" + $(this).attr("id").split("_")[2]).innerHeight()
						alturaAnterior = $("#cont_sub_" + idCategoriaAnterior.split("_")[2]).innerHeight()
						alturaConteudoAnimais = 0
						idConteudoListAnimais = ""
						
						//$(".descricaoCategoriaSub").css("display","none")
						//$("#desc_categ_" + idAtual.split("_")[2]).css("display","block")
						
						
						if( $(".listAnimais:visible").length > 0 )
						{
							alturaConteudoAnimais = $(".listAnimais:visible").innerHeight()
							idConteudoListAnimais = $(".listAnimais:visible").attr("id")
						}
						$("#" + idCategoriaAnterior).css("background","none")
						$("#cont_sub_" + idCategoriaAnterior.split("_")[2] + ",.listAnimais:visible").animate({       
							height: 0												
						}, 800,function(){
							$("#cont_sub_" + idCategoriaAnterior.split("_")[2]).hide()
							$(".listAnimais").hide()
							if( idConteudoListAnimais != "")
							{
								$("#"+idConteudoListAnimais).height(alturaConteudoAnimais)	
							}
							$("#cont_sub_" + idCategoriaAnterior.split("_")[2]).height(alturaAnterior)												
							$("#cont_sub_" + idAtual.split("_")[2]).height(0).show()
							$(".titSubCategAnimais").css("background","none")
							idCategoriaAnterior = idAtual
							$("#cont_sub_" + idAtual.split("_")[2]).animate({       
								height: altura												
							}, 800,function(){ controleClickOpen=false })
						
						})
						$("#" + idAtual).css("background","url(imagens/caixa_seta.png) no-repeat")
					}
					
					
				}
				else
				{
					if( idCategoriaAnterior == "")
					{
						altura = $("#cont_sub_" + $(this).attr("id").split("_")[2]).innerHeight()
						$("#cont_sub_" + $(this).attr("id").split("_")[2]).height(0).show()
						$("#cont_sub_" + $(this).attr("id").split("_")[2]).animate({       
							height: altura												
						}, 800)
						idAtual = $(this).attr("id")
						$("#" + idAtual).css("background","url(imagens/caixa_seta.png) no-repeat")
						idCategoriaAnterior =idAtual												
					}
					//$("#desc_categ_" + idAtual.split("_")[2]).css("display","block")
					
				}
				
			}
			else
			{
														
				if( $(this).attr("id") != idSubCategoriaAnterior && idSubCategoriaAnterior != "")
				{
					
					if( controleClickOpen == false )
					{
						controleClickOpen = true
						idAtual = $(this).attr("id")
						altura = $("#cont_animais_" + $(this).attr("id").split("_")[2]).innerHeight()
						alturaAnterior = $("#cont_animais_" + idSubCategoriaAnterior.split("_")[2]).innerHeight()
						
						//$(".descricaoCategoriaSub").css("display","none")
						//$("#desc_sub_" + idAtual.split("_")[2]).css("display","block")
						
						
						$("#" + idSubCategoriaAnterior).css("background","none")
						$("#cont_animais_" + idSubCategoriaAnterior.split("_")[2]).animate({       
							height: 0												
						}, 800,function(){
							$("#cont_animais_" + idSubCategoriaAnterior.split("_")[2]).hide()
							$("#cont_animais_" + idSubCategoriaAnterior.split("_")[2]).height(alturaAnterior)												
							$("#cont_animais_" + idAtual.split("_")[2]).height(0).show()												
							idSubCategoriaAnterior = idAtual
							$("#cont_animais_" + idAtual.split("_")[2]).animate({       
								height: altura												
							}, 800,function(){ controleClickOpen=false })	
						
						})
						$("#" + idAtual).css("background","url(imagens/caixa_seta.png) no-repeat")
					}
					
				}
				else
				{
					if( idSubCategoriaAnterior == "")
					{
						altura = $("#cont_animais_" + $(this).attr("id").split("_")[2]).innerHeight()
						$("#cont_animais_" + $(this).attr("id").split("_")[2]).height(0).show()
						$("#cont_animais_" + $(this).attr("id").split("_")[2]).animate({       
							height: altura												
						}, 800)
						idAtual = $(this).attr("id")
						$("#" + idAtual).css("background","url(imagens/caixa_seta.png) no-repeat")
						idSubCategoriaAnterior =idAtual
						
					}
					
					
				}
				
				
			}
		}
		
	})
	$(".tituloListaAnimais a[class!='linkGenealogia']").click(function(){ 
		$(this).parent().parent().click()
		return false
	})
	
	
	//Trocar Imagens dos animais no detalhamento
	$("#fotoAnimalPrincipal a:gt(0)").hide()
	$("#fotoAnimalMiniatura img").click(function(){
		
		if( $(this).attr("src").split("/")[$(this).attr("src").split("/").length-1] != $("#fotoAnimalPrincipal a:visible").attr("href").split("/")[$("#fotoAnimalPrincipal a:visible").attr("href").split("/").length-1])
		{
			
			$("#fotoAnimalMiniatura img").removeClass("fotoAnimalMiniaturaBordaCinza").addClass("fotoAnimalMiniaturaBordaNone")
			$(this).removeClass("fotoAnimalMiniaturaBordaNone").addClass("fotoAnimalMiniaturaBordaCinza")
			$("#fotoAnimalPrincipal a:visible").animate( {'opacity':'hide'},'slow');	
			$("#fotoAnimal_" + $(this).attr("id").split("_")[1]).animate( {'opacity':'show'},'slow')	
		}
		
	})
	
	
	//Trocar fundo de input
	$("input[type='text'],textarea").focus(function(){
		$(this).css("background","#FFF")												
	})
	$("input[type='text'],textarea").blur(function(){
		$(this).css("background","#98D201")													
	})
	
	//Fim trocar fundo de input
	
	$(window).resize(function() {
			 	
		if( $("#caixaAlertaJavascript").length > 0 )
		{
			$("#caixaAlertaJavascript").hide()
			wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseInt($("#caixaAlertaJavascript").width() ) ) / 2	
			$("#caixaAlertaJavascript").css("left",wleft)
			setTimeout(function(){
				widthFundo = dimensoesTela().split("x")[0] + "px"
				heightFundo = dimensoesTela().split("x")[1] + "px"	
				$(".fundoOpaco").animate({       
					height: heightFundo,
					width: widthFundo
				}, 200,function(){
					$("#caixaAlertaJavascript").animate( {'opacity':'show'},'normal')	
				});					
			},500)
			
			
			
		}		
		else
		{
			if( $("#caixaVideo").length > 0 )
			{
				$("#fundoVideo").hide()				
				$("#caixaVideo").hide()	
				$("#fundoVideo").css("width",dimensoesTela().split("x")[0]).css("height",dimensoesTela().split("x")[1]).show()
				
				setTimeout(function(){
					wleft = ( parseFloat(dimensoesTela().split("x")[0]) - parseFloat($("#caixaVideo").innerWidth()) ) / 2
					if (document.all)
					{
						var wtop = parseInt(document.documentElement.scrollTop)
					}
					else
					{
						var wtop = parseInt(window.scrollY)
					}
					wtop = parseFloat(wtop) + ( ( parseFloat($(window).height()) - parseFloat($("#caixaVideo").innerHeight()) ) / 2 )						
					$("#caixaVideo").css("left",wleft).css("top",wtop).show("normal")		
				},500)
			}			
		}
		
	});
	
	
	
}

function buscaCep()
{
	wcep = $("#cep").val();	
	wcep = wcep.replace("-","")
	ajax = ajaxInit();	
	if(ajax) {
		ajax.open("GET","busca_cep.asp?cep=" + wcep, true);
		
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 4) {
				if(ajax.status == 200) {
					retorno = ajax.responseText;
					if( retorno != "erro" )
					{
						vetRet = retorno.split("|")	
						$("#endereco").val(vetRet[0])
						$("#bairro").val(vetRet[1])
						//$("#cidade").val(vetRet[2])
						if( $("#codigoEstado").attr("type") == "input" )
						{
							if( vetRet[3].split("-").length > 0 )
							{							
								$("#codigoEstado").val(vetRet[3].split("-")[0])
								$("#nomeEstado").val(vetRet[3].split("-")[1])							
							}
							if( vetRet[2].split("-").length > 0 )
							{							
								$("#codigoCidade").val(vetRet[2].split("-")[0])
								$("#nomeCidade").val(vetRet[2].split("-")[1])							
							}
						}
						else
						{
						
							$("#codigoCidade").val(vetRet[2].split("-")[0])
							$("#nomeCidade").val(vetRet[2].split("-")[1])
							objSelect = document.getElementById("codigoEstado")
							posItem = 0
							for(i=1;i<objSelect.options.length;i++)
							{
								if(objSelect.options[i].value == vetRet[3].split("-")[0])
								{
									$("#text_select_codigoEstado").val( objSelect.options[i].text )
									objSelect.options[i].selected =  true
									posItem = i								
									break
								}
							}
							if( posicaoVetSelect("codigoEstado") < 0 )
							{
								vetSelect[vetSelect.length] = new selecao("codigoEstado",posItem)	
								//$("#text_select_estado").val( objSelect.options[i].text )
							}
							else
							{
								
								
								vetSelect[posicaoVetSelect("codigoEstado")].posSelecao = posItem	
								//$("#text_select_estado").val( objSelect.options[i].text )
							}
						}
						
						
						
					}
				}else{
					//alert(ajax.statusText);
				}
			}
		}
		ajax.send(null);
	}	
	
}
function janelaExterna(url)
{
	var largura = window.width 
	var altura =  window.height
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var wleft = parseInt( ( parseInt(xScroll)-1100 ) /2 )
	largura = parseInt(xScroll)-1000
	altura = yScroll
	//alert(xScroll + " - " + yScroll)
	var winDt = window.open(url,'','left='+ wleft +',width=1050,height='+ altura +',scrollbars=1,status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1');
	winDt.focus();
}


function dimensoesTela()
{
	/*var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;


	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	
	if(yScroll <= windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
		
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}*/
		
	dimensao = $(document).width() + "x" + $(document).height()
	return dimensao
}

function incluirCarregando(txt)
{
	
	$("#caixaCarregando").remove()
	pageWidth = dimensoesTela().split("x")[0]
	pageHeight = dimensoesTela().split("x")[1]	
	$("<div id='caixaCarregando'><img src='imagens/loading2.gif'><label></label></div>").appendTo("body").hide()
	$("#caixaCarregando label").text(txt)
	wleft = ( parseInt(dimensoesTela().split("x")[0]) - parseInt($("#caixaCarregando").width() ) ) / 2
	if (document.all)
	{
		var wtop = parseInt(document.documentElement.scrollTop) + 250
		
	}
	else
	{
		var wtop = parseInt(window.scrollY) + 250	
	}
	//wtop = ( parseInt(dimensoesTela().split("x")[1]) - parseInt( ) ) / 2	
	$("#caixaCarregando").css("left",parseInt(wleft))
	$("#caixaCarregando").css("top",wtop)
	$("#caixaCarregando").show()

}


var foto_atual,proxima_foto,id_foto_atual,id_label_atual;
var num_fotos = 5;
intervalo = new Object();
var controlePause = false;
var controleClick = true;

var arrayLink = new Array();

function iniciarGaleria()
{
	foto_atual = 0;
	id_foto_atual = "#foto_0";
	$("#titNoticia_0").css("backgroundColor","#e3e9dd")		
	if(num_fotos > 1)
	{
		for(i=0;i<=num_fotos;i++)
		{
			
			if( i > 0 )
			{
				idAux = "#foto_"+i
				$(idAux).hide()		
			}
		}
	}
}

function mudar_foto(foto)
{
	
	
	id_proxima_foto = "#foto_"+foto;	
	id_foto_atual = "#foto_"+foto_atual;
	
	id_proxima_titulo = "#titNoticia_"+foto;	
	id_titulo_atual = "#titNoticia_"+foto_atual;
	
	if( id_proxima_foto != id_foto_atual)
	{
		clearInterval(intervalo)	
		$(id_foto_atual).animate( {'opacity':'hide'},'slow');
	
		$(id_proxima_foto).animate( {'opacity':'show'},'slow',function(){
			foto_atual = foto
			id_foto_atual = id_proxima_foto;			
			if( controlePause == false )
			{
				intervalo = setInterval(function(){
					mudar_fotoAuto()
				},4000)
			}
			controleClick = true
		})
		$(id_titulo_atual).css("backgroundColor","#FFF")
		$(id_proxima_titulo).css("backgroundColor","#e3e9dd")
	}
			
}
function mudar_fotoAuto()
{
	fotoAux = parseInt(foto_atual) + 1
	if( fotoAux == $("#fotoNoticiaHome img").length )
	{
		fotoAux = 0
	}
	mudar_foto(fotoAux)
}


var posSelect = -1
var vetSelect = new Array();

function selecao(campo,posSelecao)
{
	this.campo = campo
	this.posSelecao = posSelecao		
		
}

fundoOption = new String()
corOption =  new String()
fundoOptionHover = new String()
corOptionHover =  new String()
var limiteItensSelect = 9
var controleSelecao = ""
var contClickCidade = 0
var idListPersonalizado = ""
function iniciaSelectPersonalizado(parametrosOptions,idConteudo)
{
	
	fundoOption = parametrosOptions[0]
	corOption = parametrosOptions[1]
	fundoOptionHover = parametrosOptions[2]
	corOptionHover =  parametrosOptions[3]
	if( idConteudo != "")
	{
		idConteudo = "#" + idConteudo + " "
	}
	
	$(idConteudo + ".caixaTextSelect").show()
	$(idConteudo + ".btnOpenSelect").show()
	$(idConteudo + ".inputSelect").show()
	$(idConteudo + ".selectPersonalizado select").hide()
	for(i=0;i<$(idConteudo + ".inputSelect").length;i++)
	{
				
		idElement = $(idConteudo + ".inputSelect:eq("+ i +")").attr("id").replace("text_select_","") 
		for(y=0;y<$("#"+ idElement).find("option").length;y++)
		{
			if( $("#"+ idElement).find("option:eq("+ y +")").is(":selected") )
			{
				vetSelect[vetSelect.length] = new selecao(idElement,y)	
			}
		}
		if( idElement == "codigoCidade" || idElement == "codigoCidadeHome")
		{
			
			$(idConteudo + ".inputSelect:eq("+ i +")").val("Seleção do estado obrigatória")
		}
		else
		{
			if( idElement == "codigoBairro")
			{
				
				$(idConteudo + ".inputSelect:eq("+ i +")").val("Selecione cidade")
			}
			else
			{
				$(idConteudo + ".inputSelect:eq("+ i +")").val( $("#"+ idElement).find("option:selected").text() )		
			}
		}
		//$("#"+ idElement).find("option:eq(0)").attr("selected","selected")
		
			
	}
	$(idConteudo + ".inputSelect").keydown(function(event){

		
		if( event.keyCode == 38 || event.keyCode ==40 || event.keyCode ==116 || event.keyCode ==32 || event.keyCode ==13 || event.keyCode ==27 || event.keyCode ==9)
		{
		
			if( event.keyCode == 38 || event.keyCode ==40 )
			{
				if( event.keyCode == 40 )
				{
					if( $(".listSelect:visible").length > 0 )
					{
						posSelect = parseInt(posSelect)+1
						
						if( posSelect == $(".listSelect:visible").find(".option").length)
						{
							posSelect = 0
						}
					}
					else
					{
						$(this).click()
						//$(".listSelect:visible").find(".option:eq(0)").removeClass("selectOff")
						//$(".listSelect:visible").find(".option:eq(0)").addClass("selectOn")
						idList = $(this).attr("id")
						if( posicaoVetSelect(idList.replace("text_select_","")) < 0 )
						{
							posSelect = 0
							$(".listSelect:visible").find(".option").css("background",fundoOption).css("color",corOption)
							$(".listSelect:visible").find(".option:eq(0)").css("background",fundoOptionHover).css("color",corOptionHover)
							$(this).val($(".listSelect:visible").find(".option:eq(0)").text())
						}
						else
						{
							//$("#"+idList).find(".option:eq("+ posSelect +")").removeClass("selectOff")
							//$("#"+idList).find(".option:eq("+ posSelect +")").addClass("selectOn")
							$("#"+idList.replace("text_","")).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("text_select_",""))].posSelecao +")").css("background",fundoOptionHover).css("color",corOptionHover)
							$(this).val( $("#"+idList.replace("text_","")).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("text_select_",""))].posSelecao +")").text() )   
							posSelect = vetSelect[posicaoVetSelect(idList.replace("text_select_",""))].posSelecao
						}
						
					}
				}
				else
				{
					if( $(".listSelect:visible").length > 0 )
					{
						posSelect = parseInt(posSelect)-1
						if( posSelect < 0 )
						{
							posSelect = $(".listSelect:visible").find(".option").length-1
						}	
					}
				}	
				if( $(".listSelect:visible").length > 0 )
				{
					if( parseInt(posSelect%4) ==0 )
					{
						var divOffset = $(".listSelect:visible").offset().top;
						var pOffset = $(".listSelect:visible").find(".option:eq("+ posSelect +")").offset().top;
						var pScroll = pOffset - divOffset;
						$(".listSelect:visible").animate({scrollTop: '+='  + pScroll + 'px'}, 100);
					}
					//$(".listSelect .option").removeClass("selectOn")
					//$(".listSelect .option").addClass("selectOff") 
					$(".listSelect:visible").find(".option").css("background",fundoOption).css("color",corOption)					
					//$(".listSelect:visible").find(".option:eq("+ posSelect +")").removeClass("selectOff")
					//$(".listSelect:visible").find(".option:eq("+ posSelect +")").addClass("selectOn") 
					$(".listSelect:visible").find(".option:eq("+ posSelect +")").css("background",fundoOptionHover).css("color",corOptionHover)
					idUl = $(".listSelect:visible").attr("id")
					$("#"+ idUl.replace("select_","text_select_") ).val($(".listSelect:visible").find(".option:eq("+ posSelect +")").text())
					
				}
				event.returnValue = false;
				if (event.which){
					event.preventDefault();
				}
				return false;
				
				
			}
			else
			{
				if( event.keyCode ==32 || event.keyCode ==13 )
				{
					if( posSelect >=0 )
					{
						$(".listSelect:visible").find(".option:eq("+ posSelect +")").click()
					}
					event.returnValue = false;
				  	if (event.which){
						event.preventDefault();
				 	}
				  	return false;	
					
					
				}
				else
				{
					
					if( $(".listSelect:visible").length > 0 )
					{
						idList = $(this).attr("id")
						if( posicaoVetSelect(idList.replace("text_select_","")) < 0 )
						{
							posSelect = 0						
							$(this).val($(".listSelect:visible").find(".option:eq(0)").text())
						}
						else
						{
							//$("#"+idList).find(".option:eq("+ posSelect +")").removeClass("selectOff")
							//$("#"+idList).find(".option:eq("+ posSelect +")").addClass("selectOn")						
							$(this).val( $("#"+idList.replace("text_","")).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("text_select_",""))].posSelecao +")").text() )   
						}
					}
					//if( $("#caixaCidadeInterna").length > 0 )
					//{
						//$("#caixaCidadeInterna").animate({								   
							//height: "80",
							
						//}, "hide")			
					//}
					$(".caixaSelectPersonalizado").slideUp("hide",function(){ $(".caixaSelectPersonalizado").remove() })
					$("#fundoSelect").remove()	
					
				}
				
				//$(".listSelect .option").removeClass("selectOn")
				//$(".listSelect .option").addClass("selectOff")
				$(".listSelect .option").css("background",fundoOption).css("color",corOption)
			}
			
		
		}	
		else
		{
			event.returnValue = false;
			if (event.which){
			event.preventDefault();
			}
		}			
		
	});
	
	
	
	
	$(idConteudo + ".btnOpenSelect," + idConteudo + ".inputSelect").click(function(){
		controleBtnList = true
		idBtn= $(this).attr("id")
		idList = idBtn.replace("btn_","")
		idList = idList.replace("text_","")		
		
		setTimeout(function(){ $("#text_" + idList).focus() },300)
		if( $("#"+idList).length ==0 || $("#"+idList).is(":hidden") )
		{
			$("#fundoSelect").remove()
			$(".caixaSelectPersonalizado").remove()
				
			
			/*wclassUl = "listSelect" + $("#text_select_" + idList.replace("select_","")).width()
			wclassTopo = "topoSelect" + $("#text_select_" + idList.replace("select_","")).width()
			wclassRodape = "rodapeSelect" + $("#text_select_" + idList.replace("select_","")).width()*/		
			
			if( idListPersonalizado != "" )
			{
				str = "<div class='caixaSelectPersonalizado' id='"+ idListPersonalizado +"'>"
			}
			else
			{
				str = "<div class='caixaSelectPersonalizado'>"	
			}
			
			
			if( $("#" + idList.replace("select_","")).find("option").length > limiteItensSelect )
			{
				str += "<div id='btnMoveSelectTopo' class='btnMoveSelectTopoDesable'></div>"	
			}
			else
			{
				str += "<div id='btnSelectTopo'></div>"	
			}
			str += "<div id='caixaConteudoSelectPersonalizado'>"			
			str += "<ul class='listSelect' id='"+ idList +"' >"			
			if( idList != "select_codigoCidadeHome")
			{			
				for(i=0;i<$("#" + idList.replace("select_","")).find("option").length;i++)
				{
					str += "<li id='op_"+ $("#" + idList.replace("select_","")).find("option:eq("+ i +")").val() +"' class='option'>"+ $("#" + idList.replace("select_","")).find("option:eq("+ i +")").text()  +"</li>"
				}
				
				
			}
			
			str += "</ul>"
			str += "</div>"
			if( $("#" + idList.replace("select_","")).find("option").length > limiteItensSelect )
			{
				str += "<div id='btnMoveSelectRodape' class='btnMoveSelectRodape'></div>"	
			}
			else
			{
				str += "<div id='btnSelectRodape'></div>"	
			}
			str += "</div>"
			wleft = parseFloat($(this).parent("div").offset().left) + parseFloat($("#text_select_" + idList.replace("select_","")).css("left"))
			wtop= parseFloat($(this).parent("div").offset().top) + parseFloat($("#text_select_" + idList.replace("select_","")).css("top"))
			wtop = parseFloat(wtop) + 29			
			$(str).appendTo("body").css("top",wtop).css("left",wleft)
			
			
			
			
			$("#btnMoveSelectTopo").click(function(){ moveSelectCima() })
			$("#btnMoveSelectRodape").click(function(){ moveSelectBaixo() })
			
			
			
			idList = $("#"+idList).attr("id")
			
			$("#"+idList).slideDown("hide",function(){  				
				$("#fundoSelect").animate({
					opacity:'show',				   
					height: dimensoesTela().split("x")[1],
					width: dimensoesTela().split("x")[0]
				}, 200)
			})	
			
			
			$("<div id='fundoSelect'>&nbsp;</div>").appendTo("body").show()
			objF = document.getElementById("fundoSelect")
			objF.style.width = dimensoesTela().split("x")[0] + "px"
			objF.style.height = dimensoesTela().split("x")[1] + "px"
			$("#fundoSelect").click(function(){
				
				$(".listSelect .option").css("background",fundoOption).css("color",corOption)
				if( $(".listSelect:visible").length > 0 )
				{
					idList = $(".listSelect:visible").attr("id")
					
					if( posicaoVetSelect(idList.replace("select_","")) < 0 )
					{
						posSelect = -1
						$(".inputSelect").val($("#"+idList).find(".option:eq(0)").text())	
					}
					else
					{
						//$("#"+idList).find(".option:eq("+ posSelect +")").removeClass("selectOff")
						//$("#"+idList).find(".option:eq("+ posSelect +")").addClass("selectOn")
						$("#"+idList).find(".option:eq("+ posSelect +")").css("background",fundoOptionHover).css("color",corOptionHover)
						$("#text_"+ idList ).val( $("#"+idList).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao +")").text() )   
					}
				}
				
				$(".listSelect li").unbind()
				//if( $("#caixaCidadeInterna").length > 0 )
				//{
					//$("#caixaCidadeInterna").animate({								   
						//height: "80",
						
					//}, 600)	
					
				//}
				$(".caixaSelectPersonalizado").slideUp("hide",function(){ $(".caixaSelectPersonalizado").remove() })												
				$("#fundoSelect").remove()
			})
			
			funcoesItensSelect(0)	
							
			
		}
		else
		{
			
			$(".caixaSelectPersonalizado").slideUp("hide",function(){ $(".caixaSelectPersonalizado").remove() })
			$("#text_"+ idList ).val( $(".listSelect:visible").find(".option:eq(0)").text() )
			
		}		
		
	})
	
}
function posicaoVetSelect(campo)
{
	campo
	if( vetSelect.length > 0 )
	{
		posVet = -1
		for(i=0;i<vetSelect.length;i++)
		{
			
			if( vetSelect[i].campo == campo )
			{
				posVet = i
				break		
			}
		}
		return posVet
	}
	else
	{
		return -1
	}
}
function funcoesItensSelect(posInicia)
{
	if( posInicia ==0 )
	{
		strIten = 	".listSelect .option"	
	}
	else
	{
		strIten = 	".listSelect .option:gt("+ posInicia +")"
	}
	
	$(strIten).css("background",fundoOption).css("color",corOption)
	$(strIten).unbind()
	$(strIten).mouseover(function(){ 
				
		$(".listSelect .option").css("background",fundoOption).css("color",corOption)				
		$(this).css("background",fundoOptionHover).css("color",corOptionHover)
		idUl = $(".listSelect:visible").attr("id")
		$("#"+ idUl.replace("select_","text_select_") ).val($(this).text())
		for(i=0;i<$(".listSelect .option").length;i++)
		{
			if( $("#" + idUl + " .option:eq("+ i +")").attr("id").split("_")[1] == $(this).attr("id").split("_")[1] )
			{
				posSelect = i
				break;
			}
		}
	} )
	$(strIten).mouseout(function(){ 				
		$(this).css("background",fundoOption).css("color",corOption)
	})
	
	idList = $("#caixaConteudoSelectPersonalizado ul").attr("id")
	if( posicaoVetSelect(idList.replace("select_","")) < 0 )
	{
		posSelect = -1				
		$("#text_"+idList).val( $(".listSelect:visible").find(".option:eq(0)").text() )	
	}
	else
	{
		posSelect = vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao
		//$("#"+idList).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao +")").removeClass("selectOff")
		//$("#"+idList).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao +")").addClass("selectOn")
		$("#"+idList).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao +")").css("background",fundoOptionHover).css("color",corOptionHover)
		$("#text_"+ idList ).val( $("#"+idList).find(".option:eq("+ vetSelect[posicaoVetSelect(idList.replace("select_",""))].posSelecao +")").text() )   
	}
	
	
	$(strIten).click(function(){
											
		
		
		idSelect = $(".listSelect:visible").attr("id")
		idElement = $(this).attr("id")
		textElement = $(this).text()
		
		for(i=0;i<$(".listSelect:visible").find(".option").length;i++)
		{
			if( $(".listSelect:visible").find(".option:eq("+ i +")").attr("id").split("_")[1]	==  idElement.split("_")[1] )
			{
				posSelect = i				
				break
			}
		}
		
		for(i=0;i<$("#" + idSelect.replace("select_","")).find('option').length;i++)
		{
			
			if( $("#" + idSelect.replace("select_","")).find("option:eq(" + i + ")").val() == idElement.split("_")[1] )
			{
				
				$("#" + idSelect.replace("select_","")).find("option:eq(" + i + ")").attr("selected","selected")	
				
				$(".listSelect li").unbind()
				
				//$("#"+idSelect).slideUp("hide")
				//if( $("#caixaCidadeInterna").length > 0 )
				//{
					//$("#caixaCidadeInterna").animate({								   
						//height: "80",
						
					//}, 600)			
				//}
				$(".caixaSelectPersonalizado").slideUp("hide")
				
				$("#text_"+idSelect).val( textElement )
				$("#btn_"+idSelect).blur()
				$("#fundoSelect").remove()
				
				if( posicaoVetSelect(idSelect.replace("select_","")) < 0 )
				{
					vetSelect[vetSelect.length] = new selecao(idSelect.replace("select_",""),posSelect)				
				}
				else
				{
					
					vetSelect[posicaoVetSelect(idSelect.replace("select_",""))].posSelecao = posSelect	
				}
				controleSelecao = textElement
				
				
				break					
			}
		}
				
		
	})
	$("#bloqueioClick").remove()
	
}

function moveSelectBaixo()
{
	$(".btnMoveSelectRodape").unbind()
	wtop = parseFloat($(".caixaSelectPersonalizado").find("ul").css("top")) - parseFloat($("#caixaConteudoSelectPersonalizado").height())	
	
	wlimit = $(".caixaSelectPersonalizado").find("ul").height()
	//wlimit = parseInt($("#cestaConteudoProdutos").height())
	if( (parseFloat(wtop)*(-1)) >= wlimit)
	{									
		//wtop = (parseFloat(wtop)*-1) - parseInt(wlimit)									
		wtop = parseFloat(wlimit) * (-1)
		$(".btnMoveSelectRodape").unbind()
		//$("#btnMoveSelectRodape").attr("src","imagens/lista_seta_baixo2.jpg").css("cursor","default")
		$("#btnMoveSelectRodape").removeClass("btnMoveSelectRodape").addClass("btnMoveSelectRodapeDesable")
	}
	verLimite = $(".caixaSelectPersonalizado").find("ul").height() - (parseFloat(wtop) * (-1))
	if( parseFloat(verLimite) < parseFloat($(".caixaSelectPersonalizado").find("ul").height()))
	{
		wtop = parseFloat(wtop) + (parseFloat($(".caixaSelectPersonalizado").find("li").height()) * 2 )	
	}
	
	idUlSelect = $(".caixaSelectPersonalizado ul").attr("id").replace("select_","")
	
	
	$(".caixaSelectPersonalizado").find("ul").animate({
		top:wtop + 'px'
	}, "hide",function(){
		
		$(".btnMoveSelectRodape").click(function(){ moveSelectBaixo() })			
		if( $("#btnMoveSelectTopo").attr("class") == "btnMoveSelectTopoDesable" )
		{
			
			$("#btnMoveSelectTopo").click(function(){
				 moveSelectCima()															 
			})
			//$("#btnMoveSelectTopo").attr("src","imagens/lista_seta_cima.jpg").css("cursor","pointer")
			$("#btnMoveSelectTopo").removeClass("btnMoveSelectTopoDesable").addClass("btnMoveSelectTopo")
		}
		verLimite = $(".caixaSelectPersonalizado").find("ul").height() - (parseFloat($(".caixaSelectPersonalizado").find("ul").css("top").replace("px","")) * (-1))
		if( parseFloat(verLimite) < parseFloat($("#caixaConteudoSelectPersonalizado").height()))
		{
			$("#btnMoveSelectRodape").unbind()			
			$("#btnMoveSelectRodape").removeClass("btnMoveSelectRodape").addClass("btnMoveSelectRodapeDesable")
		}
	
	});		
	
}
function moveSelectCima()
{
	wtop = parseFloat($(".caixaSelectPersonalizado").find("ul").css("top")) + parseFloat($("#caixaConteudoSelectPersonalizado").height())	
	if( parseFloat(wtop) > 0 )
	{
		wtop = 0		
	}
	$(".caixaSelectPersonalizado").find("ul").animate({
		top:wtop + 'px'
	}, "hide",function(){
		
		if( $("#btnMoveSelectRodape").attr("class") == "btnMoveSelectRodapeDesable" )
		{
			$("#btnMoveSelectRodape").click(function(){
				 moveSelectBaixo()															 
			})
			//$("#btnMoveSelectRodape").attr("src","imagens/lista_seta_baixo.jpg").css("cursor","pointer")
			$("#btnMoveSelectRodape").removeClass("btnMoveSelectRodapeDesable").addClass("btnMoveSelectRodape")
		}
		
		if( parseFloat(wtop) >= 0 )
		{
			wtop = 0
			$("#btnMoveSelectTopo").unbind()
			//$("#btnMoveSelectTopo").attr("src","imagens/lista_seta_cima2.jpg").css("cursor","default")
			$("#btnMoveSelectTopo").removeClass("btnMoveSelectTopo").addClass("btnMoveSelectTopoDesable")
		}
		
		
	});			
}

function showBannerImagem(imagem, url)
{
	objImg = new Image()
	objImg.src = 'imagens/banner/'+imagem 
	var img_b = 'imagens/banner/'+imagem
	var url
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;


	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	pageWidth = parseInt(pageWidth)-25
	
	
	if (document.all)
	{
		//var wtop = parseInt(document.documentElement.scrollTop) + 20
		var wtop = ( (parseInt(screen.height) - 450) / 2 ) - 50
		
	}
	else
	{
		//var wtop = parseInt(window.scrollY) + 20
		var wtop = ( (parseInt(screen.height) - 450) / 2 ) - 50
	}
	
	
	var wleft = ( (parseInt(pageWidth) - 1000) / 2 ) 
	wleft = parseInt(wleft) + ( (1000-parseInt(500)) / 2)
	wleft = parseInt(wleft)
	
	$("#caixaCores").remove()
	$("#fundoOpacoBannner").remove()	
	str = "<div id='caixaCores'>"	
	str += "<a href='"+url+"'><img src='"+img_b+"' alt='' border='0'></a>"
	str += "<div id='div_fecharCor'><img src='imagens/banner/botao-fechar.jpg' id='btn_fechar' title='Fechar' alt='Fechar'></div>"
	str +="</div>"

	
	$(str).css("left",wleft).css("top",wtop).appendTo("body")	
	
	$("#btn_fechar").click(function(){
		$("#caixaCores").remove()		
		$("#fundoOpacoBannner").remove()
		foto_atual = 0;
		id_foto_atual = "#img_0"
	})

	
	
	$("<div id='fundoOpacoBannner'>&nbsp;</div>").appendTo("body")		
	
	objF = document.getElementById('fundoOpacoBannner')
	objF.style.width = pageWidth + "px"
	
	objF.style.height = (pageHeight) + "px"
	$("#fundoOpacoBannner").click(function(){
		$("#div_fecharCor").remove()		
		$("#caixaCores").remove()		
		$("#fundoOpacoBannner").remove()		
		foto_atual = 0;
		id_foto_atual = "#img_0"
		
		
	})
	
}

function showBannerFlash(flash, url)
{
	objImg = new Image()
	objImg.src = flash 
	var img_b = flash
	var url
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;


	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	pageWidth = parseInt(pageWidth)-25
	
	
	if (document.all)
	{
		//var wtop = parseInt(document.documentElement.scrollTop) + 20
		var wtop = ( (parseInt(screen.height) - 450) / 2 ) - 50
		
	}
	else
	{
		//var wtop = parseInt(window.scrollY) + 20
		var wtop = ( (parseInt(screen.height) - 450) / 2 ) - 50
	}
	
	
	var wleft = ( (parseInt(pageWidth) - 1000) / 2 ) 
	wleft = parseInt(wleft) + ( (1000-parseInt(352)) / 2)
	wleft = parseInt(wleft)
	
	$("#caixaCores").remove()
	$("#fundoOpacoBannner").remove()	
	str = "<div id='caixaCores'>"	
	str += "<object data='"+img_b+"' type='application/x-shockwave-flash' width='352' height='240'><param name='movie' value='"+img_b+"'><param name='quality' value='high'><param name='wmode' value='transparent'></object>"
	str += "<div id='div_fecharCor'><img src='imagens/banner/botao-fechar.jpg' id='btn_fechar' title='Fechar' alt='Fechar'></div>"
	str +="</div>"
	
	$(str).css("left",wleft).css("top",wtop).appendTo("body")	
	
	$("#btn_fechar").click(function(){
		$("#caixaCores").remove()		
		$("#fundoOpacoBannner").remove()
		foto_atual = 0;
		id_foto_atual = "#img_0"
	})
	
	$("<div id='fundoOpacoBannner'>&nbsp;</div>").appendTo("body")		
	
	objF = document.getElementById('fundoOpacoBannner')
	objF.style.width = pageWidth + "px"
	
	objF.style.height = (pageHeight) + "px"
	$("#fundoOpacoBannner").click(function(){
		$("#div_fecharCor").remove()		
		$("#caixaCores").remove()		
		$("#fundoOpacoBannner").remove()		
		foto_atual = 0;
		id_foto_atual = "#img_0"
	})
	//fecha a tela depois de 50 segundos
	setTimeout(function(){
		$("#caixaCores").remove()		
		$("#fundoOpacoBannner").remove()
		foto_atual = 0;
		id_foto_atual = "#img_0"
	},50000)
}

function showBanner(imagem, url)
{
	objImg = new Image()
	objImg.src = imagem 
	var img_b = imagem
	var url
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;


	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	pageWidth = parseInt(pageWidth)//-25
	
	
	if (document.all)
	{
		//var wtop = parseInt(document.documentElement.scrollTop) + 20
		var wtop = ( (parseInt(screen.height) - 650) / 2 ) - 50
		
	}
	else
	{
		//var wtop = parseInt(window.scrollY) + 20
		var wtop = ( (parseInt(screen.height) - 650) / 2 ) - 50
	}
	
	
	var wleft = ( (parseInt(pageWidth) - 1000) / 2 ) 
	wleft = parseInt(wleft) + ( (1000-parseInt(500)) / 2)
	wleft = parseInt(wleft)
	
	$("#caixaCores").remove()
	$("#fundoBanner").remove()
	incluirFundo('fundoBanner','')
	str = "<div id='caixaCores'>"	
	if(url != ''){
		str += "<a href='"+url+"'><img src='"+img_b+"' alt='' border='0'></a>"
	}else{
		str += "<img src='"+img_b+"' alt='' border='0'>"
	}
	str += "<div id='div_fecharCor'><img src='imagens/botao-fechar.png' id='btn_fechar' title='Fechar' alt='Fechar' border='0'></div>"
	str +="</div>"

	
	$(str).css("left",wleft).css("top",wtop).appendTo("body")	
	
	$("#btn_fechar").click(function(){
		$("#caixaCores").remove()		
		$("#fundoBanner").remove()
		
		//alert("Fechar")
		foto_atual = 0;
		id_foto_atual = "#img_0"
		
		//armazena no cookie para não aparecer o popup por 1 dia
		//$.cookie('promocaoPopup', 'sim', { expires: 1 }); //o cookie irá expirar em 1 dias
	})
	
	$("<div id='fundoBanner'>&nbsp;</div>").appendTo("body")
	
	objF = document.getElementById('fundoBanner')
	objF.style.width = pageWidth + "px"
	
	objF.style.height = (pageHeight) + "px"
	$("#fundoBanner").click(function(){
		$("#div_fecharCor").remove()
		$("#caixaCores").remove()		
		$("#fundoBanner").remove()		
		foto_atual = 0;
		id_foto_atual = "#img_0"
		
		//armazena no cookie para não aparecer o popup por 1 dia
		//$.cookie('promocaoPopup', 'sim', { expires: 1 }); //o cookie irá expirar em 1 dias
	})
	
	//fecha a tela depois do tempo configurado
	setTimeout(function(){
		$("#div_fecharCor").remove()
		$("#caixaCores").remove()
		$("#fundoBanner").remove()
		foto_atual = 0;
		id_foto_atual = "#img_0"
	},30000)
}
