jQuery(document).ready(function() {

	// xhtml 1.0 strict way of using target _blank
	jQuery('.bookmarks a.external').attr("target", "_blank");

	// this block sets the auto vertical expand when there are more than 
	// one row of bookmarks.
	var BaseHeight=jQuery('.bookmarks').height();
	var FullHeight=jQuery('.bookmarks ul.socials').height();
	if (FullHeight>BaseHeight) {
		jQuery('.bookmarks-expand').hover(
			function() {
				jQuery(this).animate({
						height: FullHeight+'px'
				}, {duration: 400, queue: false});
			},
			function() {
				jQuery(this).animate({
						height: BaseHeight+'px'
				}, {duration: 400, queue: false});
			}
		);
	}
	// autocentering
	if (jQuery('.bookmarks-center') || jQuery('.bookmarks-spaced')) {
		var FullWidth=jQuery('.bookmarks').width();
		var BookmarkWidth=jQuery('.bookmarks:first ul.socials li').width();
		var BookmarkCount=jQuery('.bookmarks:first ul.socials li').length;
		var numPerRow=Math.floor(FullWidth/BookmarkWidth);
		var RowWidth=Math.min(numPerRow, BookmarkCount)*BookmarkWidth;
		
		if (jQuery('.bookmarks-spaced').length>0) {
			var LeftMargin=Math.floor((FullWidth-RowWidth)/(Math.min(numPerRow, BookmarkCount)+1));
			jQuery('.bookmarks ul.socials li').css('margin-left', LeftMargin+'px');
		} else if (jQuery('.bookmarks-center'.length>0)) {
			var LeftMargin=(FullWidth-RowWidth)/2;
			jQuery('.bookmarks-center').css('margin-left', LeftMargin+'px');
		}
		
	}
});