$(function(){
	
	$("#home_about_nav li a").click(function() {
		$("#home_about_nav li").removeClass("home_about_nav_active");
		$(this).parent().addClass("home_about_nav_active");
		$("#about_massbio p").hide();
		$('#' + $(this).parent().attr("id") + '_container').show();
		return false;
	});
	
	$(".filter_boxes .expand_filter").each(function() {
		$(this).click(function() {
			var box = $(this).closest('div');
			$(".filter_boxes").children("div").each(function() {
				$(".filter_boxes div").removeClass("active_filter");
				$(".filter_boxes div").addClass("nonactive_filter");
				$(".filter_boxes div .expand_filter").show();
			});
			box.removeClass("nonactive_filter");	
			box.addClass("active_filter");
			$(this).hide();
			
			return false;
		});
	});

		
	// Replace the text field with a password field
	var password_input = $('#password_input')
	var password_view  = $('#password_view');
	password_view.show().focus(function() {
		password_view.hide();
		password_input.show().focus();
		
	});
	password_input.hide().blur(function() {
		if(password_input.val() == '') {
			password_view.show();
			password_input.hide();
		}
	});
	
	// Remove the username and search value when you click on it
	$('.replace_value').each(function() {
		var default_value = this.value;
		$(this)
		.focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		})
		.blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	
	
	
	$("#nav").children("li").each(function() {
		var current = "active";
		var thisId = $(this).attr('id');
		
	});
				
	$.each(['nav_about', 'nav_membership', 'nav_purchasing_consortium', 'nav_events', 'nav_economic_development', 'nav_policy', 'nav_news', 'nav_careers', 'nav_member_portal'], function (i, val) {
		attachNavEvents("#nav", val);	
	});
	
	function hoverOver() {
		myId = $(this).attr('id');
		$("#nav #" + myId).children("ul").show();
		$("#nav #" + myId).addClass("hover");
	}
	
	function hoverOut() {
		myId = $(this).attr('id');
		$("#nav #" + myId).children("ul").hide();
		$("#nav #" + myId).removeClass("hover");		
	}
			
	function attachNavEvents(parent, myId) {
		
		
		var config = {    
			 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 50, // number = milliseconds for onMouseOver polling interval    
			 over: hoverOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 0, // number = milliseconds delay before onMouseOut    
			 out: hoverOut // function = onMouseOut callback (REQUIRED)    
		};
		
		$(parent + " #" + myId).hoverIntent(config); 
		
	}


});