indicator_image = new Image();
indicator_image.src = "/_img/indicator.gif";

function show_searchbox_type(type) {
	if (type == 'task') {
		$("#search_tasks").show();
		$("#search_specialists").hide();
		$("#link_search_tasks").attr("class", "selected");
		$("#link_search_specialists").attr("class", "");
		$("#catalog_specialists").hide();
	} else {
		$("#search_specialists").show();
		$("#search_tasks").hide();
		$("#link_search_tasks").attr("class", "");
		$("#link_search_specialists").attr("class", "selected");
		$("#catalog_specialists").show();
	}
}

function preview_profile_name() {
	$("label[base='preview_name']").text($("#name").val());
}
function preview_profile_city() {
	if (parseInt($("#city_id").val())) {
		$("#city-block").show();
		$("#city-block dt").text($("#city_id option[@selected = 1]").text()+":");
	} else {
		$("#city-block").hide();
	}
}
function preview_profile_neighborhood() {
	if (parseInt($("#neighborhood_id").val())) {
		$("#neighborhood-txt").show();
		$("#neighborhood-txt").text($("#neighborhood_id option[@selected = 1]").text());
	} else {
		$("#neighborhood-txt").hide();
	}
}
function preview_profile_birth() {
	birth_day = parseInt($("#birth_day option[@selected = 1]").text());
	birth_month = $("#birth_month option[@selected = 1]").text();
	birth_year = parseInt($("#birth_year").val());

	if (birth_day >= 1 && birth_day <= 31 && birth_year > 1900 && birth_year < 2008) {
		$("#age-block").show();
		$("#age-block dd").text(birth_day+" "+birth_month+" "+birth_year);
	} else {
		$("#age-block").hide();
	}
}
function preview_profile_simple(type) {
	str = $("#"+type).val();
	if (str.length) {
		$("#"+type+"-block").show();
		$("#"+type+"-block dd").text(str);
	} else {
		$("#"+type+"-block").hide();
	}
}
function preview_profile_about() {
	str = $("#about").val();
	if (str.length) {
		$("#about-block").show();
		$("#about-block div").text(str);
	} else {
		$("#about-block").hide();
	}
}
function filter_neighborhood() {
	city_id = parseInt($("#city_id option[@selected = 1]").val());
	if (city_id) {
		res_param = "&city_id="+city_id;
		$.post("/ajax_get_neighborhood.php", res_param, function(xml) {
			var description = $("data", xml).text();
			var xml_obj = $.xslt.textToXML(description);
			var res_html = $.xslt({xml: xml_obj, xslUrl: '/_symp/_xslt/_spec/neighborhood.xsl'});
			$("#frame_neighborhood_id").html(res_html);
		});
		$("#neighborhood_id").val(0);
		preview_profile_neighborhood();
	} else {
 		$("#frame_neighborhood_id").html('');
	}
}

function filter_search_neighborhood(type) {
	city_id = parseInt($("#"+type+"_city_id option[@selected = 1]").attr('base_id'));
	if (city_id) {
		res_param = "&city_id="+city_id+"&type="+type;
		$.post("/ajax_get_neighborhood.php", res_param, function(xml) {
			var description = $("data", xml).text();
			var xml_obj = $.xslt.textToXML(description);
			var res_html = $.xslt({xml: xml_obj, xslUrl: '/_symp/_xslt/_spec/neighborhood_'+type+'.xsl'});
			$("#frame_"+type+"_neighborhood").html(res_html);
		});

		$("#"+type+"_neighborhood_id").val(0);
	} else {
 		$("#frame_"+type+"_neighborhood").html('');
	}
}

function filter_search_rubricator(type) {
	city_id = parseInt($("#"+type+"_city_id option[@selected = 1]").attr('base_id'));
	neighborhood_id = parseInt($("#"+type+"_neighborhood_id option[@selected = 1]").attr('base_id'));

	res_param = "&type="+type;
	if (city_id) {
		res_param += "&city_id="+city_id;
	}
	if (neighborhood_id) {
		res_param += "&neighborhood_id="+neighborhood_id;
	}
	$("#frame_"+type+"_rubricator").html('');
	$.post("/ajax_get_rubricator.php", res_param, function(xml) {
		var description = $("data", xml).text();
		var xml_obj = $.xslt.textToXML(description);
		var res_html = $.xslt({xml: xml_obj, xslUrl: '/_symp/_xslt/_spec/rubricator_'+type+'.xsl'});
		$("#frame_"+type+"_rubricator").html(res_html);
	});
	$("#"+type+"_rubricator_id").val(0);
}

function preview_profile_rubricator() {
	rubricator_id = parseInt($("#rubricator_id option[@selected = 1]").val());
	rubricator2_id = parseInt($("#rubricator2_id option[@selected = 1]").val());
	rubricator3_id = parseInt($("#rubricator3_id option[@selected = 1]").val());
	if (rubricator_id || rubricator2_id || rubricator3_id) {
		$("#rubricator-block").show();
		str = "";
		if (rubricator_id) {
			str = $("#rubricator_id option[@selected = 1]").text();
			if (str.indexOf(" - ") == 0) str = str.substr(3);
		}
		if (rubricator2_id) {
			str2 = $("#rubricator2_id option[@selected = 1]").text();
			if (str2.indexOf(" - ") == 0) str2 = str2.substr(3);
			if (str.length) str = str + ", ";
			if (str2.length) str = str + str2;
		}
		if (rubricator3_id) {
			str3 = $("#rubricator3_id option[@selected = 1]").text();
			if (str3.indexOf(" - ") == 0) str3 = str3.substr(3);
			if (str.length) str = str + ", ";
			if (str3.length) str = str + str3;
		}
		$("#rubricator-block span").text(str);
	} else {
		$("#rubricator-block").hide();
	}
}

function show_form_edit_opinions(id) {
	$("#frame_opinions_"+id).css("display", "none");
	$("#frame_edit_opinions_"+id).css("display", "block");
}

function show_form_edit_proposal(id) {
	$("#frame_proposal_"+id).css("display", "none");
	$("#frame_edit_proposal_"+id).css("display", "inline");
}
function hide_form_edit_proposal(id) {
	$("#frame_proposal_"+id).css("display", "inline");
	$("#frame_edit_proposal_"+id).css("display", "none");
}