jQuery(document).ready(function() {

	// xhtml 1.0 strict way of using target _blank
	jQuery('.mexy-bookmarks a.external').attr("target", "_blank");

	// this block sets the auto vertical expand when there are more than 
	// one row of bookmarks.
	var mexyBaseHeight=jQuery('.mexy-bookmarks').height();
	var mexyFullHeight=jQuery('.mexy-bookmarks ul.socials').height();
	if (mexyFullHeight>mexyBaseHeight) {
		jQuery('.mexy-bookmarks-expand').hover(
			function() {
				jQuery(this).animate({
						height: mexyFullHeight+'px'
				}, {duration: 400, queue: false});
			},
			function() {
				jQuery(this).animate({
						height: mexyBaseHeight+'px'
				}, {duration: 400, queue: false});
			}
		);
	}
	// autocentering
	if (jQuery('.mexy-bookmarks-center')) {
		var mexyFullWidth=jQuery('.mexy-bookmarks').width();
		var mexyBookmarkWidth=jQuery('.mexy-bookmarks:first ul.socials li').width();
		var mexyBookmarkCount=jQuery('.mexy-bookmarks:first ul.socials li').length;
		var numPerRow=Math.floor(mexyFullWidth/mexyBookmarkWidth);
		var mexyRowWidth=Math.min(numPerRow, mexyBookmarkCount)*mexyBookmarkWidth;
		var mexyLeftMargin=(mexyFullWidth-mexyRowWidth)/2;
		jQuery('.mexy-bookmarks-center').css('margin-left', mexyLeftMargin+'px');
	}
});