	
	/*! Copyright (c) 2008 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
	 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
	 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
	 
	 ... this attribution is for the OS scrollbar function only, of course.
	 */
	
	/**
	 * Gets the width of the OS scrollbar
	 */
	( function( $ ) {
		
		var scrollbarWidth = 0;
		
		$.getScrollbarWidth = function() {
			
			if ( !scrollbarWidth ) {
				
				if ( $.browser.msie ) {
					
					var $textarea1 = $( '<textarea cols="10" rows="2"></textarea>' )
							.css( { position: 'absolute', top: -1000, left: -1000 } ).appendTo( 'body' ),
						$textarea2 = $( '<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>' )
							.css( { position: 'absolute', top: -1000, left: -1000 } ).appendTo( 'body' );
					
					scrollbarWidth = $textarea1.width() - $textarea2.width();
					$textarea1.add( $textarea2 ).remove();
					
				} else {
					
					var $div = $( '<div />' )
						.css( { width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: -1000 } )
						.prependTo( 'body' ).append( '<div />' ).find( 'div' )
							.css( { width: '100%', height: 200 } );
					
					scrollbarWidth = 100 - $div.width();
					$div.parent().remove();
					
				}
			}
			
			return scrollbarWidth;
		
		};
		
	} )( jQuery );
	
	//----------------------------------------------------------------------
	
    /*
     Will add a 'new window' icon behind each <a rel="external" ...> link. Clicking the icon will open the link in a new
     window, like target="_blank" used to do.
     
     This behaviour can optionally be extended to the link itself (setting the mainLinkOpensNewWindow parameter to true).
     The markup option <a rel="external noicon" ...> might then be used to suppresses the icon on a case-by-case basis.
     
     Will add info text and a 'new window' icon if the link is marked as <a rel="external verbose" ..>. The text displayed
     is customizable and must be passed as parameter. 
     
     Can also be modified to target other keywords in the 'rel' attribute, e.g. <a rel="pdf" ..>, and attach a 'new window'
     icon to these links instead.
     
     Requires jQuery, tested with version 1.3.2. Call after document-ready.
     
     Synopsis: addTargetBlank ( iconUrl, [imgWidthPx], [imgHeightPx], [toolTip = ""], [messageVerbose = ""],
								[iconHoverUrl], [attachTo = "external"], [ useXhtml= true] )
     
     Parameters:
     - iconUrl:            		the URL of the image containing the 'new window' icon. Required.
     - imgWidthPx, imgHeightPx: the size in pixels of the 'new window' icon. Required.
     - toolTip:                 the text which will appear in the tooltip. Optional. By default, no tooltip is shown.
	 - messageVerbose			text used for a visible hint if rel="external verbose" is set to a link. Optional. If 
								unspecified, the 'verbose' assignment is ignored and treated as a simple rel="external".
	 - iconHoverUrl:				the URL of an alternate image for 'hover' and 'active' states. If provided, this image will
								be shown when the user hovers the mouse over the 'new window' icon or clicks on it. Optional.
     - attachTo:	            the keyword in the rel-attribute which should trigger the attachment of a 'new window' icon.
								Optional, defaults to 'external' (targeting rel='external').
     - mainLinkOpensNewWindow:  whether a click on the original link opens in a new window (true by default). If set to false,
								the original link will not open a new window or tab, and and the user must click on the
								'new window' icon to achieve this.
     
     Usage examples:
     
     ( 1 ) Default values; no tooltip will appear.
     
     $( document ).ready( function() {
		
         addTargetBlank( '/pics/open_in_new_window_grey.png', 11, 9 );
        
	 } );
     
     
     ( 2 ) Providing the image size, a tooltip text ("Click to open in a new window"), and a message to be added to links marked
           as 'verbose' ("(open in a new window)").
     
     $( document ).ready( function() {
		
         addTargetBlank( '/pics/new_window.png', 11, 9, "Click to open in a new window", "(open in a new window)" );
        
	 } );
     
     
     ( 3 ) Attaching the 'new window' icon to rel='pdf' links and using a different image for the hover state (rollover effect).
     
     $( document ).ready( function() {
		
         addTargetBlank( '/pics/new_window.png', 11, 9, "Open PDF in a new window", "", '/pics/new_window_hover.png', 'pdf' );
        
	 } );
     
    */
    function addTargetBlank ( iconUrl, imgWidthPx, imgHeightPx, toolTip, messageVerbose, iconHoverUrl, attachTo, mainLinkOpensNewWindow ) {
        
		toolTip = toolTip || '';
		messageVerbose = messageVerbose || '';
		attachTo = attachTo || 'external';
		mainLinkOpensNewWindow = ( typeof( mainLinkOpensNewWindow ) == 'undefined' ? true : mainLinkOpensNewWindow );
		
		// Preloading hover image if provided
		if ( iconHoverUrl ) var hoverImg = $('<img />').attr( 'src', iconHoverUrl );
		
		// If the icon will be used as a background image, define its properties
		if ( mainLinkOpensNewWindow || messageVerbose ) {
			
			var defineBackgroundImg = {
				'background-image': 'url(\'' + iconUrl + '\')',
				'background-position': 'right center',
				'background-repeat': 'no-repeat'
			};
			
		}
		
		if ( ! mainLinkOpensNewWindow ) {
			
			// Inserting the icon for rel='external'
			var insertAfter = $( 'a[rel*="' + attachTo + '" ]' );
			if ( messageVerbose ) insertAfter = insertAfter.not( '[rel*="verbose"]' );
			
			var img = $( '<img />')
						.addClass( 'targetBlank' )
						.attr( { 'src': iconUrl, 'title': toolTip, 'alt': toolTip } )
						.css( { 'border': 0, 'padding-left': '0.2em' } );
			
			if ( imgWidthPx && imgHeightPx ) img.width( imgWidthPx ).height( imgHeightPx );
			
			var icon = $( '<a></a>' )
				.css( 'text-decoration', 'none' )
				.append( img )
				.insertAfter( insertAfter )
				.attr( 'href', function () { return this.previousSibling.href; } )
				.click( function ( event ) { window.open( this.href ); return false; } )
				.after( ' ' );
			
			// Setting rollover image if provided.
			if ( iconHoverUrl ) {
				
				icon.hover( function () {
								$( this ).children( 'img' ).attr( 'src', iconHoverUrl );
							}, function () {
								$( this ).children( 'img' ).attr( 'src', iconUrl );
							} );
				
			}
			
			// Inserting the verbose message as an independent element
			if ( messageVerbose ) {
				
				$( '<a>' + messageVerbose + ' </a>' )
					.insertAfter( 'a[rel*="' + attachTo + '"][rel*="verbose"]' )
					.attr( 'href', function () { return this.previousSibling.href; } )
					.click( function ( event ) { window.open( this.href ); return false; } )
					.css( defineBackgroundImg )
					.hover( function () {
							$( this ).css( 'background-image', 'url(\'' + iconHoverUrl + '\')' )
						},  function () {
							$( this ).css( 'background-image', 'url(\'' + iconUrl + '\')' )
						} )
					.before( ' ' );
					// NB .click: return false cancels the href link, so setting it to its true target, just one line
					// before, may seem nonsensical. That is, until you have a user right-click and try to copy the link.
				
			}
			
		} else {
			
			// Inline behaviour is chosen:
			// - adding target=_blank behaviour to the main link
			// - adding the icon as a background image
			// - adding the verbose message inline to the link.
			
			var insertInto = $( 'a[rel*="' + attachTo + '"]' );
			
			insertInto
				.click( function ( event ) { window.open( this.href ); return false; } )
				.filter( ':not([rel*="noicon"])' )
				.css( defineBackgroundImg )
				.css( 'padding-right', function () {
						
						return parseFloat( $( this ).css( 'font-size' ) ) * 0.3 + imgWidthPx;
						
					} )
				.hover( function () {
						$( this ).css( 'background-image', 'url(\'' + iconHoverUrl + '\')' )
					},  function () {
						$( this ).css( 'background-image', 'url(\'' + iconUrl + '\')' )
					} );
				
			if ( messageVerbose ) {
				
				insertInto
					.filter( '[rel*="verbose"]' )
					.append( ' ' + messageVerbose );
					
			}
			
			if ( toolTip ) {
				
				insertInto
					.attr( 'title', function () {
							return ( this.title ? this.title + ' - ' + toolTip : toolTip );
						} )
					.attr( 'alt', function () {
							// NB: Didn't use 'this.alt' as it was buggy - it didn't return anything but 'undefined', no matter what.
							return ( $(this).attr('alt') ? $(this).attr('alt') + ' - ' + toolTip : toolTip );
						} );
				
			}
			
			
		}
		
    }
	
	/*
	 
	 future refactoring along these lines:
	 
	function TargetBlank () {
		
		var links = $( 'a[rel*="external" ]' );
		
	}
	
	TargetBlank.prototype = {
		
		setIcon: function ( iconUrl, iconWidth, iconHeight ) {
			
			
			return this;
			
		},
		
		setRolloverIconSrc: function ( iconHoverUrl ) {
			
			
			return this;
			
		},
		
		setTooltip: function ( tooltipText ) {
			
			
			return this;
			
		},
		
		setVerboseMessage: function ( messageText ) {
			
			
			return this;
			
		},
		
		setIconSize: function ( width, height ) {
			
			
			return this;
			
		},
		
		attachTo: function ( valuesRelAttribute ) {
			
			
			return this;
			
		},
		
		setTargetBlankForIconOnly: function ( iconOnly ) {
			
			
			return this;
			
		}
		
	}
	*/
	
	
	/*
	 fontSmoothingAssumedOff:
	 
	 Returns true if LCD-type font smoothing (ClearType) is positively disabled, or at least should be by system default.
	 
	 In all IEs and in Opera, the true state of font smoothing will be detected. IE7 and IE8 even have control over it with a
	 font-smoothing setting of their own, independent of the OS-wide setting. In FF and Webkit browsers, however, the OS setting
	 for font smoothing is applied - but unfortunately its state can't be queried from the browser.
	 
	 In these instances, we rather make an informed guess: If ClearType is turned off by default - as is the case for Windows XP -,
	 it most likely still is. In newer Windows versions or on a Mac, we can safely assume that it is turned on. *nix systems will
	 also report 'on'.
	*/
	function fontSmoothingAssumedOff () {
		
		if ( typeof( screen.fontSmoothingEnabled ) != 'undefined' ) {
			
			// This works for IE and Opera
			return ( ! screen.fontSmoothingEnabled );
			
		} else if ( typeof( navigator.oscpu ) != 'undefined' ) {
			
			// This works for FF and Webkit browsers
			return ( navigator.oscpu.indexOf( 'Windows NT 5' ) != -1 ); // tests for Windows NT 5.0 (Windows 2000), 5.1 (XP 32-bit), 5.2 (XP 64-bit)
			
		} else if ( typeof( navigator.userAgent ) != 'undefined' ) {
			
			// Fallback for any unusual browser/OS combination.
			return ( navigator.userAgent.indexOf( 'Windows NT 5' ) != -1 )
			
		} else {
			
			// Assume font smoothing 'on' for any truly exceptional case. It is very unlikely that we ever end up in this branch, though.
			return false;
			
		}
		
	}
	
	
	/*
	 Printing a page:
	 - choose the 'single page' version if one exists
	 - display the printable version in an object tag;
	 - disable the outer scrollbar (that of the main window) in IE
	*/
	function preparePrinting () {
		
		var printButtons = $( '.baseTools li.print a' );
		if ( printButtons.length ) {
			
			// Set up the print button JS to load the printable version into an <object>.
			
			// Read the regular link to the print version. The URL without params will be stored in printable[0], the query
			// string in printable[1].
			var printable = printButtons.eq(0).attr('href').split( '?' );
			var currentPageNo = 1;
			if ( printable.length > 1 ) {
				
				var pageNoParam = printable[1].match( /pageno=(\d+)/ );
				if ( pageNoParam ) currentPageNo = pageNoParam[1];
				
			}
			
			var imgButtonUrl = '/pics/icons/close_overlay.png';
			var imgButtonHoverUrl = '/pics/icons/close_overlay_hover.png';
			var imgOverlayShadowUrl = '/pics/tapestry/overlay_shadow.png';
			
			var previewObj;
			
			printButtons.click( function ( event ) {
				
				event.preventDefault();
				
				if ( ! previewObj ) previewObj = $(
													'<div id="overlayShadow">' +
													'<img src="' + imgOverlayShadowUrl + '" alt="shadow" />' +
													'</div>' + 
													'<div id="printPreview">' +
													'<div id="printPreviewClose">' +
													'<img src="' + imgButtonUrl + '" alt="Schlie&#xdf;en" />' +
													'</div>' +
													'<div class="padIt">' +
													'<object name="printContent" id="printContent" data="'
													  + printable[0] + '?print=1&amp;inline=1&amp;pageno=' + currentPageNo
													  + '" type="text/html"></object>' +
													'</div>' +
													'</div>' 
												   );
				$( 'body' ).prepend( previewObj );
				
				var obj = $( '#printContent' ).get(0);
				obj.focus();
				
				// Making the content of the object print from the outside would be cool, and works in FF and Safari, but the call
				// screws up in Chrome (prints the outer document with the print preview on top) and fails completely in IE:
				//
				// window.frames[0].print();
				//
				// An alternative access method for IE does not offer a .print() method, so no luck:
				//
				// setTimeout( function () { document.getElementsByTagName ('OBJECT')[0].body.< ... children of 'inner' body ... > ... ; }, 0 );
				
				
				// Prevent scrolling in the background, ie the main page. The doubled scrollbars would be irritating. Plus, once a user
				// has scrolled to the bottom of the printable page in the object tag, the main page would begin scrolling in IE.
				$( 'body' ).css( 'overflow', 'hidden' );
				$( 'html' ).css( 'overflow', 'hidden' );		/* both (!) needed for IE7 */
				
				
				// Close button rollover image
				$( '#printPreviewClose' ).hover( function () { $( this ).children( 'img' ).attr( 'src', imgButtonHoverUrl ); }, function () { $( this ).children( 'img' ).attr( 'src', imgButtonUrl ); } );
				
				// Enable the close button
				$( '#printPreviewClose' ).click( function () {
					
					// Re-Enable the scrollbar
					$( 'body' ).css( 'overflow', '' );
					$( 'html' ).css( 'overflow', '' );
					
					// Unload overlay
					previewObj.remove();
					
				});
				
			});
			
			
			
			// Finally, preload the close button (standard and rollover) and the overlay shadow.
			var closeButton = $('<img />').attr( 'src', imgButtonUrl );
			var closeButtonHover = $('<img />').attr( 'src', imgButtonHoverUrl );
			var shadow = $('<img />').attr( 'src', imgOverlayShadowUrl );
			
		}
		
	}
    
	
	/*
	  Print preview: Disable all links, except for those in the control bar at the top.
	*/
	function previewDisableLinks () {
		
		$( 'a:not(#printTopper a)' ).css( 'cursor', 'text' ).click( function ( event ) {
			
			event.preventDefault();
			
		});
		
	}
	
	
	/*
	 Print preview: Adjust the height of the #center div to match the canvas.
	 
	 NB: In the print preview, the scrollbar is attached to the center div. The height must thus be adjusted to the window, minus
	 the space taken up by the control bar at the top. The height cannot be set in the CSS as the window (or <object>) is scaled in
	 percent, while the control bar height is set in pixels.
	 
	 Setting properties of the inner .padIt div - the normal approach - didn't solve the problem. That caused problems with the scroll
	 bar. Hence the JS.
	*/
	function previewSetHeight () {
		
		// The height of the control bar (#printTopper) is already dealt width as a #center margin-top in the CSS.
		// So we just calculate the vertical margins and padding of #center, to be deducted from the body height.
		var fixed = $( '#center' ).outerHeight( true ) - $( '#center' ).height();
		$( '#center' ).height( $( 'body' ).height() - fixed );
		
		$( window ).resize( function () {
			
			$( '#center' ).height( $( 'body' ).height() - fixed );
			
		});
		
	}
	
	/*
	 Preloads an image.
	*/
	function preloadImage ( url )  {
		
		var preloaded = $('<img />').attr( 'src', url );
		
	}
	
	/*
	 Adds the class "hyphenate" to the elements specified in the selector and runs the hyphenation function.
	 Important: The Hyphenator object must be available when the function is invoked.
	 
	 Optionally, the selected paragraphs can be justified by setting the justify parameter to true. Default is
	 false.
	 
	 NB:
	 - The hyphenation function is always run on the whole document, so avoid multiple invocations of
	   addHyphenation.
	 - Rendering may appear marginally smoother if justification is set by the initial CSS rather than this function.
	   Then again, if text should only be justified in tandem with hyphenation, the principle of progressive enhancement
	   suggests that it should be done here. Your pick - it's a trade-off.
	 
	*/
	function addHyphenation ( selector, justify ) {
		
		try {
			   
			if ( Hyphenator ) {
				
				Hyphenator.config( {
					remoteloading: false
				} );
				
				var selection = $( selector );
				
				if ( justify ) selection.css( 'text-align', 'justify' );
				
				selection.addClass( 'hyphenate' );
				Hyphenator.run();
				
			}
			
		} catch(e) {}
		
	}
	
	///**
	// * Previous function for adding a Facebook Like button. Had to be called after document-ready. A little slow, especially
	// * on first run with an unprimed cache, because the script file was loaded late. 
	// */
	//function addFacebookLikeButton ( targetSelector, pageUrl, language ) {
	//	
	//	/*$( targetSelector ).append( '<div id="fb-root"></div>' +
	//							    '<fb:like href="' + pageUrl + '" layout="button_count" show_faces="false" font="verdana"></fb:like>'
	//							  );*/
	//	
	//	// The following DID work in IE (presumably because of the nonstandard fb:like tag):
	//	$( '<fb:like></fb:like>').attr( {
	//									  'href': pageUrl,
	//									  'layout': 'button_count',
	//									  'show_faces': 'false',
	//									  'font': 'verdana'
	//							} )
	//							 .appendTo( targetSelector )
	//							 .before( '<div id="fb-root"></div>' );
	//	
	//	window.fbAsyncInit = function() {
	//		
	//		FB.init({
	//			channelUrl 	: 'http://' + window.location.hostname + '/helpers/facebook-sdk-' + language + '.html',
	//			status 		: false, 	// check login status
	//			cookie 		: false, 	// enable cookies to allow the server to access the session
	//			xfbml  		: true  	// parse XFBML
	//		});
	//		
	//		FB.XFBML.parse();
	//		
	//	};
	//	
	//	$( '#fb-root' ).append( '<script src="http://connect.facebook.net/'
	//						   + ( language == 'de' ? 'de_DE' : 'en_US' )
	//						   + '/all.js"></script>'
	//						  );
	//	
	//}
	
	///**
	// * Previous function for adding a Twitter button. Had to be called after document-ready. A little slow, especially
	// * on first run with an unprimed cache, because the script file was loaded late. 
	// */
	//function addTwitterButton ( targetSelector, pageUrl, language ) {
	//	
	//	$( '<a />').attr( {
	//						'href': 'http://twitter.com/share',
	//						'class': 'twitter-share-button',
	//						'data-url': pageUrl,
	//						'data-count': 'none',
	//						'data-lang': language
	//					  } )
	//					 .text( 'Tweet' )
	//					 .appendTo( targetSelector )
	//					 .append( '<script src="http://platform.twitter.com/widgets.js"></script>' );
	//	
	//}
	
	/**
	 * Loads a script ansynchronously (non-blocking).
	 *
	 * Returns the script tag, as a jQuery object. Does not insert the script into the DOM. 
	 * 
	 * @param   {string} src 		the URL of the script
	 * @returns {jQuery} 			the script tag (as a jQuery object)
	 */
	function loadScriptAsync ( src ) {
		
		return $( '<script />' ).attr( 'src', src );
		
	}
	
	/**
	 * Adds a Twitter button.
	 * 
	 * DO NOT CALL WITHIN $( document ).ready( function() {...} ), but immediately. That's the whole point of
	 * speeding things up. Takes care of the ready event internally.
	 * 
	 */
	function addTwitterButton ( targetSelector, pageUrl, language ) {
		
		var script = loadScriptAsync( "http://platform.twitter.com/widgets.js" );
		
		$( document ).ready( function( script, targetSelector, pageUrl, language ) {
			
			return function () {
				
				$( '<a />').attr( {
									'href': 'http://twitter.com/share',
									'class': 'twitter-share-button',
									'data-url': pageUrl,
									'data-count': 'none',
									'data-lang': language
								  } )
						   .appendTo( targetSelector )
						   .append( script );
				
			}
			
		}( script, targetSelector, pageUrl, language ) );
		
	}
	
	/**
	 * Adds a Facebook 'Like' button.
	 * 
	 * DO NOT CALL WITHIN $( document ).ready( function() {...} ), but immediately. That's the whole point of
	 * speeding things up. Takes care of the ready event internally.
	 * 
	 */
	function addFacebookLikeButton ( targetSelector, pageUrl, language ) {
		
		// Load the script file - early, but asynchronuously. Will be added to the DOM later on.
		var script = $( '<script />' );
		script.async = true;
		script.attr( 'src', 'http://connect.facebook.net/'
							   + ( language == 'de' ? 'de_DE' : 'en_US' )
							   + '/all.js'
							  );
		
		
		window.fbAsyncInit = function() {
			
			FB.init({
				channelUrl 	: 'http://' + window.location.hostname + '/helpers/facebook-sdk-' + language + '.html',
				status 		: false, 	// check login status
				cookie 		: false, 	// enable cookies to allow the server to access the session
				xfbml  		: true  	// parse XFBML
			});
			
			FB.XFBML.parse();
			
		};
		
		$( document ).ready( function( script, targetSelector, pageUrl, language ) {
			
			return function () {
				
				$( '<fb:like></fb:like>').attr( {
												  'href': pageUrl,
												  'layout': 'button_count',
												  'show_faces': 'false',
												  'font': 'verdana'
										        } )
										 .appendTo( targetSelector )
										 .before( '<div id="fb-root"></div>' )
										 .append( script );
				
			}
			
		}( script, targetSelector, pageUrl, language ) );
		
	}
	/**
	 * Adds Javascript to the social bookmark links where required. The link is set up in the document source code
	 * as far as possible. This function usually enhances them. In some cases, though, the link does not work without
	 * calling this function (e.g. in the case of delicious).
	 * 
	 * @returns {void}
	 */
	function addSocialLinks( pageUrl ) {
		
		try {
			var description = $( 'meta[name="description"]' ).attr( 'content' );
		} catch(e) {
			var description = '';
		}
		
		try {
			var keywords = $( 'meta[name="keywords"]' ).attr( 'content' );
		} catch(e) {
			var keywords = '';
		}
		
		try {
			var title = document.title;
		} catch(e) {
			var title = '';
		}
		title = title.replace( / \| \d+$/, '' ); // removing page identifiers such as "title blah | 3" for page #3
		
		
		$( '#delicious a' ).click( function ( event ) {
			
			window.open( 'http://www.delicious.com/save?v=5&noui&jump=close'
						+ '&url='   + encodeURIComponent( pageUrl )
						+ '&title=' + encodeURIComponent( title ),
						'delicious',
						'toolbar=no,width=550,height=550'
						);
			
			event.preventDefault();
			
		});
		
		$( '#digg a' ).attr( 'href', function () {
			return this.href + '&amp;bodytext=' + encodeURIComponent( title );
		});
		
		$( '#google a' ).attr( 'href', function () {
			return this.href + '&amp;title='      + encodeURIComponent( title )
							 + '&amp;annotation=' + encodeURIComponent( description )
							 + '&amp;labels='     + encodeURIComponent( keywords );
		});
		
		$( '#linkarena a' ).attr( 'href', function () {
			return this.href + '&amp;title=' + encodeURIComponent( title )
							 + '&amp;desc='  + encodeURIComponent( description )
							 + '&amp;tags='  + encodeURIComponent( keywords );
		});
		
		$( '#misterwong a' ).attr( 'href', function () {
			return this.href + '&amp;bm_description=' + encodeURIComponent( title );
		});
		
		$( '#myspace a' ).attr( 'href', function () {
			return this.href + '&amp;t=' + encodeURIComponent( title );
		});
		
		$( '#reddit a' ).attr( 'href', function () {
			return this.href + '&amp;title=' + encodeURIComponent( title );
		});
		
		$( '#studivz a' ).attr( 'href', function () {
			return this.href + '&amp;desc=' + encodeURIComponent( title );
		});
		
		$( '#stumbleupon a' ).attr( 'href', function () {
			return this.href + '&amp;title=' + encodeURIComponent( title ).replace( /%20/g, '+' );
		});
		
		if ( $( '#facebookIcon a' ).length ) {
			// The Facebook icon is only there if the Like button is not displayed.
			$( '#facebookIcon a' ).attr( 'href', function () {
				return this.href + '&amp;t=' + encodeURIComponent( title ).replace( /%20/g, '+' );
			});
		}
		
		// Add a highlight function to the "Social Networks" button in the top toolbar.
		$( '#toolsTop .socialNetworks a' ).click( function () {
			
			// Quickly fading out the icons and fading them back in, in sequence.
			// The idea how to do such a thing is here:
			// http://stackoverflow.com/questions/1981645/stagger-jquery-animations
			// 
			// It should be possible to do this with .delay() instead of setTimeout in
			// jQuery 1.4+ (not tested yet).
			$( '#share li a img' ).each( function ( i ) {
				
				// Store the item for use in a 'timeout' function
				var imgItem = $( this );
				
				// Execute this function with an increasing delay for any img[i]. The first img (i=0)
				// won't be delayed, though.
				setTimeout(function() {
					imgItem.fadeOut( 25 ).fadeIn( 25 );
				}, 70*i );
				
			});
			
		});
	}
	
