function lf_createSortList(bpid){
		//一级类别
		var isexists=lf_checkExistsSub(bpid);
		document.writeln("<table width='160' border='0' align='center' cellpadding='0' cellspacing='0'>");
		document.writeln("<tr><td class='bluelarge'>");
		if(isexists==1)
			document.writeln("<a href='javascript:void(0);' onclick='javascript:lf_doShow(\"div_"+bpid+"\",false);'>"+lf_getSortName(1,bpid)+" &gt;&gt;</a>");
		else if(PID==bpid)
			document.writeln("<a href='"+WEBROOT+"products.php?pid="+bpid+"'><span class='whitesmall2'>"+lf_getSortName(1,bpid)+" &gt;&gt;</span></a>");
		else
			document.writeln("<a href='"+WEBROOT+"products.php?pid="+bpid+"'>"+lf_getSortName(1,bpid)+" &gt;&gt;</a>");
		
		document.writeln("</td></tr>");
		document.writeln("<tr>"+
                      "<td><table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>"+
                        "<tr>"+
                          "<td height='5'></td>"+
                        "</tr>"+
                      "</table>"+
                        "<table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>"+
                          "<tr>"+
                            "<td height='2' background='"+IMGDIR+"rn022.jpg'></td>"+
                          "</tr>"+
                        "</table>"+
                        "<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>"+
                          "<tr>"+
                            "<td height='5'></td>"+
                          "</tr>"+
                        "</table></td>"+
                    "</tr>");
		document.writeln("</table>");
		
		//二级类别
		if(isexists==1)lf_getSortNameByDepth(2,bpid);
}

function lf_getSortName(depth,pid){
	for(var k in cfg_js_depth[depth]){
		if(cfg_js_depth[depth][k]['id']==pid)return cfg_js_depth[depth][k]['sortname'];
	}
	return "";
}

function lf_getSortNameByDepth(depth,pid){
	//根据depth获取类别
	var dis=in_array(pid,pidArray)?"":"none";
	document.writeln("<div id='div_"+pid+"' style='display:"+dis+";'><table width='160' border='0' align='center' cellpadding='0' cellspacing='0'>");
	for(var k in cfg_js_depth[depth]){
		var cpid=cfg_js_depth[depth][k]['pid'];
		if(cpid==pid){
			var sortid=cfg_js_depth[depth][k]['id'];
			var isexists=lf_checkExistsSub(sortid);
			
			if(isexists==1){
				if(dis=='' && in_array(sortid,pidArray)){
					//若当前为三级类别,则判断二级类别本身是否存在该数组中,若有应展开
					document.writeln("<tr>"+
				                      "<td class='whitesmall2'><img src='"+IMGDIR+"min.jpg' id='imgtb_"+sortid+"'>&nbsp;&nbsp;<a href='javascript:void(0);' class='link2' onclick='javascript:lf_doShow(\"tb_"+sortid+"\",true);'>"+cfg_js_depth[depth][k]['sortname']+"</td>"+
				                    "</tr>");
				}
			    else{
			    	document.writeln("<tr>"+
				                      "<td class='whitesmall2'><img src='"+IMGDIR+"max.jpg' id='imgtb_"+sortid+"'>&nbsp;&nbsp;<a href='javascript:void(0);' class='link2' onclick='javascript:lf_doShow(\"tb_"+sortid+"\",true);'>"+cfg_js_depth[depth][k]['sortname']+"</td>"+
				                    "</tr>");
				    }
			}
		    else{
		    	//判断PID与当前二级类别是否相同
		    	var css=(PID==sortid)?"orangect":"";
		    	document.writeln("<tr>"+
			                      "<td class='whitesmall2'><img src='"+IMGDIR+"min.jpg'>&nbsp;&nbsp;<a href='"+WEBROOT+"products.php?pid="+sortid+"' class='link2'><span class='"+css+"'>"+cfg_js_depth[depth][k]['sortname']+"</span></td>"+
			                    "</tr>");
		    }
		    
		    lf_getSortByPid(sortid);
	    }
    }
    //大类别结束增加一行空行
    document.writeln("<tr><td>&nbsp;</td></tr></table></div>");
}

function lf_doShow(objId,imgChg){
	var showObj=$(objId);
	var ds=showObj.style.display;
	if(ds=='none'){showObj.style.display='';if(imgChg)$("img"+objId).src=IMGDIR+"min.jpg";}
	else{showObj.style.display='none';if(imgChg)$("img"+objId).src=IMGDIR+"max.jpg";}
	
	//showObj.style.display=(ds=='none')?'':'none';
	return;
}

function lf_checkExistsSub(pid){
	if(typeof(cfg_jspid[pid])=='object')return 1;
	else return 0;
}

function lf_getSortByPid(pid){
	
	document.writeln("<tbody id='tb_"+pid+"' style='display:"+(in_array(pid,pidArray)?"":"none")+";'><tr><td><table width='160' border='0' align='center' cellpadding='0' cellspacing='0'>");
	for(var k in cfg_jspid[pid]){
	
	var sortid=cfg_jspid[pid][k]["id"];
	//判断PID与当前三级类别是否相同
	var css=(PID==sortid)?"orange":"";
	document.writeln("<tr>"+
                          "<td class='whitesmall'>&nbsp;&nbsp;<img src='"+IMGDIR+"min.jpg'>&nbsp;&nbsp;<a href='"+WEBROOT+"products.php?pid="+sortid+"' class='link2'><span class='"+css+"'>"+cfg_jspid[pid][k]["sortname"]+"</span></a></td>"+
                        "</tr>");
    }
    document.writeln("</table></td></tr></tbody>");
    
}

function lf_start(){
	for(var k in cfg_jspid[0]){lf_createSortList(cfg_jspid[0][k]['id']);}
}

var pidArray=new Array();
function lf_getParentSortId(sortid){
	if(sortid==0)return 0;
	for(var k in cfg_jspid){
		for(var kk in cfg_jspid[k]){
			if(cfg_jspid[k][kk]["id"]==sortid){
				if(cfg_jspid[k][kk]["pid"]==0)return;
				else{ pidArray.push(cfg_jspid[k][kk]["pid"]);lf_getParentSortId(cfg_jspid[k][kk]["pid"]);}
			}
		}
	}
}
function in_array(v,a){
	for(var k in a)if(a[k]==v)return true;
	return false;
}

function alert_array(a){
	for(var k in a)alert(a[k]);
}


//=====================额外选项=====================
function writeICP(){
	document.writeln("<a href='http://www.miibeian.gov.cn' target='_blank'><span class='bottom'>浙ICP备10014119号</span></a>");
}
function writeCount(){
	//document.writeln("<script src='http://s43.cnzz.com/stat.php?id=797826&web_id=797826' language='JavaScript' charset='gb2312'></script>");
	document.writeln("<script src='http://s66.cnzz.com/stat.php?id=797826&web_id=797826&show=pic' language='JavaScript' charset='gb2312'></script>");
}