var menuinfografis=(function(){
	return{
		init:function(a){
			var kat=a['kat'];
			
			$("#sl_group_filter").html("");
			$("#sl_jenis_filter").val(kat);
			var jenis=$("#sl_jenis_filter").val();
			
			var htm="";
			if(jenis=="pelanggan"){
				htm+="<option value='kategori'>Kategori</option>";
				htm+="<option value='propinsi'>Propinsi</option>";
				$("#sl_group_filter").html(htm);
				menuinfografis.loaddata();
			}else if(jenis=="layanan"){
				htm+="<option value='jenis'>Jenis Layanan</option>";
				//htm+="<option value='status'>Status</option>";
				$("#sl_group_filter").html(htm);
				menuinfografis.loaddata();
			}else if(jenis=="ikc"){
				mload.sh("sl_group_filter");
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "menuinfografis",
					ikdata: {0:"getkategoriik"}
				};
				
				$.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 htm="";
							for(var i=0;i<e.length;i++){
								htm+="<option value='"+e[i]['id']+"'>"+e[i]['nama']+"</option>";
							}
							$("#sl_group_filter").html(htm);
							if(a.hasOwnProperty('id')) $("#sl_group_filter").val(a['id']);
							 
							menuinfografis.loaddata();
						}
					}
				});
			}else if(jenis=="ikm"){
				mload.sh("sl_group_filter");
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "menuinfografis",
					ikdata: {0:"gettahunikm"}
				};
				
				$.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 htm="";
							for(var i=0;i<e.length;i++){
								htm+="<option value='"+e[i]['tahun']+"'>"+e[i]['tahun']+"</option>";
							}
							$("#sl_group_filter").html(htm);
							menuinfografis.loaddata();
						}
					}
				});
			}
			
		},
		jenisch:function(){
			var jenis=$("#sl_jenis_filter").val();
			menuinfografis.init({"kat":jenis});
		},
		loaddata:function(){
			var jenis=$("#sl_jenis_filter").val();
			var group=$("#sl_group_filter").val();
			
			$("#boxfilter2").hide();
			if(jenis=="ikm"){
				//$("#boxfilter2").show();
				mload.sh("sl_group2_filter");
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "menuinfografis",
					ikdata: {0:"getbulanikm",tahun:group}
				};
				
				$.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 htm="";
							for(var i=0;i<e.length;i++){
								htm+="<option value='"+e[i]['idbulan']+"'>"+e[i]['bulan']+"</option>";
							}
							$("#sl_group2_filter").html(htm);
							menuinfografis.loaddata2();
						}
					}
				});
			}else if(jenis=="ikc"){
				$("#boxfilter2").show();
				mload.sh("sl_group2_filter");
				var ik_data = {
					ajax: 1,
					mode: "mod",
					cl: "menuinfografis",
					ikdata: {0:"gettahunikc",kategori:group}
				};
				
				$.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 htm="";
							for(var i=0;i<e.length;i++){
								htm+="<option value='"+e[i]['tahun']+"'>"+e[i]['tahun']+"</option>";
							}
							$("#sl_group2_filter").html(htm);
							menuinfografis.loaddata2();
						}
					}
				});
			}else{
				var dataload={jenis:jenis,group:group};
			
				infografisgrafik.init(dataload);
			}
			
		},
		loaddata2:function(){
			var jenis=$("#sl_jenis_filter").val();
			var group=$("#sl_group_filter").val();
			var group2=$("#sl_group2_filter").val();
			
			var dataload={jenis:jenis,group:group,group2:group2};
			
			infografisgrafik.init(dataload);
		}
	};
})();
