  var calendar = {
	url_click:	false,

	tob:		0,

	events:		false,
	monthes:	false,

	obj_cal:	false,
	obj_calm:	false,

	current:	false,

	today:		false,

	init:		function (y,m,d) {
				this.today = {"y":y,"m":m-1,"d":d};
				this.current = {"y":y,"m":m-1};

				this.draw();
			},

	draw:		function () {
				var d = new Date(this.current.y,this.current.m+1,0,0,0,0);
				m_count = d.getDate();

				var d = new Date(this.current.y,this.current.m,1,0,0,0);
				this.current = {"y":d.getFullYear(),"m":d.getMonth(),"st":d.getDay(),"cnt":m_count};

				this.obj_cal.innerHTML = "";
				this.obj_calm.innerHTML = (this.monthes[this.current.m]) + ' ' + this.current.y;

				this.draw_dates();
			},

	draw_dates:	function () {
				this.current.st = (this.current.st == 0 ? 7 : this.current.st);

				for (q=1; q<this.current.st; q++)
					this.draw_date("");

				for (q=1; q<=this.current.cnt; q++)
					this.draw_date(q, ((q + this.current.st - 1) % 7));
			},

	draw_date:	function (z, day) {
				div1 = document.createElement("div");
				div1.id = "el" + this.tob + "d" + z;

				var clsnm = "date_just";
				if (z == 0) clsnm = "date_empty";

				if (this.if_today(z)) clsnm = "date_current";

				if (this.if_event(z)) {
					clsnm = "date_event" + (this.if_today(z) ? " date_current" : "");

					div1.onclick = function(me, z) {
						return function() {
							me.clicked(z);
						}
					}(this, z);
				}

				div1.className = "date " + clsnm;
				div1.innerHTML = (z > 0 ? z : "");

				this.obj_cal.appendChild(div1);
			},

	clicked:	function (z) {
				z = z + '';			//z = (z.length<2?"0"+z:z);
				m = (this.current.m+1) + '';	//m = (m.length<2?"0"+m:m);
				//document.location.href = this.events.url + z + "-" + m + "-" + this.current.y + ".html";
				document.location.href = this.events.url + this.events[this.current.y][m][z].t;
				//top.frames[ this.events.target ].location.href = this.events.url + this.events[this.current.y][m][z].t;
			},

	next:		function () {
				this.current.m += 1;
				this.draw();
			},

	prev:		function () {
				this.current.m -= 1;
				this.draw();
			},

	if_event:	function (z) {
				if (typeof this.events[this.current.y] == 'undefined') return false;
				if (typeof this.events[this.current.y][this.current.m+1] == 'undefined') return false;
				if (typeof this.events[this.current.y][this.current.m+1][z] == 'undefined') return false;

				return true;
			},

	if_today:	function (z) {
				if (z == this.today.d && this.current.m == this.today.m && this.current.y == this.today.y) return true;
				return false;
			}
  }
