// $Id: comment_notify.js,v 1.1 2009/02/13 21:43:16 greggles Exp $
(function ($) {
  Drupal.behaviors.commentNotify = {
    attach: function (context) {
      $('#edit-notify-type', context).hide();
      $('#edit-notify', context).bind('change', function() {
        if ($(this).attr('checked')) {
          $('#edit-notify-type', context).show();
          if ($('#edit-notify-type input:checked', context).length == 0) {
            $('#edit-notify-type input', context)[0].checked = 'checked';
          }
        }
        else {
          $('#edit-notify-type', context).hide();
        }
      });
      $('#edit-notify', context).trigger('change');
    }
  }
})(jQuery);
;
// $Id: mollom.js,v 1.8 2010/05/06 14:48:04 dries Exp $

(function ($) {

/**
 * Open Mollom privacy policy link in a new window.
 *
 * Required for valid XHTML Strict markup.
 */
Drupal.behaviors.mollomPrivacy = {
  attach: function (context) {
    $('.mollom-privacy a', context).click(function () {
      this.target = '_blank';
    });
  }
};

/**
 * Attach click event handlers for CAPTCHA links.
 */
Drupal.behaviors.mollomCaptcha = {
  attach: function (context, settings) {
    // @todo Pass the local settings we get from Drupal.attachBehaviors(), or
    //   inline the click event handlers, or turn them into methods of this
    //   behavior object.
    $('a.mollom-switch-captcha', context).click(getMollomCaptcha);
  }
};

/**
 * Fetch a Mollom CAPTCHA and output the image or audio into the form.
 */
function getMollomCaptcha() {
  // Get the current requested CAPTCHA type from the clicked link.
  var newCaptchaType = $(this).hasClass('mollom-audio-captcha') ? 'audio' : 'image';

  var context = $(this).parents('form');

  // Extract the Mollom session id and form build id from the form.
  var mollomSessionId = $('input.mollom-session-id', context).val();
  var formBuildId = $('input[name="form_build_id"]', context).val();

  // Retrieve a CAPTCHA:
  $.getJSON(Drupal.settings.basePath + 'mollom/captcha/' + newCaptchaType + '/' + formBuildId + '/' + mollomSessionId,
    function (data) {
      // Inject new CAPTCHA.
      $('.mollom-captcha-content', context).parent().html(data.content);
      // Update session id.
      $('input.mollom-session-id', context).val(data.session_id);
      // Add an onclick-event handler for the new link.
      Drupal.attachBehaviors(context);
      // Focus on the CATPCHA input.
      $('input[name="mollom[captcha]"]', context).focus();
    }
  );
  return false;
}

})(jQuery);
;
// $Id: textarea.js,v 1.31 2010/03/09 11:45:37 dries Exp $
(function ($) {

Drupal.behaviors.textarea = {
  attach: function (context, settings) {
    $('.form-textarea-wrapper.resizable', context).once('textarea', function () {
      var staticOffset = null;
      var textarea = $(this).addClass('resizable-textarea').find('textarea');
      var grippie = $('<div class="grippie"></div>').mousedown(startDrag);

      grippie.insertAfter(textarea);

      function startDrag(e) {
        staticOffset = textarea.height() - e.pageY;
        textarea.css('opacity', 0.25);
        $(document).mousemove(performDrag).mouseup(endDrag);
        return false;
      }

      function performDrag(e) {
        textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
        return false;
      }

      function endDrag(e) {
        $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
        textarea.css('opacity', 1);
      }
    });
  }
};

})(jQuery);
;
// $Id: filter.js,v 1.2 2010/04/30 07:48:07 dries Exp $
(function ($) {

/**
 * Automatically display the guidelines of the selected text format.
 */
Drupal.behaviors.filterGuidelines = {
  attach: function (context) {
    $('.filter-guidelines', context).once('filter-guidelines')
      .find('label').hide()
      .parents('.filter-wrapper').find('select.filter-list')
      .bind('change', function () {
        $(this).parents('.filter-wrapper')
          .find('.filter-guidelines-item').hide()
          .siblings('.filter-guidelines-' + this.value).show();
      })
      .change();
  }
};

})(jQuery);
;
/* Based on overlay-parent.js,v 1.22 2010/01/14 04:06:54 webchick */

(function ($) {

// Only act if overlay is found.
if (!Drupal.overlay) {
  return;
}

/**
 * Event handler: opens or closes the overlay based on the current URL fragment.
 *
 * @param event
 *   Event being triggered, with the following restrictions:
 *   - event.type: hashchange
 *   - event.currentTarget: document
 *
 * Overrides the same method from overlay-parent.js
 */
Drupal.overlay.eventhandlerOperateByURLFragment = function (event) {
  // If we changed the hash to reflect an internal redirect in the overlay,
  // its location has already been changed, so don't do anything.
  if ($.data(window.location, window.location.href) === 'redirect') {
    $.data(window.location, window.location.href, null);
    return;
  }

  // Get the overlay URL from the current URL fragment.
  var state = $.bbq.getState('overlay');
  if (state) {
    // Append render variable, so the server side can choose the right
    // rendering and add child frame code to the page if needed.
    var url = $.param.querystring(Drupal.settings.basePath + state, { render: 'overlay' });

    this.open(url);
    this.resetActiveClass(this.getPath(Drupal.settings.basePath + state));

    // @gardens: look for gardener specific paths.
    var isGardener = (state.indexOf('gardener/') > -1);
    if (isGardener) {
      // Ok, now we can tell the parent window we're ready.
      // @todo revisit this to use the overlay API more properly.
      $(this.inactiveFrame).addClass('overlay-active');
    }
  }

  // If there is no overlay URL in the fragment and the overlay is (still)
  // open, close the overlay.
  else if (this.isOpen && !this.isClosing) {
    this.close();
    this.resetActiveClass(this.getPath(window.location));
  }
};

})(jQuery);
;
(function($) {

Drupal.behaviors.gardensHelp = {
  attach: function(context) {
          Drupal.gardensHelp.init(context);
  }
};

Drupal.gardensHelp = Drupal.gardensHelp || {};

Drupal.gardensHelp.init = function(context) {
  // Move help area to inside the toolbar, so the toolbar resizes with it.
  var helpHeader = $('#help-header').html();
  $('#help-header').remove();
  $('#toolbar').prepend('<div id="help-header" style="display: none;">' + helpHeader + '</div>');

  // Bind our click handler to the help item.
  $('#toolbar-user .help a', context).bind('click', Drupal.gardensHelp.open);

  // Bind search submission handler to search form.
  $('#gardens-help-search-form').bind('submit', Drupal.gardensHelp.searchSubmit);

  // Bind links in the help header so that they will open a single new window
  $('#help-header a').bind('click', Drupal.gardensHelp.helpClick);

  // Check to see if the module has added the #help-alert div because the user should see it and set the timer to show the alert
  if ($('#help-alert').html()) {
    $timer = setTimeout(Drupal.gardensHelp.helpAlert, 2000);
}
};

Drupal.gardensHelp.open = function() {
  $("#help-header").slideToggle("slow", Drupal.gardensHelp.positionOverlay);
  $("#toolbar-user .help").toggleClass("help-active");
  // Blur the link so that the :active suedo-class doesn't cause it to have the grey background
  $("#toolbar-user .help a").blur();
  return false;
};

Drupal.gardensHelp.positionOverlay = function() {
  // As the toolbar is an overlay displaced region, overlay should be
  // notified of it's height change to adapt its position.
  $(window).triggerHandler('resize.overlay-event');

  // Porting the fix for IE and the slideToggle from the Gardener
  var wrapper = $(this).parent();
  if (wrapper.css('zoom') != 1) {
    wrapper.css('zoom', 1);
  } else {
    wrapper.css('zoom', '');
  }
}

Drupal.gardensHelp.searchSubmit = function(event) {
  // This method needs to work the same way as the link click handler so that it doesn't create an additional window
  event.preventDefault();
  if (Drupal.gardensHelp.helpWindow) {
          Drupal.gardensHelp.helpWindow.close();
  }
  // The Gardener will read the URL arguments and take care of the lack of a POST submition
  Drupal.gardensHelp.helpWindow = window.open(Drupal.settings.gardenerURL + '/search/apachesolr_search/' + $('#gardens-help-search-query').val(), 'gardens_help');
	
}

Drupal.gardensHelp.helpAlert = function() {
  // Check to see if the alert is visible
  if (!$('#help-alert:visible').length > 0) {
    // Show the alert if it is hidden
    $('#help-alert').fadeIn('slow')
    // Set the click handler to hide the alert on the close link
    $('.alert-close').bind('click', Drupal.gardensHelp.closeHelpBubble);
    // Set a timer to automatically hide the alert after some time
    //$timer = setTimeout(Drupal.gardensHelp.helpAlert, 20000);
  }
}

/**
 * Called when the user clicks the close button in the help bubble.  This
 * causes the bubble to disappear and be removed so it won't pop up again.
 */
Drupal.gardensHelp.closeHelpBubble = function (event) {
  var $help = $('#help-alert');
  if ($help.length > 0) {
    // Hide the alert if it is visible
    $help.fadeOut('slow', Drupal.gardensHelp.killHelpBubble);
    if ($timer) {
      clearTimeout($timer);
      $timer = null;
    }
  }

  // Stop the event so the page doesn't move and the overlay doesn't disappear
  // as a result of clicking the close link.
  if (event) {
    if (event.preventDefault) {
      event.preventDefault;
    }
    if (event.stopPropagation) {
      event.stopPropagation();
    }
  }
  return false;
};

/**
 * If you show the overlay, the helpAlert method will be called again.  If the
 * user closed it, that could get annoying.  Kill the thing.  It is not
 * supposed to pop up more than once.
 */
Drupal.gardensHelp.killHelpBubble = function () {
  $('#help-alert').remove();
};

Drupal.gardensHelp.helpClick = function (event) {
  // Stop normal link behavior
  event.preventDefault();

  // If there has already been a window created by the help drop down, close it.  Creating a new window will put focus on that window.
  if (Drupal.gardensHelp.helpWindow) {
    Drupal.gardensHelp.helpWindow.close();
  }
  Drupal.gardensHelp.helpWindow = window.open($(event.target).attr('href'), 'gardens_help');
};

})(jQuery);
;
/*jslint bitwise: true, eqeqeq: true, immed: true, newcap: true, nomen: false,
 onevar: false, plusplus: false, regexp: true, undef: true, white: true, indent: 2
 browser: true */

/*global jQuery: true Drupal: true window: true ThemeBuilder: true */

/*
 * Acquia object is created if it doesn't exist and a theme object built or referenced
 * if it exists to store the functions for this theme.
 */

var Acquia = Acquia || {};
Acquia.theme = Acquia.theme || {};

/**
 * Scrolls the page to the clicked element's location
 * @param {event} event
 *   The event.
 */
Acquia.theme.scrollTo = function (event) {
  // Keep the page from jumping to the hash target
  event.preventDefault();
  var targetOffset = event.data.scrollTarget.offset().top;
  jQuery('html,body').animate({scrollTop: targetOffset}, 1000);
};

/**
 * Equalizes all .col elements in a stack to the height of the tallest .col
 *
 * @param {DomElement} stacks
 *   Set of .stack DomElements
 */
Acquia.theme.equalizeColumns = function (stacks) {
  for (var i = 0; i < stacks.size(); i++) {
    // Get the current stack reference
    var _this = stacks.eq(i);
    // Store the stack's height
    var boxHeight = _this.height();
    // Get the columns in the stack
    var cols = _this.find('.tb-height-balance');
    for (var j = 0; j < cols.size(); j++) {
      if (cols.eq(j).height() > boxHeight) {
        // If the height of the col is more than previous height, use it
        boxHeight = cols.eq(j).height(); 
      }
    }
    cols.css('min-height', boxHeight);
  }
};

/**
 * Adds a click handler to the layout wrapper of the rotating banner.  Otherwise this element
 * would obsure the link wrapped around the image element
 */
Acquia.theme.enhanceRotatingBanner = function () {
  var $ = jQuery;
  var layouts = $('.layout-wrapper', '.rotating-banner');
  var len = layouts.length;
  if (len > 0) {
    while (len--) {
      Acquia.theme.pseudoLink(layouts.eq(len));
    }
  }
};

/**
 * Navigates to the designated element's data-link attribute value
 * 
 * @param {DomElement} element
 *   Element that the pseudo link will be applied to
 *
 * @attribute 
 *   data-link is an element attribute that uses the HTML5 data- pattern to store information in the DOM
 */
Acquia.theme.pseudoLink = function (element) {
  var $ = jQuery;
  var link = element.attr('data-link');
  if (link.length > 0) {
    //Bind a click event to the slide layout wrapper if it has a link, stored in data-link attribute
    element.click(function (event) {
      window.location = $(event.currentTarget).attr('data-link');
    });
  }
};

/**
 * Determines if the ThemeBuilder is open
 *
 * @return {Boolean}
 *   returns a boolean that represents the open state of the ThemeBuilder. True equals open.
 */
Acquia.theme.checkThemeBuilderStatus = function () {
  var $ = jQuery;
  return $('body').hasClass('themebuilder') ? true : false;
};

/**
* Document ready handler.
*/
jQuery(document).ready(function () {
  var $ = jQuery;
  var addCommentTrigger = jQuery('.comment_add');
  var addCommentForm = jQuery('#comment-new');
  var themebuilderIsOpen = Acquia.theme.checkThemeBuilderStatus();
  // Add only if the comment form exists on the page.
  if (addCommentForm.size() > 0) {
    // Bind click event handlers to all .comment_add links
    addCommentTrigger.bind('click', {scrollTarget: addCommentForm}, Acquia.theme.scrollTo);
  }
  // Set all sidebars to the height of their parent container.
  Acquia.theme.equalizeColumns(jQuery('.box', '.stack'));
  // Run the following only if the ThemeBuilder is closed
  if (!themebuilderIsOpen) {
    Acquia.theme.enhanceRotatingBanner();
  }
});
;
// @file Custom JavaScript which applies to Gardens features

(function ($) {
  Drupal.behaviors.RotatingBannerInThemeBuilder = {
    attach: function(context) {
      if ($('body').hasClass('themebuilder')) {
        $('.rb-slides').each( function() {
          if ($(this).cycle) {
            $(this).cycle('stop');
          }
        });
      }
    }
  };
})(jQuery);

;
