﻿
// КАЛЕНДАРЬ

$(document).ready(function() {
	$(".contentnav a:first").addClass("active");
	var contentwidth = $(".contentholder").width();
	var totalcontent = $(".content").size();
	var allcontentwidth = contentwidth * totalcontent;
	$(".contentslider").css({'width' : allcontentwidth});
	rotate = function(){
		var slideid = $active.attr("rel") - 1;
		var slidedistance = slideid * contentwidth;
		$(".contentnav a").removeClass('active');
		$active.addClass('active');
		$(".contentslider").animate({
      	left: -slidedistance
    	}, 500 );
	}; 

	rotation = function(){
		play = setInterval(function(){
			$active = $('.contentnav a.active').next();
			if ( $active.length === 0) {
				$active = $('.contentnav a:first');
			}
			rotate();
		}, 90000000);
	};

	$(".contentnav a").click(function() {
		$active = $(this);
		rotate();
		return false;
	});

	function set_calendar(month) {
		if (month > 0) {
			$active = $(".contentnav a[rel='" + month + "']");
		} else {
			var d = new Date();
			var cur_month = d.getMonth() + 1;
			$active = $(".contentnav a[rel='" + cur_month + "']");
		}
		rotate();
	}
	
	set_calendar();
	
});
