// JavaScript Document
$(document).ready(function(){
	
$("body").on('click', ".vertical-menu li.arrow a", function(event){
	$(this).parent("li").toggleClass("in");
		localStorage.setItem("dataid", $(this).parent("li").attr("data-id"));
	});

	$("body").on('click', ".vertical-menu li.book > a", function(event){
		localStorage.setItem("dataid", $(this).parent("li").attr("data-id"));
		event.stopImmediatePropagation();
	});
	
	
	
	if(localStorage.getItem("dataid") === null || localStorage.getItem("dataid").length == 0){
		//sidebar menu function
		var k = window.location.pathname;
		var n = k.lastIndexOf("/") + 1;
		var m = k.slice(n);
		var v = $(".vertical-menu li a");
		var anchr;
		$.each(v, function(index, item){
			var temp  = $(item).attr('href');
			if(temp.indexOf(m) != -1){
				anchr = item;
				$(anchr).parents("li.arrow").addClass('in');
			}
		})
		//sidebar ends
	}else{
		var dataid = localStorage.getItem("dataid");
		$("li[data-id='"+dataid+"']").addClass('in');
		$("li[data-id='"+dataid+"']").parents("li.arrow").addClass('in');
	}
	
	
	//Clearing dataid in localstorage for sidemenu
	localStorage.setItem("dataid", "");
	
	
});