/* Menu Rollover Code */
$.fn.rolloverMenu = function(){
	return this.each(function(){
		var active = $('LI.active', this);
		active.addClass('over');
		$('LI', this).hover(
			function(){
				active.removeClass('over');
				$(this).addClass('over');
			},
			function(){
				$(this).removeClass('over');
				active.addClass('over');
			}
		);
	});
};

$.slugify = function(value){
	return value.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/[-]+/g, '-').replace(/^-|-$/g, '');
};

$.fn.idify = function() {
	return $(this).each(function(){
		if (!this.id) {
			this.id = $.slugify($(this).text());
		}
	});
};

$(function(){
	$('#nav').rolloverMenu();
});

$(function(){
	$('hr').replaceWith('<div class="hr"></div>');
});

$(function(){
	$('.base TBODY TR:even').addClass('even');
});

$(function(){
	$('a[rel^=fancybox]').fancybox({
		zoomSpeedIn:400,
		zoomSpeedOut:400,
		overlayShow: true,
		overlayColor: '#000',
		overlayOpacity: 0.8,
		hideOnContentClick:false
	});
});

$(function(){
	$('A, AREA').filter(function(){
		var href = $(this).attr('href');
		return !this.target && href && ((href.indexOf(window.location.hostname) == -1 && href.match(/^https?/i)) || href.match(/\.pdf$/i));
	}).attr('target', '_blank');
});

$(function(){
	$('#projectsMenu A').click(function(){
		window.location.href = this.href;
		$(document).scrollTop(Math.max(0, $(window.location.hash).offset().top - 305));
		return false;
	});
});
