/*
 * jQuery Form Example Plugin 1.4.3
 * Populate form inputs with example text that disappears on focus.
 *
 * e.g.
 *  $('input#name').example('Bob Smith');
 *  $('input[@title]').example(function() {
 *    return $(this).attr('title');
 *  });
 *  $('textarea#message').example('Type your message here', {
 *    className: 'example_text'
 *  });
 *
 * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008.
 * Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
 * licenses.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
(function($) {

  $.fn.example = function(text, args) {

    /* Only calculate once whether a callback has been used. */
    var isCallback = $.isFunction(text);

    /* Merge the arguments and given example text into one options object. */
    var options = $.extend({}, args, {example: text});

    return this.each(function() {

      /* Reduce method calls by saving the current jQuery object. */
      var $this = $(this);

      /* Merge the plugin defaults with the given options and, if present,
       * any metadata.
       */
      if ($.metadata) {
        var o = $.extend({}, $.fn.example.defaults, $this.metadata(), options);
      } else {
        var o = $.extend({}, $.fn.example.defaults, options);
      }

      /* The following event handlers only need to be bound once
       * per class name. In order to do this, an array of used
       * class names is stored and checked on each use of the plugin.
       * If the class name is in the array then this whole section
       * is skipped. If not, the events are bound and the class name
       * added to the array.
       *
       * As of 1.3.2, the class names are stored as keys in the
       * array, rather than as elements. This removes the need for
       * $.inArray().
       */
      if (!$.fn.example.boundClassNames[o.className]) {

        /* Because Gecko-based browsers cache form values
         * but ignore all other attributes such as class, all example
         * values must be cleared on page unload to prevent them from
         * being saved.
         */
        $(window).unload(function() {
          $('.' + o.className).val('');
        });

        /* Clear fields that are still examples before any form is submitted
         * otherwise those examples will be sent along as well.
         *
         * Prior to 1.3, this would only be bound to forms that were
         * parents of example fields but this meant that a page with
         * multiple forms would not work correctly.
         */
        $('form').submit(function() {

          /* Clear only the fields inside this particular form. */
          $(this).find('.' + o.className).val('');
        });

        /* Add the class name to the array. */
        $.fn.example.boundClassNames[o.className] = true;
      }

      /* Several browsers will cache form values even if they are cleared
       * on unload, so this will clear any value that matches the example
       * text and hasn't been specified in the value attribute.
       *
       * If a callback is used, it is not possible or safe to predict
       * what the example text is going to be so all non-default values
       * are cleared. This means that caching is effectively disabled for
       * that field.
       *
       * Many thanks to Klaus Hartl for helping resolve this issue.
       */
      if (!$this.attr('defaultValue') && (isCallback || $this.val() == o.example))
        $this.val('');

      /* Initially place the example text in the field if it is empty
       * and doesn't have focus yet.
       */
      if ($this.val() == '' && this != document.activeElement) {
        $this.addClass(o.className);

        /* The text argument can now be a function; if this is the case,
         * call it, passing the current element as `this`.
         */
        $this.val(isCallback ? o.example.call(this) : o.example);
      }

      /* Make the example text disappear when someone focuses.
       *
       * To determine whether the value of the field is an example or not,
       * check for the example class name only; comparing the actual value
       * seems wasteful and can stop people from using example values as real
       * input.
       */
      $this.focus(function() {

        /* jQuery 1.1 has no hasClass(), so is() must be used instead. */
        if ($(this).is('.' + o.className)) {
          $(this).val('');
          $(this).removeClass(o.className);
        }
      });

      /* Detect a change event to the field and remove the example class. */
      $this.change(function() {
        if ($(this).is('.' + o.className)) {
          $(this).removeClass(o.className);
        }
      });

      /* Make the example text reappear if the input is blank on blurring. */
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(o.className);

          /* Re-evaluate the callback function every time the user
           * blurs the field without entering anything. While this
           * is not as efficient as caching the value, it allows for
           * more dynamic applications of the plugin.
           */
          $(this).val(isCallback ? o.example.call(this) : o.example);
        }
      });
    });
  };

  /* Users can override the defaults for the plugin like so:
   *
   *   $.fn.example.defaults.className = 'not_example';
   */
  $.fn.example.defaults = {
    className: 'example'
  };

  /* All the class names used are stored as keys in the following array. */
  $.fn.example.boundClassNames = [];

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

  Drupal.behaviors.featuredContent = {
    attach: function (context) {
      // show manual or filter fieldset depending on type selection
      var type = $('#edit-featured-content-block-type');
      if (type) {
        showHideFeaturedBlockSettings(type);
      }
      $('#edit-featured-content-block-type').bind('change', {}, onchangeFeaturedBlockSettings);
    
      // show style select list depending on display selection
      var display = $('#edit-featured-content-block-display');
      if (display) {
        showHideFeaturedBlockStyleSettings(display);
      }
      $('#edit-featured-content-block-display').bind('change', {}, onchangeFeaturedBlockStyleSettings);
    
      // show read more fields depending on more selection
      var more = $('#edit-featured-content-block-more-display');
      if (more) {
        showHideFeaturedBlockMoreSettings(more);
      }
      $('#edit-featured-content-block-more-display').bind('change', {}, onchangeFeaturedBlockMoreSettings);
    
      // show rss fields depending on rss selection
      var rss = $('#edit-featured-content-block-rss-display');
      if (rss) {
        showHideFeaturedBlockRSSSettings(rss);
      }
      $('#edit-featured-content-block-rss-display').bind('change', {}, onchangeFeaturedBlockRSSSettings);
    }
  };

  function onchangeFeaturedBlockSettings(event) {
    showHideFeaturedBlockSettings($(this));
  }

  function showHideFeaturedBlockSettings(select) {
    var choice = select.attr('value');
    if (choice == 'manual') {
      $('fieldset.featured-content-block-filter').hide();
      $('fieldset.featured-content-block-cck').hide();
      $('fieldset.featured-content-block-manual').show();
    }
    else if (choice == 'filter') {
      $('fieldset.featured-content-block-manual').hide();
      $('fieldset.featured-content-block-cck').hide();
      $('fieldset.featured-content-block-filter').show();
    }
    else if (choice == 'cck') {
      $('fieldset.featured-content-block-manual').hide();
      $('fieldset.featured-content-block-filter').hide();
      $('fieldset.featured-content-block-cck').show();
    }
  }

  function onchangeFeaturedBlockStyleSettings(event) {
    showHideFeaturedBlockStyleSettings($(this));
  }

  function showHideFeaturedBlockStyleSettings(select) {
    var choice = select.attr('value');
    if (choice == 'links') {
      $('.form-item-featured-content-block-style').show();
    }
    else {
      $('.form-item-featured-content-block-style').hide();
    }
  }

  function onchangeFeaturedBlockMoreSettings(event) {
    showHideFeaturedBlockMoreSettings($(this));
  }

  function showHideFeaturedBlockMoreSettings(select) {
    var choice = select.attr('value');
    if (choice == 'custom') {
      $('fieldset#edit-more').show();
      $('.form-item-featured-content-block-more-text').show();
      $('.form-item-featured-content-block-more-url').show();
      $('.form-item-featured-content-block-more-num').hide();
      $('.form-item-featured-content-block-more-style').hide();
      $('.form-item-featured-content-block-more-title').hide();
      $('.form-item-featured-content-block-more-header').hide();
      $('.form-item-featured-content-block-more-footer').hide();
    }
    else if (choice == 'none') {
      $('fieldset#edit-more').hide();
    }
    else if (choice == 'links') {
      $('fieldset#edit-more').show();
      $('.form-item-featured-content-block-more-text').show();
      $('.form-item-featured-content-block-more-url').hide();
      $('.form-item-featured-content-block-more-num').show();
      $('.form-item-featured-content-block-more-style').show();
      $('.form-item-featured-content-block-more-title').show();
      $('.form-item-featured-content-block-more-header').show();
      $('.form-item-featured-content-block-more-footer').show();
    }
    else {
      $('fieldset#edit-more').show();
      $('.form-item-featured-content-block-more-text').show();
      $('.form-item-featured-content-block-more-url').hide();
      $('.form-item-featured-content-block-more-num').show();
      $('.form-item-featured-content-block-more-style').hide();
      $('.form-item-featured-content-block-more-title').show();
      $('.form-item-featured-content-block-more-header').show();
      $('.form-item-featured-content-block-more-footer').show();
    }
  }

  function onchangeFeaturedBlockRSSSettings(event) {
    showHideFeaturedBlockRSSSettings($(this));
  }

  function showHideFeaturedBlockRSSSettings(checkbox) {
    if (checkbox.attr('checked')) {
      $('fieldset#edit-rss').show();
    }
    else {
      $('fieldset#edit-rss').hide();
    }
  }

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

$(document).ready(function() {

  // Accepts a string; returns the string with regex metacharacters escaped. The returned string
  // can safely be used at any point within a regex to match the provided literal string. Escaped
  // characters are [ ] { } ( ) * + ? - . , \ ^ $ # and whitespace. The character | is excluded
  // in this function as it's used to separate the domains names.
  RegExp.escapeDomains = function(text) {
    return (text) ? text.replace(/[-[\]{}()*+?.,\\^$#\s]/g, "\\$&") : '';
  }

  // Attach onclick event to document only and catch clicks on all elements.
  $(document.body).click(function(event) {
    // Catch the closest surrounding link of a clicked element.
    $(event.target).closest("a,area").each(function() {

      var ga = Drupal.settings.googleanalytics;
      // Expression to check for absolute internal links.
      var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
      // Expression to check for special links like gotwo.module /go/* links.
      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
      // Expression to check for download links.
      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
      // Expression to check for the sites cross domains.
      var isCrossDomain = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/.*(" + RegExp.escapeDomains(ga.trackCrossDomains) + ")", "i");

      // Is the clicked URL internal?
      if (isInternal.test(this.href)) {
        // Is download tracking activated and the file extension configured for download tracking?
        if (ga.trackDownload && isDownload.test(this.href)) {
          // Download link clicked.
          var extension = isDownload.exec(this.href);
          _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
        }
        else if (isInternalSpecial.test(this.href)) {
          // Keep the internal URL for Google Analytics website overlay intact.
          _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
        }
      }
      else {
        if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) {
          // Mailto link clicked.
          _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
        }
        else if (ga.trackOutbound && this.href) {
          if (ga.trackDomainMode == 2 && isCrossDomain.test(this.href)) {
            // Top-level cross domain clicked. document.location is handled by _link internally.
            _gaq.push(["_link", this.href]);
          }
          else if (ga.trackOutboundAsPageview) {
            // Track all external links as page views after URL cleanup.
            // Currently required, if click should be tracked as goal.
            _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]);
          }
          else {
            // External link clicked.
            _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);
          }
        }
      }
    });
  });
});

})(jQuery);
;

