
$(document).ready(function() {



function mainnav() {
$('.current').prev().children().css('border-right','1px solid transparent');
$('.dropdown').each(function () {
	
	var config = {    
     over: mainnavSlideDown, // function = onMouseOver callback (REQUIRED)    
     timeout: 500, // number = milliseconds delay before onMouseOut    
     out: mainnavSlideUp // function = onMouseOut callback (REQUIRED)    
};

$('.dropdown li').click( function() {
	var $href = $(this).children('a').attr('href');
	window.location = $href;
});

$('#nav li').click (function () {
	var $href = $(this).children('a').attr('href');
	window.location = $href;
});

$('#content_subnav li').click(function () {
	var $href = $(this).children('a').attr('href');
	window.location = $href;
});

$('.subsubnav li').click(function() {
	var $href = $(this).children('a').attr('href');
	window.location = $href;
});

$(this).parent().eq(0).hoverIntent( config );

	
	$(this).parent().eq(0).hover( function() {
		if (!$(this).hasClass('current')) {
			$(this).addClass('hovered');
			$(this).children().css('border-right','1px solid transparent');
			
			$(this).prev().children().css('border-right','1px solid transparent');	
		}
	}, function() {
		if (!$(this).hasClass('current')) {
			$(this).removeClass('hovered');
			if (!$(this).children().hasClass('reach')) {
				$(this).children().css('border-right','1px solid #ccc');
				
			}
	
			
			if (!$(this).prev().hasClass('current') ) {
				if (!$(this).hasClass('current')) {
					$(this).prev().children().css('border-right','1px solid #ccc');
				}
			}	
		}
	});
	
	function mainnavSlideDown() {
	//$(this).parent().eq(0).hoverIntent(function () {	
		
		

		
		$('.dropdown:eq(0)', this).show('blind', {}, 100);
		
	
	} function mainnavSlideUp () {
		

		
		$('.dropdown:eq(0)', this).hide('blind', {}, 100);
		$('.current').prev().children().css('border-right','1px solid transparent');
		$('.current').children().css('border-right','1px solid transparent');
	}
		
	});
}

	mainnav();
	content_subnav();
	subsubnav();
	

function content_subnav() {

$('.subcurrent').prev().children().css('border-right','1px solid transparent');

	$('.contentdropdown').each(function () {
	
	
	$(this).eq(0).children().hover(function () {
		
		if (!$(this).is(':last-child')) {
		
			$(this).children().css('border-right','1px solid transparent');
			//$(this).children().css('width','+=1');
		}
		
		if (!$(this).prev().hasClass('subcurrent')) {
			$(this).prev().children().css('border-right','1px solid transparent');
			
			//$(this).prev().children().css('width','+=1');
		}
		
	
	}, function () {
		
		if (!$(this).is(':last-child')) {
			$(this).children().css('border-right','1px solid #ccc');
			
		}
		
		
		
		if (!$(this).prev().hasClass('subcurrent')) {
			$(this).prev().children().css('border-right','1px solid #ccc');
			
		}
		$('.subcurrent').prev().children().css('border-right','1px solid transparent');
		$('.subcurrent').children().css('border-right','1px solid transparent');
		
		});
	});
}

function subsubnav() {

$('.subsubnav').each(function () {
	$(this).parent().eq(0).hover(function () {	
		
		
		$('.subsubnav:eq(0)', this).show('blind', {}, 100);
		
	
	}, function () {

		$('.subsubnav:eq(0)', this).hide('blind', {}, 100);

	});
		
	});
}

});

	
