/*
	gamby developed by alesshh
*/

var posiciaoInicial;
var totalBloco= 0;




/*
	desloca o banner para frente
	@return void
*/
function avancaBanner(){

	//se chegou no limite
	if(posicaoInicial + $("#bannerImages img").width() + $("#next").width() == totalBloco)
		posicaoInicial = -$("#next").width();
		
	else
		posicaoInicial +=  $("#bannerImages img").width();
	
	$("#bannerImages").animate({
		left: -posicaoInicial+"px"
	},500);
	
}


/*
	desloca o banner para traz
	@return void
*/
function retrocedeBanner(){

	//se chegou no limite
	if(!(posicaoInicial + $("#back").width()))
		posicaoInicial = (totalBloco - ($("#bannerImages img").width() + $("#back").width()));
	else	
		posicaoInicial += -$("#bannerImages img").width();
	
	$("#bannerImages").animate({
		left: -posicaoInicial+"px"
	},500);
	
	
	
	

}









$(document).ready(function(){


/*inicio-> configura o carrossel do banner*/

	/*
		percorro todas as imagens do banner, e atribuo ao bloco que elas 
		se encontram
	*/
	$("#bannerImages img").each(function(){
		totalBloco += $(this).width();
	});
	
	$("#bannerImages").width(totalBloco);
	/*
		posiciono as imagens no centro 
	*/

	
	posicaoInicial = (totalBloco / 2) - ($("#banner").width() /2);
	
	
	/*
		se numero de imagens for par, somo o tamanho de uma imagem qualquer 
			*considerando imagens do mesmo tamanho
	*/
	if(!($("#bannerImages img").length % 2))
		posicaoInicial += $("#bannerImages img").width() /2;
		
	$("#bannerImages").css("left",-posicaoInicial+"px");
	
	
	/*
		automatiza o ciclo
	*/
	var interval = setInterval("avancaBanner()",5000);
  	
  	$("#back, #next").hover(
  		function(){clearInterval(interval)},
  		function(){interval = setInterval("avancaBanner()",5000)}
  	);

/*fim-> configura o carrossel do banner*/


	//cycle
	$('.imagesGalery ul ').cycle({
        fx: 'fade',
        speed: 'slow',
        timeout:'5000',
        pager:'#pagerGalery'
  	});
  	
  	
  	$("#thumbsAlbum li a").hover(
  		function(){
  			$(this).find("span").fadeIn();
  		},
  		function(){
  			$(this).find("span").hide();
  		}
  	);
  	
  	
	//mascaras
	
	$("input[name='phone']").mask("(99) 9999-9999");
	$("input[name='zip']").mask("99999-999");
	$("input[name='check_in'],input[name='check_out']").mask("99/99/9999")
	
	
	$(".blank").click(function(){
		
		window.open($(this).attr("href"))
		
		return false;
	})
	

});
