
jQuery(function(){
	
	if(jQuery.browser.msie && jQuery.browser.version < 7) {
		console.log(jQuery('#topNav .level1 > li'));
		// IE 6 compatibility
		jQuery('#topNav .level1 > li').hover(function(){
				jQuery(this).addClass('iehover');
				console.log(this)
			},
			function(){
				jQuery(this).removeClass('iehover');
				console.log("out")
		});
	}
});

jQuery(function(){
	// Don't run if ie6
	//if(!(jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0,1)) == 6))
	//{
		// tag all the non expandable items
		jQuery("#leftNav li a:only-child").parent("li").addClass("notExpandable");
		jQuery("#leftNav li ul").parent("li").addClass("expandable");
		
		// show the current selection when the page loads
		jQuery('#leftNav ul li.expandable ul').hide();
		jQuery('#leftNav ul li.selected ul').show();
		jQuery('#leftNav ul.level1 li a').click
		( 
			function()
			{
				var checkElement = jQuery(this).next();
				
				// if the item click is already opened, close it and update the classes
				if(checkElement.is('ul') && checkElement.is(':visible'))
				{
					var theLi = jQuery('#leftNav ul li ul:visible');
					theLi.slideUp('normal');
					theLi.parent('li').addClass('closed');
					// this is for closed selected items that need a blue arrow pointing sideways

					// remove the active tag and update the page length.
					theLi.parent("li").removeClass('active');

					return false;
				}
				// if the item clicked has a ul child that is not visible
				if((checkElement.is('ul')) && (!checkElement.is(':visible')))
				{
					// close any current open sub levels
					jQuery('#leftNav ul li ul:visible').slideUp('normal');
					jQuery('#leftNav ul li ul:visible').parent('li').addClass('closed');
					jQuery('#leftNav ul li ul:visible').parent("li").removeClass('active');
					
					// slide down the one clicked.
					checkElement.slideDown('normal');
					checkElement.parent("li").removeClass('closed');
					checkElement.parent("li").addClass("active");
					
					return false;
				}
			}
		);
	//}
});
