String.prototype.validEmail = function() {
	emailRegex = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_])*@([0-9a-zA-Z]([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/;
	return emailRegex.test(this);
} // end String.prototype.validEmail

$.fn.exists = function(){return $(this).length > 0;}

$(function() {
	$(':checkbox, :radio').addClass('no_border');
	$('#nav_text ul li a').click(function(e) {
		e.stopPropagation(); /* Prevent a nav link with rel="external" from opening two new windows. */
	});
	$('a[rel=external][href]').attr('target', '_blank');
	$('#nav_text ul li').hover(
		function() {
			$(this).css({ backgroundPosition: 'bottom' })
		},
		function() {
			$(this).css({ backgroundPosition: 'top' })
		}
	)
	.mousedown(function() {
		$('a', this).addClass('active');
	})
	.mouseup(function() {
		$('a', this).removeClass('active');
	})
	.click(function() {
		var childHref = $('a', this).attr('href');
		if ($('a', this).attr('rel') == 'external') {
			window.open(childHref);
		}
		else {
			window.location = childHref;
		}
	});
});


