sortable_options = {
	cursor: 'move',
	helper: function(e,el) {
		var h = el.height() + 10;
		return $('div#sortable_helper').clone()
			.css('background','transparent')
			.width(el.width()+'px')
			.height(h+'px');
	}
};

$(function(){ // onload
	//$('ul').sortable(sortable_options);
	//$('body').append('<div id="sortable_helper" '+
	//	'style="position:absolute;top:-1000px;border:1px dashed #000;background-color:#fff;">&nbsp;</div>');
});


jLoader = function(url,replace_or_append,container_id,callback) {

	if( arguments.length < 3 ) {
		alert('need at least 3 args...');
		return;
	}

	var loader = $(                        // create and save the loading image
	'<div class="loading">'+
		'<image src="images/loading.gif" />'+
	'</div>').appendTo('#'+container_id);      // it is removed in the replacement

	$.get(url, {}, function(resp) {        // make async call to the <a>'s url
		loader.remove();

		if( replace_or_append == 'replace' )
			$('#'+container_id).replaceWith(resp); // * replace with the response
		else if( replace_or_append == 'append' )
			$('#'+container_id).append(resp);      // * replace with the response

		if( callback !== undefined )
			callback();
	}); 

	//$('ul').sortable(sortable_options);
	return false;                          // dont actually follow the link
};

jFormer = function(form_id,url,replace_or_append, container_id, method ){

	if( arguments.length < 4 ) { 
		alert('need 3'); return; 
	} else {
	}

	var container = $('#'+container_id);
	var method = method || 'post'; // default value
	
	//alert('jFormer called');

	var loader = $(                        // create and save the loading image
	'<div class="loading">'+
		'<image src="images/loading.gif" />'+
	'</div>').appendTo('#'+container_id);      // it is removed in the replacement


	$('#'+form_id).ajaxForm({ 
		type: method,
		success: function(resp){
			loader.remove();

			if( replace_or_append == 'replace' )
				container.replaceWith(resp); // * replace with the response
			else if( replace_or_append == 'append' )
				container.append(resp);      // * replace with the response
		}
	}).submit();

	
};
