var ajax;
function ajax_updater(url) {
	if ($('editformloader'))
		$('editformloader').show();		
	url = url + "&dummy=" + new Date().getTime();
	ajax =  new Ajax.Updater(
         'content_file',        // DIV id must be declared before the method was called
         url,        // URL
         {                // options
		 encoding:'utf-8',
         method:'post',
         //onComplete: Table.auto
         onComplete: function(){ /*new Table.auto; new convertTrees; */initTinyMce(); createsortable();  },asynchronous:true
         });
}

function createsortable()
{
	Sortable.create("firstlist",
 	{dropOnEmpty:true});

}


function ajax_updater_form(form)
{
	
	if ($('editformloader'))
		$('editformloader').show();		

	var params = Form.serialize($(form));
	//alert(params);
	var url = $(form).readAttribute('action');
	url = url + "&dummy=" + new Date().getTime();
	//alert(url);
	//var params = urlDecode(params);
	new Ajax.Updater('content_file', url, {asynchronous:true, encoding:'utf-8',parameters:params, onComplete: function(){/*new Table.auto; new convertTrees; */msg_set();initTinyMce(); }});
}
function ajax_updater_action(url) {
	url = url + "&dummy=" + new Date().getTime();
	ajax =  new Ajax.Updater(
         'content_file',        // DIV id must be declared before the method was called
         url,        // URL
         {                // options
         method:'post',
         //onComplete: Table.auto
         onComplete: function(){/* new Table.auto;  new convertTrees; */msg_set();initTinyMce();},asynchronous:true, evalScripts:true
         });
}
function ajax_updater_div(url, divobj) {
    /*start SUBMITING FORM*/
    if (typeof divobj == "undefined")
    {
        divobj = "editformcontent";
    }

	
	if ($('editformloader'))
		$('editformloader').show();	
		
	if ($('editformcontent'))
		$('editformcontent').hide();			
	
	url = url + "&dummy=" + new Date().getTime();
	ajax =  new Ajax.Updater(
         divobj,        // DIV id must be declared before the method was called
         url,        // URL
         {                // options
         method:'post',
         //onComplete: Table.auto
         onComplete: function(){ if ($('editformloader')) $('editformloader').hide();		
	if ($('editformcontent'))
		$('editformcontent').show(); initTinyMce();},asynchronous:true, evalScripts:true
         });
}

function ajax_sign(url) {
	url = url + "&dummy=" + new Date().getTime();
	ajax =  new Ajax.Updater(
         'main_tbl',        // DIV id must be declared before the method was called
         url,        // URL
         {                // options
         method:'post',
         onComplete: function(){/* new Table.auto; new convertTrees;*/},asynchronous:true, evalScripts:true
         });
}

function ajax_send_2_bas(url, obj, price) {
	url = url + "&dummy=" + new Date().getTime();
	ajax = new Ajax.Request(url, {
  	method: 'post',
  	onSuccess: function(transport) {
  	msg_set(obj, price);
  }
});
}

function ajax_send_noret(url) {
	url = url + "&dummy=" + new Date().getTime();
	ajax = new Ajax.Request(url, {
  	method: 'post',
  	onSuccess: function(transport) {

  }
});
}

function validateStructureForm(form,structid,newname) {
	if (checkValidForm(form)==false)
		return false;
	/*start SUBMITING FORM*/	
	var params = Form.serialize($(form));
	var url = $(form).readAttribute('action');
	url = url + "&dummy=" + new Date().getTime();
	new Ajax.Updater('rightcontent', url, { asynchronous:true, parameters:params, onLoading:structure_showload(), onComplete: function(){/*new Table.auto; */msg_set(); $('struct'+structid).update($F(newname));$('rightcontentloader').hide();$('rightcontent').show(); }});

	/*end SUBMITING FORM*/
}

function structure_showload ()
{
	$('rightcontent').hide();
	$('rightcontentloader').show();
}
