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();

  
};
