endTime = new Date(2014,2,6,23,0,0,0).getTime(); var days = 24*60*60, hours = 60*60, minutes = 60; function reload_timer(){ leftTime = Math.floor((endTime - (new Date())) / 1000); timerD = Math.floor(leftTime / days); leftTime -= timerD*days; timerH = Math.floor(leftTime / hours); leftTime -= timerH*hours; timerM = Math.floor(leftTime / minutes); leftTime -= timerM*minutes; timerS = leftTime; $('.t_d').text(timerD); $('.t_h').text(timerH); $('.t_m').text(timerM); $('.t_s').text(timerS); } function openPopup(name){ $('#shadow').fadeIn(500); $('#popup_'+name).fadeIn(700); } function closePopup(){ $('.popup').fadeOut(500); $('#shadow').fadeOut(700); } /* Закрываем модальное окно: */ function close_popup(box) { $(box).hide(); $('.popup').fadeOut(500); $('#shadow').fadeOut(500); } function clear(obj){ $(obj).find('input[type="text"]').each(function(){ $(this).val(''); }); $(obj).find('input[type="file"]').val('').change(); } function check(obj){ ret = true; texts = $(obj).find('input[type="text"]'); texts.each(function(){ if(($(this).attr('placeholder').indexOf('*')!=-1) && ($(this).val().length==0)){ $(this).addClass('error'); ret = false; } }); if(ret){ closePopup(); openPopup('message'); setTimeout(function(){ closePopup(); clear(obj); },3000); } return ret; } $(function(){ setInterval(function(){ reload_timer(); },1000); });