var managmenu=(function(){
	var hal=0;
	var jumlah=30;
	var idmenu=0;
	var namaicon="";
	var idicon=0;
	var totalsub=new Object;
	var submodule=null;
	var tautanmod="";
	var boxkonten=null;
	var boxeditsub=null;
	var idkonten=0;
	var jumlahaksesmenu=new Object;
	var jumlahaksessubmenu=new Object;
	return{
		caricanggih:function(){
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"datacari01",1:1}
			};
			
			$.ajax({url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					if(e!=false){
						var boxcari;
						var obj=new Object;
						obj.proses=function(a){
							$("#cari").val(a);
							boxcari.tutup();
							document.getElementById("btcari").click();
						};
						var datacari={"data":e,"proses":obj}
						boxcari=caricanggih.buka(datacari);
					}
				}
			});
		},
		enter:function(e){
			if(e.which == 13 || e.keyCode == 13){
				managmenu.loade();
			}
		},
		loade:function(){
			$("#hal_ke").val(0);
			managmenu.load();
		},
		load:function(){
			var nohal=$("#hal_ke").val()
			jumlah=$("#jumlah_hal").val();
			hal=(nohal-1)*jumlah;
			var cr=$("#cari").val();
			
			$("#grid_managmenu").html("");
			var loaderdata=mload.loading({"el":"loader_data_menu"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:"getTabel",1:hal,2:jumlah,3:cr}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					loaderdata.tutup();
					//alert(JSON.stringify(e));
					if(e!=false){
						
						if(e.length>0 && e[0]['halaman']>0){
							var htm;
							for(var i=0;i<e[0]['halaman'];i++){
								htm+="<option value='"+(i+1)+"'>"+(i+1)+"</option>";
							}
							$("#hal_ke").html(htm);
							
						}
						$("#hal_ke").val(nohal);
						
						var datatb={
							box:"grid_managmenu",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":hal,"jumlah":jumlah},
									{"col":"jenis","judul":"Jenis","tipe":"data","lebar":"140px"},
									{"col":"menu","judul":"Nama Menu","tipe":"data"},
									//{"judul":"Tautan Module","tipe":"tpl","tpl":"bttautan","lebar":"140px"},
									{"judul":"Urutan","tipe":"tpl","tpl":"bturutan","lebar":"40px","align":"center"},
									{"col":"nama_awal","judul":"Icon","tipe":"data","lebar":"140px"},
									{"align":"center","judul":"Akses","tipe":"tpl","tpl":"btakses","lebar":"60px"},
									//{"align":"center","judul":"Akses Sub","tipe":"tpl","tpl":"btaksessublevel","lebar":"60px"},
									{"align":"center","judul":"Sub Menu","tipe":"tpl","tpl":"btsub","lebar":"50px"},
									{"align":"center","judul":"Status","tipe":"tpl","tpl":"btstatus","lebar":"60px"},
									{"align":"center","judul":"","tipe":"tpl","tpl":"btedit","lebar":"70px"}
									
								],
							mod:"mod",
							module:"managmenu"
						};
						tabel.multisub(datatb);
					}
				}
			});
		},
		
		loade:function(){
			$("#hal_ke").val(0);
			managmenu.load();
		},
		buat:function(a){
			document.location=lokal+"member/mod/managmenu?id="+a+"&scrmenu="+modmenu.getmenuscr();
		},
		kembali:function(){
			document.location=lokal+"member/mod/managmenu?scrmenu="+modmenu.getmenuscr();
		},
		edit:function(a,b,c,d){
			idmenu=a['id'];
			$("#sl_level").val(a['level']);
			$("#sl_kategorimenu").val(a['idjenis']);
			idkonten=a['idkonten'];
			idicon=a['idicon'];
			tautanmod=a['tautan'];
			
			var namalama=a['namalama'];
			var namabaru=a['namabaru'];
			var folder=a['folder'];
			
			var prev="tidak";
			if(idicon>0){
				prev="ya";
			}
			upload.tambahupload("upload_icon",managmenu.objuploadicon(namalama,prev));
			
			managmenu.katch(a['jenistautan']);
		},
		katch:function(a){
			var jenistautan=a || "module";
			var kat=$("#sl_kategorimenu").val();
			var htm="";
			if(kat==1){
				htm="<option value=\"module\">Module</option>";
			}else{
				htm="<option value=\"halaman\">Halaman</option>";
				htm+="<option value=\"katkonten\">Kategori Konten</option>";
				htm+="<option value=\"konten\">Konten</option>";
				htm+="<option value=\"url\">URL</option>";
			}
			
			$("#sl_jenistautan").html(htm);
			$("#sl_jenistautan").val(jenistautan);
			managmenu.jenistautanch();
		},
		jenistautanch:function(){
			var jenistautan=$("#sl_jenistautan").val();
			$("#boxtautanurl").hide();
			$("#boxtautankonten").hide();
			$("#boxsltautan").show();
			if(jenistautan=="url"){
				$("#boxtautanurl").show();
				$("#boxsltautan").hide();
				$("#boxtautankonten").hide();
			}else if(jenistautan=="konten"){
				$("#boxtautanurl").hide();
				$("#boxsltautan").hide();
				$("#boxtautankonten").show();
			}else{
				managmenu.gettautan();
			}
		},
		gettautan:function(){
			var jenistautan=$("#sl_jenistautan").val();
			var level=$("#sl_level").val();
			var htm="<option value='#'>None</option>";
			$("#sl_tautan").html(htm);
			var fg="";
			if(jenistautan=="halaman"){
				fg="getdatahalaman";
			}else if(jenistautan=="module"){
				fg="getdatamodule";
			}else if(jenistautan=="katkonten"){
				fg="getdatakategori";
			}
			if(fg=="") return;
			
			mload.sh();
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:fg,"level":level,"jenistautan":jenistautan}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					mload.hd();
					if(e!=false && e.length>0){
						for(var i=0;i<e.length;i++){
							var namat="";
							var kodet="";
							if(jenistautan=="halaman"){
								namat=e[i]['nama'];
								kodet=e[i]['halaman'];
							}else if(jenistautan=="module"){
								namat=e[i]['nama'];
								kodet=e[i]['module'];
							}else if(jenistautan=="katkonten"){
								namat=e[i]['nama'];
								kodet=e[i]['id'];
							}
							htm+="<option value='"+kodet+"'>"+namat+"</option>";
						}
						
						$("#sl_tautan").html(htm);
						$("#sl_tautan").val(tautanmod);
					}
				}
			});
		},
		simpan:function(){
			var lv=$("#sl_level").val();
			var idjenis=$("#sl_kategorimenu").val();
			var nm=$("#nama").val();
			var jenistautan=$("#sl_jenistautan").val();
			
			var tt=$("#sl_tautan").val();
			if(jenistautan=="url") tt=$("#tautanurl").val();
			if(jenistautan!="konten") idkonten=0;
			
			var err="";
			if(nm=="") err.push({"pesan":"Nama Menu belum diisi."});
			if(jenistautan!="konten" && tt=="") err.push({"pesan":"Tautan Menu belum diisi."});
			if(jenistautan=="konten" && idkonten<=0) err.push({"pesan":"Tautan Konten Menu belum dipilih."});
			if(err!=""){
				var ps={"title":"Peringatan","pesan":err};
				boxpesan.peringatan(ps);
				return;
			}
			var fg="inputmanagmenu";
			if(idmenu>0){
				fg="editmanagmenu";
			}
			var loadersimpan=mload.loader({"keterangan":"Proses menyimpan data.."});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:fg,level:lv,nama:nm,
					tautan:tt,
					idicon:idicon,
					idjenis:idjenis,
					jenistautan:jenistautan,
					idkonten:idkonten,
					id:idmenu}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					if(e!=false){
						managmenu.kembali();
					}else{
						loadersimpan.error([{"pesan":"Terjadi kesalahan menyimpan data!"}]);
					}
				}
			});
		},
		hapus:function(a){
			if(a<=0) return;
			var ps={"pesan":"Yakin akan menghapus menu ini ??",
					"title":"Peringatan Hapus data"};
				
			var boxyesno=boxpesan.yesno(ps);
			boxyesno.proses.onclick=function(){
				
				var loaderhapus=mload.loader({"keterangan":"Proses menghapus data.."});
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "managmenu",
					ikdata: {0:"hapusData","id":a}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",
					type: "POST",
					dataType: "json",
					async:true,
					data: ik_data,
					success: function(e){
						
						if(e!=false){
							loaderhapus.tutup();
							boxyesno.tutup();
							managmenu.load();
						}else{
							loadersimpan.error([{"pesan":"Terjadi kesalahan menghapus data!"}]);
						}
					}
				});
			}
		},
		setstatus:function(a,b,c,d){
			var st=1;
			if(tabel.gettabel(b).getdata(c,"status")==1){
				st=0;
			}
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"setStatus",status:st,id:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					//alert(JSON.stringify(e));
					if(e!=false){
						d.className="mini_dis";
						if(st==1){
							d.className="mini_ok";
						}
						tabel.gettabel(b).setdata(c,"status",st);
					}
				}
			});
		},
		
		seturutan:function(a,b){
			var ps={"lebar":"200px","box":"box_urutan","title":"Pengaturan urutan"};
			var boxurutan=boxpesan.win(ps);
			$("#urutan_sub").val(b);
			document.getElementById("bt_tutup_urutan").onclick=function(){
				boxurutan.tutup();
			};
			
			document.getElementById("bt_simpan_urutan").onclick=function(){
				
				var urutan=$("#urutan_sub").val();
				mload.sh();
				var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
					ikdata: {0:"setUrutan",1:urutan,2:a}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
					success: function(e){
						
						mload.hd();
						//alert(JSON.stringify(e));
						if(e!=false){
							managmenu.load();
							boxurutan.tutup();
						}
					}
				});
			};
		},
		bukasub:function(a,b,c,d){
			var idtb=b+"_"+c;
			
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>SUB MENU</b></div>";
			htm+="<div id='grid_sub_"+idtb+"'></div>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="<span class='bthijau medium' id='bt_inputsub_"+idtb+"'>TAMBAH SUB MENU</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			
			var urutan=1;
			
			document.getElementById("bt_inputsub_"+idtb).onclick=function(){
				var ps={"box":"box_edit_sub",
						"title":"Input Sub menu","tinggimax":"fit"};
					
				boxeditsub=boxpesan.win(ps);
				boxeditsub.mode=0;
				boxeditsub.idmenu=a;
				boxeditsub.id=0;
				boxeditsub.tabel=b;
				boxeditsub.baris=c;
				boxeditsub.el=d;
				boxeditsub.idsub=0;
				boxeditsub.idkonten=0;
				
				$("#nama").val("");
				$("#sl_level").val(0);
				
				$("#sl_tautan").val(0);
				$("#urutan").val(urutan);
				$("#sl_tautan").val(0);
				$("#sl_kategorimenu").val(tabel.gettabel(b).getdata(c,"idjenis"));
				
				managmenu.katch();
				
			};
			
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"getSub",1:a}};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					
					
					if(e!=false && e.length>0){
						var dataisi=[
							{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
							{"col":"sub_menu","judul":"Nama Menu","tipe":"data"},
							{"judul":"Tautan Module","tipe":"tpl","tpl":"bttautansub","lebar":"140px"},
							{"judul":"Urutan","tipe":"tpl","tpl":"bturutansub","lebar":"80px","align":"center"},
							{"align":"center","judul":"Akses","tipe":"tpl","tpl":"btaksessub","lebar":"60px"},
						];
						if(tabel.gettabel(b).getdata(c,"idjenis")==2){
							dataisi.push({"align":"center","judul":"Sub","tipe":"tpl","tpl":"btjumlahsubsub","lebar":"60px"});
						}
						dataisi.push({"align":"center","judul":"Status","tipe":"tpl","tpl":"btstatussub","lebar":"60px"});
						dataisi.push({"align":"center","judul":"","tipe":"tpl","tpl":"bteditsub","lebar":"60px"});
						urutan=e.length+1;
						var datatb={
							box:"grid_sub_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:dataisi,
							mod:"mod",
							module:"managmenu"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_sub_"+idtb).html("TIDAK MEMPUNYAI SUB MENU");
					}
					
				}
			});
		},
		
		batalsubmenu:function(){
			if(boxeditsub!=null) boxeditsub.tutup();
			boxeditsub=null;
		},
		editdsub:function(a,b,c,d){
			
			var ps={"box":"box_edit_sub",
					"title":"Edit Sub menu","tinggimax":"fit"};
			
			var tbpar=tabel.gettabel(b).parrent;
			var el=document.getElementById("btsub_"+tbpar.tabel+"_"+tbpar.baris);
			var idk=0;
			if(tabel.gettabel(b).getdata(c,"jenistautan")=="konten") idk=tabel.gettabel(b).getdata(c,"tautan");	
			boxeditsub=boxpesan.win(ps);
			boxeditsub.mode=0;
			boxeditsub.idmenu=tabel.gettabel(b).getdata(c,"idmenu");
			boxeditsub.id=a;
			boxeditsub.idsub=0;
			boxeditsub.tabel=tbpar.tabel;
			boxeditsub.baris=tbpar.baris;
			boxeditsub.el=el;
			boxeditsub.idkonten=idk;
			
			tautanmod=tabel.gettabel(b).getdata(c,"tautan");
			
			$("#nama").val(tabel.gettabel(b).getdata(c,"sub_menu"));
			$("#sl_level").val(tabel.gettabel(b).getdata(c,"level"));
			
			$("#sl_tautan").val(0);
			$("#urutan").val(tabel.gettabel(b).getdata(c,"urutan"));
			$("#sl_tautan").val(0);
			$("#sl_kategorimenu").val(tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"idjenis"));
			
			var jenistautan=tabel.gettabel(b).getdata(c,"jenistautan");
			if(jenistautan=="konten"){
				$("#tautankonten").val(tabel.gettabel(b).getdata(c,"judulkonten"));
			}
			managmenu.katch(jenistautan);
		},
		simpansubmenu:function(){
			var nm=$("#nama").val();
			var tt=$("#sl_tautan").val();
			var url=$("#tautanurl").val();
			var idjenis=$("#sl_jenistautan").val();
			var lv=$("#sl_level").val();
			var ur=$("#urutan").val();
			if(idjenis!="konten") boxeditsub.idkonten=0;
			
			var err="";
			if(nm=="") err+="Nama Sub menu belum diisi.</br>";
			if(idjenis=="konten" && boxeditsub.idkonten<=0) err+="Tautan konten sub menu belum dipilih.</br>";
			if(err!=""){
				var ps={"title":"Peringatan","pesan":err};
				boxpesan.peringatan(ps);
				return;
			}
			var fg="";
			if(boxeditsub.mode==0){
				fg="inputmanagsubmenu";
				if(boxeditsub.id>0){
					fg="editmanagsubmenu";
				}
			}else if(boxeditsub.mode==1){
				fg="inputmanagsubsubmenu";
				if(boxeditsub.id>0){
					fg="editmanagsubsubmenu";
				}
			}
			
			mload.sh("box_loader_submenu");
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:fg,
					level:lv,
					nama:nm,
					tautan:tt,
					idkonten:boxeditsub.idkonten,
					idmenu:boxeditsub.idmenu,
					idjenis:idjenis,
					urutan:ur,
					idsub:boxeditsub.idsub,
					url:url,
					id:boxeditsub.id}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					mload.hd();
					if(e==1){
						if(boxeditsub.mode==0){
							if(boxeditsub.id<=0){
								var jumlah=parseInt(tabel.gettabel(boxeditsub.tabel).getdata(boxeditsub.baris,"jumlahsub"))+1;
								boxeditsub.el.innerHTML=jumlah;
								tabel.gettabel(boxeditsub.tabel).setdata(boxeditsub.baris,"jumlahsub",jumlah);
							}
							managmenu.bukasub(boxeditsub.idmenu,boxeditsub.tabel,boxeditsub.baris,boxeditsub.el);
							managmenu.batalsubmenu();
						}else if(boxeditsub.mode==1){
							if(boxeditsub.id<=0){
								var jumlah=parseInt(tabel.gettabel(boxeditsub.tabel).getdata(boxeditsub.baris,"jumlah_sub_sub"))+1;
								boxeditsub.el.innerHTML=jumlah;
								tabel.gettabel(boxeditsub.tabel).setdata(boxeditsub.baris,"jumlah_sub_sub",jumlah);
							}
							managmenu.bukasubsub(boxeditsub.idsub,boxeditsub.tabel,boxeditsub.baris,boxeditsub.el);
							managmenu.batalsubmenu();
						}
						
					}
				}
			});
		},
		statussub:function(a,b,c,d){
			var tbl=tabel.gettabel(b);
			var st=1;
			if(parseInt(tbl.getdata(c,"status"))==1){
				st=0;
			}
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"setStatussub",1:st,2:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					//alert(JSON.stringify(e));
					if(e==1){
						var parr=tbl.parrent;
						var idmenu=tbl.getdata(c,"idmenu");
						var el=document.getElementById("btsub_"+parr.tabel+"_"+parr.baris);
						managmenu.bukasub(idmenu,parr.tabel,parr.baris,el);
					}
				}
			});
		},
		seturutasub:function(a,b,c,d){
			var tbl=tabel.gettabel(b);
			var parr=tbl.parrent;
			var ur=tbl.getdata(c,"urutan");
			
			var ps={"lebar":"200px","box":"box_urutan","title":"Pengaturan urutan Sub menu"};
			var boxurutan=boxpesan.win(ps);
			$("#urutan_sub").val(ur);
			document.getElementById("bt_tutup_urutan").onclick=function(){
				boxurutan.tutup();
			};
			
			document.getElementById("bt_simpan_urutan").onclick=function(){
				
				var urutan=$("#urutan_sub").val();
				mload.sh();
				var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
					ikdata: {0:"setUrutansub",1:urutan,2:a}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
					success: function(e){
						
						mload.hd();
						//alert(JSON.stringify(e));
						if(e!=false){
							var idmenu=tbl.getdata(c,"idmenu");
							var el=document.getElementById("btsub_"+parr.tabel+"_"+parr.baris);
							managmenu.bukasub(idmenu,parr.tabel,parr.baris,el);
							boxurutan.tutup();
						}
					}
				});
			};
		},
		
		hapussub:function(a,b,c,d){
			if(a<=0) return;
			var ps={"pesan":"Yakin akan menghapus Sub menu ini ??",
					"title":"Peringatan Hapus data"};
				
			var boxyesno=boxpesan.yesno(ps);
			boxyesno.proses.onclick=function(){
				var parr=tabel.gettabel(b).parrent;
				var idtb=parr.tabel+"_"+parr.baris;
				
				var idmenu=tabel.gettabel(b).getdata(c,"idmenu");
				mload.sh();
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "managmenu",
					ikdata: {0:"hapusSubmenu",1:a}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",
					type: "POST",
					dataType: "json",
					async:true,
					data: ik_data,
					success: function(e){
						mload.hd();
						if(e==1){
							boxyesno.tutup();
							totalsub[idtb]=totalsub[idtb]-1;
							var el=document.getElementById("btsub_"+parr.tabel+"_"+parr.baris);
							el.innerHTML=totalsub[idtb];
							
							managmenu.bukasub(idmenu,parr.tabel,parr.baris,el);
							
						}else{
							boxpesan.err(e);
						}
					}
				});
			}
		},
		bukamenuakses:function(a,b,c,d){
			var idtb=b+"_"+c;
			if(jumlahaksesmenu[idtb]==null){
				jumlahaksesmenu[idtb]=parseInt(tabel.gettabel(b).getdata(c,"jumlah_akses"));
			}
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>MENU AKSES</b></div>";
			htm+="<div id='grid_sub_"+idtb+"'></div>";
			
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			
			mload.sh();
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:"getMenuakses",1:a,2:tabel.gettabel(b).getdata(c,"level")}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					mload.hd();
					if(e!=false && e.length>0){
						
						var datatb={
							box:"grid_sub_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
									{"col":"nama","judul":"Level","tipe":"data"},
									{"align":"center","judul":"Akses","tipe":"tpl","tpl":"btstatusmenu","lebar":"60px"}
								],
							mod:"mod",
							module:"managmenu"
						};
						tabel.multisub(datatb);
					}
				}
			});
			
		},
		setaksesmenu:function(a,b,c){
			var tbpar=tabel.gettabel(b).parrent;
			var idmenu=tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"id");
			var status=tabel.gettabel(b).getdata(c,"status");
			var st=1;
			if(status==1){
				st=0;
			}
			
			mload.sh();
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:"setmenuakses",status:st,idmenu:idmenu,idlevel:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					mload.hd();
					if(e==1){
						var idtb=tbpar.tabel+"_"+tbpar.baris;
						var el=document.getElementById("btstatusmenu_"+b+"_"+c);
						if(st==1){
							jumlahaksesmenu[idtb]=jumlahaksesmenu[idtb]+1;
							el.className="mini_ok";
						}else{
							jumlahaksesmenu[idtb]=jumlahaksesmenu[idtb]-1;
							el.className="mini_dis";
						}
						var elj=document.getElementById("btakses_"+idtb);
						elj.innerHTML=jumlahaksesmenu[idtb];
						tabel.gettabel(b).setdata(c,"status",st);
					}
				}
			});
		},
		bukasubakses:function(a,b,c,d){
			var idtb=b+"_"+c;
			if(jumlahaksessubmenu[idtb]==null){
				jumlahaksessubmenu[idtb]=parseInt(tabel.gettabel(b).getdata(c,"jumlah_akses"));
			}
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>SUB MENU AKSES</b></div>";
			htm+="<div id='grid_sub_"+idtb+"'></div>";
			
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			var lv=tabel.gettabel(b).getdata(c,"level");
			mload.sh();
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:"getsubMenuakses",1:a,2:lv}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					mload.hd();
					if(e!=false && e.length>0){
						
						var datatb={
							box:"grid_sub_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
									{"col":"nama","judul":"Level","tipe":"data"},
									{"align":"center","judul":"Akses","tipe":"tpl","tpl":"btstatussubmenu","lebar":"60px"}
								],
							mod:"mod",
							module:"managmenu"
						};
						tabel.multisub(datatb);
					}
				}
			});
		},
		setaksessubmenu:function(a,b,c){
			var tbpar=tabel.gettabel(b).parrent;
			var idsubmenu=tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"id");
			var status=tabel.gettabel(b).getdata(c,"status");
			var st=1;
			if(status==1){
				st=0;
			}
			
			mload.sh();
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "managmenu",
				ikdata: {0:"setsubmenuakses",status:st,idsubmenu:idsubmenu,idlevel:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					mload.hd();
					if(e==1){
						var idtb=tbpar.tabel+"_"+tbpar.baris;
						var el=document.getElementById("btstatussubmenu_"+b+"_"+c);
						if(st==1){
							jumlahaksessubmenu[idtb]=jumlahaksessubmenu[idtb]+1;
							el.className="mini_ok";
						}else{
							jumlahaksessubmenu[idtb]=jumlahaksessubmenu[idtb]-1;
							el.className="mini_dis";
						}
						var elj=document.getElementById("btaksessub_"+idtb);
						elj.innerHTML=jumlahaksessubmenu[idtb];
						tabel.gettabel(b).setdata(c,"status",st);
					}
				}
			});
		},
		loadaksessub:function(a,b,c,d){
			var idtb=b+"_"+c;
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>MENU SUB LEVEL AKSES</b></div>";
			htm+="<div id='grid_subakses_"+idtb+"'></div>";
			
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah btnclose' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"getaksessub",id:a}};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					
					
					if(e!=false && e.length>0){
						
						var datatb={
							box:"grid_subakses_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
									{"col":"namalevel","judul":"Level","tipe":"data","lebar":"150px"},
									{"col":"namasublevel","judul":"Sub","tipe":"data"},
									{"judul":"Akses","tipe":"tpl","tpl":"btlevelsubstatus","lebar":"50px","align":"center"}
								],
							mod:"mod",
							module:"moduleakses"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_akses_"+idtb).html("TIDAK ADA LEVEL");
					}
				}
			});
		},
		setaksessub:function(a,b,c,d){
			var st=1;
			if(tabel.gettabel(b).getdata(c,"status")>0){
				st=0;
			}
			var tbpar=tabel.gettabel(b).parrent;
			var idmenu=tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"id");
			var idlevel=tabel.gettabel(b).getdata(c,"idlevel");
			var kodesub=tabel.gettabel(b).getdata(c,"kode");
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"setStatusaksessub",status:st,kodesub:kodesub,idmenu:idmenu,idlevel:idlevel}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					
					if(e==1){
						var el=document.getElementById("btaksessublevel_"+tbpar.tabel+"_"+tbpar.baris);
						var total=parseInt(tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"jumlah_akses_sub"));
						d.className="mini_dis";
						if(st==1){
							total=total+1;
							d.className="mini_ok";
						}else{
							total=total-1;
							d.className="mini_dis";
						}
						el.innerHTML=total;
						tabel.gettabel(b).setdata(c,"status",st);
						tabel.gettabel(tbpar.tabel).setdata(tbpar.baris,"jumlah_akses_sub",total);
						
					}
				}
			});
		},
		bukasubaksessub:function(a,b,c,d){
			var idtb=b+"_"+c;
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>SUB MENU SUB LEVEL AKSES</b></div>";
			htm+="<div id='grid_subsubakses_"+idtb+"'></div>";
			
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah btnclose' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"getaksessubsub",id:a}};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					
					//alert(JSON.stringify(e));
					if(e!=false && e.length>0){
						
						var datatb={
							box:"grid_subsubakses_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
									{"col":"namalevel","judul":"Level","tipe":"data","lebar":"150px"},
									{"col":"namasublevel","judul":"Sub","tipe":"data"},
									{"judul":"Akses","tipe":"tpl","tpl":"btstatussubmenusub","lebar":"50px","align":"center"}
								],
							mod:"mod",
							module:"moduleakses"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_subakses_"+idtb).html("TIDAK ADA SUB LEVEL AKSES");
					}
				}
			});
		},
		setaksessubmenusub:function(a,b,c,d){
			var st=1;
			if(tabel.gettabel(b).getdata(c,"status")>0){
				st=0;
			}
			var tbpar=tabel.gettabel(b).parrent;
			var idsubmenu=tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"id");
			var idlevel=tabel.gettabel(b).getdata(c,"idlevel");
			var kodesub=tabel.gettabel(b).getdata(c,"kode");
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"setStatusaksessubsub",status:st,kodesub:kodesub,idsubmenu:idsubmenu,idlevel:idlevel}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					
					if(e==1){
						var el=document.getElementById("btaksessubsub_"+tbpar.tabel+"_"+tbpar.baris);
						var total=parseInt(tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"jumlah_akses_sub"));
						d.className="mini_dis";
						if(st==1){
							total=total+1;
							d.className="mini_ok";
						}else{
							total=total-1;
							d.className="mini_dis";
						}
						el.innerHTML=total;
						tabel.gettabel(b).setdata(c,"status",st);
						tabel.gettabel(tbpar.tabel).setdata(tbpar.baris,"jumlah_akses_sub",total);
						
					}
				}
			});
		},
		carikonten:function(a){
			var ps={"box":"box_cari_konten",
						"judul":"Pilih Konten Untuk Menu","tinggimax":"fit","tinggi":"auto","lebar":"800"};
			boxkonten=boxwin.load(ps);
			boxkonten.id=0;
			boxkonten.mode=a;
			boxkonten.buka();
			
			$("#box_loader_konten").html("");
			managmenu.loadekonten();
		},
		loadekonten:function(){
			$("#hal_ke_konten").val(0);
			managmenu.loaddatakonten($("#hal_ke_konten").val(),$("#jumlah_hal_konten").val());
		},
		loadkonten:function(){
			managmenu.loaddatakonten($("#hal_ke_konten").val(),$("#jumlah_hal_konten").val());
		},
		enterkonten:function(e){
			if(e.which == 13 || e.keyCode == 13){
				managmenu.loadekonten();
			}
		},
		loaddatakonten:function(h,jm){
			$("#grid_data_konten").html("");
			
			var cr=$("#cari_konten").val();
			var posisiawal=(h-1)*jumlah;
			
			$("#hal_ke_konten").html("<option value=\"1\">1</option>");
			
			mload.sh("box_loader_konten");
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"getdatakonten",halaman:h,jumlah:jm,cari:cr}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					//alert(JSON.stringify(e));
					if(e!=false && e.hasOwnProperty("data")){
						var jumlahhalaman=e['totalhalaman'];
						if(jumlahhalaman>1){
							var htm;
							for(var i=0;i<jumlahhalaman;i++){
								htm+="<option value='"+(i+1)+"'>"+(i+1)+"</option>";
							}
							$("#hal_ke_konten").html(htm);
							
						}
						$("#hal_ke_konten").val(h);
						
						if((e['data']).length>0){
							var datatb={
								box:"grid_data_konten",
								data:e['data'],
								lebarmin:"500px",
								trklik:{"data":"id","fungsi":"barisklik"},
								title:"kategori Menu",
								isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":posisiawal,"jumlah":jumlah},
									{"col":"kategori","judul":"NIS","tipe":"data","lebar":"160px"},
									{"col":"judul","judul":"Judul Konten","tipe":"data"},
									{"align":"center","judul":"Pilih","tipe":"tpl","tpl":"btpilihkonten","lebar":"60px"},
								],
								mod:"mod",
								module:"managmenu"
							};
							tabel.multisub(datatb);
						}else{
							$("#grid_data_konten").html("Tidak ada data");
						}
						
					}
				}
			});
		},
		pilihdatakonten:function(a,b,c,d){
			if(boxkonten.mode==0){
				idkonten=a;
				$("#tautankonten").val(tabel.gettabel(b).getdata(c,"judul"));
			}else if(boxkonten.mode==1){
				boxeditsub.idkonten=a;
				$("#tautankonten").val(tabel.gettabel(b).getdata(c,"judul"));
			}
			
			managmenu.batalpilihkonten();
		},
		batalpilihkonten:function(){
			if(boxkonten!=null) boxkonten.tutup();
			boxkonten=null;
		},
		bukasubsub:function(a,b,c,d){
			var idtb=b+"_"+c;
			
			var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>SUB SUB MENU</b></div>";
			htm+="<div id='grid_sub_"+idtb+"'></div>";
			htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
			htm+="<div align='left'>";
			htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span> ";
			htm+="<span class='bthijau medium' id='bt_inputsub_"+idtb+"'>TAMBAH SUB SUB MENU</span> ";
			htm+="</div>";
			htm+="</div>";
			
			htm+="</div>";
			var obj=new Object;
			obj.html=htm;
			//alert(b);
			
			if(tabel.gettabel(b)!=null){
				
				tabel.gettabel(b).maxim(obj,c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
				d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
			};
			
			document.getElementById("bt_hide_"+idtb).onclick=function(){
				tabel.gettabel(b).minim(c);
				var trparr=d.offsetParent.parentNode;
				var tdarr=trparr.childNodes;
				for(var n=0;n<tdarr.length;n++){
					tdarr[n].removeAttribute("class");
					tdarr[n].setAttribute("class","garis_kiri_td");
				}
			};
			
			var urutan=1;
			
			document.getElementById("bt_inputsub_"+idtb).onclick=function(){
				var ps={"box":"box_edit_sub",
						"title":"Input Sub menu","tinggimax":"fit"};
				var tbpar=tabel.gettabel(b).parrent;
					
				boxeditsub=boxpesan.win(ps);
				boxeditsub.mode=1;
				boxeditsub.idmenu=tabel.gettabel(b).getdata(c,"idmenu");
				boxeditsub.idsub=a;
				boxeditsub.id=0;
				boxeditsub.tabel=b;
				boxeditsub.baris=c;
				boxeditsub.el=d;
				boxeditsub.idkonten=0;
				
				var idjenis=tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"idjenis");
				
				$("#nama").val("");
				$("#sl_level").val(0);
				
				$("#sl_tautan").val(0);
				$("#urutan").val(urutan);
				$("#sl_tautan").val(0);
				$("#sl_kategorimenu").val(idjenis);
				
				managmenu.katch();
				
			};
			
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"getSubsub",idsub:a}};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					
					
					if(e!=false && e.length>0){
						var dataisi=[
							{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
							{"col":"nama","judul":"Nama Menu","tipe":"data"},
							{"judul":"Tautan Module","tipe":"tpl","tpl":"bttautansub","lebar":"140px"},
							{"judul":"Urutan","tipe":"tpl","tpl":"bturutansubsub","lebar":"80px","align":"center"},
						];
						
						dataisi.push({"align":"center","judul":"Status","tipe":"tpl","tpl":"btstatussubsub","lebar":"60px"});
						dataisi.push({"align":"center","judul":"","tipe":"tpl","tpl":"bteditsubsub","lebar":"60px"});
						urutan=e.length+1;
						var datatb={
							box:"grid_sub_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tabelpar:b,
							barispar:c,
							isi:dataisi,
							mod:"mod",
							module:"managmenu"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_sub_"+idtb).html("TIDAK MEMPUNYAI SUB SUB MENU");
					}
					
				}
			});
		},
		setstatussubsubmenu:function(a,b,c,d){
			var tbl=tabel.gettabel(b);
			var st=1;
			if(parseInt(tbl.getdata(c,"status"))==1){
				st=0;
			}
			
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "managmenu",
				ikdata: {0:"setStatussubsub",status:st,id:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					
					mload.hd();
					//alert(JSON.stringify(e));
					if(e==1){
						d.className="mini_dis";
						if(st==1) d.className="mini_ok";
						tabel.gettabel(b).setdata(c,"status",st);
					}
				}
			});
		},
		editdsubsub:function(a,b,c,d){
			var ps={"box":"box_edit_sub",
					"title":"Input Sub menu","tinggimax":"fit"};
			var tbpar=tabel.gettabel(b).parrent;
			var tbparmain=tabel.gettabel(tbpar.tabel).parrent;
			var el=document.getElementById("btjumlahsubsub_"+tbpar.tabel+"_"+tbpar.baris);	
			boxeditsub=boxpesan.win(ps);
			boxeditsub.mode=1;
			boxeditsub.idmenu=tabel.gettabel(b).getdata(c,"idmenu");
			boxeditsub.idsub=tabel.gettabel(b).getdata(c,"idsub");
			boxeditsub.id=a;
			boxeditsub.tabel=tbpar.tabel;
			boxeditsub.baris=tbpar.baris;
			boxeditsub.el=el;
			boxeditsub.idkonten=tabel.gettabel(b).getdata(c,"tautan");
			
			var idjenis=tabel.gettabel(tbparmain.tabel).getdata(tbparmain.baris,"idjenis");
			tautanmod=tabel.gettabel(b).getdata(c,"tautan");
			$("#sl_level").val(tabel.gettabel(b).getdata(c,"level"));
			$("#nama").val(tabel.gettabel(b).getdata(c,"nama"));
			$("#sl_level").val(tabel.gettabel(b).getdata(c,"level"));
			$("#tautankonten").val(tabel.gettabel(b).getdata(c,"judulkonten"));
			
			$("#sl_tautan").val(tabel.gettabel(b).getdata(c,"tautan"));
			$("#urutan").val(tabel.gettabel(b).getdata(c,"urutan"));
			$("#sl_kategorimenu").val(idjenis);
			console.log(tabel.gettabel(b).getdata(c,"jenistautan"));
			managmenu.katch(tabel.gettabel(b).getdata(c,"jenistautan"));
		},
		hapussubsub:function(a,b,c,d){
			if(a<=0) return;
			var ps={"pesan":"Yakin akan menghapus Sub sub menu ini ??",
					"title":"Peringatan Hapus data"};
				
			var boxyesno=boxpesan.yesno(ps);
			boxyesno.proses.onclick=function(){
				var tbpar=tabel.gettabel(b).parrent;
				var idtb=tbpar.tabel+"_"+tbpar.baris;
				
				var idsub=tabel.gettabel(b).getdata(c,"idsub");
				mload.sh();
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "managmenu",
					ikdata: {0:"hapusSubsubmenu",id:a}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",
					type: "POST",
					dataType: "json",
					async:true,
					data: ik_data,
					success: function(e){
						mload.hd();
						if(e==1){
							var jumlah=parseInt(tabel.gettabel(tbpar.tabel).getdata(tbpar.baris,"jumlah_sub_sub"))-1;
							var el=document.getElementById("btjumlahsubsub_"+tbpar.tabel+"_"+tbpar.baris);
							tabel.gettabel(tbpar.tabel).setdata(tbpar.baris,"jumlah_sub_sub",jumlah);
							
							el.innerHTML=jumlah;
							managmenu.bukasubsub(idsub,tbpar.tabel,tbpar.baris,el);
							boxyesno.tutup();
							
							
							
						}else{
							boxpesan.err(e);
						}
					}
				});
			}
		},
		lihatdokumen:function(a){
			var idmenu=a;
			if(idmenu<=0) return;
			var myWindow = window.open(lokal+"service.php?pos=managmenu&mode=mod&fl=download&id="+idmenu, "", "left=100,top=50,width=800, height=600");
		},
		objuploadicon:function(a,b){
			var nama=a || "PILIH FILE ICON MENU";
			var prev=b || "tidak";
			
			var obp=new Object;
			obp.proses=function(dataupload){
				idicon=dataupload.id;
				var namalama=dataupload.nama;
				
				$("#upload_icon").html("");
				upload.tambahupload("upload_icon",managmenu.objuploadicon(namalama,"ya"));
			};
			
			obp.hapus=function(a){
				
			};
			obp.lihat=function(a){
				managmenu.lihatdokumen(idmenu);
			};
			
			obp.pilihfile=function(a){
				idicon=0;
			};
			
			var dtpost={"jenis":6};
			var obj={"tautan":lokal+"service.php?pos=managmenu&mode=mod&fl=upload",
				"status":lokal+"service.php?pos=managmenu&mode=mod&fl=progres","tutup":"tidak","finish":obp,
				"data":dtpost,"namafile":nama,"preview":prev};
			return obj;
		},
	};
})();
