function Wnd (pb1Id, pb2Id, dateStart, dateEnd) {

	this.pb1 = document.getElementById(pb1Id);
	this.pb2 = document.getElementById(pb2Id);

	this.dateStart = dateStart.getTime();
	this.dateEnd = dateEnd.getTime();

	this.init = function () {
		setInterval('wnd.reload()', 1000);
	}

	this.reload = function() {
		var now = new Date();
		
		var progress = (now.getTime() - this.dateStart) / (this.dateEnd - this.dateStart) * 100;

    if (progress <= 100) {
	    this.pb1.style.width = progress + '%';
			var left = parseInt((this.dateEnd - now.getTime()) / 1000);

			//left -= 60 * 60;

			var leftS = left % 60; 
			left -= leftS;
			var leftM = Math.ceil(left / 60 % 60);
			left -= leftM * 60;
			var leftH = Math.ceil(left / 60 / 60 % 24);
			left -= leftH * 60 * 24;
			var leftD = Math.ceil(left / 60 / 60 / 24);

			var output = '<table><tr><td><div class="msg">ÇÀÃÐÓÇÊÀ ÇÈÌÛ &mdash; ' + parseInt(progress)  + '%</div>';
			output += '<div class="left">îñòàëîñü: ' 
				+ leftD + ' ' + this.getLangDay(leftD) + ', '
				+ leftH + ' ' + this.getLangHours(leftH) + ', '
				+ leftM + ' ' + this.getLangMinutes(leftM) + ', '
				+ leftS + ' ' + this.getLangSeconds(leftS) + '</div></td></tr></table>';
			this.pb2.innerHTML = output;
    }
	}

	this.getLangDay = function (d) {
		switch (d % 10) {
			case 1:
				return 'äåíü';
			case 2:
			case 3:
			case 4:
				return 'äíÿ';
			default:	
				return 'äíåé';
		}
	}

	this.getLangHours = function (h) {
		switch (h % 10) {
			case 1:
				return '÷àñ';
			case 2:
			case 3:
			case 4:
				return '÷àñà';
			default:	
				return '÷àñîâ';
		}
	}

	this.getLangMinutes = function (m) {
		switch (m % 10) {
			case 1:
				return 'ìèíóòà';
			case 2:
			case 3:
			case 4:
				return 'ìèíóòû';
			default:	
				return 'ìèíóò';
		}
	}
	
	this.getLangSeconds = function (s) {
		switch (s % 10) {
			case 1:
				return 'ñåêóíäà';
			case 2:
			case 3:
			case 4:
				return 'ñåêóíäû';
			default:	
				return 'ñåêóíä';
		}
	}

	this.init();	
}
