function initMenu(){
	var i = 0;
	$('#menu ul').hide();
        if(typeof(urlcate)=='undefined')urlcate = document.location.href;
	($('#menu li a')).each(function(){
		
		if(this.href == urlcate){
			($('#menu li')).removeClass("active");
			$(this).addClass("active");
			$(this).parent().addClass("active");
			if($(this).next().length>0){
				$(this).next().show();
			}
//			return false;
		}
		var checkElement = $(this).next();
		if(checkElement.is('ul')) {
			($(checkElement).children()).each(function(){
				temp = $(this).children()[0];
		
				if(temp.href == urlcate){
					($(temp).parent()).parent().show();
                                        ($(temp).parent()).parent().prev().addClass("active");
					if($(temp).next().length>0){
						$(temp).next().show();
					}
				}
			});
		}
	});
	
	
	
	$('#menu li a').click(function(){
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
//			$(this).dblclick(function(){
				document.location.href = this.href;
//			})
			return false;
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#menu ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
//			$(this).dblclick(function(){
//				document.location.href = this.href;
//			})
			return false;
        }
		document.location.href = this.href;
	});

	
}
$(document).ready(function() {initMenu();});
