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 sexyBaseHeight=jQuery('.bookmarks').height();
	var sexyFullHeight=jQuery('.bookmarks ul.socials').height();
	if (sexyFullHeight>sexyBaseHeight) {
		jQuery('.bookmarks-expand').hover(
			function() {
				jQuery(this).animate({
						height: sexyFullHeight+'px'
				}, {duration: 400, queue: false});
			},
			function() {
				jQuery(this).animate({
						height: sexyBaseHeight+'px'
				}, {duration: 400, queue: false});
			}
		);
	}
	// autocentering
	if (jQuery('.bookmarks-center') || jQuery('.bookmarks-spaced')) {
		var sexyFullWidth=jQuery('.bookmarks').width();
		var sexyBookmarkWidth=jQuery('.bookmarks:first ul.socials li').width();
		var sexyBookmarkCount=jQuery('.bookmarks:first ul.socials li').length;
		var numPerRow=Math.floor(sexyFullWidth/sexyBookmarkWidth);
		var sexyRowWidth=Math.min(numPerRow, sexyBookmarkCount)*sexyBookmarkWidth;
		
		if (jQuery('.bookmarks-spaced').length>0) {
			var sexyLeftMargin=Math.floor((sexyFullWidth-sexyRowWidth)/(Math.min(numPerRow, sexyBookmarkCount)+1));
			jQuery('.bookmarks ul.socials li').css('margin-left', sexyLeftMargin+'px');
		} else if (jQuery('.bookmarks-center'.length>0)) {
			var sexyLeftMargin=(sexyFullWidth-sexyRowWidth)/2;
			jQuery('.bookmarks-center').css('margin-left', sexyLeftMargin+'px');
		}
		
	}

	jQuery('.bookmarks a.external').click(function() {
		var url = encodeURIComponent(window.location.href), desc = '';
		if( jQuery('p.bookmarks-content').length ) {
			desc = encodeURIComponent(jQuery('p.bookmarks-content').text());
		}
		switch(this.parentNode.className) {
			case 'digg':
				this.href += '?phase=2&title=' + document.title + '&url=' + url + '&desc=' + desc;
				break;
			case 'twitter':
				this.href += '?status=RT+@your_twitter_id:+' + document.title + '+-+' + url;
				break;
			case 'delicious':
				this.href += '?title=' + document.title + '&url=' + url;
				break;
			case 'stumbleupon':
				this.href += '?title=' + document.title + '&url=' + url;
				break;
			case 'myspace':
				this.href += '?t=' + document.title + '&u=' + url;
				break;
			case 'facebook':
				this.href += '?t=' + document.title + '&u=' + url;
				break;
			case 'linkedin':
				this.href += '?mini=true&title=' + document.title + '&url=' + url;
				break;
			case 'google':
				this.href += '?op=add&title=' + document.title + '&bkmk=' + url;
				break;
		}
	})
});
function externalLinks() {  
 if (!document.getElementsByTagName) return;  
 var anchors = document.getElementsByTagName("a");  
 for (var i=0; i<anchors.length; i++) {  
   var anchor = anchors[i];  
   if (anchor.getAttribute("href") &&  
       anchor.getAttribute("rel") == "external")  
     anchor.target = "_blank";  
 }  
}  
window.onload = externalLinks;

$(function() {
	$(".hover").mouseover(function() { 
		var src = $(this).attr("src").match(/[^\.]+/) + "_hover.png";
		$(this).attr("src", src);
	}).mouseout(function() {
		var src = $(this).attr("src").replace("_hover", "");
		$(this).attr("src", src);
	});
	$(".cvhelpers a").hover(function(){
	    $(this).stop().animate({"opacity": .5});
	},function(){
	    $(this).stop().animate({"opacity": 1});
	});
	$('.menuItems > ul').dropmenu({
		effect	: 'slide',
		nbsp	: true
		});
});
jQuery(document).ready(function() {
	//$('.menuItems').show();
	//$(".menuItems").css({display:"block"});
	});
