$(document).ready(function() {
	
	// initialize superfish nav bar with drop downs
	$('ul.sf-menu').supersubs({ 
		minWidth:    10,
		maxWidth:    15,
		extraWidth:  1
	}).superfish({
		delay:       500,
		animation:   {opacity:'show',height:'show'},
		speed:       'fast',
		autoArrows:  false,
		dropShadows: false
	});
	
	// give anchor tags target="_blank" if applicable
	$('a[rel*=external]').click(function(){window.open(this.href);return false;});
	
	$('form.external').attr('target','blank');
	
	$('#sidebar form input[type="text"]').defaultvalue('Email Address');
	
	// anti-spam mailto hyperlinks
	$('span.mailme').mailme();
	
	// add support for pseudo-classes
	$('.homebox p:last-child').css('margin','0');
	$('#nav ul:first li:first').attr('id','nav-home');
	
	// give first input field focus on forms if applicable
	$('.form td:first input[type="text"]').focus();
	
	// add our "required field" bullets to forms accordingly
	$('.req td:not(.notreq)').prepend('<em class="bull">&bull;</em>')
	
	// initilize yes/no radio button choices on forms
	$('input.rd-yes-no').change(function() {
		$(this).siblings('.newfield').slideToggle('fast', function() {
			if (!$.browser.msie) $(':input:first',this).select();
		});
	});
	
	// initialize select inputs with an "Other" selection on forms
	$('select.sel-other').change(function() {
		if ($(this).val() == 'Other') {
			$(this).siblings('.newfield').slideDown('fast', function() {
				if (!$.browser.msie) $(':input:first',this).select();
			});
		} else {
			$(this).siblings('.newfield').slideUp('fast');
		}
	});
	
	// ensure that hyperlinks that "go nowhere" function properly
	$('a[href="#"]').click(function(){return false;});
	
	// show "loading" image on all forms upon submission
	$('.form').submit(function(){
		$('input[type="submit"]', this).hide();
		$('#loading').show();
	})
	
	// hide the longest loading form on the site until it's done loading
	$('#content form.form').removeClass('hide');
});
