function TQuestion(id) {
	if (!id) id = '0';
	this.elemQ = $('#idquestion_'+id);
	var variants, isDetect;
	var q = this;
	var win = null;
	var a = null;

	this.vote = function() {
		variants = Array();
		isDetect = 0;
		$('input:checkbox', q.elemQ).each(function() {variants[variants.length] = (this.checked?1:0);if (this.checked) isDetect = 1;});
		$('input:radio', q.elemQ).each(function() {variants[variants.length] = (this.checked?1:0);if (this.checked) isDetect = 1;});
		if (!isDetect) {alert('Необходимо выбрать варианты ответа!');return 1;}
		$.post('/db/jx-web-c.php', {
			jx: 'cmpwork',
			cmp: 'question',
			pkey_id: id,
			variants: variants.join(';')
		}, q.onVote, 'json');
		$('#votebuttons', q.elemQ).hide();
		$('#loading', q.elemQ).show();
		return 1;
	};
	this.onVote = function(data) {
		$('#loading', q.elemQ).hide();
		if (data.err) {alert(data.err);return;}
		alert('Ваш голос учтён!');
	};
	this.showResults = function(e) {
		if (win) return false;
		a = e;
		win = 'qn_'+(uid++);
		var str = '<div id="'+win+'" style="z-index: 100; position: absolute; border: 1px outset #aaa; background-color: #ebebeb; display: none; left: -1000px; top: -1000px">';
		str += '<div class="cn f9" style="background: url(/src/imgs/tr.jpg) #f4f4f4; height: 20px; padding-top:3px; padding-bottom: 3px; cursor: move">Результаты опроса</div>';
		str += '<div class="r" style="margin-top: -24px; padding: 3px; cursor: move"><img class="cur" src="/src/imgs/x.gif"/></div>';
		str += '<div class="graphres"></div></div>';
		$(str).appendTo('body');
		win = $('#'+win);
		$('img:eq(0)', win).hover(function(){
			$(this).css('background-color', '#ddd');
		}, function(){
			$(this).css('background-color', 'transparent');
		}).click(function(){
			win.fadeOut(350, function(){$(this).remove(); win = null; });
		});
		$('.graphres', win).load('/cmp/cache/question/'+id+'_res.html', {}, this.printResults);
		return false;
	};
	this.printResults = function() {
		win.css('left', parseInt(screen.availWidth / 2 - win.width() / 2));
		win.css('top', parseInt(($('#idquestion_'+id).offset().top + $(a).offset().top) / 2 - win.height() / 2)+15);
		$('.qngrv', win).each(function(){
			this.title = this.innerHTML;
			simple_tooltip(this, (uid++));
		});
		$('#close', win).click(function(){
			win.fadeOut(350, function(){$(this).remove(); win = null;});
		});
		$(win).draggable({
			revert: true,
			revertDuration: 1000
		});
		win.fadeIn(350);
	};
}