var str = window.location.href;
var rest = str.substring(0, str.lastIndexOf("/") + 1);
var vars = str.substring(str.lastIndexOf("/") + 1, str.length);
var last = vars.split("&");
var currentPageType = last = last[0].split("?")[0];
var currentPage = currentPageType;
var isMarketingPage = true;
$(document).ready(function(){
$("#originPage").val(currentPageType);
handleNavigationLinks(last);
});
function replaceDashWithSpace(str){
str = str.replace(/-/g, ' ');
return str;
}
function handleNavigationLinks(last){
//Mobile - adding the bread crumb
currentPagename = replaceDashWithSpace(last);
currentPagename += ' ';
$("#bcr-current-page").html(currentPagename); // For mobile
//Reseting the menus active state
$(".leaf > a").removeClass("active");
$(".menu-head").removeClass("active");
//To add active state to the left nav menus
$(".link-"+last).addClass("active");
$(".link-"+last).closest(".menu-group").find(".menu-head").addClass("active");
$(".link-"+last).closest(".menu-group").find(".sub-menus").show();
$(".level-2 li a.selected").closest("li.open").find("a.open").addClass("active");
$(".level-2 li a.selected").append(' ');
//Adding class to change the jimf in top left section
$(".leftnav-jimf").addClass("jimf-"+last);
//Handling click/navigation happens from the menu list - leftside
$(".menu-head").click(function(){
$(".menu-head").removeClass("active");
$(".sub-menus").slideUp();
$(this).addClass("active");
$(this).siblings(".sub-menus").slideDown();
});
//Mobile leftbox open
$('.nav-open-link > i').click(function(){
$(".left-section").addClass("leftbox-active");
$(".aui .row-fluid .portlet-column-first.span4").addClass("leftbox-active");
$(".leftbar-separate-window").addClass("leftbox-active");
$(".mobile-menu-overlay-new").show();
});
//Mobile leftbox close
$(".mobile-menu-closebut").click(function(){
$(".left-section").removeClass("leftbox-active");
$(".aui .row-fluid .portlet-column-first.span4").removeClass("leftbox-active");
$(".leftbar-separate-window").removeClass("leftbox-active");
$(".mobile-menu-overlay-new").hide();
})
}