var share_thing = {
	'Facebook': {'class':'facebook',
		'url':function(url, title){return 'http://www.facebook.com/share.php?u='+url+'&t='+title;}},
	'Twitter': {'class':'twitter',
		'url':function(url, title){return 'http://twitter.com/home?status='+url+'%20(via%20RI.gov)'}},
	'MS Live': {'class':'mslive',
		'url':function(url, title){return 'https://favorites.live.com/quickadd.aspx?url='+url+'&title='+title;}},
	'Google': {'class':'google',
		'url':function(url, title){return 'http://www.google.com/bookmarks/mark?op=add&bkmk='+url+'&title='+title;}},
	'Digg': {'class':'digg',
		'url':function(url, title){return 'http://digg.com/submit?phase=2&url='+url+'&title='+title;}},
	'Delicious': {'class':'delicious',
		'url':function(url, title){return 'http://delicious.com/post?v=4&noui&url='+url+'&title='+title;}},
	'Email': {'class':'email',
		'url':function(url, title){return 'mailto:?subject='+title+'&body='+url;}}
};

initShareBox = function(box){
	var share_title = document.title;
	var share_url = window.location.href;
	
	var html_string = "<ul>"
	
	$.each(share_thing, function(service, url_scheme){
		html_string += '<li><a class="'+url_scheme['class']+'"href="'+url_scheme['url'](encodeURIComponent(share_url), encodeURIComponent(share_title))+'">'+service+'</a></li>'
	})
	
	html_string += '</ul>'
	box.children("#shareContainer").children().append(html_string);
	
	box.children("#shareContainer").hide();
	var sharetimeout = null;
	box.hover(function(){
		var _self = $(this);
		_self.addClass('hoveredShareBox');
		if (sharetimeout) clearTimeout(sharetimeout);
		var leftpos = $(this).children("#shareButton").offset()['left'] + $(this).children("#shareButton").width() - $(this).children("#shareContainer").width();
		var toppos = $(this).children("#shareButton").offset()['top'] + $(this).children("#shareButton").height();
		_self.children("#shareContainer").css({'top':toppos,'left':leftpos});
		_self.children("#shareContainer").fadeIn();
	},function(){
		var _self = $(this);
		sharetimeout = setTimeout(function(){
			_self.children("#shareContainer").fadeOut();
			_self.removeClass('hoveredShareBox');
		},1000);
			
	});
}