// Function to dump out a collection of social networking tags for a given URL
//
// Insert it into your web page with these lines at the start:
//		<link rel="stylesheet" href="social.css" type="text/css" media="screen" charset="utf-8">
//		<script type='text/javascript' src='urlencode.js'></script>
//		<script type='text/javascript' src='social.js'></script>
//
// And this where you want the links:
//	<script>
//		social( "http://MyURL", "My URL", "category", "My Url Verbosely" );
//	</script>
//
// Usage:
//     social(url, title, category, summary)
//			url   = Link, usually http://mysite.com
//			title = Headline title, e.g. "My Blog Entry"
//			category(optional) = Yahoo Category, e.g. "science"
//			summary(optional) = Body details, e.g. "In this entry I compare social links to various types of wood"
//
diggLink = function(url, title, category, summary)
{
	return "http://digg.com/submit?phase=2&url=" + url + "&title=" + title;
}
sphinnLink = function( url, title, category, summary )
{
	return "http://sphinn.com/submit.php?url=" + url + "&title=" + title;
}
deliciousLink = function( url, title, category, summary )
{
	return "http://del.icio.us/post?url=" + url + "&title=" + title;
}
facebookLink = function( url, title, category, summary )
{
	return "http://www.facebook.com/share.php?u=" + url + "&t=" + title;
}
mixxLink = function( url, title, category, summary )
{
	return "http://www.mixx.com/submit?page_url=" + url + "&title=" + title;
}
googleLink = function( url, title, category, summary )
{
	return "http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=" + url + "&title=" + title;
}
furlLink = function( url, title, category, summary )
{
	return "http://www.furl.net/storeIt.jsp?u=" + url + "&t=" + title;
}
linkedInLink = function( url, title, category, summary )
{
	return "http://www.linkedin.com/shareArticle?mini=true&amp;url=" + url + "&title=" + title + "&source=Kevin%20Picott;summary=" + summary;
}
liveLink = function( url, title, category, summary )
{
	return "https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=" + url + "&title=" + title;
}
stumbleUponLink = function( url, title, category, summary )
{
	return "http://www.stumbleupon.com/submit?url=" + url + "&title=" + title;
}
technoratiLink = function( url, title, category, summary )
{
	return "http://technorati.com/faves?add=" + url;
}
twitterLink = function( url, title, category, summary )
{
	return "http://twitter.com/home?status=" + url;
}
yahooLink = function( url, title, category, summary )
{
	return "http://buzz.yahoo.com/submit/?submitUrl=" + url +
			"&submitHeadline=" + title + "&submitSummary=" + summary +
			"&submitCategory=" + category + "&submitAssetType=text";
}
//----------------------------------------------------------------------
social = function(url, title, category, summary)
{
	document.write( "<div class='sociable'>\n" );
	document.write( "<div class='sociable_tagline'>\n" );
	document.write( "<strong>Share and Enjoy:</strong>\n" );
	document.write( "</div>\n" );
	document.write( "<ul>\n" );
	url = URLEncode( url );
	title = URLEncode( title );
	summary = URLEncode( summary );

	var linkTypes = [ "Digg", "Sphinn", "Delicious", "Facebook",
					   "Mixx", "Google", "Furl", "LinkedIn", "Live",
					   "StumbleUpon", "Technorati", "Twitter", "YahooBuzz" ];
	var imgTypes = [ "digg", "sphinn", "delicious", "facebook",
					   "mixx", "google", "furl", "linkedIn", "live",
					   "stumbleupon", "technorati", "twitter", "yahoobuzz" ];
	for( var idx in linkTypes )
	{
		var type = linkTypes[idx];
		var link = "";
		var img = "Icons/" + imgTypes[idx] + ".png";
		var title = type;
		var alt = type;
		switch( type )
		{
			case 'Digg':		link = diggLink( url, title, category, summary ); break;
			case 'Sphinn':		link = sphinnLink( url, title, category, summary ); break;
			case 'Delicious':
				title = 'del.icio.us';
				alt = 'del.icio.us';
				link = deliciousLink( url, title, category, summary );
			break;
			case 'Facebook':	link = facebookLink( url, title, category, summary ); break;
			case 'Mixx':		link = mixxLink( url, title, category, summary ); break;
			case 'Google':		link = googleLink( url, title, category, summary ); break;
			case 'Furl':		link = furlLink( url, title, category, summary ); break;
			case 'LinkedIn':	link = linkedInLink( url, title, category, summary ); break;
			case 'Live':		link = liveLink( url, title, category, summary ); break;
			case 'StumbleUpon':	link = stumbleUponLink( url, title, category, summary ); break;
			case 'Technorati':	link = technoratiLink( url, title, category, summary ); break;

			case 'Twitter':
				title = "TwitThis";
				alt = "TwitThis";
				link = twitterLink( url, title, category, summary );
			break;

			case 'YahooBuzz':	link = yahooLink( url, title, category, summary ); break;
		}
        document.write( '<li><a rel="nofollow" target="_blank"' );
		document.write( ' href="' + link + '" title="' + title + '">' );
		document.write( '<img border="0" src="' + img + '" title="' + title );
		document.write( '" alt="' + alt + '" class="sociable-hovers"/></a></li>\n' );
	}
	document.write( '<li><a rel="nofollow" href="javascript:window.print();" ' );
	document.write( 'title="Print this article!"><img border="0" src="Icons/printer.png"' );
	document.write( 'title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a></li>' );

	document.write( '<li><a rel="nofollow" href="mailto:?subject=' + title + '&body=' + link + '\n\n' + summary );
	document.write( ' title="E-mail this story to a friend!">' );
	document.write( '<img border="0" src="Icons/email_link.png"' );
	document.write( ' title="E-mail this story to a friend!"' );
	document.write( ' alt="E-mail this story to a friend!"' );
	document.write( ' class="sociable-hovers" /></a></li>' );

	document.write( "</ul>\n" );
	document.write( "</div>\n" );
}

