!function(e){function t(t,a){timer_html='<div class="timer-head-block">'+a.headTitle+"</div>",timer_html+='<div class="timer-body-block">',a.dayVisible&&(timer_html+='            <div class="table-cell day">                <div class="tab-val">0</div>                <div class="tab-metr"></div>            </div>'),timer_html+='            <div class="table-cell hour">                <div class="tab-val">00</div>                <div class="tab-metr"></div>            </div>            <div class="table-cell minute">                <div class="tab-val">00</div>                <div class="tab-metr"></div>            </div>            <div class="table-cell second">                <div class="tab-val">00</div>                <div class="tab-metr"></div>            </div>',timer_html+="</div>",timer_html+='<div class="timer-foot-block">'+a.footTitle+"</div>",t.addClass("timer").html(timer_html),headBlock=e(".timer-head-block",t),bodyBlock=e(".timer-body-block",t),footBlock=e(".timer-foot-block",t),timerBlocks={headBlock:headBlock,bodyBlock:bodyBlock,footBlock:footBlock},t=e.extend(t,timerBlocks)}function a(e,t){return t=""==t?t:!0,9>=e&&t?"0"+e:""+e}function i(e,t,a){switch(a){case"rus":return cases=[2,0,1,1,1,2],t[e%100>4&&20>e%100?2:cases[5>e%10?e%10:5]];case"eng":return t[1==e?0:1]}}var d=86400,l=3600,s=60,n={rus:{second:["секунда","секунды","секунд"],minute:["минута","минуты","минут"],hour:["час","часа","часов"],day:["день","дня","дней"]},eng:{second:["second","seconds"],minute:["minute","minutes"],hour:["hour","hours"],day:["day","days"]}};e.fn.syotimer=function(o){defaultTimer={year:2014,month:7,day:31,hour:0,minute:0,second:0,periodic:!1,periodInterval:7,periodUnit:"d",dayVisible:!0,dubleNumbers:!0,effectType:"none",lang:"eng",headTitle:"",footTitle:"",afterDeadline:function(e){e.bodyBlock.html('<p style="font-size: 1.2em;">The countdown is finished!</p>')}};var r=e.extend(defaultTimer,o||{}),c=this;return c.each(function(){var o=e(this);t(o,r),function c(){if(e(".second .tab-val",o).css("opacity",1),Now=new Date,DeadDate=new Date(r.year,r.month-1,r.day,r.hour,r.minute,r.second),different=Math.floor((DeadDate.getTime()-Now.getTime())/1e3),r.periodic){switch(r.periodUnit){case"d":unit_ms=d;break;case"h":unit_ms=l;break;case"m":unit_ms=s;break;case"s":unit_ms=1}differentUnits=Math.abs(Math.ceil((DeadDate.getTime()-Now.getTime())/(1e3*unit_ms))),different>=0?(dUnits=differentUnits%r.periodInterval,dUnits=0==dUnits?r.periodInterval-1:dUnits-1):dUnits=r.periodInterval-differentUnits%r.periodInterval,addUnits=different%unit_ms,0==addUnits&&different<0&&dUnits--,alls=Math.abs(dUnits*unit_ms+addUnits)}else alls=different;if(alls>=0)switch(dd=Math.floor(alls/d),alls%=d,dh=Math.floor(alls/l),alls%=l,dm=Math.floor(alls/s),alls%=s,ds=Math.floor(alls),r.dayVisible?(e(".day .tab-val",o).html(dd),e(".day .tab-metr",o).html(i(dd,n[r.lang].day,r.lang)),e(".hour .tab-val",o).html(a(dh,r.dubleNumbers)),e(".hour .tab-metr",o).html(i(dh,n[r.lang].hour,r.lang))):(dh+=24*dd,e(".hour .tab-val",o).html(a(dh,r.dubleNumbers)),e(".hour .tab-metr",o).html(i(dh,n[r.lang].hour,r.lang))),e(".minute .tab-val",o).html(a(dm,r.dubleNumbers)),e(".minute .tab-metr",o).html(i(dm,n[r.lang].minute,r.lang)),e(".second .tab-val",o).html(a(ds,r.dubleNumbers)),e(".second .tab-metr",o).html(i(ds,n[r.lang].second,r.lang)),r.effectType){case"none":setTimeout(function(){c()},1e3);break;case"opacity":e(".second .tab-val",o).animate({opacity:.1},1e3,"linear",c)}else r.afterDeadline(o)}()})}}(jQuery);