$(function() {
	$explore_box = $('#explore-box');
	$campus_list = $('#campus-list');
			
	$('#explore-nav a.header-button-left').click(function(e) {
		toggle_nav();
		return false;
	});
	$('#campus-nav a.header-button-left').click(function(e) {
		toggle_campus();
		return false;
	});
	
	/*$('#explore-nav div:not(a), #campus-nav div:not(a)').click(function(e) {
		//return false;
	});*/
	
	$('#masker').live('click', function() {
		hide_all();
	});
	
	$('.indent_2').parent('li').addClass('has_child');
	$('.indent_2').parent('li').children('a').toggle(
		function() {
			$(this).parent('li').children('ul').show();
			$(this).parent('li').addClass('has_child_open');
			$(this).parent('li').removeClass('has_child');
		},
		function() {
			$(this).parent('li').children('ul').hide();
			$(this).parent('li').addClass('has_child');
			$(this).parent('li').removeClass('has_child_open');
		}
	);
	
	$('.indent_2').hide();
});

function toggle_nav() {
	if ($explore_box.css('display') == 'none') {
		//$('body:not(.noclick)').click(hide_all);
		
		$explore_box.show('fast');
		
		hide_campus();
		$('body').append('<div id="masker" style="position: absolute; top:0; right:0; bottom:0; left:0; width: 100%; height: 100%; background-color: #fff; opacity: .7; z-index:20;"></div>');
	} else {
		//$('*').unbind('click', hide_all);
		
		hide_nav();
	}
	
	return false;
}

function hide_nav() {
	$explore_box.hide('fast');
	$('#masker').remove();
}

function toggle_campus() {
	if ($campus_list.css('display') == 'none') {
		//$('*').click(hide_all);
		//$('#explore-box *').unbind('click', hide_all);

		$campus_list.show('fast');
		
		hide_nav();
		$('body').append('<div id="masker" style="position: absolute; top:0; right:0; bottom:0; left:0; width: 100%; height: 100%; background-color: #fff; opacity: .7; z-index:20;"></div>');
	} else {
		//$('*').unbind('click', hide_all);
		
		hide_campus();
	}
	
	return false;
}

function hide_campus() {
	$campus_list.hide('fast');
	$('#masker').remove();
}

function hide_all() {
	hide_nav();
	hide_campus();
	//$('*').unbind('click', hide_all);
	return false;
}