// $Id: rootcandy.js,v 1.2 2008/02/29 01:38:13 sign Exp $

if (Drupal.jsEnabled) {
  $(document).ready(function () {

    $('.rootcandy').click(function() {
      //ajax callback - prepend rootcandy url
      fname = $(this).attr('href');
      SplitURL = fname.split("?q=");
      if (SplitURL[1]) {
        url = Drupal.settings.basePath + '?q=rootcandy/' + SplitURL[1];
      } else {
        url = Drupal.settings.basePath + 'rootcandy' + $(this).attr('href');
      }
      active = $(this);
      //print to region based on arguments
      $.get(url, null, function(data){
        $(".rootcandy.active").removeClass();
        $(active).addClass("rootcandy active");
        $("#content").fadeOut("fast",function(){
          $("#sidebar-right").fadeOut("fast");
          $("#content").html(data);
          $("#content").fadeIn("fast");
        });

      });
      return false;
    });

    $('.compact-link').click(function() {
      $("dd").toggle();
      return false;
    });
  });
}