

function ajax_doUpdater(content_div,url)
{
	new Ajax.Updater(content_div,url, {
		onCreate: new Function("ajax_spin_div('" +content_div+ "');"),
		'method':'get',
		'parameters':'asAjax=Y',
		'evalScripts': true
	});
	return false;
}

function ajax_submitForm(divid,frm)
{


	if (typeof(CMS_FCK_prepare_submit) == 'function') {
		CMS_FCK_prepare_submit();
	}

	params =  Form.serialize(frm, true);
	params.asAjax = 'Y';

	new Ajax.Updater(divid,frm.action,
		{
			onCreate: new Function("ajax_spin_div('" +divid+ "');"),
			method: frm.method,
			parameters: params, 
			evalScripts: true
		}
	);
	
	return false;
}

// div_id id of div to put spinner in
//
// sub_width = width of left + right border/padding
// sub_height = width of top + bottom border/padding

function ajax_spin_div(div_id, sub_width, sub_height)
{
	var container = document.getElementById(div_id);

	spin_div = document.createElement("div");
	spin_div.style.position = 'absolute';
	spin_div.style.top = '0px';
	spin_div.style.left = '0px';

	if (!sub_width || !sub_height) {
		sub_width = 0;
		sub_height = 0;
	}

	spin_div.style.width = (container.offsetWidth - sub_width)+'px';
	spin_div.style.height = (container.offsetHeight - sub_height)+'px';

	spin_div.style.zIndex = 100;
	spin_div.className = 'spin_div';



	first_child = container.firstChild;

	if (first_child) {
	  	relative_div = document.createElement("div");
		relative_div.appendChild(spin_div);
		relative_div.style.position = 'relative';
		first_child.parentNode.insertBefore(relative_div, first_child);
	}
	else {
		Element.update(container, spin_div)
	}
} 
