var cConversationView = Class.create(cValaszto, {
	initialize: function($super, _name, _container, _reference) {
		$super(_name, _container, _reference);
		this.question = null;
		this.menu_container = $('kerdezes_div');
		this.flash_containerNm = "ajanlo_flash";
		this.enableSound = false;
		this.selectedFilter = 3;
	},
	// feltolti tartalommal
	init: function($super) {
		//$super();
		this.tablak = [];
		this.tablak.push(new cTable('movie', 'template_movie_big', 0, 0, 0, 1, $('conversation_output0'), $$('.conversation_lapozo0'), $('conversation_fejlec0'), this, this.reference + '.tablak[0]'));
		this.tablak.push(new cTable('ppl', 'template_ppl_small', 0, 0, 1, 1, $('conversation_output1'), $$('.conversation_lapozo1'), $('conversation_fejlec1'), this, this.reference + '.tablak[1]'));
		this.tablak[0].refreshContent(this.tablak[0].tipus, 0, 0);
	},
	activateView: function($super) {
		if (this.container == null) return;
		menuer.changeIt('kerdezes');
		$super();
		if ( userer && userer.getSetting('machine_reader') !== null ) {
			this.enableSound = userer.getSetting('machine_reader');
		}
		this.loadQuestion();
	},
	loadQuestion: function(answer) {
		var reference = this.reference;
		var uri = '?';
		if (this.question && this.question.id)
			uri += '&current_question=' + this.question.id;
		if (answer)
			uri += '&answer=' + answer;
		var filterValue = browserFilter.getConversationChkBoxValue();
		if ( filterValue ) {
			uri += '&filter_type=' + filterValue;
			if ( filterValue == 'movie') this.selectedFilter = 1;
			else if ( filterValue == 'serie') this.selectedFilter = 2;
			else this.selectedFilter = 3;

		}
		var keres = new Ajax.Request('getConv.php' + uri, {
			method:'get',
			onSuccess: this.parseQuestion.bind(this)
		});
	},
	parseQuestion: function(transport) {
		var ret = transport.responseText.evalJSON();
		this.filters = ret.params;
		this.question = ret.question;
		this.question.checkedMR = this.enableSound;
		this.question.selectedFilter = this.selectedFilter;
		templater.render(this.menu_container, 'template_question', this.question, this.renderQuestionCallback.bind(this));
		this.highlighted = 0;
		this.tablak[0].template = this.getBlockTemplate('movie', 0);
		this.tablak[0].refreshContent('movie', 0, 0);
	},
	renderQuestionCallback: function() {
		var qTableLeftMargin = ( screen.width - 400 ) / 2;
		$('question_align_table').style.marginLeft = qTableLeftMargin + "px";
		templater.bindElement($('answer1'), this.loadQuestion.bind(this, 1));
		templater.bindElement($('answer2'), this.loadQuestion.bind(this, 2));
		templater.bindElement($('answer3'), this.loadQuestion.bind(this, 3));
		browserFilter.setConversationChkBox();
		this.changeSoundChkBox();
	},
	changeSoundChkBox: function() {
		var tmpCont = $( this.flash_containerNm );
		if ( $('flash_reader') && $('flash_reader').checked ) {
			this.enableSound = true;
			templater.render(tmpCont, 'template_ajanlo_flash', this.question, this.changeSoundChkBoxCallback.bind(this));
			tmpCont.style.display = "inline";
		}
		else {
			this.enableSound = false;
			tmpCont.innerHTML = "";
		}
	},
	changeSoundChkBoxCallback: function() {
		// fake
	}
});
