
function leftNav(where, data) {
	var where = where;
	var menu = "";
	var html = "";
	var defaultmenu = {
		name: '', //名字
		level:'0',//第几级
		haschildren: true, //是否有子节点
		url: '#', //url路径
		isopen: false, //是否展开
		children: [{ //子节点
			name: '1',
			level: '1',
			haschildren: true,
			url: '',
			isopen: true,
			children: [{
				name: '1.1',
				level: '2',
				haschildren: true,
				url: '',
				isopen: true,
				children: [{
					name: '1.1.1',
					level: '3',
					haschildren: false,
					url: './14-1.html',
					isopen: true,
					children: ''
				}]
			}]
		}]
	};
	var here = $("body").find(where);
	if(!here.length) {
		where = "body";
	}
	if(data) {
		menu = data;
	} else {
		menu = defaultmenu;
	}
	$(where).append('<div class="nav_box"><ul class="nav"></ul></div>');
	sidebarNav(menu);
	function sidebarNav(data) {
		html += '<li class="left_nav_list">';
		html += '<div class="left_nav_name level' + data.level;
		html += '" data-id = ' + data.id + '><em>' + data.classificationName + '</em></div>';
		if(data.children!=[]) {
			html += '<ul class="nav_ul">';
			for(var i = 0, l = data.children.length; i < l; i++) {
				var children = data.children[i];
				if(children.children.length>0) {
					sidebarNav(children);
				} else {
					html += '<li class="nav_li" data-id=' + children.id;
					html +=	'>';
					html += '<em>' + children.classificationName + '</em>';
					html += '</li>';
				}
			}
			html += '</ul>';
		}
		html += '</li>';
	}
	$(where + " .nav").html('<div class="left_nav_name noBefore" data-id=""><em>全部项目</em></div>'+html);
	$(where + " .left_nav_name").on("click", function() {
		var open = $(this).hasClass("nav_open");
		var id = $(this).attr("data-id");
		$(where + " .nav_li").removeClass("nav_li_open");
		$(where + " .left_nav_name").removeClass("nav_open");
		if(open) {
			$(this).removeClass("nav_open");
			$(this).removeClass("nav-move");
			searchType("");
			$(this).next(".nav_ul").slideUp();
		} else {
			$(this).addClass("nav_open");
			$(this).next(".nav_ul").slideDown();
			$(this).parents(".left_nav_list").siblings("li").find(".nav_ul").slideUp();
			$(this).parents(".left_nav_list").siblings("li").find(".left_nav_name").removeClass("nav_open");
			searchType(id);
		}
	})
	$(where + " .nav_li").on("click", function() {
		$(where + " .nav_li").removeClass("nav_li_open");
		// $(where + " .left_nav_name").removeClass("nav_open");
		$(this).addClass("nav_li_open");
		$(this).parents(".nav_ul").siblings(".left_nav_name").addClass("nav-move");
		$(this).siblings(".left_nav_list").find(".nav_ul").slideUp();
		$(this).siblings(".left_nav_list").find(".left_nav_name").removeClass("nav_open");
		var id = $(this).attr("data-id");
		searchType(id);
	})
}