			</div><!-- End Dv Container-fluid -->
			<!-- END PAGE CONTAINER--> 

		</div>

		<!-- END PAGE -->    

	</div>

	<!-- END CONTAINER -->

	<!-- BEGIN FOOTER -->

	<div class="footer">

		<div class="footer-inner">

			<?php echo date('Y');?> &copy; <?php echo $this->lang->line('website_name');?>.

		</div>

		<div class="footer-tools">

			<span class="go-top">

			<i class="icon-angle-up"></i>

			</span>

		</div>

	</div>

	<!-- END FOOTER -->

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->

	<!-- BEGIN CORE PLUGINS -->

	<script src="<?php echo base_url();?>assets/js/jquery-1.10.1.min.js" type="text/javascript"></script>

	<script src="<?php echo base_url();?>assets/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>

	<!-- IMPORTANT! Load jquery-ui-1.10.1.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->

	<script src="<?php echo base_url();?>assets/js/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>      

	<script src="<?php echo base_url();?>assets/js/bootstrap.min.js" type="text/javascript"></script>

	<!--[if lt IE 9]>

	<script src="<?php echo base_url();?>assets/js/excanvas.min.js"></script>

	<script src="<?php echo base_url();?>assets/js/respond.min.js"></script>  

	<![endif]-->   

	<script src="<?php echo base_url();?>assets/js/jquery.slimscroll.min.js" type="text/javascript"></script>

	<script src="<?php echo base_url();?>assets/js/jquery.blockui.min.js" type="text/javascript"></script>  

	<script src="<?php echo base_url();?>assets/js/jquery.cookie.min.js" type="text/javascript"></script>

	<script src="<?php echo base_url();?>assets/js/jquery.uniform.min.js" type="text/javascript" ></script>

	<!-- END CORE PLUGINS -->

	<!-- BEGIN PAGE LEVEL PLUGINS -->

	<script type="text/javascript" src="<?php echo base_url();?>assets/js/select2.min.js"></script>
	
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/wysihtml5-0.3.0.js"></script> 
	
	<?php if($this->uri->segment(1) == 'announcement') {?>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.form.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/tinymce/tinymce.min.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>assets/js/tinymce/jquery.tinymce.min.js"></script>
	<?php } else {?>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/bootstrap-wysihtml5.js"></script>
	<?php }?>
	
	<script>
		var js_text_records_per_page = "<?php echo $this->lang->line('js_text_records_per_page');?> ";
		var js_no_matching_records_found = "<?php echo $this->lang->line('js_no_matching_records_found');?> ";
		var js_filtered = "<?php echo $this->lang->line('js_filtered');?> ";
		var js_text_search = "<?php echo $this->lang->line('js_text_search');?> ";
		var js_text_prev = "<?php echo $this->lang->line('js_text_prev');?> ";
		var js_text_next = "<?php echo $this->lang->line('js_text_next');?> ";
		var js_text_show_info = "<?php echo $this->lang->line('js_text_show_info');?> ";
		var js_text_show_info_empty = "<?php echo $this->lang->line('js_text_show_info_empty');?> ";
		var js_text_loading = "<?php echo $this->lang->line('js_text_loading');?> ";
		var js_text_processing = "<?php echo $this->lang->line('js_text_processing');?> ";
	</script>
	
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.dataTables.js"></script>

	<script type="text/javascript" src="<?php echo base_url();?>assets/js/DT_bootstrap.js"></script>
	
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/bootstrap-datepicker.js"></script>
	
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/jquery.tagsinput.min.js"></script>

	<!-- END PAGE LEVEL PLUGINS -->

	<!-- BEGIN PAGE LEVEL SCRIPTS -->

	<script src="<?php echo base_url();?>assets/js/app.js"></script>     

	<script src="<?php echo base_url();?>assets/js/table-editable.js"></script> 	
	
	<script src="<?php echo base_url();?>assets/js/form-components.js"></script>  
	
	<?php if($this->uri->segment(1) == 'member') {?>
	<script>
		var js_text_checking = "<?php echo $this->lang->line('js_text_checking');?>";
		var js_text_registration_check_existing_of_placement = "<?php echo $this->lang->line('registration_check_existing_of_placement');?>";
	</script>
	
	<script src="<?php echo base_url();?>assets/js/custom.js"></script>  
	<?php }?>

	<!-- END PAGE LEVEL SCRIPTS -->

	<script>

		jQuery(document).ready(function() {       

		   // initiate layout and plugins

		   App.init();
		   
		   TableEditable.init();
		   
		   FormComponents.init();

		});

	</script>
	
	<?php 
		if($this->uri->segment(1) == 'member') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			$('.insurance-date-picker').datepicker({
				format: 'dd-mm-yyyy',
			});
		});
	</script>	
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>member/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][3]*1;
						TotalAmount2 += aaData[i][5]*1;
						TotalAmount3 += aaData[i][8]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[6].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
				}
			});
			
			$('#search_register_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});

		function update_setting(opt, mid) {
			var confirm_txt = '<?php echo $this->lang->line('registration_confirm_message')?>';
			var success_txt = '<?php echo $this->lang->line('registration_setting_update_successful_message')?>';
			var fail_txt = '<?php echo $this->lang->line('registration_setting_update_fail_message')?>';
			var active_txt = '<?php echo $this->lang->line('registration_active')?>';
			var deactivated_txt = '<?php echo $this->lang->line('registration_deactivated')?>';
			var suspended_txt = '<?php echo $this->lang->line('registration_suspended')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$.post('<?php echo base_url();?>member/update_setting/', {
						type: opt,
						member_id: mid,
						csrf_metabets_ad_token: '<?php echo $this->security->get_csrf_hash();?>'
					},
					function(data){
						if (data == 1) {
							if(opt == 1) {
								var obj = $('#allowed_withdraw_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 2) {
								var obj = $('#unlimited_withdraw_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 3) {
								var obj = $('#allowed_transfer_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 4) {
								var obj = $('#account_status_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
									$('#allowed_withdraw_' + mid).removeClass('label-fail').addClass('label-success').html(active_txt);
									$('#allowed_transfer_' + mid).removeClass('label-fail').addClass('label-success').html(active_txt);
									$('#allowed_convert_' + mid).removeClass('label-fail').addClass('label-success').html(active_txt);
									$('#allowed_topup_' + mid).removeClass('label-fail').addClass('label-success').html(active_txt);
									$('#allowed_game_' + mid).removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(suspended_txt);
									$('#allowed_withdraw_' + mid).removeClass('label-success').addClass('label-fail').html(deactivated_txt);
									$('#allowed_transfer_' + mid).removeClass('label-success').addClass('label-fail').html(deactivated_txt);
									$('#allowed_convert_' + mid).removeClass('label-success').addClass('label-fail').html(deactivated_txt);
									$('#allowed_topup_' + mid).removeClass('label-success').addClass('label-fail').html(deactivated_txt);
									$('#allowed_game_' + mid).removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 5) {
								var obj = $('#allowed_topup_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 6) {
								var obj = $('#allowed_convert_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							else if(opt == 7) {
								var obj = $('#allowed_game_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(active_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(deactivated_txt);
								}
							}
							
							alert(success_txt);
						}
						else {
							alert(fail_txt);
						}
					}
				);

				return false;
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && $this->uri->segment(2) == 'wallet_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>member/getwalletlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": false, "bSearchable": false, "bSortable": true },
					{ "bVisible": false, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					// var TotalAmount4 = 0;
					// var TotalAmount5 = 0;
					// var TotalAmount6 = 0;
					// var TotalAmount7 = 0;
					// var TotalAmount8 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][2]*1;
						TotalAmount2 += aaData[i][5]*1;
						TotalAmount3 += aaData[i][6]*1;
						// TotalAmount4 += aaData[i][5]*1;
						// TotalAmount5 += aaData[i][6]*1;
						// TotalAmount6 += aaData[i][10]*1;
						// TotalAmount7 += aaData[i][11]*1;
						// TotalAmount8 += aaData[i][12]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
					// nCells[4].innerHTML = Math.round(TotalAmount4 * 10000) / 10000;
					// nCells[5].innerHTML = Math.round(TotalAmount5 * 10000) / 10000;
					// nCells[6].innerHTML = Math.round(TotalAmount6 * 10000) / 10000;
					// nCells[7].innerHTML = Math.round(TotalAmount7 * 10000) / 10000;
					// nCells[8].innerHTML = Math.round(TotalAmount8 * 10000) / 10000;
				}
			});
		});
		
		var is_allowed = true;
		function update_wallet(mid) {
			if(is_allowed == true) {
				is_allowed = false;
				
				$.ajax({url: '<?php echo base_url();?>member/update_wallet/' + mid + '/',
					type: 'get',                  
					async: 'true',
					beforeSend: function() {
						$('#waction-' + mid).html('<?php echo $this->lang->line('js_text_processing')?>');
					},
					complete: function() {
					},
					success: function (data) {
						var json = JSON.parse(JSON.stringify(data));
						$('#w1-' + mid).html(json.v_unit6);
						$('#w2-' + mid).html(json.v_unit7);
						$('#w3-' + mid).html(json.v_unit8);
						$('#waction-' + mid).html('<?php echo $this->lang->line('member_update_wallet')?>');
						is_allowed = true;
					},
					error: function (request,error) {
						is_allowed = true;
					}
				});
			}	
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && $this->uri->segment(2) == 'downline') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>member/getdownlinelist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
			
			$('#search_register_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && $this->uri->segment(2) == 'reinvest_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>member/getreinvestlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
			
			$('#search_register_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && $this->uri->segment(2) == 'intro') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>member/getintrolist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
			
			$('#search_register_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'report' && $this->uri->segment(2) == 'daily_bonus' && $this->session->userdata('report_start_date') && $this->session->userdata('report_end_date')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>report/daily_bonus_getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalLeaderBonus = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalLeaderBonus += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalLeaderBonus * 10000) / 10000;
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'report' && $this->uri->segment(2) == 'income_summary' && $this->session->userdata('report_income_date')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>report/income_summary_getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalLeaderBonus = 0;
					var GrandTotal = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalLeaderBonus += aaData[i][1]*1;
						GrandTotal += aaData[i][2]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalLeaderBonus * 10000) / 10000;
					nCells[2].innerHTML = Math.round(GrandTotal * 10000) / 10000;
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'report' && $this->uri->segment(2) == 'income_detail' && $this->session->userdata('report_income_date')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>report/income_detail_getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'report' && $this->uri->segment(2) == 'balance' && $this->session->userdata('report_income_date')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>report/balance_getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc'], [1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'report') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			$('#income_date').change(function() {
				var val = $(this).val();
				if(val == 7) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'member' && ($this->uri->segment(2) == 'structure')) {
			if($json != '') {
	?>
	<script src="<?php echo base_url();?>assets/js/jquery.orgchart.js"></script>

    <script type="text/javascript">
    var chartData = [
       <?php echo $json;?>
    ];
    $(function(){
        org_chart = $('#orgChart').orgChart({
            data: chartData,
            showControls: false,
            allowEdit: false
        });
    });
    </script>
	<?php } }?>
	
	<?php 
		if($this->uri->segment(1) == 'transfer' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>transfer/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalIn = 0;
					var TotalOut = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalIn += aaData[i][2]*1;
						TotalOut += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[2].innerHTML = Math.round(TotalIn * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalOut * 10000) / 10000;
				}
			});
			
			$('#search_transfer_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'convert' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>convert/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmt = 0;
					var TotalAmt2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmt += aaData[i][2]*1;
						TotalAmt2 += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmt * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmt2 * 10000) / 10000;
				}
			});
			
			$('#search_convert_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'message' && ($this->uri->segment(2) == 'inbox' || $this->uri->segment(2) == 'sent')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>message/getlist/<?php echo $this->uri->segment(2);?>/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && ($this->uri->segment(2) == 'request' || $this->uri->segment(2) == 'submit')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			$('#remark').change(function() {
				var val = $(this).val();
				if(val == 'Others') {
					$('#remark_others_panel').show();
				}
				else {
					$('#remark_others_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>topup/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][2]*1;
						TotalAmount2 += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && $this->uri->segment(2) == 'offline_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>topup/get_offline_list/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][3]*1;
						TotalAmount2 += aaData[i][4]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_offline_topup_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>topup/update_offline_topup/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_topup_offline_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#topup-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && $this->uri->segment(2) == 'usdt_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>topup/get_usdt_list/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][2]*1;
						TotalAmount2 += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_usdt_topup_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>topup/update_usdt_topup/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_topup_usdt_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#topup-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && $this->uri->segment(2) == 'platform_listing_1') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>topup/get_platform_list_1/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'topup' && $this->uri->segment(2) == 'platform_listing_2') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>topup/get_platform_list_2/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'adjustment' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>adjustment/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][2]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_topup_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'adjustment' && $this->uri->segment(2) == 'platform_listing_1') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>adjustment/get_platform_list_1/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_adjustment_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'adjustment' && $this->uri->segment(2) == 'platform_listing_2') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>adjustment/get_platform_list_2/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_adjustment_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'withdrawal' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>withdrawal/getList/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalActual = 0;
					var TotalWithdraw = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalActual += aaData[i][2]*1;
						TotalWithdraw += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalActual * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalWithdraw * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_withdrawal_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>withdrawal/update_withdrawal/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_withdrawal_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#withdrawal-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'withdrawal' && $this->uri->segment(2) == 'coin_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>withdrawal/getCoinList/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalActual = 0;
					var TotalWithdraw = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalActual += aaData[i][2]*1;
						TotalWithdraw += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalActual * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalWithdraw * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_withdrawal_coin_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>withdrawal/update_withdrawal_coin/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_withdrawal_coin_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#withdrawal-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'withdrawal' && $this->uri->segment(2) == 'chip_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>withdrawal/getChipList/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalActual = 0;
					var TotalWithdraw = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalActual += aaData[i][2]*1;
						TotalWithdraw += aaData[i][3]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalActual * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalWithdraw * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_withdrawal_chip_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>withdrawal/update_withdrawal_chip/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_withdrawal_chip_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#withdrawal-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'game' && $this->uri->segment(2) == 'withdrawal_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>game/get_withdrawal_list/',
				"iDisplayLength": 25,
				"aaSorting": [[11, 'asc'], [2, 'asc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					// { "bVisible": false, "bSearchable": false, "bSortable": false },
					// { "bVisible": false, "bSearchable": false, "bSortable": false },
					{ "bVisible": false, "bSearchable": false, "bSortable": false },
					{ "bVisible": false, "bSearchable": false, "bSortable": false },
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					var TotalAmount4 = 0;
					var TotalAmount5 = 0;
					var TotalAmount6 = 0;
					var TotalAmount7 = 0;
					var TotalAmount8 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						// TotalAmount1 += aaData[i][3]*1;
						// TotalAmount2 += aaData[i][17]*1;
						// TotalAmount3 += aaData[i][18]*1;
						// TotalAmount4 += aaData[i][7]*1;
						// TotalAmount5 += aaData[i][19]*1;
						// TotalAmount6 += aaData[i][20]*1;
						// TotalAmount7 += aaData[i][10]*1;
						// TotalAmount8 += aaData[i][11]*1;
						TotalAmount1 += aaData[i][3]*1;
						TotalAmount2 += aaData[i][4]*1;
						TotalAmount3 += aaData[i][15]*1;
						TotalAmount4 += aaData[i][16]*1;
						TotalAmount5 += aaData[i][7]*1;
						TotalAmount6 += aaData[i][8]*1;
						TotalAmount7 += aaData[i][9]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
					nCells[4].innerHTML = Math.round(TotalAmount4 * 10000) / 10000;
					nCells[5].innerHTML = Math.round(TotalAmount5 * 10000) / 10000;
					nCells[6].innerHTML = Math.round(TotalAmount6 * 10000) / 10000;
					nCells[7].innerHTML = Math.round(TotalAmount7 * 10000) / 10000;
					// nCells[9].innerHTML = Math.round(TotalAmount8 * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_withdrawal_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>game/update_withdrawal/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_withdrawal_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#withdrawal-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
		
		function update_setting(tid, mid) {
			var confirm_txt = '<?php echo $this->lang->line('registration_confirm_message')?>';
			var success_txt = '<?php echo $this->lang->line('registration_setting_update_successful_message')?>';
			var fail_txt = '<?php echo $this->lang->line('registration_setting_update_fail_message')?>';
			var unfreeze_txt = '<?php echo $this->lang->line('game_unfreeze')?>';
			var freeze_txt = '<?php echo $this->lang->line('game_freeze')?>';
			var opt = 7;
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$.post('<?php echo base_url();?>member/update_setting/', {
						type: opt,
						member_id: mid,
						csrf_metabets_ad_token: '<?php echo $this->security->get_csrf_hash();?>'
					},
					function(data){
						if (data == 1) {
							if(opt == 7) {
								var obj = $('#allowed_game_' + tid + '_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(unfreeze_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(freeze_txt);
								}
							}
							
							alert(success_txt);
						}
						else {
							alert(fail_txt);
						}
					}
				);

				return false;
			}
		}
		
		var is_allowed = true;
		function update_turnover(tid) {
			if(is_allowed == true) {
				is_allowed = false;
				
				$.ajax({url: '<?php echo base_url();?>game/update_turnover/' + tid + '/',
					type: 'get',                  
					async: 'true',
					beforeSend: function() {
						$('#waction-' + tid).html('<?php echo $this->lang->line('js_text_processing')?>');
					},
					complete: function() {
					},
					success: function (data) {
						var json = JSON.parse(JSON.stringify(data));
						
						if (json.p1_total_bet === "undefined") {
							//do something
						}
						else {
							$('#w1-' + tid).html(json.p1_total_bet);
							$('#w2-' + tid).html(json.p1_total_turnover);
							$('#w3-' + tid).html(json.p2_total_bet);
							$('#w4-' + tid).html(json.p2_total_turnover);
						}
						
						$('#waction-' + tid).html('<?php echo $this->lang->line('game_update_turnover')?>');
						is_allowed = true;
					},
					error: function (request,error) {
						is_allowed = true;
					}
				});
			}	
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'game' && $this->uri->segment(2) == 'withdrawal_listing_2') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>game/get_withdrawal_list_2/',
				"iDisplayLength": 25,
				"aaSorting": [[11, 'asc'], [2, 'asc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					// { "bVisible": false, "bSearchable": false, "bSortable": false },
					// { "bVisible": false, "bSearchable": false, "bSortable": false },
					{ "bVisible": false, "bSearchable": false, "bSortable": false },
					{ "bVisible": false, "bSearchable": false, "bSortable": false },
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					var TotalAmount4 = 0;
					var TotalAmount5 = 0;
					var TotalAmount6 = 0;
					var TotalAmount7 = 0;
					var TotalAmount8 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						// TotalAmount1 += aaData[i][3]*1;
						// TotalAmount2 += aaData[i][17]*1;
						// TotalAmount3 += aaData[i][18]*1;
						// TotalAmount4 += aaData[i][7]*1;
						// TotalAmount5 += aaData[i][19]*1;
						// TotalAmount6 += aaData[i][20]*1;
						// TotalAmount7 += aaData[i][10]*1;
						// TotalAmount8 += aaData[i][11]*1;
						TotalAmount1 += aaData[i][3]*1;
						TotalAmount2 += aaData[i][4]*1;
						TotalAmount3 += aaData[i][15]*1;
						TotalAmount4 += aaData[i][16]*1;
						TotalAmount5 += aaData[i][7]*1;
						TotalAmount6 += aaData[i][8]*1;
						TotalAmount7 += aaData[i][9]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
					nCells[4].innerHTML = Math.round(TotalAmount4 * 10000) / 10000;
					nCells[5].innerHTML = Math.round(TotalAmount5 * 10000) / 10000;
					nCells[6].innerHTML = Math.round(TotalAmount6 * 10000) / 10000;
					nCells[7].innerHTML = Math.round(TotalAmount7 * 10000) / 10000;
					// nCells[9].innerHTML = Math.round(TotalAmount8 * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_withdrawal_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>game/update_withdrawal_2/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_withdrawal_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#withdrawal-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
		
		function update_setting(tid, mid) {
			var confirm_txt = '<?php echo $this->lang->line('registration_confirm_message')?>';
			var success_txt = '<?php echo $this->lang->line('registration_setting_update_successful_message')?>';
			var fail_txt = '<?php echo $this->lang->line('registration_setting_update_fail_message')?>';
			var unfreeze_txt = '<?php echo $this->lang->line('game_unfreeze')?>';
			var freeze_txt = '<?php echo $this->lang->line('game_freeze')?>';
			var opt = 7;
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$.post('<?php echo base_url();?>member/update_setting/', {
						type: opt,
						member_id: mid,
						csrf_metabets_ad_token: '<?php echo $this->security->get_csrf_hash();?>'
					},
					function(data){
						if (data == 1) {
							if(opt == 7) {
								var obj = $('#allowed_game_' + tid + '_' + mid);
								if(obj.hasClass('label-fail')) {
									obj.removeClass('label-fail').addClass('label-success').html(unfreeze_txt);
								}
								else {
									obj.removeClass('label-success').addClass('label-fail').html(freeze_txt);
								}
							}
							
							alert(success_txt);
						}
						else {
							alert(fail_txt);
						}
					}
				);

				return false;
			}
		}
		
		var is_allowed = true;
		function update_turnover(tid) {
			if(is_allowed == true) {
				is_allowed = false;
				
				$.ajax({url: '<?php echo base_url();?>game/update_turnover/' + tid + '/',
					type: 'get',                  
					async: 'true',
					beforeSend: function() {
						$('#waction-' + tid).html('<?php echo $this->lang->line('js_text_processing')?>');
					},
					complete: function() {
					},
					success: function (data) {
						var json = JSON.parse(JSON.stringify(data));
						
						if (json.p1_total_bet === "undefined") {
							//do something
						}
						else {
							$('#w1-' + tid).html(json.p1_total_bet);
							$('#w2-' + tid).html(json.p1_total_turnover);
							$('#w3-' + tid).html(json.p2_total_bet);
							$('#w4-' + tid).html(json.p2_total_turnover);
						}
						
						$('#waction-' + tid).html('<?php echo $this->lang->line('game_update_turnover')?>');
						is_allowed = true;
					},
					error: function (request,error) {
						is_allowed = true;
					}
				});
			}	
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'game' && $this->uri->segment(2) == 'bet_history') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			// var oTable = $('#table-listing').dataTable({
				// "bProcessing": true,
				// "bServerSide": true,
				// "bFilter": false,
				// "sAjaxSource": '<?php echo base_url();?>game/get_bet_list_1/<?php echo $this->uri->segment(3);?>/',
				// "iDisplayLength": 10,
				// "aaSorting": [[0, 'desc']],
				// "aoColumns": [
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": false, "bSortable": true },
					// { "bVisible": true, "bSearchable": true, "bSortable": true }
				// ],
				// "fnInitComplete": function () {
					// oTable.fnAdjustColumnSizing();
				// },
				// 'fnServerData': function (sSource, aoData, fnCallback) {
					// aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					// $.ajax
					// ({
						// 'dataType': 'json',
						// 'type': 'POST',
						// 'url': sSource,
						// 'data': aoData,
						// 'success': fnCallback
					// });
				// },
				// "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					// var TotalAmount1 = 0;
					// var TotalAmount2 = 0;
					// for ( var i=0 ; i<aaData.length ; i++ )
					// {
						// TotalAmount1 += aaData[i][5]*1;
						// TotalAmount2 += aaData[i][6]*1;
					// }

					// var nCells = nRow.getElementsByTagName('th');
					// nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					// nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				// }
			// });
			
			var oTable_2 = $('#table-listing-2').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>game/get_bet_list_2/<?php echo $this->uri->segment(3);?>/',
				"iDisplayLength": 10,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable_2.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][5]*1;
						TotalAmount2 += aaData[i][6]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			$('#search_bet_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>

	<?php 
		if($this->uri->segment(1) == 'insurance' && $this->uri->segment(2) == 'buy_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>insurance/getbuylist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmt = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmt += aaData[i][1]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmt * 10000) / 10000;
				}
			});
			
			$('#search_insurance_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'insurance' && $this->uri->segment(2) == 'claim_listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>insurance/getclaimlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount += aaData[i][2]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount * 10000) / 10000;
				}
			});
			
			$('#search_insurance_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_claim_status(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>insurance/update_claim/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_claim_listing_status() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#insurance-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'insurance' && $this->uri->segment(2) == 'platform_listing_1') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>insurance/get_platform_list_1/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][4]*1;
						TotalAmount2 += aaData[i][5]*1;
						TotalAmount3 += aaData[i][6]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_missbet_status_platform_1(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>insurance/update_missbet_platform_1/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_missbet_listing_status_platform_1() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#missbet-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'insurance' && $this->uri->segment(2) == 'platform_listing_2') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>insurance/get_platform_list_2/',
				"iDisplayLength": 25,
				"aaSorting": [[1, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": false },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					var TotalAmount3 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][4]*1;
						TotalAmount2 += aaData[i][5]*1;
						TotalAmount3 += aaData[i][6]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
					nCells[3].innerHTML = Math.round(TotalAmount3 * 10000) / 10000;
				}
			});
			
			$('#search_withdrawal_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
		
		function update_missbet_status_platform_2(id, val) {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				location.href = '<?php echo base_url();?>insurance/update_missbet_platform_2/' + id + '/' + val + '/';
			}
			else {
				$('#update_status').val(0);
			}
		}
		
		// check or uncheck all checkbox 
		function checkBox(t) {
			if(t.checked == true) {
				checkAll(document.getElementsByName(t.name));
			}
			else {
				uncheckAll(document.getElementsByName(t.name));
			}
			
		}

		// All chekcbox checking
		function checkOrUncheck(t) {
			var check = true;
			var field = document.getElementsByName(t.name);
			for(i = 1; i < field.length; i++) {
				if(field[i].checked == false)
					check = false;
			}
			field[0].checked = check;
			if(check == true) {
				$('#uniform-mainchkbox span').addClass('checked');
			}
			else {
				$('#uniform-mainchkbox span').removeClass('checked');
			}
		}

		function checkAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = true ;
		}

		function uncheckAll(field) {
			for (i = 0; i < field.length; i++)
				field[i].checked = false ;
		}
		
		function update_missbet_listing_status_platform_2() {
			var confirm_txt = '<?php echo $this->lang->line('withdrawal_confirm_approve_withdrawal')?>';
			
			var r = confirm(confirm_txt);
			if (r == true) {
				$('#missbet-form').submit();
			}
			else {
				$('#listing_submit').val(0);
			}
		}
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'insurance' && $this->uri->segment(2) == 'bet_history') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>insurance/get_bet_list_1/<?php echo $this->uri->segment(3);?>/',
				"iDisplayLength": 10,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][5]*1;
						TotalAmount2 += aaData[i][6]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			var oTable_2 = $('#table-listing-2').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"bFilter": false,
				"sAjaxSource": '<?php echo base_url();?>insurance/get_bet_list_2/<?php echo $this->uri->segment(3);?>/',
				"iDisplayLength": 10,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true }
				],
				"fnInitComplete": function () {
					oTable_2.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				},
				"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
					var TotalAmount1 = 0;
					var TotalAmount2 = 0;
					for ( var i=0 ; i<aaData.length ; i++ )
					{
						TotalAmount1 += aaData[i][5]*1;
						TotalAmount2 += aaData[i][6]*1;
					}

					var nCells = nRow.getElementsByTagName('th');
					nCells[1].innerHTML = Math.round(TotalAmount1 * 10000) / 10000;
					nCells[2].innerHTML = Math.round(TotalAmount2 * 10000) / 10000;
				}
			});
			
			$('#search_bet_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'announcement' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>announcement/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'admin' && $this->uri->segment(2) == 'listing') {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			var oTable = $('#table-listing').dataTable({
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": '<?php echo base_url();?>admin/getlist/',
				"iDisplayLength": 25,
				"aaSorting": [[0, 'desc']],
				"aoColumns": [
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": true, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": true },
					{ "bVisible": true, "bSearchable": false, "bSortable": false }
				],
				"fnInitComplete": function () {
					oTable.fnAdjustColumnSizing();
				},
				'fnServerData': function (sSource, aoData, fnCallback) {
					aoData.push({name: '<?php echo $this->security->get_csrf_token_name();?>', value : '<?php echo $this->security->get_csrf_hash();?>'});
					$.ajax
					({
						'dataType': 'json',
						'type': 'POST',
						'url': sSource,
						'data': aoData,
						'success': fnCallback
					});
				}
			});
		});
    </script>
	<?php }?>
	
	<?php 
		if($this->uri->segment(1) == 'message' && ($this->uri->segment(2) == 'compose' || $this->uri->segment(2) == 'compose_submit')) {
	?>
	<script type="text/javascript">
        $(document).ready(function() {
			$('#search_register_date').change(function() {
				var val = $(this).val();
				if(val == 2) {
					$('#custom_date_panel').show();
				}
				else {
					$('#custom_date_panel').hide();
				}
			});
		});
    </script>
	<?php }?>
	
	<?php
        if($this->uri->segment(1) == 'announcement') {
    ?>
    <script type="text/javascript">
        +function() {
            $(document).ready(function() {
                tinymce.init({
                    selector:'textarea#message_en',
                    height: 450,
					document_base_url: "<?php echo base_url();?>",
					convert_urls : false,
					plugins: [
						"advlist autolink lists link image charmap print preview anchor",
						"searchreplace visualblocks code fullscreen",
						"insertdatetime media table contextmenu paste"
					],
					toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
                    file_browser_callback: function(field_name, url, type, win) {
                        if(type=='image') $('#file_form_en input').click();
                    }
                });
				tinymce.init({
					selector:'textarea#message_zh_cn',
					height: 450,
					document_base_url: "<?php echo base_url();?>",
					convert_urls : false,
					plugins: [
						"advlist autolink lists link image charmap print preview anchor",
						"searchreplace visualblocks code fullscreen",
						"insertdatetime media table contextmenu paste"
					],
					toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
					file_browser_callback: function(field_name, url, type, win) {
						if(type=='image') $('#file_form_zh_cn input').click();
					}
				});
				tinymce.init({
					selector:'textarea#message_zh_hk',
					height: 450,
					document_base_url: "<?php echo base_url();?>",
					convert_urls : false,
					plugins: [
						"advlist autolink lists link image charmap print preview anchor",
						"searchreplace visualblocks code fullscreen",
						"insertdatetime media table contextmenu paste"
					],
					toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
					file_browser_callback: function(field_name, url, type, win) {
						if(type=='image') $('#file_form_zh_hk input').click();
					}
				});
                $('#file_form_selector_en').on('change', function() {
                    $('#file_form_en').ajaxSubmit({
                        dataType: 'json',
                        method: 'post',
                        success: function(resp) {
                            if (resp.status && resp.status == 'success') {
                                $('.mce-btn.mce-open').parent().find('.mce-textbox').val(resp.img).closest('.mce-window').find('.mce-primary').click();
                            } else {
                                alert(resp.msg);
                            }

                            $(this).val('');
                            $('.mce-btn.mce-open').parent().find('.mce-textbox').val('');
                        }
                    });
                });
				$('#file_form_selector_zh_cn').on('change', function() {
					$('#file_form_zh_cn').ajaxSubmit({
						dataType: 'json',
						method: 'post',
						success: function(resp) {
							if (resp.status && resp.status == 'success') {
								$('.mce-btn.mce-open').parent().find('.mce-textbox').val(resp.img).closest('.mce-window').find('.mce-primary').click();
							} else {
								alert(resp.msg);
							}

							$(this).val('');
							$('.mce-btn.mce-open').parent().find('.mce-textbox').val('');
						}
					});
				});
				$('#file_form_selector_zh_hk').on('change', function() {
					$('#file_form_zh_hk').ajaxSubmit({
						dataType: 'json',
						method: 'post',
						success: function(resp) {
							if (resp.status && resp.status == 'success') {
								$('.mce-btn.mce-open').parent().find('.mce-textbox').val(resp.img).closest('.mce-window').find('.mce-primary').click();
							} else {
								alert(resp.msg);
							}

							$(this).val('');
							$('.mce-btn.mce-open').parent().find('.mce-textbox').val('');
						}
					});
				});
            });
        }(jQuery);
    </script>
    <?php
        }
    ?>
	
	<script type="text/javascript">
		function validateForm(formId) {
			$('form .btn').attr("disabled", true);
			if (confirm('<?php echo $this->lang->line('js_text_confirm_to_proceed');?>')) {
				$('#' + formId).submit(function(e) {
					e.preventDefault();
					this.submit();
				});
				
				return true;
			}
			else {
				$('form .btn').attr("disabled", false);
			}
			
			return false;
		}
	</script>
	
	<?php if($this->uri->segment(1) == 'admin') {?>
	<script>
		$(document).ready(function() {
			$('#modules-selector').select2({
				allowClear: true
			});
		});
	</script>
	<?php } ?>

	<!-- END JAVASCRIPTS -->

</body>

<!-- END BODY -->

</html>