
	var currentElement;
	
	function showNav(html,x,y) {
		cattheme = jQuery('#cattheme').text();	
		jQuery('#drop-nav').html('<ul>' + html + '</ul>');
		jQuery('#drop-nav').show();
		jQuery('#drop-nav').css({left: x + 1, top: y -1});
		jQuery('#drop-nav a').addClass('text' +cattheme);	
		jQuery('#drop-nav ul li').addClass('text' +cattheme);	
		clearTimeout(navTimer);
		jQuery('#drop-nav a').hover(
			function () {
				clearTimeout(navTimer);
  			},
			function () {
				navTimer = setTimeout("hideNav()",800);
  			}
		);		
	}
	
	function hideNav() {
		jQuery('#drop-nav').hide();
		jQuery(currentElement).removeClass('tophover');
	}
	
	function getCssValue(e,prop) {
		 num = parseInt(jQuery(e).css(prop), 10);
		 if (isNaN(num)) return 0;
		 
		 return num;
	}
	
	var navTimer;
	jQuery(document).ready(function() {
		jQuery('#top-nav a.top').hover(
			function () {
				clearTimeout(navTimer);			
				jQuery('#top-nav a.top').removeClass('tophover');
				currentElement = jQuery(this);
				jQuery(this).addClass('tophover');
				var offset = jQuery(this).offset();
				/*
				totalWidth = jQuery(this).width();
				totalWidth += getCssValue(this,"paddingLeft");
				totalWidth += getCssValue(this,"paddingRight");
				totalWidth += getCssValue(this,"marginLeft");
				totalWidth += getCssValue(this,"marginRight");	
				*/
				totalHeight = jQuery(this).height();
				jQuery('#drop-nav').css({width: jQuery(this).width() + 'px'});
				totalHeight += getCssValue(this,"paddingTop");
				totalHeight += getCssValue(this,"paddingBottom");
				totalHeight += getCssValue(this,"marginTop");
				totalHeight += getCssValue(this,"marginBottom");					
				showNav(jQuery(this).parent().find('ul').html(),offset.left,offset.top + totalHeight);
  			},
			function () {
				navTimer = setTimeout("hideNav()",800);
  			}
		);
	});

