$(document).ready(function(){
	
	// Schools Dropdown
	$('#schools_dropdown').hide();
	$('#schools_dropdown').addClass('closed');
	$('#schools_dropdown').animate({opacity: 0});
	$('#schools_dropdown_arrow').hide();
	if(!$.browser.msie)
	{
		$('#schools_dropdown_arrow').animate({opacity: 0});
	}

	$('#school_sites a').click(function(){
		if($('#schools_dropdown').hasClass('closed'))
		{
			if(!$.browser.msie)
			{
				$('#schools_dropdown_arrow').show().animate({opacity: 1});
			} else {
				$('#schools_dropdown_arrow').show();
			}
			$('#schools_dropdown').removeClass('closed').addClass('open').animate({opacity: 1, height: 'toggle'}, function(){
				// Re-evaluate nav position
				navTop = $('#main_nav').offset().top;
			});
			$('#school_sites').addClass('active');
		}
		else
		{
			if(!$.browser.msie)
			{
				$('#schools_dropdown_arrow').animate({opacity: 0});
			} else {
				$('#schools_dropdown_arrow').hide();
			}
			
			$('#schools_dropdown').removeClass('open').addClass('closed').animate({opacity: 0, height: 'toggle'}, function(){
				// Re-evaluate nav position
				navTop = $('#main_nav').offset().top;
				$('#schools_dropdown_arrow').hide();
			});
			$('#school_sites').removeClass('active');
		}
	});
	
	// Jump Menus
	$('select#parents').change(function() {
		var the_val = $(this).attr('value');
		if(the_val.indexOf("http:") != -1 || the_val.indexOf("https:") != -1) {
			window.open($(this).attr('value'));
		} else {	
			eval("parent.location='"+$(this).attr('value')+"'");
		}
	});

	$('select#staff').change(function() {
		var the_val = $(this).attr('value');
		if(the_val.indexOf("http:") != -1 || the_val.indexOf("https:") != -1) {
			window.open($(this).attr('value'));
		} else {	
			eval("parent.location='"+$(this).attr('value')+"'");
		}
	});
	
	$('div.select label').mousedown(function(){
		//$(this).siblings('div').children('a').trigger('mousedown.selectmenu');
	});
		
	// Main Nav Dropdown
	$('#main_nav ul li.children').hover(function(){
		$(this).addClass('open');
		$(this).children('ul').show();
	}, function(){
		$(this).removeClass('open');
		$(this).children('ul').hide();
	});
	
	// Don't let tertiary level dropdown
	$('#main_nav ul li.children ul li.children').hover(function(){
		$(this).children('ul').hide();
	});
	
	// Sec Nav Dropdown/Slideout
	$('#sec_nav ul li.children').not('#sec_nav ul li.children.current').hover(function(){
		$(this).addClass('open');
		$(this).children('ul').show();
	}, function(){
		$(this).removeClass('open');
		$(this).children('ul').hide();
	});

    
    //hide/show title/ 'x' when clicking input
    $('.text_filter input').blur(function() { 
	if( $('.text_filter input').val() == '' ) {
    	$(".text_filter .clear_button").hide();
	}
	}).focus(function() {
    	$(".text_filter .clear_button").show();
	});
    
    //hide 'x', show title when clicking 'x', reset filter
    $(".text_filter .clear_button").click(function(){
    	$(this).prev('input').val('');
    	$(this).prev('input').trigger('keyup');
    	$(this).hide();
    
	});
	
	/*
// Only show document download button on hover
	$('#docs .result').hover(function(){
		$(this).children('.download_btn').show();
		alert('everyday i\'m hovering');
	}, function(){
		$(this).children('.download_btn').hide();
	});
*/
});

