function startclass_page(depths, ldiv, selname) { // start select
         for (i = 0; i <= depths; i++) {
             var ndiv = newdiv_page(i, "seldiv_" + selname); //create seldiv
               var selid = selname + i;
               var se = document.createElement("select"); //create  select
               se.name = selid;
               se.id = selid;
               opt_page(se, "\u8bf7\u9009\u62e9", "", 0, "");
               var object = ndiv.appendChild(se);
               ldiv.appendChild(ndiv); 
         } 
    }

    function loadclass_page(depth, pid, nowid, depths, fileurl, classpath, selname) {
    /*
     //五个参数：当前深度,参数父id,当前选中的id(0为未选中),liveclass层,文件url,class路径
         //se.options[0] = new Option("请选择", "");
        //data start
        */
        var selid = selname + depth;
        var se = document.getElementById(selid);  // get select
        for (i = depth; i <= depths; i++) {
            var sel = document.getElementById(selname + i);
            sel.options.length = 0;
            opt_page(sel, "\u8bf7\u9009\u62e9", "", 0, ""); //option
        }
        Optionadd_page(pid, se, nowid, fileurl)
        //data finsih    
        //se.size = "2";
        if (depth<depths)
        {
            depth++;            
            //load have class
            var nowid2 = getclassid_page(depth, classpath)
            if (nowid2 > 0)
                loadclass_page(depth, nowid, nowid2, depths, fileurl, classpath, selname);
            //load have finish

        } 
    }

    function Selectchange_page(depths, fileurl, selname) {
        var selid = "";
        var sid = "";
        var n = 0;
        var sel = "";
        for (k = 0; k <= depths; k++) {
            selid = selname + k;
			if (k < depths) {
			    $("#" + selid).change(function () {

					var psortid = this.options[this.selectedIndex].getAttribute("title");
					if (psortid != "")
						$("#" + number_id).val(psortid);  //auto fill
						sid = this.id;
						n = sid.substring(selname.length, sid.length);
						n++;
						for (j = n; j <= depths; j++) {
							sel = document.getElementById(selname + j);
							sel.options.length = 0;
							opt_page(sel, "\u8bf7\u9009\u62e9", "", 0, ""); //opt--------opt
						}
						var tempv = this.options[this.selectedIndex].value;
						if (tempv != "") 
							loadclass_page(n, tempv, 0, depths, fileurl, "", selname); //classpath is ""
			   });
		   }
		   else
		   {
		       $("#" + selid).change(function () {//auto fill
				  var psortid = this.options[this.selectedIndex].getAttribute("title");
				  if (psortid != "")
					  $("#" + number_id).val(psortid);  
			   });
		   }//if (k < depths) 
        } //for  
    }

    function Optionadd_page(pid, sel, nowid, fileurl) { 
    /*
     //pid父类id ,sel,nowid现在正在的nowid----创建多个option
     */
        //start class
        $.ajax({
            type: "POST",
            url: fileurl, //
            dataType: "json",
            data: { "p": "" + pid + "" },  
            success: function(json) {
                if (json != 0) {
                    var issel = 0;
                    for (i = 0; i < json.classtable.length; i++) {  
                        issel = 0
                        if (json.classtable[i].id == nowid) {
                            issel = 1;
                        }
                        opt_page(sel, json.classtable[i].classname, json.classtable[i].id, issel, json.classtable[i].sortid); //opt--------opt
                    }
                }

            }, error: function (json) {
               // alert("error-$.ajax" + json); 
            }
        });
        //class finish 
    }
   
   
   //create one option
    function opt_page(sel, txt, value, issel,psortid) {  //opt--------opt
        var op = document.createElement("option");
        op.value = value;
        op.text = txt;
        op.setAttribute('title', psortid);
        if (issel == 1) {
            op.setAttribute("selected", "selected");            
        }
        sel.options.add(op);
    }

    //create div 
    function newdiv_page(i, divname) {
        var ndiv = document.createElement("div");
        ndiv.id = divname + i;
        ndiv.className = divname;
        ndiv.setAttribute("name", divname + i);
        return ndiv;
    }

    function getclassid_page(depth, classpath) {
    /*
        //depth当前深度,class路径
        */

        var id = 0;
        var p = classpath.split(',');
        if (p.length>0)
            id = p[depth];
        return id;
    }
	
	 /* 
	  原创：郝海波 www.53bk.com QQ:28094735
	  ndiv.style.border = '1px solid #DDD';
      var newText = document.createTextNode('这是新建立div中的文字。');
      ndiv.appendChild(newText);
	  appendChild() 方法在节点的子节点列表末添加新的子节点。
　　  insertBefore() 方法在节点的子节点列表任意位置插入新的节点。
　　  l.insertBefore(ndiv1,ndiv2);　　插入ndiv1;
　　  l.removeChild(div1);
　    */