
//Исполнитель отправки форм

indicator_image = new Image();
indicator_image.src = "/_img/indicator.gif";

function ajax_send_question() {
	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_question.php";
	sr.form_tag = "form_question";
	sr.accept_tag = "frame_question";
	sr.error_tag = "frame_feedback_error";
	sr.send();
}

function ajax_send_question_dop2() {
	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_question_dop.php";
	sr.form_tag = "form_question";
	sr.accept_tag = "frame_question";
	sr.error_tag = "frame_feedback_error";
	sr.type_res = "obj";
	sr.add_accept_function_obj = function(xml) {
		if ($("glob_message", xml).text() == 'kz') {
			$("#frame_feedback_error").html($("#kazreport").html());
		} else {
			$("#frame_feedback_error").html($("glob_message", xml).text());
		}
	}
	sr.send();
}

function ajax_send_question_dop() {
	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_question_dop.php";
	sr.form_tag = "form_question2";
	sr.accept_tag = "frame_question_ab";
	sr.error_tag = "frame_feedback_error_ab";
	sr.type_res = "obj";
	sr.add_accept_function_obj = function(xml) {
		if ($("glob_message", xml).text() == 'kz') {
			$("#res_quest").html($("#kazreport2").html()+'<br/><br/><input type="button" value="'+$("#but_close").attr("value")+'" onclick="$(\'#frame_question_ab\').hide();">');
		} else {
			$("#res_quest").html($("glob_message", xml).text()+'<br/><br/><input type="button" value="'+$("#but_close").attr("value")+'" onclick="$(\'#frame_question_ab\').hide();">');
		}
	}
	sr.send();
}

function show_form_question() {
	$("#frame_question").css("display", "block");
	$("#link_show_form").html('<a href="javascript:hide_form_question()">'+$("#text_close").attr("value")+'</a>');
}

function hide_form_question() {
	$("#frame_question").css("display", "none");
	$("#link_show_form").html('<a href="javascript:show_form_question()">'+$("#text_open").attr("value")+'</a>');
}

function ajax_send_training_order() {
	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_training_order.php";
	sr.form_tag = "form_training_order";
	sr.accept_tag = "frame_training_order";
	sr.error_tag = "frame_training_order_error";
	sr.type_res = "obj";
	//Переопределим стадартную функцию
	sr.add_accept_function_obj = function(xml) {
		$("#frame_training_order").html($("glob_message", xml).text());
	}
	sr.send();
}

function show_mailer_window(mailto) {
	var height_frame = document.getElementById("mailer_window").clientHeight;
	$("#mailer_window").css("top", document.body.scrollTop+((document.body.clientHeight-height_frame)/2));
	$("#mailer_window").css("visibility", "visible");
	$("#tomail").val(mailto);
	
}
function hide_mailer_window() {
	$("#mailer_window").css("visibility", "hidden");
}

function ajax_send_mailer() {
 	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_mailer.php";
	sr.form_tag = "form_mailer";
	sr.error_tag = "result_mailer_error_string";
	sr.type_res = "obj";
	
	//Переопределим стадартную функцию
	sr.add_accept_function_obj = function(xml) {
		$("#frame_mailer_close").css("display", "block");
		$("#frame_mailer").html($("glob_message", xml).text());
	}
	sr.send();	
}

function ajax_send_regconf() {
	var sr = new sendForm_symp;
	sr.sever_file_name = "/ajax_sent_regconf.php";
	sr.form_tag = "form_regconf";
	sr.accept_tag = "frame_regconf";
	sr.error_tag = "frame_regconf_error";
	sr.send();
}


function check_reg_form() {
	var filed = new Array("family", "name", "country", "city", "name_org", "org_rod", "structure", "email", "phone", "address"),
		error = 0;
		
	for (i=0; i<filed.length; i++) {
		if ($("#"+filed[i]).val() == '') {
			$("#"+filed[i]).css("background", "#ffc5c3");
			error++;
		} else {
			$("#"+filed[i]).css("background", "#fff");
		}
	}
	
	if (error == 0) {
		email = $("#email").val()
		var re = /[a-zA-Z0-9_\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]/i;
    	if (!re.test(email)) {
			$("#email").css("background", "#ffc5c3");
			error++;
		} else {
			$("#email").css("background", "#fff");
		}
	}
	
	if (error == 0) {
		ajax_send_regconf();
	} else {
		return false;
	}
	
}

function display_form_dop() {
	$('#frame_question_ab').show();
}