var cs_info_counter = 0; var cs_info_divider = 1; function setCookie(cname, cvalue, eMinutes) { var d = new Date(); d.setTime(d.getTime() + (eMinutes * 60 * 1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } $(document).ready(function () { $('#kom .kom_close').click(function() { $(this).parent().hide(); setCookie("kom1info", true, 2); }); $('#kom2 .kom_close').click(function() { $(this).parent().hide(); setCookie("kom2info", true, 2); }); $('#kom3 .kom_close').click(function() { $(this).parent().hide(); setCookie("kom3info", true, 2); }); setInterval(function() { cs_info_counter = cs_info_counter + 1; if (cs_info_counter % cs_info_divider == 0) { if (cs_info_divider < 16) cs_info_divider = cs_info_divider + cs_info_divider; if (cs_info_counter == 32) cs_info_counter = 0; if ($('#kom').css("display") != "block" && !getCookie("kom1info")) { $('#kom').parent("div").css("z-index","2000"); $.ajax({ url: 'http://www.ec-24.pl/index.php?do=komunikaty&promotions=true', success: function(data) { if ($.trim(data) != '' && $('#kom').css('block') != 'block') { $('#kom .kom_mid').html(data); $('#kom').fadeIn(400, function() { }); } } }); } if ($('#kom2').css("display") != "block" && !getCookie("kom2info")) { $('#kom2').parent("div").css("z-index","2000"); $.ajax({ url: 'http://www.ec-24.pl/index.php?do=komunikaty&news=true', success: function(data) { if ($.trim(data) != '' && $('#kom2').css('block') != 'block') { $('#kom2 .kom_mid').html(data); $('#kom2').fadeIn(400, function() { }); } } }); } if ($('#kom3').css("display") != "block" && !getCookie("kom3info")) { $('#kom3').parent("div").css("z-index","2000"); $.ajax({ url: 'http://www.ec-24.pl/index.php?do=komunikaty&info=true', success: function(data) { if ($.trim(data) != '' && $('#kom3').css('block') != 'block') { $('#kom3 .kom_mid').html(data); $('#kom3').fadeIn(400, function() { }); } } }); } } }, 6000); });