$(function() {
	// initialize Superfish dropdowns for the primary nav
	$('#header-nav').superfish({autoArrows: false});
	
	// side nav rollovers 
	$('#side-nav ul a').hover(
		function() {
			$(this).animate({backgroundColor: '#efefef'}, 'fast');
		},
		function() {
			$(this).animate({backgroundColor: '#fff'}, 'fast');
		}
	);
	
	// If form inputs have a default value, clear on focus
	$('.default-text').focus(function() {
		this.value = "";
		$(this).removeClass('default-text');
	})
	// Restore default text
	.blur(function() {
		if(!this.value.length) {
			this.value = this.defaultValue;
			$(this).addClass("default-text");
		}
	});

	// open/close form divs based on selection. input has class "opennext"
	function switchyswitch() {
		var thediv =  $(this).parent().next("div");
		switch ($(this).val()) {
			case "Friend/Referral": // how did you find us
			case "Other": // how did you find us
			case "Redesign of Existing Site": // project type
			case "Updates/Changes to Existing Site": // project type
			case "Yes": // radio buttons and checkboxes
			thediv.slideDown();
			break;
			default: thediv.slideUp();
		}
	}
	// ie will not trigger change() until the radio button or checkbox loses focus. must use click()
	$(":radio.open-next, :checkbox.open-next").click(switchyswitch);
	
	// safari doesn't do click() on a select element. must use change()
	$("select.open-next").change(switchyswitch); 
});