	function toggle_mirror(element_id, focus_element_id)
	{
		var el = $(element_id);
		if (el)
		{
			var disp = el.css('display');
			el.css('display', disp == 'none' ? 'block' : 'none');
			disp = el.css('display');
			
			if (disp == 'block')
			{
				if (focus_element_id != null && focus_element_id != undefined && focus_element_id != '')
				{
					$(focus_element_id + '').focus();
				}
			}
		}
	}
	
	function mirror_save_callback()
	{
		if (this.readyState == 4 && this.status == 200)
		{
			var text = this.responseText;
			var m = text.match(/<success>(.*?)<\/success>/);
			var m1 = text.match(/<error>(.*?)<\/error>/);
			
			if (m != null && m.length > 0)
			{
				$('#mirror-block-success').css('display', 'block');
			}
			else if (m1 != null && m1.length > 0)
			{
				$('#mirror-block-error').css('display', 'block');
			}
		}
	}
	
	function mirror_save(news_id)
	{
		var el = $('textarea[name=mirrors]');
		var text = el[0].value;
	
		if (text == '')
		{
			return false;
		}
		
		var el2 = $('textarea[name=mirrors-comment]');
		var comment = el2[0].value;
		
		var x = $('#mirrors-type-1');
		var mirrors_type = x[0].checked ? 'links' : 'parts';
	
		$('#mirror-block-1').css('display', 'none');
	
		var q = 'urls=' + encodeURIComponent(text) + '&rnd=' + Math.random() + '&mirrors_type=' + mirrors_type;
		q += '&comment=' + encodeURIComponent(comment);
		var url = '/ajax-mirror.php?news_id=' + news_id;
		aj = new MyAjax.Request();
		aj.load(url, 'POST', q, 'UTF-8', mirror_save_callback);
	}