$(document).ready(function() {
	  // Ripple
	  $('[ripple]').on('click', function (e) {
	  	var rippleDiv = $('<div class="ripple" />'),
	  	rippleOffset = $(this).offset(),
	  	rippleY = e.pageY - rippleOffset.top,
	  	rippleX = e.pageX - rippleOffset.left,
	  	ripple = $('.ripple');

	  	rippleDiv.css({
	  		top: rippleY - (ripple.height() / 2),
	  		left: rippleX - (ripple.width() / 2),
	  		background: $(this).attr("ripple-color")
	  	}).appendTo($(this));

	  	window.setTimeout(function () {
	  		rippleDiv.remove();
	  	}, 1500);
	  });

	 // ADD SLIDEDOWN ANIMATION TO DROPDOWN //
	  $('.dropdown').on('show.bs.dropdown', function(e){
	  	$(this).find('.dropdown-menu').first().stop(true, true).show();
	  });
	  // ADD SLIDEUP ANIMATION TO DROPDOWN //
	  $('.dropdown').on('hide.bs.dropdown', function(e){
	  	$(this).find('.dropdown-menu').first().stop(true, true).fadeOut(300)
	  });

 	 // $('#myTabs').on('click', '.dc li', function(){
     //                $(this).closest('.dropdown').addClass('dontClose');
     //            })
     //            $('#myDropDown').on('hide.bs.dropdown', function(e) {
     //                if ( $(this).hasClass('dontClose') ){
     //                    e.preventDefault();
     //                }
     //                $(this).removeClass('dontClose');
     //            });

	$('#side-swh').click(function(){
		if ($(this).hasClass('open')) {
			$(this).removeClass('open');
			$('#right-side-bar').hide('right');
		}
		else{
			$(this).addClass('open');
			$('#right-side-bar').show('right');
		}
	});

// thaeme swicher
$('.swh-sm li').click(function(){
	var th_name = $(this).attr('data-theam')
	var tvalue = $('aside').attr('data-tvalue')
	$('aside').removeClass(tvalue).addClass(th_name).attr('data-tvalue',th_name);
});
$('#s-cs').change(function() {
	if($(this).is(":checked")) {
		var tvalue = $('aside').attr('data-tvalue');
		$('aside').removeClass(tvalue).addClass('custom').attr('data-tvalue','custom');
		$('#s-body').removeClass('disabled');
	}
	else{
		$('aside').removeClass('custom').addClass('').attr('data-tvalue','');
		$('#s-body').addClass('disabled');
	}
});
$('.swh-tb li').click(function(){
	var th_name = $(this).attr('data-theam')
	var tvalue = $('#header').attr('data-tvalue')
	$('#header').removeClass(tvalue).addClass(th_name).attr('data-tvalue',th_name);
});
$("#s-bg").spectrum({
    	change: function(color) {
    var sbg = color.toHexString();
	$('aside').css('background',sbg);
    }
});
$('.swh-b li').click(function(){
	var th_name = $(this).attr('data-theam')
	var tvalue = $('body').attr('data-tvalue')
	$('body').removeClass(tvalue).addClass(th_name).attr('data-tvalue',th_name);
});
$("input[name=sm-style]:radio").change(function(){
	var sm = $(this).val();
	aside.addClass(sm);
});
// end
  $('.page-heading').rippleria({
		  // aniamtion speed
		  duration: 3000,
		  // custom easing effect
		  easing: 'ease-in-out',
		  // custom color
		  color: '#fff'
		});
  $('.side-toggle').rippleria({duration: 700,easing: 'ease-in-out',color: 'rgba(255, 255, 255, 0.3)'});
  //$('.btn').rippleria({duration: 700,easing: 'ease-in-out',color: 'rgba(255, 255, 255, 0.28)'});
 // $('.btn-round').rippleria({duration: 500,easing: 'ease-in-out',color: 'rgba(134, 134, 134, 0.48)'});
	//$('.big li.side-menu').rippleria({duration: 700,easing: 'ease-in-out',color: 'rgba(66, 133, 244, 0.5)'});
	//$('.material').materialForm();
	$('.cst-btn').click(function (e) {
		e.preventDefault();
		$(this).parent().toggleClass('expand');
		$(this).parent().children().toggleClass('expand');
	});
	$('.date-picker').datepicker({language: 'en'})
	$('.clockpicker').clockpicker();
	//side menu
	var ns_data = {
			cursorcolor:"#E9188F",
			cursoropacitymin:"0.3",
			cursoropacitymax:"0.7",
			cursorwidth:"4px",
			cursorborder:"0",
			cursorborderradius:"0",
			mousescrollstep:"10",
			touchbehavior:true,
			autohidemode:false,
			background:"#ccc"
		};
	if ($('aside').hasClass('big')) {
		$("aside.big").niceScroll(ns_data);
		$("aside.big").hover(function() {
			$("aside.big").getNiceScroll().show()
		}, function() {
			$("aside.big").getNiceScroll().hide()
		});
	};
	$('aside.big').click(function(){
		$("aside.big").getNiceScroll().resize();
	});
	$( "#side-toggle" ).click(function() {
		if ($('#side-bar-left').hasClass( "big" )){
			$("aside.big").getNiceScroll().hide()
			$("#side-bar-left").removeClass("big").addClass( "mini").css("overflow","visible");
			$(".main-contant").css("padding-left","70px")
		}
		else if ($('#side-bar-left').hasClass( "mini" )){
			$("#side-bar-left").removeClass("mini").addClass( "big").css("overflow","hidden");
			$("aside.big").getNiceScroll().show()
			$(".main-contant").css("padding-left","235px")
		}
	});
	// end side menu
	$(".m-s").select2();
	$(".multiselect").multiselect({
            includeSelectAllOption: true,
            enableFiltering: true
        });
	$('.search-ic').click(function(){
		if ($(this).parent('.add-search').hasClass('open')){
			$(this).parent('.add-search').removeClass('open')
			$(this).children('.fa').removeClass('fa-times')
		}
		else{
			$(this).parent('.add-search').addClass('open')
			$(this).children('.fa').addClass('fa-times')
		}
	});
	function zoomTbl(){
		var fsize = 16;
		$('.z-plus').click(function(){
		fsize += 1;
		$(this).parents('.tbl-zoom').children('table').css('font-size',fsize+'px')
		if (fsize>21) {$(this).addClass('disabled')};
		if (fsize>13) {$(this).parents('.add-zoom').children('.z-min').removeClass('disabled')};
		});
		$('.z-min').click(function(){
		fsize -= 1;
		$(this).parents('.tbl-zoom').children('table').css('font-size',fsize+'px')
		if (fsize<14) {$(this).addClass('disabled')};
		if (fsize<22) {$(this).parents('.add-zoom').children('.z-plus').removeClass('disabled')};
		});
	}
	zoomTbl();
	$('li.has-sub>a').click(function(){
		if ($(this).parent('li.has-sub').hasClass('open')) {
			$(this).parent('li.has-sub').removeClass('open');
			$(this).parent('li.has-sub').children('ul').slideUp( "slow" );
		}
		else {
			$(this).parent('li.has-sub').addClass('open');
			$(this).parent('li.has-sub').children('ul').slideDown( "slow" );
		}
	});
});

$(window).load( function() {
        $('#mycalendar').monthly();
});

function h3i(){
	$(".box-sm").each(function(){
		var vx = $('h3',this).attr('data-value');
		var tx = vx-250;
	//if (tx<-1) {tx=0}
	var h3p = $('h3',this);
	var h3t = setInterval(function () {
		h3p.html(tx);
		tx=tx+1;
		if(tx==vx){clearTimeout(h3t);}
	},10);
});
}
h3i();

function requestFullScreen() {

 if ((document.fullScreenElement && document.fullScreenElement !== null) ||
   (!document.mozFullScreen && !document.webkitIsFullScreen)) {
    if (document.documentElement.requestFullScreen) {
      document.documentElement.requestFullScreen();
    } else if (document.documentElement.mozRequestFullScreen) {
      document.documentElement.mozRequestFullScreen();
    } else if (document.documentElement.webkitRequestFullScreen) {
      document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
    }
  } else {
    if (document.cancelFullScreen) {
      document.cancelFullScreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen();
    }
  }
}