$(".datepicker").datepicker({
	format: "mm/dd/yyyy",
	clearBtn: !0,
	multidate: !0,
	multidateSeparator: ",",
	autoclose: !0,
	todayHighlight: !0,
	changeMonth: true,
    changeYear: true
});
$(".input-daterange-datepicker").daterangepicker({
	buttonClasses: ["btn", "btn-sm"],
	applyClass: "btn-secondary",
	cancelClass: "btn-primary",
	showDropdowns:true,
	
});
$(".select2").select2();
    $(".select2-limiting").select2({
        maximumSelectionLength: 6
    })
    
    $(document).ready(function() {
        var radio_selected = $('input[name="aadhar"]:checked').val()
        if(radio_selected == 1){
            $('#adhar-input').show();
            $('#national-id').hide();
            
        }else{
            $('#adhar-input').hide();
            $('#national-id').show();
        }
    })
    $("input[name='aadhar']").click(function(){
        var radioValue = $("input[name='aadhar']:checked").val();
        if(radioValue == 1){
            $('#adhar-input').show();
            $('#national-id').hide();
            $('#national-id-num').hide();
        }else{
            $('#adhar-input').hide();
            $('#national-id').show();
        }
    });
    
    $('#national-id-num').hide();
    $('#id-card').on('change', function() {
      var data = $("#id-card option:selected").text();		  
      if(data == "Select Id Card"){
        $('#national-id-num').hide();
      }else{
          $('#national-id-num').show();
      }
    })

    
    
    $('.aadhar-no').mask('0000-0000-0000');
    $('.mobile-no').mask('0000000000');
	$('.pincode').mask('000000');

    
    
$(document).ready(function() {
	var max_fields = 15; //maximum input boxes allowed
	var wrapper = $(".input_fields_wrap"); //Fields wrapper
	var add_button = $(".add-delete-btn"); //Add button ID
	var x = 1; //initlal text box count
	$(add_button).click(function(e){ //on add input button click
		e.preventDefault();
		if(x < max_fields){ //max input box allowed
		x++; //text box increment
		$(wrapper).append('<fieldset><legend>Family Member '+ x +'</legend><a class="btn btn-danger add-delete-btn2" href="javascript:void(0);"><i class="fa fa-minus"></i></a><div class="row"><div class="col-md-4"><div class="form-group"><label class="col-form-label">Name</label><div class="input-group"><input type="text" class="form-control" placeholder="" name="m-name[]"><div class="input-group-append"><select class="form-control" name="relation[]"><option value="">Relation</option><option value="Father">Father</option><option value="Mother">Mother</option><option value="Uncle">Uncle</option><option value="Uncle">Aunty</option><option value="Wife">Wife</option><option value="Husband">Husband</option><option value="Brother">Brother</option><option value="Sister">Sister</option></select></div></div></div></div><div class="col-md-4"><div class="form-group"><label class="col-form-label">Age:</label><input type="number" class="form-control" name="mage[]"> </div></div><div class="col-md-4"><div class="form-group"><label class="col-form-label">Education:</label><select class="form-control" name="meducation[]"><option value="">Education</option><option value="Post Graduate">Post Graduate</option><option value="Graduate">Graduate</option><option value="12th">12th</option><option value="10th">10th</option><option value="8th">8th</option><option value="5th">5th</option></select></div></div><div class="col-md-4"><div class="form-group"><label class="col-form-label">Occupation:</label><input type="text" class="form-control" name="moccupation[]"></div></div><div class="col-md-4"><div class="form-group"><label class="col-form-label">Monthly Income:</label><div class="input-group"><div class="input-group-prepend"><div class="input-group-text"><i class="fa fa-rupee-sign"></i></div></div><input type="text" class="form-control" name="mmincome[]"></div></div></div></div></fieldset>'); //add input box
		}
	});
	$(wrapper).on("click",".add-delete-btn2", function(e){ //user click on remove text
	e.preventDefault(); $(this).parent('fieldset').remove(); x--;
	})
});

$(".dropify").dropify({
		messages:{
			default:"Drag and drop a file here or click",
			replace:"Drag and drop or click to replace",
			remove:"Remove",
			error:"Ooops, something wrong appended."
		},
		error:{
			fileSize:"The file size is too big (1M max)."
		}
		
});

$(".btn-fixed-circle").hover(function(){
	$('.show_hide').css({"color":"red","transform":"rotate(180deg)","margin-left":"105px","margin-bottom":"-50px"});
	$('.show_hide').toggle();
	
});

$(".show_hide").hide();

$(".btn-fixed-circle").hover(
  function () {
	$(this).closest('.add-button-bg').addClass("active");
  },
  function () {
	$(this).closest('.add-button-bg').removeClass("active");
  }
);   

$('body').attr('class',$.cookie('btnclass'));
function checkWidth() {
	var windowSize = $(window).width();

	
	if (windowSize <= 768) {
		$.cookie('btnclass', '',{ expires: 7, path: '/' });
		$('.button-menu-mobile').on("click",function(){
			$('body').toggleClass("sidebar-enable")
		});
	}
	else if (windowSize >= 768) {
		if($.cookie('btnclass')=='sidebar-enable enlarged'){
			$('body').addClass('sidebar-enable enlarged');
		}			
		$('.button-menu-mobile').on("click",function(){
			var initial = $('body').attr('class');	
			if(initial == 'sidebar-enable enlarged'){
				$.cookie('btnclass', '',{ expires: 7, path: '/' });
				$('body').removeClass('sidebar-enable enlarged');
			}else{
				$.cookie('btnclass', 'sidebar-enable enlarged',{ expires: 7, path: '/' });	
				$('body').addClass('sidebar-enable enlarged');	
			}
			//alert(initial);
		});
		
	}
}

// Execute on load
checkWidth();
// Bind event listener
//$(window).resize(checkWidth);


/*pie chart*/
// window.onload = function() { 
// 	$("#chartContainerCon").CanvasJSChart({ 
// 		title: { 
// 			text: "",
// 			fontSize: 24
// 		}, 
// 		axisY: { 
// 			title: "Products in %" 
// 		}, 
// 		legend :{ 
// 			verticalAlign: "center", 
// 			horizontalAlign: "right" 
// 		}, 
// 		data: [ 
// 		{ 
// 			type: "pie", 
// 			showInLegend: true, 
// 			toolTipContent: "{label} <br/> {y} %", 
// 			indexLabel: "{y} %", 
// 			dataPoints: [ 
// 				{ label: "Census",  y: 30.3, legendText: "Census"}, 
// 				{ label: "Soil Test",    y: 19.1, legendText: "Soil Test"  }, 
// 				{ label: "Coconut Farmer",   y: 4.0,  legendText: "Coconut Farmer" }, 
// 				{ label: "Child Monitoring",       y: 3.8,  legendText: "Child Monitoring"}, 
// 				{ label: "Pregnant Women",   y: 3.2,  legendText: "Pregnant Women" }, 
// 				{ label: "Others",   y: 39.6, legendText: "Others" } 
// 			] 
// 		} 
// 		] 
// 	}); 
// } 


window.onload = function() { 
	$("#chartContainer").CanvasJSChart({ 
		title: { 
			text: "",
			fontSize: 24
		}, 
		axisY: { 
			title: "Products in %" 
		}, 
		legend :{ 
			verticalAlign: "center", 
			horizontalAlign: "right" 
		}, 
		data: [ 
		{ 
			type: "pie", 
			showInLegend: true, 
			toolTipContent: "{label} <br/> {y} %", 
			indexLabel: "{y} %", 
			dataPoints: [ 
				{ label: "Census",  y: 30.3, legendText: "Census"}, 
				{ label: "Soil Test",    y: 19.1, legendText: "Soil Test"  }, 
				{ label: "Coconut Farmer",   y: 4.0,  legendText: "Coconut Farmer" }, 
				{ label: "Child Monitoring",       y: 3.8,  legendText: "Child Monitoring"}, 
				{ label: "Pregnant Women",   y: 3.2,  legendText: "Pregnant Women" }, 
				{ label: "Others",   y: 39.6, legendText: "Others" } 
			] 
		} 
		] 
	}); 
} 






// window.onload = function () {

// 	var options = {
// 		title: {
// 			text: ""
// 		},
// 		subtitles: [{
// 			text: ""
// 		}],
// 		animationEnabled: true,
// 		data: [{
// 			type: "pie",
// 			startAngle: 40,
// 			toolTipContent: "<b>{label}</b>: {y}%",
// 			showInLegend: "true",
// 			legendText: "{label}",
// 			indexLabelFontSize: 16,
// 			indexLabel: "{label} - {y}%",
// 			dataPoints: [
// 				{ y: 48.36, label: "Windows 7" },
// 				{ y: 26.85, label: "Windows 10" },
// 				{ y: 1.49, label: "Windows 8" },
// 				{ y: 6.98, label: "Windows XP" },
// 				{ y: 6.53, label: "Windows 8.1" },
// 				{ y: 2.45, label: "Linux" },
// 				{ y: 3.32, label: "Mac OS X 10.12" },
// 				{ y: 4.03, label: "Others" }
// 			]
// 		}]
// 	};
// 	$("#chartContainer").CanvasJSChart(options);
	
// 	}

/* select for add widget*/

document.getElementById('SelectOption').addEventListener('change', function() {
	val = $( "#SelectOption" ).val();
	  
	console.log(val)
	if(val === 'Pie Chart') {
	  window.open('Census-pie.php','_self');
	  }
	if(val === 'Bar Chart') {
	  window.open('Census-bar.php','_self');
	}
	if (val === 'Data_list') {
	  window.open('data_list.php', '_self');
	}
  });


/*bar chart*/


$(function() {
	var chart_data = getData();
	var options = {
	   data: chart_data, // data for chart rendering
	   legend: { // default legend settings
		  position: LegendPosition.right, // legend position (LegendPosition.bottom, LegendPosition.top, LegendPosition.right, LegendPosition.left)
		  width: 130 // legend width in pixels for left/right
	   }
	};
	$('#chtAnimatedBarChart').animatedBarChart(options);
 });

 getData = function() {
	return [
	   { "group_name": "Census", "name": "Jan", "value": 38367 },
	   { "group_name": "Census", "name": "Feb", "value": 32684 },
	   { "group_name": "Census", "name": "Mar", "value": 28236 },
	   { "group_name": "Census", "name": "Apr", "value": 44205 },
	   { "group_name": "Census", "name": "May", "value": 3357 },
	   { "group_name": "Census", "name": "Jun", "value": 3511 },
	   { "group_name": "Census", "name": "Jul", "value": 10372 },
	   { "group_name": "Census", "name": "Aug", "value": 15565 },
	   { "group_name": "Census", "name": "Sep", "value": 23752 },
	   { "group_name": "Census", "name": "Oct", "value": 28927 },
	   { "group_name": "Census", "name": "Nov", "value": 21795 },
	   { "group_name": "Census", "name": "Dec", "value": 49217 },
	   { "group_name": "Soil Test", "name": "Jan", "value": 28827 },
	   { "group_name": "Soil Test", "name": "Feb", "value": 13671 },
	   { "group_name": "Soil Test", "name": "Mar", "value": 27670 },
	   { "group_name": "Soil Test", "name": "Apr", "value": 6274 },
	   { "group_name": "Soil Test", "name": "May", "value": 12563 },
	   { "group_name": "Soil Test", "name": "Jun", "value": 31263 },
	   { "group_name": "Soil Test", "name": "Jul", "value": 24848 },
	   { "group_name": "Soil Test", "name": "Aug", "value": 41199 },
	   { "group_name": "Soil Test", "name": "Sep", "value": 18952 },
	   { "group_name": "Soil Test", "name": "Oct", "value": 30701 },
	   { "group_name": "Soil Test", "name": "Nov", "value": 16554 },
	   { "group_name": "Soil Test", "name": "Dec", "value": 36399 },
	   { "group_name": "Coconut Farmer", "name": "Jan", "value": 38674 },
	   { "group_name": "Coconut Farmer", "name": "Feb", "value": 9595 },
	   { "group_name": "Coconut Farmer", "name": "Mar", "value": 7520 },
	   { "group_name": "Coconut Farmer", "name": "Apr", "value": 2568 },
	   { "group_name": "Coconut Farmer", "name": "May", "value": 6583 },
	   { "group_name": "Coconut Farmer", "name": "Jun", "value": 44485 },
	   { "group_name": "Coconut Farmer", "name": "Jul", "value": 3405 },
	   { "group_name": "Coconut Farmer", "name": "Aug", "value": 31709 },
	   { "group_name": "Coconut Farmer", "name": "Sep", "value": 45442 },
	   { "group_name": "Coconut Farmer", "name": "Oct", "value": 37580 },
	   { "group_name": "Coconut Farmer", "name": "Nov", "value": 23445 },
	   { "group_name": "Coconut Farmer", "name": "Dec", "value": 7554 },
	   { "group_name": "Pregnant Women", "name": "Jan", "value": 40110 },
	   { "group_name": "Pregnant Women", "name": "Feb", "value": 35605 },
	   { "group_name": "Pregnant Women", "name": "Mar", "value": 15768 },
	   { "group_name": "Pregnant Women", "name": "Apr", "value": 15075 },
	   { "group_name": "Pregnant Women", "name": "May", "value": 12424 },
	   { "group_name": "Pregnant Women", "name": "Jun", "value": 12227 },
	   { "group_name": "Pregnant Women", "name": "Jul", "value": 40906 },
	   { "group_name": "Pregnant Women", "name": "Aug", "value": 34032 },
	   { "group_name": "Pregnant Women", "name": "Sep", "value": 18110 },
	   { "group_name": "Pregnant Women", "name": "Oct", "value": 4755 },
	   { "group_name": "Pregnant Women", "name": "Nov", "value": 42202 },
	   { "group_name": "Pregnant Women", "name": "Dec", "value": 36183 }
	];
 }


 /****************************** */
//  bar and pie chart in single page


// $("#chartContainer").click(function(e){
//     e.preventDefault();
//     $(".toggle").hide();
//     var toShow = $(this).attr('href');
//     $(toShow).show();
// });

// $("#chtAnimatedBarChart").click(function(e){
//     e.preventDefault();
//     $(".toggle").hide();
//     var toShow = $(this).attr('href');
//     $(toShow).show();
// });


$("#first , #second a").click(function(e){
    e.preventDefault();
    $(".toggle").hide();
    var toShow = $(this).attr('href');
    $(toShow).show();
});