$(function(){ comprova_carousel(); $(window).resize(function(){ //comprova_carousel(); }); }); var num_slides = 0; function comprova_carousel() { if($("#carousel").length > 0) { if($(window).width() <= 650 && num_slides != 3) { $("#carousel").cycle('destroy'); $("#carousel .cycle-slide").css('vertical-align','top').removeClass(".cycle-slide"); setTimeout(function(){ $("#carousel").cycle({ fx: "carousel", timeout:2000, speed:500, carouselVisible:3, carouselFluid:true, slides:"> div", pauseOnHover:false }); },0); num_slides = 3; } else if($(window).width() > 650 && num_slides != 5) { $("#carousel").cycle('destroy'); $("#carousel .cycle-slide").css('vertical-align','top').removeClass(".cycle-slide"); setTimeout(function(){ $("#carousel").cycle({ fx: "carousel", timeout:2000, speed:500, carouselVisible:5, carouselFluid:true, slides:"> div", pauseOnHover:false }); },0); num_slides = 5; } } } function desplegar_menu() { $("#nav").toggleClass("desplegat"); } function comprova_form_contacte() { error = ""; frm = document.frm_contacte; if(frm.nom.value.length < 3) error += 'Ompli el camp: Nom\n'; if(frm.telefon.value.length < 3) error += 'Ompli el camp: Telèfon\n'; if(frm.xmal.value.length < 3) error += 'Ompli el camp: E-mail\n'; else if(!(/\S+@\S+\.\S+/.test(frm.xmal.value))) error += 'Email incorrecte\n'; if(frm.captcha_client.value.length < 4) error += 'Escriu el codi\n'; if(!frm.check_condicions.checked) error += 'Cal acceptar les condicions\n'; if(error) alert(error); else frm.submit(); }