// $Id: pageax.js,v 1.1.2.1 2006/12/22 21:15:41 mfredrickson Exp $

jQuery.fn.pageax = function(el) {
   return this.each( function() {
    jQuery(this).click( function() { 
      pageaxLinkHandle(jQuery(this), el); 
      return false;
    }); 
  });
};

function pageaxLinkHandle(l, el) {
  // var l = JQ(this);
  // alert(l.href());
  JQ.get(pageaxbaseurl, {loadpath: l.href()}, function(xml) {
    pageaxRecieve(l, el, xml);
  }); 
  el.empty().append('<div class = "pageax-loading"><img src ="' + pageaxloader + '" /> Loading content... </div>').fadeIn();
  return false;
}

function pageaxRecieve(link, el, xml) {

  // if we can't find any content, just send the browser to the path
  if (xml == '') {
    window.location = link.href();
    return;
  }

  // fill that child with the returned XML
  // I wanted to do something fancy with animations, but it was
  // giving weird results. Perhaps for version 2.0
  el.empty().append(xml).fadeIn();

}