$(function() {

	$("a.overlay").overlay({

		onBeforeLoad: function() {

			var wrap = this.getOverlay().find(".contentWrap");
			wrap.load(this.getTrigger().attr("href"));
			$('#overlay-background').css('opacity', '0.5').fadeIn('fast');
		},

		onBeforeClose: function() {
			$('#overlay-background').fadeOut('fast');
		}

	});

	$('div#ribbon').hover(
	function () {
	    $(this).css('z-index', 3);
	},
	function () {
	    $(this).css('z-index', 1);
	});


	// Set opacity to 0 on ready document
	$('ul#menu li span:not(.active)').css({'opacity' : '0'});

    // Button Hover Effect
	$('ul#menu li span:not(.active) a').hover(function() {
		$(this).parent().stop().animate({'opacity' : '1'}, 200);
	}, function(){
		$(this).parent().stop().animate({'opacity' : '0'}, 200);
	});

	// Social Bar Hover Effect
	$('#social-bar a').hover(function() {
		$(this).stop().animate({'margin-left' : '0'}, 200);
	}, function(){
		$(this).stop().animate({'margin-left' : '-17px'}, 200);
	});

	// Social Bar Tooltips
	$("#social-bar a").hover(function(e) {
		var y = $(this).offset().top - $("#social-bar").offset().top;
		var content = $(this).attr('title');
		var id = $(this).attr('id');

		$(this).attr('title', '');

		$("#social-bar").append("<div id='tooltip'>" + content + "</div>");
		$("#social-bar #tooltip").css('opacity', 0.7).css('top', y + 8).css("left", 50).data('trigger', id).fadeIn();
	},
		function() {
			var trigger = $("#social-bar #tooltip").data('trigger');
			var content = $("#social-bar #tooltip").html();
			$('#' + trigger).attr('title', content);
			$("#social-bar #tooltip").remove();
		}
	);

	// Open external links automatically in a now window except if it's a blog site
	$('a[href^=http]').click( function() {
		if (this.href.indexOf('xxx') < 0 && this.href.indexOf('xxx') < 0) {
			window.open(this.href);
			return false;
		}
	});

	
	
	
});
