function Faq(form_name, area_id)
{	this.form_name = form_name;
	this.area_id = area_id;
	this.construct = function ()
	{		this.form_obj = document.forms[this.form_name];
		this.area = document.getElementById(this.area_id);
		this.areaHTML = (this.area.innerHTML + '');
		this.clear_area = document.getElementById(this.area_id+'2');
		this.clear_areaHTML = (this.clear_area.innerHTML + '');
		this.default_question = this.form_obj['faq[default_question]'].value;
		this.form_obj['faq[question]'].value = this.default_question;
		this.form_obj['faq[question]'].onfocus = function()
		{
			if(Faq.form_obj['faq[question]'].value == Faq.default_question)
			{
				Faq.form_obj['faq[question]'].value = '';
				Faq.form_obj['faq[question]'].style.color = '#000000';
			}
		}

		this.form_obj['faq[question]'].onblur = function()
		{
			if(Faq.form_obj['faq[question]'].value == '')
			{
				Faq.form_obj['faq[question]'].style.color = '#BBBBBB';
				Faq.form_obj['faq[question]'].value = Faq.default_question;
			}
		}
	}


	this.construct();
	this.send = function(but)
	{		but.disabled = true;		var tmp = this.check();
		if(tmp != 4)
		{			alert(error_message[tmp]);
			this.form_obj[error_field[tmp]].focus();
			but.disabled = false;
			return false;
		}
	    var req = new JsHttpRequest();
	    req.onreadystatechange = function()
	    {
	        if (req.readyState == 4)
	        {	        	Faq.result(req.responseText, req.responseJS['is_spam'], but);
	        }
	    }

        var arr = Array();
        arr['lang'] = this.special_chars(this.form_obj['faq[lang]'].value);
	    arr['question'] = this.special_chars(this.form_obj['faq[question]'].value);

	    req.open(null, '/www/a2.php', true);
	    req.send(arr);
	}
	this.check = function()
	{		if(this.form_obj['faq[question]'].value == this.default_question || this.form_obj['faq[question]'] == '') return 1;
		if(this.form_obj['faq[question]'].value.length < 5) return 1;
		return 4;
	}
	this.result = function(text, flood, but)
	{		if(flood)
		{			alert(text);
			but.disabled = false;
			return false;		}
		but.disabled = false;
		var c_height = $("#ask_parent_div").height();
		$("#ask_parent_div").css({height: c_height + 'px'});
		this.globalize_vars = {text: text, flood: flood, but: but};
		$(this.area).animate({left: '-400px'}, function(){			text = Faq.globalize_vars.text;
			but = Faq.globalize_vars.but;
			Faq.mybut = $(but).remove();
			Faq.clear_area.innerHTML = '<br><center>' + text + '<br><a onclick="return !Faq.again();" href="#" style="border-bottom: 1px dashed #b22a22; text-decoration: none;" alt="Задать еще раз" title="Задать еще раз">Задать другой вопрос</a></center><br>&nbsp;';
			$("#ask_parent_div").animate({height: $(Faq.area).height() + 'px'});

			setTimeout(function(){				$(Faq.area).animate({left: '0px'});
			}, 500);

		});
	}
	this.special_chars = function(txt)
	{		var new_txt = '';		var chrs = Array(1240, 1241, 1186, 1187, 1170, 1171, 1198, 1199, 1200, 1201, 1178, 1179, 1256, 1257, 1210, 1211);
		for(var i = 0, to = txt.length; i < to; i++)
		{			tmp_chrcode = txt.charCodeAt(i);
			repl = false;
			for(var a = 0; a < 16; a++)
			{				if(chrs[a] == tmp_chrcode) repl = true;			}
			if(repl) new_txt += '&#' + tmp_chrcode + ';';
			else new_txt += txt.charAt(i);		}
		return new_txt;	}
	this.again = function()
	{		if(this.clear_area.innerHTML != this.clear_areaHTML)
		{			//this.mybut.appendTo($(this.area));
			this.clear_area.innerHTML = this.clear_areaHTML;
			this.construct();
			//$("#ask_parent_div").animate({height: $(this.area).height() + 'px'});
			return true;
		}	}
}