//*********************************************************************************
// CMS Symp 3.0
// JavaScript класс для отправки данных формы
//*********************************************************************************
function sendForm_symp () {
	//public attributes
	this.sever_file_name = ""; 		//Имя серверного скрипта;
	this.form_tag = ""; 			//id Имя формы для отправки;
	this.accept_tag = ""; 			//id элемента, в случаи удачной операции;
	this.error_tag = ""; 			//id элемента, в случаи удачной операции;
	this.type_res = "str";
	this.isFeed = 'no';

	//private method
	this.send = function() {			//отрпавка данных на сервер
		//Найдем все элементы формы
		try{
		var ind = document.getElementById('pwlocaltext').innerHTML;
		}catch(e){}
		$("form#"+this.form_tag+" input[@type = 'text']").css("background-color", "#ffffff");
		$("form#"+this.form_tag+" input[@type = 'password']").css("background-color", "#ffffff");
		$("form#"+this.form_tag+" textarea").css("background-color", "#ffffff");
		$("label[@type='result_field']").text("");
		this.param = $("form#"+this.form_tag).serialize();

		if(this.isFeed=='yes'){
			$("#"+this.error_tag).html(document.getElementById('pwlocaltext').innerHTML);
		}else{
			$("#"+this.error_tag).html("<img src=\"/_img/indicator.gif\">");
		}
		$.post(this.sever_file_name, this.param, this.response);
	}

	this.response = function(xml) {			//получаем результат
		var accept = $("accept", xml).text();
		var obj_parent = this.success.parent;
		if (accept == 0) {
			$("#"+obj_parent.error_tag).text($("glob_message", xml).text());
			$("filed", xml).each(
				function() {
					$("#result_"+$(this).attr("name")).text($(this).text());
					$("#"+$(this).attr("name")).css("background-color", "#c9d9e9");
				}
			)
		} else if (accept == 1) {
			//$("#"+obj_parent.accept_tag).text($("glob_message", xml).text());
			if (obj_parent.type_res == "obj") {
				obj_parent.add_accept_function_obj(xml);
			} else {
				obj_parent.add_accept_function($("glob_message", xml).text());
			}
		}
	}
	this.response.parent = this; //Позволит обращаться к предку класса

	this.add_accept_function = function(accept_text) {		//Стандартная функция вывода результатов
		$("#"+this.response.parent.accept_tag).text(accept_text);
	}

	this.add_accept_function_obj = function(xml) {		//Стандартная функция вывода результатов
	}

}