function readCookie(name) { var cookieArr = document.cookie.split(";"); /* Loop through the array elements */ for(var i = 0; i < cookieArr.length; i++) { var cookiePair = cookieArr[i].split("="); /* Removing whitespace at the beginning of the cookie name and compare it with the given string */ if(name == cookiePair[0].trim()) { /* Decode the cookie value and return */ return decodeURIComponent(cookiePair[1]); } } /* Return null if not found */ return null; /* return null; */ } function setCookie(c_name, value, exdays) { var CookieDate = new Date; CookieDate.setFullYear(CookieDate.getFullYear() +10); var c_value = escape( value ) + ( ( exdays == null ) ? "" : "; expires=" + CookieDate.toGMTString()); console.log('expires '+CookieDate.toGMTString()); document.cookie = c_name + "=" + c_value + "; path=/"; } $(function() { $('body').append(''); $('body').append(''); var popup = '
'; $('body').append(popup); rot_banner = ''; $('body').append(rot_banner); tout_l = ' '; $('body').append(tout_l); /* ========================= Header Banner ======================= */ var banner_cookiename = 'head-banner'; /* Headerbanner */ $('.header_banner .btn-close').click(function(e){ e.preventDefault(); setCookie(banner_cookiename, '1'); $('.header_banner').css('opacity','0'); $('.t-nav-spacer').css('padding-bottom',0); setTimeout(function(){ $('.header_banner').remove(); $(window).resize(); }, 1000); }); $('.header_banner a').click(function(e){ e.preventDefault(); if($(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); } var date = new Date(); date.setTime(date.getTime()+(1800*1000)); var expiry = '; expires=' + date.toUTCString(); setCookie(banner_cookiename, '1', expiry); }); if(readCookie(banner_cookiename) != 1){ $('.header_banner').removeClass('t-hide'); } /* ========================= Tout Banner ======================= */ var tout_cookiename_l = 'tout-l-banner'; /* Tout */ $('.tout_l .btn-close').click(function(e){ e.preventDefault(); var date = new Date(); date.setTime(date.getTime()+(1800*1000)); var expiry = '; expires=' + date.toUTCString(); setCookie(tout_cookiename_l, '1', expiry); $('.tout_l').css('opacity','0'); setTimeout(function(){ $('.tout_l').remove(); $(window).resize(); }, 1000); }); $('.tout_l a').click(function(e){ e.preventDefault(); if($(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); } var date = new Date(); date.setTime(date.getTime()+(1800*1000)); var expiry = '; expires=' + date.toUTCString(); setCookie(tout_cookiename_l, '1', expiry); }); if(readCookie(tout_cookiename_l) != 1){ $('.tout_l').removeClass('t-hide'); } else{ $('.tout_l').remove(); $('footer').attr('style',''); if($('.toutcheck_r').length!= 1){ $('footer').attr('style',''); } } /* ========================= Tout 2 Banner ======================= */ var tout_cookiename_r = 'tout-r-banner'; /* Tout */ $('.tout_r .btn-close').click(function(e){ e.preventDefault(); var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(tout_cookiename_r, '1', date); $('.tout_r').css('opacity','0'); setTimeout(function(){ $('.tout_r').remove(); $(window).resize(); }, 1000); }); $('.tout_r a').click(function(e){ e.preventDefault(); if($(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); } var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(tout_cookiename_r, '1', date); }); if(readCookie(tout_cookiename_r) != 1){ $('.tout_r').removeClass('t-hide'); } else{ $('.toutcheck_r').remove(); $('footer').attr('style',''); if($('.toutcheck_l').length!= 1){ $('footer').attr('style',''); } } /* ========================= Tout Rotator Banner ======================= */ var rot_banner_cookie = 'rot-banner'; /* Tout Rotator*/ $('.tout_rot .btn-close').click(function(e){ e.preventDefault(); var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(rot_banner_cookie, '1', date); $('.tout_rot').css('opacity','0'); setTimeout(function(){ $('.tout_rot').remove(); $(window).resize(); }, 1000); }); $('.tout_rot a').click(function(e){ e.preventDefault(); if($(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); } var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(rot_banner_cookie, '1', date); }); if(readCookie(rot_banner_cookie) != 1){ $('.tout_rot').removeClass('t-hide'); function rot_banner_show(){ if($(window).width()>728){ $('.tout_rot a:last-of-type').addClass('swipeaway'); console.log(' rotate banner'); setTimeout( function(){ $('.tout_rot .tout-container .rotator').prepend($('.swipeaway')); $('.tout_rot .swipeaway').removeClass('swipeaway'); } , 1000 ) } } if($('.tout_rot').length>0){ setInterval(rot_banner_show, 5000); } } else{ $('.tout_rot').remove(); $('footer').attr('style',''); if($('.toutcheck_l').length!= 1 && $('.toutcheck_r').length!= 1){ $('footer').attr('style',''); } } /* ====== Sign up pop-up banner ========= */ function initsignup(){ console.log('initsignup'); function showemailerror(){ $('.emailerror.t-hide').removeClass('t-hide'); } $('.popup.signup-discount .button.send').click(function(evt){ evt.preventDefault(); var emailfield = $('.signupfield [type="email"]').val(); var checkerfield = $('[name="checker"]').val(); if(emailfield !='' && checkerfield==''){ if(emailfield.indexOf('@') != -1){ if(emailfield.indexOf('.') != -1){ $.get("https://www.jolovineyards.com/welcome-email/send.php?src=jolo&e="+emailfield, function(data, status){ /* alert("Data: " + data + "\nStatus: " + status); */ }); $('.popup.signup-discount').addClass('sent'); } else{ showemailerror(); } } else{ showemailerror(); } } else{ showemailerror(); } }); } /* ========================= Popup Banner ======================= */ var popup_cookiename = 'signup-discount oct-discount oct'; /* Pop-up */ $('.popup .btn-close.stand').click(function(e){ console.log('close standard pop-up'); e.preventDefault(); setCookie(popup_cookiename, '1'); $('.popup').css('opacity','0'); setTimeout(function(){ $('.popup').remove(); $('.popup-box.temporary').removeClass('t-hide') $(window).resize(); }, 1000); }); $('.popup .popup-box.standard a').click(function(e){ e.preventDefault(); /* if($(this).attr('href') && $(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); }*/ setCookie(popup_cookiename, '1'); }); if(readCookie(popup_cookiename) != 1){ console.log('Standard cookie is not set '+readCookie(popup_cookiename)); $('.popup').removeClass('t-hide'); $('.popup .popup-box.standard').removeClass('t-hide'); initsignup(); } else{ console.log('Standard cookie is set to '+readCookie(popup_cookiename)); $('.popup .popup-box.standard').addClass('t-hide'); if($('.popup.temp').length<1 && $('.popup-box.temporary').length<1 ){ console.log('remove popup'); $('.popup').remove(); } } /* ========================= Temporary Popup Banner ======================= */ var popup_cookiename_temp = 'temp-banner'; var currentTime = new Date(); var popuptemp_start = new Date(''); var popuptemp_end = new Date(''); var popuptemp_islive; popuptemp_start_check = (currentTime >=popuptemp_start); popuptemp_end_check = (currentTime <= popuptemp_end); /* console.log('currentTime= '+currentTime+' popuptemp_start = '+popuptemp_start+' popuptemp_end= '+popuptemp_end); console.log(' Start time '+(currentTime >= popuptemp_start)); console.log(' End time '+(currentTime <= popuptemp_end)); console.log('popuptemp_start_check= '+(popuptemp_start_check == true)); console.log('popuptemp_end_check= '+(popuptemp_end_check == true)); */ if((popuptemp_start_check == true) && (popuptemp_end_check == true)){ popuptemp_islive = 1; } else{ popuptemp_islive = 0; } /* Temporary Pop-up */ $('.popup.temp .btn-close.temp').click(function(e){ console.log('Close temporary popup'); e.preventDefault(); var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(popup_cookiename_temp, '1', date); $('.popup.temp .popup.temporary').css('opacity','0'); setTimeout(function(){ $('.popup-box.temporary').remove(); $('.popup-box.standard').removeClass('t-hide') if($('.popup-box.standard').length<1 ){ $('.popup').remove(); } else{ $('.popup-box.standard').removeClass('t-hide'); } $(window).resize(); }, 1000); }); $('.popup.temp .popup-box.standard a').click(function(e){ e.preventDefault(); if($(this).attr('href').includes(window.location.hostname)){ window.location.href = $(this).attr('href'); } else{ window.open($(this).attr('href'), "_blank"); } var date = new Date(); date.setTime(date.getTime()+(1800*1000)); setCookie(popup_cookiename_temp, '1', date); }); if(readCookie(popup_cookiename_temp) != 1 && popuptemp_islive == 1){ console.log('Temp cookie is not set'); $('.popup.temp').removeClass('t-hide'); $('.popup-box.temporary').removeClass('t-hide'); $('.popup-box.standard').addClass('t-hide'); } else{ console.log('Temp cookie is set or is not live '); $('.popup.temp').removeClass('temp'); $('.popup-box.temporary').remove(); if($('.popup-box.standard').length<1 || $('.popup-box.standard.t-hide').length>0){ $('.popup').remove(); } } });