/*
	jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider
	Copyright (c) 2009 Niall Doherty
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

$(function(){
	// Remove the coda-slider-no-js class from the body
	$("body").removeClass("coda-slider-no-js");
	// Preloader
	$(".coda-slider").children('.panel').hide().end().prepend('<p class="loading">Loading...<br /><img src="images/ajax-loader.gif" alt="loading..." /></p>');
});

var sliderCount = 1;

$.fn.codaSlider = function(settings) {

	settings = $.extend({
		autoHeight: true,
		autoHeightEaseDuration: 1000,
		autoHeightEaseFunction: "easeInOutExpo",
		autoSlide: false,
		autoSlideInterval: 7000,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: true,
		dynamicArrowLeftText: "&#171; left",
		dynamicArrowRightText: "right &#187;",
		dynamicTabs: true,
		dynamicTabsAlign: "center",
		dynamicTabsPosition: "top",
		externalTriggerSelector: "a.xtrig",
		firstPanelToLoad: 1,
		panelTitleSelector: "h2.title",
		slideEaseDuration: 1000,
		slideEaseFunction: "easeInOutExpo"
	}, settings);
	
	return this.each(function(){
		
		// Uncomment the line below to test your preloader
		// alert("Testing preloader");
		
		var slider = $(this);
		
		// If we need arrows
		if (settings.dynamicArrows) {
			slider.parent().addClass("arrows");
			slider.before('<div class="coda-nav-left" id="coda-nav-left-' + sliderCount + '"><a href="#">' + settings.dynamicArrowLeftText + '</a></div>');
			slider.after('<div class="coda-nav-right" id="coda-nav-right-' + sliderCount + '"><a href="#">' + settings.dynamicArrowRightText + '</a></div>');
		};
		
		var panelWidth = slider.find(".panel").width();
		var panelCount = slider.find(".panel").size();
		var panelContainerWidth = panelWidth*panelCount;
		var navClicks = 0; // Used if autoSlideStopWhenClicked = true
		
		// Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
		$('.panel', slider).wrapAll('<div class="panel-container"></div>');
		// Specify the width of the container div (wide enough for all panels to be lined up end-to-end)
		$(".panel-container", slider).css({ width: panelContainerWidth });
		
		// Specify the current panel.
		// If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position...
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			var currentPanel = parseInt(location.hash.slice(1));
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// If that's not the case, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) { 
			var currentPanel = settings.firstPanelToLoad;
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// Otherwise, we'll just set the current panel to 1...
		} else { 
			var currentPanel = 1;
		};
			
		// Left arrow click
		$("#coda-nav-left-" + sliderCount + " a").click(function(){
			navClicks++;
			if (currentPanel == 1) {
				offset = - (panelWidth*(panelCount - 1));
				alterPanelHeight(panelCount - 1);
				currentPanel = panelCount;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current');
			} else {
				currentPanel -= 1;
				alterPanelHeight(currentPanel - 1);
				offset = - (panelWidth*(currentPanel - 1));
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});
			
		// Right arrow click
		$('#coda-nav-right-' + sliderCount + ' a').click(function(){
			navClicks++;
			if (currentPanel == panelCount) {
				offset = 0;
				currentPanel = 1;
				alterPanelHeight(0);
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current');
			} else {
				offset = - (panelWidth*currentPanel);
				alterPanelHeight(currentPanel);
				currentPanel += 1;
				slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current');
			};
			$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
			if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking)
			return false;
		});
		
		// If we need a dynamic menu
		if (settings.dynamicTabs) {
			var dynamicTabs = '<div class="coda-nav" id="coda-nav-' + sliderCount + '"><ul></ul></div>';
			switch (settings.dynamicTabsPosition) {
				case "bottom":
					slider.parent().append(dynamicTabs);
					break;
				default:
					slider.parent().prepend(dynamicTabs);
					break;
			};
			ul = $('#coda-nav-' + sliderCount + ' ul');
			// Create the nav items
			$('.panel', slider).each(function(n) {
				ul.append('<li class="tab' + (n+1) + '"><a href="#' + (n+1) + '">' + $(this).find(settings.panelTitleSelector).text() + '</a></li>');												
			});
			navContainerWidth = slider.width() + slider.siblings('.coda-nav-left').width() + slider.siblings('.coda-nav-right').width();
			ul.parent().css({ width: navContainerWidth });
			switch (settings.dynamicTabsAlign) {
				case "center":
					ul.css({ width: ($("li", ul).width() + 2) * panelCount });
					break;
				case "right":
					ul.css({ float: 'right' });
					break;
			};
		};
			
		// If we need a tabbed nav
		$('#coda-nav-' + sliderCount + ' a').each(function(z) {
			// What happens when a nav link is clicked
			$(this).bind("click", function() {
				navClicks++;
				$(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current');
				offset = - (panelWidth*z);
				alterPanelHeight(z);
				currentPanel = z + 1;
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
			});
		});
		
		// External triggers (anywhere on the page)
		$(settings.externalTriggerSelector).each(function() {
			// Make sure this only affects the targeted slider
			if (sliderCount == parseInt($(this).attr("rel").slice(12))) {
				$(this).bind("click", function() {
					navClicks++;
					targetPanel = parseInt($(this).attr("href").slice(1));
					offset = - (panelWidth*(targetPanel - 1));
					alterPanelHeight(targetPanel - 1);
					currentPanel = targetPanel;
					// Switch the current tab:
					slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (targetPanel - 1) + ') a').addClass('current');
					// Slide
					$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
					if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified
				});
			};
		});
			
		// Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking).
		if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (location.hash.slice(1) - 1) + ")").addClass("current");
		// If there's no cross-linking, check to see if we're supposed to load a panel other than Panel 1 initially...
		} else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) {
			$("#coda-nav-" + sliderCount + " a:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current");
		// Otherwise we must be loading Panel 1, so make the first tab the current one.
		} else {
			$("#coda-nav-" + sliderCount + " a:eq(0)").addClass("current");
		};
		
		// Set the height of the first panel
		if (settings.autoHeight) {
			panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height();
			slider.css({ height: panelHeight });
		};
		
		// Trigger autoSlide
		if (settings.autoSlide) {
			slider.ready(function() {
				setTimeout(autoSlide,settings.autoSlideInterval);
			});
		};
		
		function alterPanelHeight(x) {
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height()
				slider.animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);
			};
		};
		
		function autoSlide() {
			if (navClicks == 0 || !settings.autoSlideStopWhenClicked) {
				if (currentPanel == panelCount) {
					var offset = 0;
					currentPanel = 1;
				} else {
					var offset = - (panelWidth*currentPanel);
					currentPanel += 1;
				};
				alterPanelHeight(currentPanel - 1);
				// Switch the current tab:
				slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (currentPanel - 1) + ') a').addClass('current');
				// Slide:
				$('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction);
				setTimeout(autoSlide,settings.autoSlideInterval);
			};
		};
		
		// Kill the preloader
		$('.panel', slider).show().end().find("p.loading").remove();
		slider.removeClass("preload");
		
		sliderCount++;
		
	});
};
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */ 
(function($) {

function Excerpt(elem,options){this.$elem=$(elem);this.options=$.extend({end:' ',always_end:undefined,lines:1},options);this.original_text=this.$elem.text();if(typeof(this.options.end)!='string'){this.$end_node=$(this.options.end);this.end_string=this.$end_node.text()}else{this.end_string=this.options.end;this.$end_node=$(document.createTextNode(this.end_string))}if(this.options.always_end){if(typeof(this.options.always_end)!='string'){this.$always_end_node=$(this.options.always_end);this.always_end_string=this.$always_end_node.text()}else{this.always_end_string=this.options.always_end;this.$always_end_node=$(document.createTextNode(this.always_end_string))}}this._attach();this.refresh()}$.extend(Excerpt.prototype,{_attach:function(){},refresh:function(){if(!this.$elem[0].firstChild)return;var wh=this._calculate_desired_width_height();var w=wh[0];var h=wh[1];var s=this.original_text.replace(/\s+/,' ');var spaces=[];spaces.push(0);for(var i=1;i<s.length;i++){if(s.charAt(i)==' '){spaces.push(i)}}spaces.push(s.length);var lbound=0;var rbound=spaces.length-1;var cur=0;var cutoff=100;while(lbound<rbound&&cutoff){cur=Math.floor(lbound+(rbound-lbound)/2);if(cur==lbound)cur+=1;var sub=this._substring(s,spaces[cur]);if(this._is_string_small_enough(sub,w,h)){lbound=cur}else{rbound=cur-1}cutoff-=1}this.$elem[0].firstChild.nodeValue=this._substring(s,spaces[lbound],true);if(s.length!=spaces[lbound]){this.$elem.append(this.$end_node.clone())}if(this.$always_end_node){this.$elem.append(this.$always_end_node.clone())}},_substring:function(s,length,exclude_end_string){if(length==s.length)return s;var substr=s.substr(0,length);if(exclude_end_string){return substr}else{return substr+this.end_string+(this.always_end_string||'')}},_is_string_small_enough:function(s,w,h){var node=this.$elem[0];node.firstChild.nodeValue=s;return node.offsetHeight<=h&&node.offsetWidth<=w},_calculate_desired_width_height:function(){var node=this.$elem[0];var s='&nbsp;';for(var i=0;i<this.options.lines-1;i++){s+="<br />&nbsp;"}node.innerHTML=s;var w=node.offsetWidth;var h=node.offsetHeight;node.innerHTML='&nbsp;';return[w,h]}});$.fn.excerpt=function(options){return $(this).each(function(){new Excerpt(this,options)})}})(jQuery);

$(document).ready(function(){$("#twitter").getTwitter({userName:"rightrespect",numTweets:4,loaderText:"Loading tweets...",slideIn:true,slideDuration:750,showHeading:false,showProfileLink:false,showTimestamp:true})});$().ready(function(){$('#featured-images').codaSlider({autoHeight:false,crossLinking:false,dynamicArrows:false,dynamicTabsPosition:"bottom",dynamicTabsAlign:false,slideEaseDuration:600,slideEaseFunction:"easeOutExpo"});$(".itemtitle").each(function(){t=$(this).html();arr=t.split(" - ");fi=arr.join("</a></span><br /><span class='date'>");$(this).html(fi)})});$(function(){$('.featured-tease').hover(function(){$(this).children('a.xtrig').click()})});$(function(){$(".featured-tease:first").css({paddingRight:"10px"}).css({marginLeft:"0"}).css({borderLeft:"none"});$(".featured-tease p").excerpt({lines:5,end:' '});});

/*! 
 * A jQuery plugin by Brian Holt that will search the selected blocks for 
 * specially-defined footnote elements.	 If found, these elements will be 
 * moved to a footnotes section and links to and from the footnotes will 
 * be created.
 *
 * See http://www.planetholt.com/articles/jQuery-Footnotes	
 * for full documentation.
 *
 * By default, footnotes will be found in SPANs with the footnote class,
 * and in BLOCKQUOTEs with a TITLE attribute.
 *
 * Thanks to CSSNewbies.com for the general idea, which I have enhanced 
 * and implemented with as a jQuery plugin.
 * 
 * Copyright 2008-2009 Brian Holt.	
 * Licensed under the LGPL license. See 
 * http://www.gnu.org/licenses/lgpl-3.0-standalone.html
 * 
 * Version 1.2.2
 */
;(function ($) {
	$.fn.footnotes = function (options) {
		
		var opts = $.extend({}, $.fn.footnotes.defaults, options);
	
		return this.each(function (j) {
		
			logToConsole("INFO: Building footnotes for " + (j + 1) + "...", opts.debugMode);
			/**
			 * Add a fake class to the elements we want to select, so that
			 * the jQuery.each() function iterates over them in the 
			 * correct order.
			 */
			$(opts.footnotes, this).addClass(opts.autoFootnoteClass);
			
			
			var $contentPlaceholder = ("" === opts.contentBlock) ? $(this) : $(opts.contentBlock, this),
				newListElement = opts.orderedList ? "<ol/>" : "<ul/>";
			
			/**
			 * Iterate over the elements we selected earlier
			 */
			$("." + opts.autoFootnoteClass).each(function (i) {
	
			var foundFootnoteIdx = -1,
				refID = j + "-" + i,
				$this = $(this),
				$footnoteDestination, footnoteHTML, $foundFootnoteLI,
				$anchor, $li, $backRefSpan, $backRefs,
				letterCounter;

			// Make sure we have a place to put our footnotes
			if(opts.singleFootnoteDestination) {
				$footnoteDestination = $("#" + opts.destination);
				if(0 === $footnoteDestination.length) {
					logToConsole("INFO: No #autoFootnotes found; adding our own", opts.debugMode);
					$footnoteDestination = $(newListElement)
						.attr("id", opts.destination)
						.addClass("footnotesList")
						.appendTo($contentPlaceholder);
				}
			} else {
				$footnoteDestination = $("#" + opts.destination + j);
				if(0 === $footnoteDestination.length) {
					logToConsole("INFO: No #autoFootnotes" + j + " found; adding our own for " + (j+1), opts.debugMode);
					$footnoteDestination = $(newListElement)
						.attr("id", opts.destination + j)
						.addClass("footnotesList")
						.appendTo($contentPlaceholder);
				}
			}
		
			// First, remove the class that selected this
			// element so that we only do this once
			$this.removeClass(opts.autoFootnoteClass);
			
			footnoteHTML = opts.fnExtractFootnote(this);
			foundFootnoteIdx = -1;
			refID = j + "-" + i;
	
			// Check to see if we've already encountered this exact footnote				
			$footnoteDestination.find("li > .footnoteContent").each(function (k) {
				var $this = $(this);
				
				if($this.html() === footnoteHTML) {
					foundFootnoteIdx = k;
					$foundFootnoteLI = $($this.parents("li").get(0));
					return false;
				}
			});
			
			if(-1 === foundFootnoteIdx) {
			// First, add the link to the footnote
				// Add a new A tag and set its properties
				$anchor = $("<a/>")
					.attr("href", "#cite-text-" + refID)
					.attr("name", "cite-ref-" + refID)
					.attr("id", "cite-ref-" + refID)
					.attr("dir", "ltr")
					.attr("title", footnoteHTML)
					.text("[" + ($footnoteDestination.find("li").length + 1) + "]")
					.addClass("footnoteLink");
					
				// Add a new SUP tag and set its properties
				if($this.is(opts.prependTags)) {
					$("<sup/>")
						.prependTo(this)
						.append($anchor);
				} else {
					$("<sup/>")
						.appendTo(this)
						.append($anchor);
				}
		
			// Second, add the footnote and the link back to the text
				// Create the LI for the footnote
				$li = $("<li/>")
					.attr("id", "cite-text-" + refID);
				
				$backRefSpan = $("<span/>")
					.addClass("footnoteBackReferenceGroup")
					.appendTo($li);
					
				$("<span/>")
					.addClass("footnoteContent")
					.html(footnoteHTML)
					.appendTo($li);
					
				// Create the backreference A 
				$anchor = $("<a/>")
					.text("↩")
					.attr("href", "#cite-ref-" + refID)
					.addClass("footnoteBackref")
					.appendTo($backRefSpan);
				
				// Add the footnote LI to the OL
				$footnoteDestination.append($li);
			} else {
				// Reset the reference ID so we link to the correct places
				refID = j + "-" + foundFootnoteIdx;
				
				$backRefSpan = $($("li > .footnoteBackReferenceGroup", $footnoteDestination)
					.get(foundFootnoteIdx));
				$backRefs = $backRefSpan.find(".footnoteBackref");
				
				letterCounter = $backRefs.length;
				
				if(0 === $backRefs.length) {
					logToConsole("ERROR: $backRefs.length == 0, which should have prevented this code path", opts.debugMode);
				} else {
					if(1 === $backRefs.length) {
						// We need to insert a non-linked ^, and change the link text to "a"
						$("<sup/>")
							.text("^ ")
							.addClass("footnoteBackref")
							.prependTo($backRefSpan);
						$backRefs.html("<sup>a</sup>");
						
						++letterCounter;
					}
					
					// Insert the two links for this footnote
					
					// first, the link to the footnote
					$anchor = $("<a/>")
						.attr("href", "#" + $foundFootnoteLI.attr("id"))
						.attr("name", "cite-ref-" + refID + "-" + $backRefs.length)
						.attr("id", "cite-ref-" + refID + "-" + $backRefs.length)
						.attr("title", footnoteHTML)
						.text("[" + (foundFootnoteIdx + 1) + "]")
						.addClass("footnoteLink");
						
					// Add a new SUP tag and set its properties
					if($this.is(opts.prependTags)) {
						$("<sup/>")
							.prependTo(this)
							.append($anchor);
					} else {
						$("<sup/>")
							.appendTo(this)
							.append($anchor);
					}
					
					// The backreference
					$anchor = $("<a/>")
						.attr("href", "#cite-ref-" + refID + "-" + $backRefs.length)
						.addClass("footnoteBackref");
					
					if(letterCounter >= 26) {
						logToConsole("WARN: multiple letter functionality is probably broken when more than 26 footnotes exist", opts.debugMode);
					}
					$anchor.prepend(String.fromCharCode((letterCounter) + 96));
					
					$("<sup/>")
						.appendTo($backRefSpan)
						.append($anchor);					
					
				}
			}
			});	// end $("." + opts.autoFootnoteClass).each(function(i))
			
			logToConsole("INFO: Done building footnotes for " + (j+ 1), opts.debugMode);
			
		}); // return this.each()
	}; // jQuery.fn.footnotes
	
	// Publicly expose the version number
	$.fn.footnotes.version = function () { return "1.2.2"; };
	
	// Publicly expose defaults
	$.fn.footnotes.defaults = {
		/**
		 * Overriding the footnotes option allows users to select which 
		 * entities get turned into footnotes.	Note that the fnExtractFootnote 
		 * option should be probably be overridden as well.
		 */
		footnotes: "blockquote[title],span.footnote,blockquote[cite]",

		/**
		 * By default, the link to the footnote will be appended to the 
		 * end of an element selected by the <code/>footnotes</code/> 
		 * selector.  If some elements should have their footnote 
		 * links prepended, appropriate selectors should be added here.
		 * Note that elements selected here are a subset of those selected
		 * by <code/>footnotes</code/>.
		 *
		 * For example, if automatic quotation marks are added to P elements 
		 * within BLOCKQUOTEs, one might use the :last-child pseudo-selector 
		 * to trigger the addition of close quotes to the last paragraph.  
		 * However, if a SUP tag is appended to the BLOCKQUOTE, :last-child
		 * will no longer match the last P, and the quotes will not be added.
		 * Adding BLOCKQUOTE here will cause the SUP tag to be prepended, 
		 * avoiding this issue.
		 */
		prependTags: "blockquote",

		/**
		 * - When TRUE, all footnotes will be put into a single ordered list.  
		 * - When FALSE, each block on which the footnotes() plugin function 
		 *	 is applied will have its own footnote ordered list.
		 */
		singleFootnoteDestination: false,
		/**
		 * Specifies the ID (without the leading #) where footnotes will be placed.	 
		 * - If singleFootnoteDestination is TRUE, the ID is used with no suffix
		 * - If singleFootnoteDestination is FALSE, an index suffix is appended 
		 *	 to the ID
		 */
		destination: "autoFootnotes",
		
		/**
		 * Allows for the selection of a block within the outer block, to which the 
		 * ordered list where footnotes will be placed will be appended.
		 */
		contentBlock: ".content",
		
		/**
		 * CSS class name to be added to each of the elements matching the 
		 * footnotes selector option.  This allows us to ensure that the footnotes
		 * are added to the list in the correct order.	Set to something that 
		 * won't be used otherwise.
		 */
		autoFootnoteClass: "autoFootnote",
		
		/**
		 * Function to extract the footnote HTML from the elements that are 
		 * selected by the footnotes option.  
		 */
		fnExtractFootnote: fnDefaultExtractHTML,
		
		/**
		 * - When TRUE, footnotes will be added to an ordered list.
		 * - When FALSE, footnotes will be added to an unordered list.
		 */
		orderedList: true,
		
		/**
		 * - When TRUE, we will attempt to output console log messages.
		 * - When FALSE, console log messages will be suppressed.
		 */
		debugMode: true
	};// $.fn.footnotes.defaults
	
	// private console logger function
	function logToConsole(str, debugMode) {
		if(debugMode) {
			if(window.console && window.console.log) {
				window.console.log(str);
			}
		}
	}
	
	/**
	 * This default HTML extraction function handles SPAN.footnote and 
	 * blockquote[title] selections.  
	 * 
	 * The entire contents of any SPAN.footnotes are returned, unless 
	 * the text is surrounded by parentheses (with optional leading
	 * whitespace), in which case the parentheses are stripped.
	 *
	 * The entire contents of any BLOCKQUOTE's TITLE attribute are 
	 * directly returned, including any surrounding parantheses.
	 *
	 * The contents of the SPAN, or the BLOCKQUOTE's TITLE attribute 
	 * are cleared.
	 */
	function fnDefaultExtractHTML(obj) {
		var $obj = $(obj),
			footnoteHTML, regexRemoveParens, matches, cite, a;
		
		/*
		 * If this is a SPAN with the footnote class, move the footnote
		 * text to the footnotes area and replace it in the span 
		 * with a link to the footnote.
		 */
		if($obj.is("span.footnote")) {
			footnoteHTML = $(obj).html();
			
			/**
			 * In order to enhance progressively, we probably put the 
			 * footnote text in parentheses. We probably also don't want
			 * those to appear in the footnote, so remove them if they're 
			 * present.
			 * 
			 * This regex uses [\S\s]+ in place of .+ so it matches over
			 * multiple lines.	
			 */
			regexRemoveParens = /^(?:(?:&nbsp;)|\s)*\(([\S\s]+)\)(?:(?:&nbsp;)|\s)*$/;
			matches = footnoteHTML.match(regexRemoveParens);
			
			if(matches && 2 === matches.length) {
				footnoteHTML = matches[1];
			}
			
			// Clear the SPAN; the text will be placed below
			$obj.empty();
		}
		
		/*
		 * If it's a blockquote with a title, we just do a citation-style
		 * footnote, so we don't have to do as much work.
		 */
		else if($obj.is("blockquote[title]")) {
			cite = $obj.attr("cite");
			
			// Grab the contents to put in the footnote
			footnoteHTML = $obj.attr("title");
			
			if("" !== cite) {
				a = $("<a/>").attr("href", cite);
				
				/*
				 * If we just have text, use it as the displayed 
				 * text for the anchor
				 */
				if(0 === $(footnoteHTML).length) {
					footnoteHTML = a.text(footnoteHTML);
				}
				
				/*
				 * If we have more than just text, display the citation link,
				 * and then the contents of the blockquote's TITLE attribute.
				 */
				else {
					footnoteHTML = a
									.text(cite)
									.wrap("<span/>")
									.parent()
										.append(": " + footnoteHTML);
										
					// since we have more than just text, clear the title
					// so the user doesn't see the ugly title in a tooltip
					$obj.attr("title", "");
				}
			}
		} 
		
		/*
		 * If it's a blockquote with just a CITE, we create a link to the resource,
		 * using the URL as the text of the link.  If we've gotten this far, we 
		 * know that if it's a blockquote, it does not have a TITLE.
		 */
		else if($obj.is("blockquote[cite]")) {
			cite = $obj.attr("cite");
			footnoteHTML = $("<a/>").attr("href", cite).text(cite);
		}
		
		return footnoteHTML;
	}
})(jQuery);
