// JavaScript Document

jQuery.preloadImages = function() {
  for(var i=0; i<arguments.length; i++)   {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

function selecLugar(loc) {
   var veri=false;
   var reg=2;
   areg0=$('#r_0');
   reg1 = new Array("rs","pr","sc");
   reg2 = new Array("sp");
   tela=$(document).height()+'px';
   $('#fade').css({'display' : 'none', 'height' : tela});
   //document.getElementById('fade').style.display="none";
   for(x=1; x<=reg; x++) {
	   adiv="r_"+x;
	   areg=eval("reg"+x);
	   aregt=areg.length;
	   for(y=0; y<aregt; y++) {
		   if(loc==areg[y]) {
			   divtx=document.getElementById(adiv);
			   document.getElementById('fade').style.display="block";
			   $(divtx).fadeIn();
			   veri=true;
		   }
		   if(loc=="x") veri=true;
	   }
   }
   if (veri==false) {
	   //areg0.style.display="block";
	   $(areg0).fadeIn();
		document.getElementById('fade').style.display="block";
	   //window.location.href="#lk_0";
   } else {
	   //areg0.style.display="none";
	   $(areg0).fadeOut();
   }
};


$(function(){
		   
	//$.preloadImages("img/foto0.jpg","img/foto1.jpg");
	// fix for target="_blank"
	var w = 900; var h = 650;
	var ww = $(window).width(); 
	var wh = $(window).height();
	
	if(wh<h) {
		w = ww; 
		h = wh;
	}
	
     // Lightbox para imagens
	 if($("a[rel^='prettyPhoto']").length>0) {
		 $("a[rel^='prettyPhoto']").prettyPhoto({
			theme:'facebook',
			overlay_gallery: false
		  });
	 }

	// fix for target="_blank"
	$("a[rel='external']").click(function(){
		window.open($(this).attr("href"), 'janela','scrollbars=yes,resizable=yes,width='+w+',height='+h);
		return false;
	});
	
	$("#Onde_conheceu").change(function() {
		if($(this).val()=="Outros") $('.hide').css('display', 'inline');
			else $('.hide').css('display', 'none');
	})
	
	$('.light_conteudo').each(function() {
		$(this).prepend('<div class="light_fecha">[ X ] Fechar </div>');
	})
	
	$('.light_fecha').click(function() {
		$('.light_conteudo').css('display', 'none');
		$('.light_sombra').css('display', 'none');
	})

	$('.backtotop').click(function(event){
		$('html, body').animate({scrollTop:0}, 'slow');
		event.preventDefault();
	});

});


