jQuery(document).ready(function(){
	jQuery('#dd-nav > ul > li:first').addClass('dd-li-first');
	jQuery('#dd-nav > ul > li:last').addClass('dd-li-last');
	
	jQuery('#dd-nav li').each(function(){
		if( jQuery(this).find('> .dd').length > 0 ){
			jQuery(this).addClass('dd-li-hasdd');
		}
	});
	
	jQuery('#dd-nav .dd').hide();
	
	jQuery('#dd-nav li').hover(
		function(){
			var sub = jQuery(this).find('> .dd').eq(0);
			
			if( sub.length == 0 )
				return;
				
			sub.show();
			jQuery(this).addClass('dd-li-active');
			jQuery(this).find('a:eq(0)').addClass('dd-a-active');
		},
		function(){
			var sub = jQuery(this).find('> .dd').eq(0);
			
			if( sub.length == 0 )
				return;
				
			sub.hide();
			jQuery(this).removeClass('dd-li-active');
			jQuery(this).find('a:eq(0)').removeClass('dd-a-active');
		}
	);
	
	
	// Set active class
	var location = window.location.href;
	var active_link = false;
	jQuery('#dd-nav').find('a').each(function(){
		var href = jQuery(this).attr('href');
		if( location.indexOf(href) != -1 ){
			active_link = jQuery(this);
			return false;
		}
	});
	
	if( active_link ) {
		active_link.parents('li').each(function(){
			if( jQuery(this).parent().parent().attr('id') == 'dd-nav' ){
				jQuery(this).addClass('active');
				jQuery(this).find('a').eq(0).addClass('active');
				return false;
			}
		});
	}
	
	
	if( typeof(DONT_USE_DEFAULT_STYLE) == 'undefined' || !DONT_USE_DEFAULT_STYLE )
		jQuery('#dd-nav').addClass('default-menu');
	
});