(function(c){var b=this;var d={ro:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"],ru:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],en:["January","February","March","April","May","June","July","August","September","October","November","December"]};var a={ro:["Du","Lu","Ma","Mi","Jo","Vi","Si"],ru:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],en:["Su","Mo","Tu","We","Th","Fr","Sa"]};DateCarousel=b.DateCarousel=function(g,j){DateCarousel.fn=DateCarousel.prototype={init:function(N,M){if(N.nodeType){F=N;q=c(F);l();c.extend(F,DateCarousel.fn);i(M);u=B.timestamp;C();e();return F}if(typeof N==="string"){return DateCarousel(document.getElementById(N),M)}},CLASSNAME:"DateCarousel"};var F;var q;var B=null;var n=["day","month","year"];var u;var f=0;var v=false;var m=null;var k=null;return new DateCarousel.fn.init(g,j);function I(O,P,N){var M=new Date(P);var Q="";O=O.replace(/%Y/g,M.getFullYear());O=O.replace(/%n/g,M.getMonth()+1);O=O.replace(/%j/g,M.getDate());Q=A(M.getDay(),B.lang);if(Q===null){Q=""}O=O.replace(/%D/g,Q);Q=L(M.getMonth(),(B.lang=="ru"&&N==true?"en":B.lang));if(Q===null){Q=""}O=O.replace(/%F/g,Q);return O}function l(){B=new Object();B.lang="ro";B.cellHrefPattern="/ro/arhiva/evenimente/%Y-%F";B.cellTextPattern="%j-%n<br />%Y";B.isCellSelectedAnchor=false;B.unitToIncrease="month";B.selectedCellTimestamp=null;var M=new Date();B.timestamp=new Date(M.getFullYear(),M.getMonth(),M.getDate()).getTime();B.cellsCount=7;B.cellWidth=90;B.animateDuration=500;B.minTimestamp=-1;B.maxTimestamp=-1}function i(N){if(typeof N!="object"){return}if(typeof N.unitToIncrease=="undefined"){N.unitToIncrease=n[0]}if(N.selectedCellTimestamp&&N.selectedCellTimestamp!=null){var M=new Date(N.selectedCellTimestamp);N.selectedCellTimestamp=M.getTime();if(N.selectedCellTimestamp&&N.selectedCellTimestamp!="NaN"){v=true}}if(typeof N.minTimestamp!="number"){N.minTimestamp=-1}if(typeof N.maxTimestamp!="number"){N.maxTimestamp=-1}c.extend(B,N)}function C(){F.innerHTML="<div class='btn-prev'></div><div class='cells-list'><div class='cells-container'>"+E(u,B.cellsCount)+"</div></div><div class='btn-next'></div><div style='clear:both;float:none;'></div>";q.find(".cells").addClass("selected");p();D();m=q.find(".btn-next");k=q.find(".btn-prev");var N=J(u,B.cellsCount);var M=o(u,B.cellsCount);if(B.maxTimestamp>=0&&N>B.maxTimestamp){z()}if(B.minTimestamp>=0&&u<=B.minTimestamp){x()}}function e(){k.bind("click",s);m.bind("click",t)}function E(Q,P){var O="<div class='cells'>";var N;for(var M=0;M<P;M++){N=false;if(v&&Q==B.selectedCellTimestamp){N=true}O+="<div class='cell"+(N?" selected":"")+"'>"+(N&&!B.isCellSelectedAnchor?"<span>":"<a href='"+I(B.cellHrefPattern,Q,true).toLowerCase()+"'>")+I(B.cellTextPattern,Q,false)+(N&&!B.isCellSelectedAnchor?"</span>":"</a>")+"</div>";Q=J(Q,1)}O+="</div>";return O}function p(){var M=B.cellsCount;q.find(".cells-container").prepend(E(o(u,M),M));f-=B.cellWidth*M;q.find(".cells-container")[0].style.marginLeft=f+"px"}function D(){q.find(".cells-container").append(E(J(u,B.cellsCount),B.cellsCount))}function K(){c(q.find(".cells").get(0)).remove();f+=B.cellWidth*B.cellsCount;q.find(".cells-container")[0].style.marginLeft=f+"px"}function G(){c(q.find(".cells").get(2)).remove()}function r(M){f-=B.cellWidth*B.cellsCount;q.find(".cells-container").stop(true,false).animate({marginLeft:f+"px"},B.animateDuration,null,function(){if(typeof M=="function"){M()}})}function H(M){f+=B.cellWidth*B.cellsCount;q.find(".cells-container").stop(true,false).animate({marginLeft:f+"px"},B.animateDuration,null,function(){if(typeof M=="function"){M()}})}function t(){var O=J(u,B.cellsCount);if(O>B.maxTimestamp&&B.maxTimestamp>=0){return false}u=O;K();D();w();O=J(u,B.cellsCount);if(O>B.maxTimestamp&&B.maxTimestamp>=0){z()}else{y()}var M=q.find(".cells");var N=M.filter(".selected");c(M.get(1)).addClass("selected");r(function(){N.removeClass("selected")});return false}function s(){if(u<=B.minTimestamp&&B.minTimestamp>=0){return false}var N=o(u,B.cellsCount);u=N;G();p();y();if(u<=B.minTimestamp&&B.minTimestamp>=0){x()}else{w()}var M=q.find(".cells");var O=M.filter(".selected");c(M.get(1)).addClass("selected");H(function(){O.removeClass("selected")});return false}function L(M,N){if(d&&d[N]&&d[N][M]){return d[N][M]}return null}function A(M,N){if(a&&a[N]&&a[N][M]){return a[N][M]}return null}function J(N,M){var O=new Date(N);if(B.unitToIncrease=="day"){O.setDate(O.getDate()+M)}else{if(B.unitToIncrease=="month"){O.setMonth(O.getMonth()+M)}else{if(B.unitToIncrease=="year"){O.setFullYear(O.getFullYear()+M)}}}return O.getTime()}function o(N,M){var O=new Date(N);if(B.unitToIncrease=="day"){O.setDate(O.getDate()-M)}else{if(B.unitToIncrease=="month"){O.setMonth(O.getMonth()-M)}else{if(B.unitToIncrease=="year"){O.setFullYear(O.getFullYear()-M)}}}return O.getTime()}function h(M,S){if(S<M){var N=M;M=S;S=N}var Q=new Date(M);var P=new Date(S);var R=null;try{if(B.unitToIncrease=="day"){R=parseInt((P.getTime()-Q.getTime())/(24*3600*1000))}else{if(B.unitToIncrease=="month"){R=P.getMonth()-Q.getMonth()+(12*(P.getFullYear()-Q.getFullYear()))}else{if(B.unitToIncrease=="year"){R=P.getFullYear()-Q.getFullYear()}}}}catch(O){R=null}return(R!=null&&R>=0&&R<B.cellsCount?R:B.cellsCount)}function y(){m.css("visibility","visible")}function z(){m.css("visibility","hidden")}function w(){k.css("visibility","visible")}function x(){k.css("visibility","hidden")}}})(jQuery);
