$(document).ready(function (){ if(typeof window.matchMedia == 'function') { } else{ window.location.href = '/error.html'; } $( '.swipebox' ).swipebox({ hideBarsDelay : 0 }); // fetch $('#ph_hotel .drop').load('/pt/hotel'); $('#ph_localizacao .drop').load('/pt/localizacao'); //anima = undefin; $("#bt-menu").click(function(){ if($("#menu1").is(":hidden")) { $("#menu1").slideDown("fast"); } else { $("#menu1").slideUp("fast"); } }); $(".menu_lat li a").click(function(){ anima = true; }); $("#menu1 li a").click(function(){ anima = true; if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ $("#menu1").slideUp("fast"); } }); $('#bt_envia').click(function(){ send_form('form_contactos'); }); // Set a timeout... }); anima = false; $(function(){ $(window).hashchange([ { hash: '#!/pt/home', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='1']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_home').offset().top - $("#topo-1").height() - parseInt($('#ph_home').css('margin-top')); } else { var goTo = $('#ph_home').offset().top - parseInt($('#ph_home').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/hotel', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='2']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/hotel/hotel', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='827']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/hotel', function(){ }); }); } //} }, { hash: '#!/pt/hotel/recepcao', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='828']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/recepcao', function(){ }); }); } //} }, { hash: '#!/pt/hotel/piscinas', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='829']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/piscinas', function(){ }); }); } //} }, { hash: '#!/pt/hotel/pool-bar', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='830']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/pool-bar', function(){ }); }); } //} }, { hash: '#!/pt/hotel/cocktail-bar', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='831']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/cocktail-bar', function(){ }); }); } //} }, { hash: '#!/pt/hotel/sala-de-jogos', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='832']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/sala-de-jogos', function(){ }); }); } //} }, { hash: '#!/pt/hotel/parque-infantil', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='833']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/parque-infantil', function(){ }); }); } //} }, { hash: '#!/pt/hotel/sala-de-reunioes', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='834']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_hotel').offset().top - $("#topo-1").height() - parseInt($('#ph_hotel').css('margin-top')); } else { var goTo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_hotel .drop').html(''); $('#ph_hotel .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_hotel .drop').load('/pt/hotel/sala-de-reunioes', function(){ }); }); } //} }, { hash: '#!/pt/apartamentos', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='3']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_apartamentos').offset().top - $("#topo-1").height() - parseInt($('#ph_apartamentos').css('margin-top')); } else { var goTo = $('#ph_apartamentos').offset().top - parseInt($('#ph_apartamentos').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/restaurante', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='4']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_restaurante').offset().top - $("#topo-1").height() - parseInt($('#ph_restaurante').css('margin-top')); } else { var goTo = $('#ph_restaurante').offset().top - parseInt($('#ph_restaurante').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/health-club', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='5']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_health-club').offset().top - $("#topo-1").height() - parseInt($('#ph_health-club').css('margin-top')); } else { var goTo = $('#ph_health-club').offset().top - parseInt($('#ph_health-club').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/galeria', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='6']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_galeria').offset().top - $("#topo-1").height() - parseInt($('#ph_galeria').css('margin-top')); } else { var goTo = $('#ph_galeria').offset().top - parseInt($('#ph_galeria').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/localizacao', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='7']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, { hash: '#!/pt/localizacao/intro', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='835']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_localizacao .drop').html(''); $('#ph_localizacao .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_localizacao .drop').load('/pt/localizacao/intro', function(){ }); }); } //} }, { hash: '#!/pt/localizacao/a-visitar', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='836']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_localizacao .drop').html(''); $('#ph_localizacao .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_localizacao .drop').load('/pt/localizacao/a-visitar', function(){ }); }); } //} }, { hash: '#!/pt/localizacao/actividades', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='837']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_localizacao .drop').html(''); $('#ph_localizacao .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_localizacao .drop').load('/pt/localizacao/actividades', function(){ }); }); } //} }, { hash: '#!/pt/localizacao/golfe', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='838']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_localizacao .drop').html(''); $('#ph_localizacao .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_localizacao .drop').load('/pt/localizacao/golfe', function(){ }); }); } //} }, { hash: '#!/pt/localizacao/centro-de-estagios', onSet: function() { $(".menu_lat li a").removeClass("on"); $(".menu_lat li").find("[data-id='839']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_localizacao').offset().top - $("#topo-1").height() - parseInt($('#ph_localizacao').css('margin-top')); } else { var goTo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } //if(anima == true){ $('#ph_localizacao .drop').html(''); $('#ph_localizacao .drop').html('
'); $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; $('#ph_localizacao .drop').load('/pt/localizacao/centro-de-estagios', function(){ }); }); } //} }, { hash: '#!/pt/contactos', onSet: function() { $("#menu1 li a").removeClass("on"); $("#menu1 li").find("[data-id='8']").addClass("on"); if(window.matchMedia('only screen and (min-width: 1024px)').matches == false){ var goTo = $('#ph_contactos').offset().top - $("#topo-1").height() - parseInt($('#ph_contactos').css('margin-top')); } else { var goTo = $('#ph_contactos').offset().top - parseInt($('#ph_contactos').css('margin-top')) - $("#menu1").height() - $("#topo-1").outerHeight(); } if(anima == true){ $('html, body').animate({ scrollTop: goTo}, 1000, function() { anima = false; }); } } }, ]); }); // function $(window).scroll(function () { if(!anima){ alt = $('#topo-1').height()+$("#menu1").outerHeight(); topY = $(window).scrollTop() + alt; //console.log('Top do y '+alt); altMenu = $('#menu1').height()-40; topo = $('#ph_home').offset().top - parseInt($('#ph_home').css('margin-top')); altura = $('#ph_home').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_home').css('margin-top')); window.location.hash = '#!/pt/home'; } topo = $('#ph_hotel').offset().top - parseInt($('#ph_hotel').css('margin-top')); altura = $('#ph_hotel').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_hotel').css('margin-top')); window.location.hash = '#!/pt/hotel'; } topo = $('#ph_apartamentos').offset().top - parseInt($('#ph_apartamentos').css('margin-top')); altura = $('#ph_apartamentos').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_apartamentos').css('margin-top')); window.location.hash = '#!/pt/apartamentos'; } topo = $('#ph_restaurante').offset().top - parseInt($('#ph_restaurante').css('margin-top')); altura = $('#ph_restaurante').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_restaurante').css('margin-top')); window.location.hash = '#!/pt/restaurante'; } topo = $('#ph_health-club').offset().top - parseInt($('#ph_health-club').css('margin-top')); altura = $('#ph_health-club').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_health-club').css('margin-top')); window.location.hash = '#!/pt/health-club'; } topo = $('#ph_galeria').offset().top - parseInt($('#ph_galeria').css('margin-top')); altura = $('#ph_galeria').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_galeria').css('margin-top')); window.location.hash = '#!/pt/galeria'; } topo = $('#ph_localizacao').offset().top - parseInt($('#ph_localizacao').css('margin-top')); altura = $('#ph_localizacao').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_localizacao').css('margin-top')); window.location.hash = '#!/pt/localizacao'; } topo = $('#ph_contactos').offset().top - parseInt($('#ph_contactos').css('margin-top')); altura = $('#ph_contactos').height(); if(topY >= topo && topY <= topo + altura){ //console.log($('#ph_contactos').css('margin-top')); window.location.hash = '#!/pt/contactos'; } } // if anima }); // scroll function