/**
 * @package Spark Bibles
 * @author {@link mailto:ss@toolboxstudios.com Steve Simons, Toolbox Studios, Inc.}
 * @license http://toolboxstudios.com Contact about usage
 * @revision $Revision: $
 * @copyright Copyright 2010
**/

/**
	Do this stuff after everything on the page has been loaded
**/

jQuery( 'span.sharethis')
	.each( function( index) {
		var thisURL = document.location.href.replace( /\#.*$/, '');
		var spanTitle = jQuery( this).attr( 'title');
		var spanURL = jQuery( this).text();
		if ( spanURL == '' && jQuery( this).closest( '.story').length > 0)
			spanURL = thisURL + (thisURL.match(/\?/) ? '&' : '?') + 'Story';
		else if ( spanURL == '' && jQuery( this).closest( '.nrsv').length > 0)
			spanURL = thisURL + (thisURL.match(/\?/) ? '&' : '?') + 'NRSV';
		var obj = SHARETHIS.addEntry(
			{
				title: ( spanTitle == '' ? 'Share This' : spanTitle),
				summary: 'Sharing is good for the soul.',
				url: ( spanURL == '' ? thisURL : spanURL)
			},
			{
				button: false
			}
		);
		jQuery( this)
			.empty()
			.removeClass( 'sharethis')
			.append( '<a class="shareThisButton" href="Javascript:void(0);">Share This</a>');
		obj.attachButton( this);
	});

