function startclass(f,b,d){for(i=0;i<=f;i++){var g=newdiv(i,"seldiv_"+d);var e=d+i;var c=document.createElement("select");c.name=e;c.id=e;opt(c,"\u8bf7\u9009\u62e9","",0);var a=g.appendChild(c);b.appendChild(g)}}function loadclass(d,f,e,h,l,b,n){var c=n+d;var g=document.getElementById(c);for(i=d;i<=h;i++){var a=document.getElementById(n+i);a.options.length=0;opt(a,"\u8bf7\u9009\u62e9","",0)}Optionadd(f,g,e,l);if(d<h){d++;var m=getclassid(d,b);if(m>0){loadclass(d,e,m,h,l,b,n)}}}function Selectchange(f,b,d){var e="";var a="";var g=0;var c="";for(k=0;k<=f;k++){e=d+k;if(k<f){$("#"+e).change(function(){a=this.id;g=a.substring(d.length,a.length);g++;for(j=g;j<=f;j++){c=document.getElementById(d+j);c.options.length=0;opt(c,"\u8bf7\u9009\u62e9","",0)}var h=this.options[this.selectedIndex].value;if(h!=""){loadclass(g,h,0,f,b,"",d)}})}}}function Optionadd(a,d,b,c){$.ajax({type:"POST",url:c,dataType:"json",data:{p:""+a+""},success:function(e){if(e!=0){var f=0;for(i=0;i<e.classtable.length;i++){f=0;if(e.classtable[i].id==b){f=1}opt(d,e.classtable[i].classname,e.classtable[i].id,f)}}},error:function(e){}})}function opt(d,a,c,b){var e=document.createElement("option");e.value=c;e.text=a;if(b==1){e.setAttribute("selected","selected")}d.options.add(e)}function newdiv(a,c){var b=document.createElement("div");b.id=c+a;b.className=c;b.setAttribute("name",c+a);return b}function getclassid(c,a){var d=0;var b=a.split(",");if(b.length>0){d=b[c]}return d};