function stopBubble(e) {
	if (e && e.stopPropagation ) e.stopPropagation();
	else window.event.cancelBubble = true;
}
	
$(document).ready(function() {
	
	// check if the nav-main was loaded
	var getNav = function() {
		if ( $('#cat_725312_divs').size()  ) return true;
		return false;
	};
	
	var timer = setInterval( function() {
		if ( getNav() ) {
			clearInterval(timer);
			onload();			
		}
	}, 100);
	
	// load finish
	var onload = function() {
		
		var $_nav = $('#cat_725312_divs');
		
		// set all the same level li has the same max width with its parent
		$_nav.find('ul ul').each(function() {
			var _this = $(this);
			var maxM = 0;
			
			// fix visibility bug for ie6,ie7
			_this.addClass('vis');
			
			// find the max width
			_this.find(' > li').each(function() {
				maxM = Math.max(maxM, $(this).find(' > a').text().length);
				//alert(maxM);
			});
			// set the width
			maxM = (maxM * 10 > 60) ? maxM * 10 + 12 : 60 + 12;
			//alert(maxM);
			_this.width(maxM);
			_this.find('li').width(maxM);
			//_this.css('left',maxM);
			_this.css('left','0');
			/*if(_this.width() == '242')
			{
				_this.css('left','0');
			}
			else if(_this.width() == '172')
			{
				_this.css('left','242');
			}*/
		});
		
		// set the sub-level's position
		$_nav.find('ul li ul li').each(function() {
			var _this = $(this);
			var ul = _this.find(' > ul');
			var maxwidth = _this.width();
			// set left position
			//if ( ul.size() ) ul.css({'left': maxwidth + 'px'});
			//alert(ul.size());
			if ( ul.size() ) ul.css({'left': maxwidth + 'px'});
		});
		
		setTimeout(function() {
			$('#cat_725312_divs ul ul').removeClass('vis').hide();
		}, 300)
		
		// hover
		$_nav.find('li').hover(function() {
			$(this).find(' > ul').show();
		}, function() {
			$(this).find('ul').hide();
		});
	};
	
});
