var modmenu=(function(){
	var submenu=new Object;
	var keys = [];
	var updatewaktu=null;
	var posisiscroll=0;
	return{
		
		menuklik:function(a){
			if(a['sub']>0){
				var namasub="mod_sub_"+a['id'];
				if(submenu[namasub]==null){
					var data=new Object;
					data.box=document.getElementById(namasub);
					data.status=1;
					submenu[namasub]=data;
					document.getElementById(namasub).style.display="block";
					submenu[namasub].box.className="mod_box_sub_menu anim_sum";
					keys.push(namasub);
				}else{
					if(submenu[namasub].status==1){
						submenu[namasub].status=0;
						submenu[namasub].box.style.display="none";
						submenu[namasub].box.className="mod_box_sub_menu";
					}else{
						submenu[namasub].status=1;
						submenu[namasub].box.style.display="block";
						submenu[namasub].box.className="mod_box_sub_menu anim_sum";
					}
				}
				
				var ik_data = {ajax: 1,mode: "mod",cl: "menu",
					ikdata: {0:"setStatus",1:a,
						2:submenu[namasub].status,kodeulang:0}
				};
				
				$.ajax({
					url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
					success: function(e){
						if(e==1){
							
						}
					}
				});
			}
			
			if(a['tautan']!="#"){
				document.location=lokal+"member/mod/"+a['tautan']+"?scrmenu="+posisiscroll;
			}
			
		},
		menuset:function(a,b){
			if(submenu[a]==null){
				var data=new Object;
				data.box=document.getElementById(a);
				submenu[a]=data;
				keys.push(a);
			}
			submenu[a].status=b;
			if(b==1){
				document.getElementById(a).style.display="block";
				submenu[a].box.className="mod_box_sub_menu anim_sum";
			}else{
				document.getElementById(a).style.display="none";
				submenu[a].box.className="mod_box_sub_menu";
			}
		},
		tutupsemua:function(){
			if(keys.length>0){
				for(var i=0;i<keys.length;i++){
					submenu[keys[i]].status=0;
					submenu[keys[i]].box.style.display="none";
					submenu[keys[i]].box.className="mod_box_sub_menu";
				}
			}
		},
		
		buka:function(a){
			var arr=Object.keys(a);
			for(var i=0;i<arr.length;i++){
				modmenu.menuklik(a[arr[i]],i);
			}
		},
		scrmenu:function(a){
			posisiscroll = a.scrollY || a.scrollTop;
		},
		menusubklik:function(a){
			if(a['tautan']!="#") document.location=lokal+"member/mod/"+a['tautan']+"?scrmenu="+posisiscroll;
		},
		scrmenuto:function(a){
			var el=document.getElementById("box_menu");
			el.scrollTo(0,a);
		},
		getmenuscr:function(){
			return posisiscroll;
		}
	};
})();
