function get_content(name){
	show_loading('ajax_content_editor_content', 32);
	new Ajax.Request('ajax.php?mode=content&f=get_content&n=' + name,
	  {
		method:'get',
		onSuccess: function(transport){
			x=transport.responseXML.documentElement.childNodes;
			var _temp = document.createElement('div');
			for (i=0;i<x.length;i++)
			{
				_temp.appendChild(x[i]);
			}
			xinha_editors1['ajax_content_editor_content'].setEditorContent(_temp.innerHTML);
			hide_loading('ajax_content_editor_content');
		},
		onFailure: function(){ alert('Something went wrong...') }
	  });
}

function ajax_content_editor_submit()
{
	url = "http://" + base_href + '/ajax.php?mode=content&f=save&n=' + encodeURIComponent($('ajax_content_editor_content_name').value) + '&content=' + encodeURIComponent(xinha_editors1['ajax_content_editor_content'].getEditorContent()) + "&RandomKey=" + Math.random() * Date.parse(new Date());
	var xmlhttp=false;try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} catch (E) {xmlhttp = false;}}if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest();} try{
		xmlhttp.onreadystatechange=function()
		{
			try
			{
				if ( (xmlhttp.readyState == 4) && (xmlhttp.responseText.length > 0))
				{
					if(xmlhttp.responseText == '1')
					{
						//ref('chat_input').value = '';
						hide_loading('ajax_content_editor_submit');
						$('ajax_content_editor_content').focus();
					}
					else
					{
						setTimeout('ajax_content_editor_submit()', 3000);
					}
				}
			}
			catch(e)
			{
				alert(e + ' - ' + e.description);
			}
		}
		xmlhttp.open("GET", url, true);
		xmlhttp.send("");
		show_loading('ajax_content_editor_submit', 32);
	}
	catch(e)
	{
		alert(e + ' - ' + e.description);
		//ajax_imenik_get_info();
	}
}

function show_loading(obj_id, size)
{
	if (!$(obj_id + '_loading_holder'))
	{
		var loading_holder = document.createElement("DIV");
		loading_holder.id = obj_id + '_loading_holder';
		var loading_img = document.createElement("IMG");
		
		loading_img.src = 'images/loading_a_' + size + '.gif';
		loading_holder.style.width = size + 'px';
		loading_holder.style.height = size + 'px';
		loading_holder.style.position = 'absolute';
		loading_holder.style.display = 'none';
		loading_holder.style.zIndex = '9999999';
		loading_holder.style.top = Math.round((((findPosY($(obj_id)) + ($(obj_id).offsetHeight)/ 2)) - (size / 2))) + 'px';
		loading_holder.style.left = Math.round((((findPosX($(obj_id)) + ($(obj_id).offsetWidth)/ 2)) - (size / 2))) + 'px';
		loading_holder.appendChild(loading_img);
		document.body.appendChild(loading_holder);
		new Effect.Appear($(obj_id + '_loading_holder'), { sync: false, duration: 0.12 });
	}
}

function hide_loading(obj_id)
{
	loading_holder = $(obj_id + '_loading_holder');
	if ($(obj_id + '_loading_holder'))
		new Effect.Fade(loading_holder, { duration: 0.12, afterFinish: function() {if ($(obj_id + '_loading_holder')) $(obj_id + '_loading_holder').parentNode.removeChild($(obj_id + '_loading_holder'));} });
	
};

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
		while(1) 
		{
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
};

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
};

// <a href="images/thumb_.gif" class="referenz" alt=""><img src="images/thumb.gif" alt="" /></a>

function add_reference()
{
	//$('add_reference_form_title').value
	//$('add_reference_form_desc').value
	//$('add_reference_form_title').value
}

function switch_tab(a, b, c)
{
	for (i=1; i<=c; i++)
	{
		if (i!=b)
		{
			$('tab_' + a + '_li_' + i).setAttribute('class', 'tab');
			$('tab_' + a + '_li_' + i).className =  'tab';
			$('tab_' + a + '_content_' + i).style.display = 'none';
		}
		else
		{
			$('tab_' + a + '_li_' + i).setAttribute('class', 'tab_selected');
			$('tab_' + a + '_li_' + i).className =  'tab_selected';
			$('tab_' + a + '_content_' + i).style.display = '';
		}
	}
};

var reference_image = '';
var xinha_editors2_loaded = false;