(function ($) {
  $.fn.fullscreenr = function(options) {
    if(options.height === undefined) {
      alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
    }
    if(options.width === undefined) {
      alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
    }
    if(options.wrapper === undefined) {
      alert('Please supply the wrapper selector, default .wrapper will now be used.');
    }
    if(options.background === undefined) {
      alert('Please supply the background selector, default .bg will now be used.');
    }

    var defaults = {
      width: 1280,
      height: 1024,
      wrapper: '.wrapper',
      background: '.bg',
      wOffset: 0,
      hOffset: 0
    },
        options = $.extend({}, defaults, options);

    // Eliminates scrollbars caused by the background image.
    $(options.wrapper).css('overflow', 'hidden');

    $(document).ready(function() {
      $(options.background).fullscreenrResizer(options);
    });
    $(window).bind("resize", function() {
      $(options.background).fullscreenrResizer(options);
    });

    return this;
  };

  $.fn.fullscreenrResizer = function(options) {
    // Set the size of the background.
    var elem = $(this),
        wrap = $(options.wrapper),
        w = $(window),
        ratio = options.height / options.width;

    // Set the wrapper height to the browser window height.
    var height = w.height();
    wrap.height(height - options.hOffset);

    // Set the wrapper width to the browser window width.
    var width = w.width();
    wrap.width(width - options.wOffset);

    // Scale the image.
    if ((height / width) > ratio) {
      elem.height(height).width(height / ratio);
    }
    else {
      elem.width(width).height(width * ratio);
    }

    // Center the image
    elem.css('left', (width - elem.width()) / 2).css('top', (height - elem.height()) / 2);

    return this;
  };
})(jQuery);
;
(function($) {
  /**
   * Implements the jQuery fullscreenr plugin.
   */
  Drupal.behaviors.theNewGroupFullscreenr = {
    attach: function (context, settings) {
      // Calculate the hOffset.
      var hOffset = $('#toolbar').height() + $('#zone-administration-wrapper').height();

      // Specify the fullScreenr options.
      var options = {
        width: 1700,
        height: 900,
        wrapper: '.view-conversation-statements .views-slideshow-cycle-main-frame-row-item',
        background: '.view-conversation-statements .views-field-field-conv-statement-image img',
        hOffset: hOffset
      };

      // Set the top offset of the content region on the front page to match that
      // of fullscreenr.
      $('.front .region-content').offset({ top: hOffset, left: 0 });

      // Call the jQuery fullscreenr pulgin.
      $.fn.fullscreenr(options);
    }
  }
})(jQuery);
;
// bigTarget.js - A jQuery Plugin
// Version 1.0.1
// Written by Leevi Graham - Technical Director - Newism Web Design & Development
// http://newism.com.au
// Notes: Tooltip code from fitted.js - http://www.trovster.com/lab/plugins/fitted/

// create closure
(function($) {
	// plugin definition
	$.fn.bigTarget = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.bigTarget.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			// set the anchor attributes
			var $a = $(this);
			var href = $a.attr('href');
			var title = $a.attr('title');
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $a.data()) : opts;
			// update element styles
			$a.parents(o.clickZone)
				.hover(function() {
					$h = $(this);
					$h.addClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.attr('title',title);
					}
				}, function() {
					
					$h.removeClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.removeAttr('title');
					}
				})
				// click
				.click(function() {
					if(getSelectedText() == "")
					{
						if($a.is('[rel*=external]')){
							window.open(href);
							return false;
						}
						else {
							//$a.click(); $a.trigger('click');
							window.location = href;
						}
					}
				});
		});
	};
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log)
		window.console.log('bigTarget selection count: ' + $obj.size());
	};
	// get selected text
	function getSelectedText(){
		if(window.getSelection){
			return window.getSelection().toString();
		}
		else if(document.getSelection){
			return document.getSelection();
		}
		else if(document.selection){
			return document.selection.createRange().text;
		}
	};
	// plugin defaults
	$.fn.bigTarget.defaults = {
		hoverClass	: 'hover',
		clickZone	: 'li:eq(0)',
		title		: true
	};
// end of closure
})(jQuery);;
(function($) {
  /**
   * Implements Conversation Tiles found on the home page.
   */
  Drupal.behaviors.theNewGroupConversationTiles = {
    attach: function (context, settings) {
      // Scrollpane parts.
      var scrollPane = $('.view-conversation-tiles'),
          scrollContent = $('.view-conversation-tiles .view-content');

      // Build slider.
      var scrollbar = $('.scroll-bar').slider({
        slide: function(event, ui) {
          if (scrollContent.width() > scrollPane.width()) {
            scrollContent.css('margin-left', Math.round(
              ui.value / 100 * (scrollPane.width() - scrollContent.width())
            ) + 'px');
          }
          else {
            scrollContent.css('margin-left', 0);
          }
        }
      });

      // Change overflow to hidden now that slider handles the scrolling
      scrollPane.css('overflow', 'hidden');

      // Calculate the width of scrollContent:
      // children().length: number of children
      // 240: .container_24 .grid_6 width + left/right margin
      // 10: .container_24 .alpha + .container_24 .omega margins
      scrollContent.width((scrollContent.children().length * 240) - 10);

      // Add a class to each filter option.
      $('#views-exposed-form-conversation-tiles-default input').each(function() {
        $(this).parent('.form-item-pillar').addClass(this.id);
      });

      // Reset slider value based on scroll content position.
      function resetValue() {
        var remainder = scrollPane.width() - scrollContent.width();
        var leftVal = scrollContent.css('margin-left') === 'auto' ? 0 :
          parseInt(scrollContent.css('margin-left'));
        var percentage = Math.round(leftVal / remainder * 100);
        scrollbar.slider('value', percentage);
      }

      // If the slider is 100% and window gets larger, reveal content.
      function reflowContent() {
        var showing = scrollContent.width() + parseInt(scrollContent.css('margin-left'), 10);
        var gap = scrollPane.width() - showing;
        if (gap > 0) {
          scrollContent.css('margin-left', parseInt(scrollContent.css('margin-left'), 10) + gap);
        }
      }

      // Change handle position on window resize.
      $( window ).resize(function() {
        resetValue();
        reflowContent();
      });

      // Animate rollover effect.
      $(function() {
        $('.views-row .group-default').mouseenter(function() {
          $(this).next().animate({
            top: 0
          }, {
            queue: false,
            duration: 500
          });

          // Track when a tile is hovered over.
          _gaq.push(['_trackEvent', 'Tile View', 'Mouseover', $(this).closest('.views-row article').attr('id'), '']);
        });
        $('.views-row').mouseleave(function() {
          $('.group-hover', this).animate({
            top: 220
          }, {
            queue: false,
            duration: 500
          });
        });
      });

      // Track when the slider is engaged.
      $('.ui-slider-handle').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Slide', 'Scrollbar', '']);
      });

      // Track when filters are used.
      $('.edit-pillar-all label').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Click', 'Reset Colors', '']);
      });
      $('.edit-pillar-1 label').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Click', 'Magenta Button', '']);
      });
      $('.edit-pillar-2 label').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Click', 'Blue Button', '']);
      });
      $('.edit-pillar-3 label').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Click', 'Green Button', '']);
      });
      $('.edit-pillar-4 label').click(function() {
        _gaq.push(['_trackEvent', 'Homepage Actions', 'Click', 'Purple Button', '']);
      });
    }
  }
})(jQuery);
;

