var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); var lang = cmsPageParams['lang'] ; var siteApp = { params : { homepage:{ images:[ // rimossa per richiamo esplicito colesterolo // '/source/index-1.jpg', '/source/index-2.jpg', '/source/index-3.jpg', ], images_mobile:[ // 'http://cmsmedia.titanka.com/www.colestat.com/crp700x280-index-1.jpg?o=5', 'http://cmsmedia.titanka.com/www.colestat.com/crp700x280-index-2.jpg?o=5', 'http://cmsmedia.titanka.com/www.colestat.com/crp700x280-index-3.jpg?o=5', ] }, }, init : function(){ if(siteApp.allComponentIsLoaded()){ siteApp.startApplication(); }else{ componentVerifyCycle++; if(componentVerifyCycle<200){ setTimeout(function(){siteApp.init();}, 100); }else{ console.warn('Init Application Error! waiting for: '+siteApp.params.tmp); return false; } } }, allComponentIsLoaded: function(){ var loaded = true; var msg = ''; if (typeof jQuery == 'undefined'){loaded = false; msg += '-jQuery';} if (typeof hs == 'undefined') {loaded = false; msg += '-hs';} if (typeof jQuery().slick == 'undefined') {loaded = false; msg += '-slick';} if (typeof jQuery().imageLightbox == 'undefined') {loaded = false; msg += '-imagelightbox';} if (typeof cms == 'undefined') {loaded = false; msg += 'cms';} if(!loaded){ //console.info('waiting for: '+msg); siteApp.params.tmp = msg; return false; }else{ return true; } }, startApplication: function(){ console.info('startApplication...'); siteApp.chkDocFiles(); startImageLightBox(); siteApp.openMenuMobile(); siteApp.openLanguage(); //siteApp.openSubMenu(); siteApp.countAnimation(); siteApp.scrollAnimation(); siteApp.fadeInHeader(jQuery('.barra-desktop')); siteApp.accordionTab(); jQuery( ".box" ).wrapInner( "
"); // Initialize Background Stretcher for homepage if (window.innerWidth > 767) { if(cmsPageParams.type == 3){ //controllo di essere solo in homepage switch(cms.variables.deviceType) { case "phone": jQuery('#blk_48003').backstretch(siteApp.params.homepage.images_mobile, {duration: 3300, fade: 1250}); break; default: jQuery('#blk_48003').backstretch(siteApp.params.homepage.images, {duration: 3300, fade: 1250}); } } } //aggiungo una freccia a qualunque voce abbia un sottomenu jQuery(".level1 > li:has('.level2')").addClass('submenu'); jQuery('#button_email_min').val(''); //jQuery('.bottone_alt').val('prenota'); var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if(parametro){ //console.log('passo') goToByScroll('#'+parametro); } /*****************************************************/ /* slider foto */ /* ******************* */ jQuery('.slider-foto').slick({ dots: true, infinite: true, speed: 800, arrows:false, slidesToShow: 2, slidesToScroll: 1, autoplay: true, slide:'a', autoplaySpeed: 5000, responsive: [ { breakpoint: 767, settings: { slidesToShow: 1, arrows: false } }, { breakpoint: 480, settings: { slidesToShow: 1, centerMode: false, arrows: false } } ] }); jQuery('.slider-home').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2500, pauseOnHover:false, fade: true, cssEase: 'linear' }); jQuery('.prodotti-dw').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, slide:'.col-md-4', responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1 } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1, centerMode: false } } ] }); // SLIDER PLUS // jQuery('.slider-plus').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1 } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1, centerMode: false } } ] }); /* gestione tab prodotti */ jQuery('.cont-tabs input').click(function(){ jQuery('.tab-content').hide(); var element = jQuery(this).attr('id'); //console.log(element); jQuery(this).parent('.cont-tabs').siblings(jQuery('.'+ element +'').show()); }) /************************/ /* gestione stile prezzo se non presente */ jQuery('.cont-prezzo').each(function(){ var html = jQuery(this).html(); var prezzo = jQuery(html).find('[itemprop=price]').html(); if(typeof prezzo=='undefined'){ jQuery(this).remove(); } }) if (window.innerWidth > 991) { //console.log('ok') jQuery('.moveUp,.moveRight,.moveDown, .moveLeft,.hideme, .image-container').viewportChecker({ classToAdd: 'visible', // Class to add to the elements when they are visible, classToAddForFullView: 'full-visible', // Class to add when an item is completely visible in the viewport repeat: false // Add the possibility to remove the class if the elements are not visible }); } jQuery(window).on('resize', function(){ if (window.innerWidth > 991) { jQuery('.image-container').each(function(){ var h_image = jQuery(this).find('img.foto, img.image_item').height(); jQuery(this).height(h_image); }) } }) console.info('startApplication started!'); }, // FUNZIONI AD HOC SITO // // AREA MEDICI // chkDocFiles:function() { /*var wrapper = jQuery('#tit_doc_files'); if (wrapper.length == 0 ) { jQuery('.container_files').hide(); } var esistono_files = jQuery('.container_files li'); if (esistono_files.length ==0) { jQuery('#tit_doc_files').hide(); }*/ var wrapper_doc = jQuery('.container_files'); if (wrapper_doc.length>0) { var file_scaricabili = jQuery('.container_files li'); var esistono_files = file_scaricabili.length; if (esistono_files ==0) { jQuery('#tit_doc_files').hide(); } } }, // Create the element openMenuMobile: function(){ /* variabili menu */ var $id_menu = '#menu_2384'; var $menu = jQuery($id_menu); var $btn = jQuery('.op_block'); /**************************/ jQuery($btn).click(function() { jQuery('.level1').toggleClass('slide-menu'); //if(window.innerWidth > 991){ // jQuery('.menu-fix').fadeToggle(); //} $btn.find('.click').toggleClass('open'); $btn.toggleClass('open'); if(jQuery($id_menu+' .level2').hasClass('slide-menu')){ jQuery($id_menu+' .level2').removeClass('slide-menu') } }); /* jquery per chiudere la tendina del menu al click esterno alla tendina */ jQuery(document).bind("click touchstart", function(event){ if(jQuery(event.target).parents('.op_block').size()|(jQuery(event.target).hasClass('open'))|(jQuery(event.target).parents('ul#root_2384 li').size() ) ){ return; } // if(window.innerWidth > 991){ // jQuery('.menu-fix').fadeOut(); //} jQuery(".op_block").removeClass('open'); $btn.find('.click').removeClass('open'); if(jQuery('.level1').hasClass('slide-menu')){ jQuery(".level1").removeClass('slide-menu'); } if(jQuery(".level2").hasClass('slide-menu')){ jQuery(".level2").removeClass('slide-menu'); } }); }, // Effetto Superfish // /* openSubMenu: function(){ jQuery('#root_2384 ul.level2').css('margin-top','-5px'); // setta la posizione verticale dei sottomenu rispetto alle voci principali jQuery('#root_2384 ul.level2').css('margin-left','0px'); // setta la posizione orizzontale dei sottomenu rispetto alle voci principali jQuery('.menu-fix #root_2384, #root_2384').superfish({ delay: 600, // the delay in milliseconds that the mouse can remain outside a submenu without it closing speed: 'normal' // fast, normal }); }, // fine effetto // /* ***************gestione tab a fisarmonica*********** */ accordionTab: function(param){ jQuery('.slider-titolo').click(function(){ if(!jQuery(this).hasClass('opened')){ jQuery('.slider-titolo.opened').removeClass('opened'); jQuery(this).addClass('opened'); jQuery('.slider-corpo.opened').slideUp('fast',function() { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('fast',function() { jQuery(this).addClass('opened'); }); } else{ jQuery(this).removeClass('opened'); jQuery('.slider-corpo.opened').slideUp('fast',function() { jQuery(this).removeClass('opened'); }); } }); }, /**************** tendina lingue ********************/ openLanguage: function(){ //APRO MENU LINGUE jQuery('.tendina-lingue').click(function() { var lingua = jQuery(this).next(); if( lingua.is(':hidden') ) { lingua.slideDown(); jQuery(this).children('.click').addClass('open'); }else{ lingua.slideUp(); jQuery(this).children('.click').removeClass('open'); } }); jQuery("#select_lingue").click(function() { jQuery(this).slideUp(); jQuery('.tendina-lingue').children('.click').removeClass('open') }); /* jquery per chiudere la tendina delle lingue al click esterno alla tendina */ jQuery(document).click(function(event) { if(jQuery(event.target).parents('.tendina-lingue').size()|(jQuery(event.target).hasClass('tendina-lingue'))){ return; } if(!jQuery("#select_lingue").is(':hidden')){ jQuery("#select_lingue").fadeOut(250); jQuery('.tendina-lingue').children('.click').removeClass('open') } }); }, showMe: function(elem){ anim = jQuery(elem).attr('data-anim'); jQuery(elem).addClass('animated '+anim); }, scrollAnimation: function(){ jQuery(window).on('scroll load', function(){ setTimeout(function() { if(window.innerWidth > 991){ jQuery('.hideme.visible').each( function(i){ siteApp.showMe(this); }); } }, 150); }); }, fadeInHeader: function(element){ if(window.innerWidth > 991){ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); if(scrollpos > 200){ element.fadeIn(); } else{ element.fadeOut(); } }); } }, countAnimation: function(){ if(window.innerWidth > 991){ jQuery(window).on('scroll', function(){ jQuery('.count').each(function () { var bottom_of_object = jQuery(this).offset().top + jQuery(this).height(); var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); if( bottom_of_window > bottom_of_object ){ if(!jQuery(this).hasClass('fatto')){ jQuery(this).prop('Counter',0).animate({ Counter: jQuery(this).text() }, { duration: 1000, easing: 'swing', step: function (now) { jQuery(this).text(Math.ceil(now)); } }); jQuery(this).addClass('fatto'); } } }); }); } }, adatta: function(elem){ var win_h = window.innerHeight; jQuery(elem).css('height',win_h); } } window.addEventListener("load", function(){siteApp.init(); if (window.innerWidth > 991) { jQuery('.image-container').each(function(){ var h_image = jQuery(this).find('img.foto, img.image_item').height(); console.log(h_image); jQuery(this).height(h_image); }) } }); /*gestione di funzioni es. onclick="gotobyscroll('.classe')"*/ function add_slide_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log(item) } function back_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log('vado') } function goToByScroll(param){ jQuery('html, body').animate({scrollTop: jQuery(param).offset().top-180}, 2000, "easeInOutQuad"); } /***** FUNZIONI AREA RIS. MEDICI ********/ function mostra(div) { if ( jQuery("#"+div).css("display")=='none' ) { jQuery("#"+div).slideDown(); if (div =='modulo_acquista') { scroll_to('modulo_acquista'); } } else { jQuery("#"+div).slideUp(); } } function scroll_to(div) { jQuery('html, body').stop().animate({ scrollTop: jQuery('#'+div).offset().top }, 1500,'easeInOutExpo'); } function check_email_utente(id_utente, lingua_cur) { var email_utente = jQuery('#email_utente').val(); if (lingua_cur =='it') msg = 'ESISTE GIA\' QUESTA EMAIL IN ARCHIVIO, ESEGUIRE IL LOGIN O MODIFICARE EMAIL.'; else msg = 'EMAIL EXISTS, PLEASE LOGIN..'; if (email_utente !='' ) { var ws = '/ws.php?act=check_email&email_utente='+email_utente+'&id_utente_email='+id_utente; jQuery.ajax({ type: 'GET', url : ws, success: function(str) { if (str>0) { alert(msg); jQuery('#email_utente').val(''); } } }); } } function verifica_modulo_reg(lingua_cur, id_utente) { var errore = ''; var msg; jQuery('.obbligatorio').each(function() { var valore = jQuery(this).val(); if (valore =='') { errore =1; } } ); var ok_privacy = jQuery('input[name="privacy"]:checked').val(); if (ok_privacy != '1') { alert(getDictionaryTranslate('ACCETTA_PRIVACY',lang)); errore = 2; } var ok_dichiaro = jQuery('input[name="dichiaro"]:checked').val(); if (ok_dichiaro != '1') { alert(getDictionaryTranslate('ACCETTA_AUTO_DICHIARAZIONE',lang)); errore = 3; } if (errore>0) { if (lang =='it') msg = 'ATTENZIONE COMPILARE TUTTI I DATI RICHIESTI'; if (lang =='en') msg = 'PLEASE FILL ALL MANDATORY FIELDS'; if (lang =='de') msg = 'Geben Sie die erforderlichen Informationen'; if (errore==1) alert(msg); } else { var serializzato= jQuery('#form_reg').serialize(); var url = '/ws.php?act=registra_medico&'+serializzato; jQuery.ajax({ type: 'GET', //dataType: 'json', url : url, success: function(esito) { if (esito=='1') { if (id_utente=='') jQuery('#modulo_reg').html(getDictionaryTranslate('REGISTRAZIONE_SUCCESS',lang)); else jQuery('#modulo_reg').html(getDictionaryTranslate('UPDATE_SUCCESS',lang)); } } }); } } function stampaDiv(div){ var divToPrint=document.getElementById(div); var newWin=window.open('','Print-Window'); newWin.document.open(); // newWin.document.write(''+divToPrint.innerHTML+''); newWin.document.write(''+divToPrint.innerHTML+''); newWin.document.close(); setTimeout(function(){newWin.close();},10); } function getDictionaryTranslate(lbl, lang){ return dictionaryTranslate('[DIZIONARIO:'+lbl+']', lang); } function recupera_pwd() { var email_reg = jQuery('#email_reg').val(); if (email_reg!='') { var url = '/ws.php?act=recupera_pwd&email_rec='+email_reg; jQuery.ajax({ type: 'GET', // dataType: 'json', url : url, success: function(str) { if (str!='-1') jQuery('#container_frm_recupero').html(getDictionaryTranslate('PASSWORD_INVIATA',lang)); else jQuery('#container_frm_recupero').html(getDictionaryTranslate('EMAIL_NON_TROVATA',lang)); } }); } else alert('Inserisci l\'email con cui ti sei registrato.'); }