$(function(){
	$("[class*='calendario']").datepicker({
		dateFormat: 'dd/mm/yy',

		dayNames: [
			'Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado','Domingo'
		],
		dayNamesMin: [
			'D','S','T','Q','Q','S','S','D'
		],
		dayNamesShort: [
			'Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'
		],
		monthNames: [
			'Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro',
			'Outubro','Novembro','Dezembro'
		],
		monthNamesShort: [
			'Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set',
			'Out','Nov','Dez'
		],
		nextText: 'Próximo',
		prevText: 'Anterior'
	});
	$('#carousel li img').click(function(){
	    var href = $(this).attr('rel');
	    var array_href = href.split("/");

	    var tamanho = array_href.length - 1;
	    var url = "http://www.pousadadelmares.com.br/img/site/g-" + array_href[tamanho];
	    $(".ampliar").attr('href', url);

	    var legenda = $(this).attr('alt');
		$('.foto-slide span').text(legenda);
	});
	$('#slider').cycle({
	        fx:'fade',
	        speed:'1000',
	        timeout:'6000',
	        next:   '#next-btn',
            prev:   '#prev-btn'
	});
	$('#carousel').jcarousel({
	    scroll: 2
	});

	$('.mini').click(function(){
		$('.change').attr('src',$(this).attr('rel'));
	});
	$('.sel').wrap('<div class="selec"></div>');
	$('.che').wrap('<div class="checks"></div>');
	$("#TestimonialImage").wrap('<div id="file"></div>');
	$('.selec').jNice()
	$('.checks').jNice()
	$("a.ampliar").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
	});
	$("a.galery").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
	});
	$("a.fan").fancybox({
				'href'	        : 'testimonials/add',
				'type'	        : 'iframe',
				'overlayShow'	: false,
				'width'  	    : 465,
				'height'  	    : 362,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
	});
	$("a.tour").fancybox({
				'href'	        : 'tour/index.php',
				'type'	        : 'iframe',
				'overlayShow'	: false,
				'width'         :'100%',
				'height'        : 900,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
	});

	$('.tel').mask('(99) 9999-9999');
	$('.date').mask('99/99/9999');

	$('#en').click(function(){
        $('body').translate('en',{toggle:true, not:'.notranslate'});
        $.getJSON('pages/idioma/2');
    });
    $('#pt').click(function(){
        $('body').translate('pt-br',{toggle:true, not:'.notranslate'});
        $.getJSON('pages/idioma/1');
    });
    $('#es').click(function(){
        $('body').translate('es',{toggle:true, not:'.notranslate'});
        $.getJSON('pages/idioma/3');
    });

    $.getJSON('pages/idioma',function(data){
        if(data==1){
            $('#pt').click();
        }
        if(data==2){
            $('#en').click();
        }
        if(data==3){
            $('#es').click();
        }
    });
});


