cllc = {
	exists: true, // Indicates that the CLLC core has loaded and is required to use any other module.
	init: function() {
		// Allow console logging across all browsers
		try { console.log('console ready'); } catch(e) { var console = { log: function() {} }; }
		cllc.setup_nav();
	},

	// function standard_error_handler
	// Runs the standard error handler which merely logs errors to the console. Typically called via catch{} blocks.
	// PARAMS
	//     error: [required] The thrown Error() object or a string describing the error
	standard_error_handler: function(error) {
		// If a string was provided, simply log the error string
		if (typeof(error) == "string" || typeof(error) == "STRING") {
			var error_msg = 'error: '+error;
		}
		// If an Error() was thrown, log its name and message.
		// If the browser provides it, also log the file name and line number of the error.
		else {
			var error_msg = "error ("+error.name;
			if (error.lineNumber) {
				error_msg += ", line "+error.lineNumber+", "+error.fileName;
			}
			error_msg += "): "+error.message;
		}
		console.log(error_msg);
	},
	
	setup_nav: function() {
		$('#cllc_corp_header ul.menu > li').each(function() {
			var menu = $(this).find('ul:first');
			$(this).data('menu_size', {
				'padding_top': menu.css('padding-top'),
				'height': menu.height(),
				'padding_bottom': menu.css('padding-bottom')
			});
		})
		.hover(function(e) {
			var menu_size = $(this).data('menu_size');
			
			$(this).find('ul').stop().css('height', 0).show().animate({
				'padding-top': menu_size.padding_top,
				'height': menu_size.height,
				'padding-bottom': menu_size.padding_bottom
			}, {queue: false, duration: 200});
		}, function(e) {
			$(this).find('ul').animate({
				'padding-top': 0,
				'height': 0,
				'padding-bottom': 0
			}, {queue: false, duration: 200, complete: function() {
				$(this).hide();
			}});
		});
		
		// Allow clicking anywhere in the menu item
		$('#cllc_corp_header ul ul li').live('click', function(e) {
			window.location.pathname = $(this).find('a').attr('href');
		});

		// Highlight this page's nav item
		$("#cllc_corp_header ul li a[href='"+window.location.pathname+"']")
			.closest('ul.menu > li')
			.find('h4')
			.addClass('active');
	}
};

$(cllc.init);