/*
  $Id$
  */
//ignorei18n_start
// JavaScript Document
$(document).ready(function () {
	$(".ic").on('click', function () {
		$(".menu-it").slideToggle();
		$(this).toggleClass('active');
		$(".lhs").toggleClass('active');
	});
	$(".mclo").on('click', function () {
		$(".lhs").removeClass('active');
		$(".ic").removeClass('active');
		$(".menu-it").slideUp();
	});

	$('a[href*=\\#]').on('click', function (e) {
		// e.preventDefault();
		var target = this.hash,
			$target = $(target);

		$('html, body').stop().animate({
			'scrollTop': $target.offset().top - 70
		}, 900, 'swing', function () {
			window.location.hash = target;
		});
	});


	if (window.location.hash) {
		var offset = -100;
		// smooth scroll to the anchor id
		$('html, body').animate({
			scrollTop: ($(window.location.hash).offset().top + offset) + 'px'
		}, 1000, 'swing');
	}


	/*$("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){
			//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');
		}*/


});

$(document).ready(function () {

	var nav = [{
			"title": "Welcome to ADSelfService Plus",
			"url": "index.html"
		}, {
			"title": "Features On Offer",
			"url": "features.html"
		},
		{
			"title": "Getting Started",
			"url": "gettingstarted/getting-started.html",
			"children": [{
				"title": "System Requirements",
				"url": "requirements.html"
			}, {
				"title": "Installing ADSelfService Plus",
				"url": "installation.html"
			}, {
				"title": "Starting and accessing ADSelfService Plus",
				"url": "working.html"
			}, {
				"title": "Licensing of ADSelfService Plus",
				"url": "gettingstarted/licensing.html"
			}]
		}, {
			"url": "domain-settings.html",
			"title": "Domain Configuration"
		}, {
			"title": "Rolling out ADSelfService Plus",
			"url": "Deployment/Deployment.html",
			"children": [{
				"title": "Password Self-Service Deployment",
				"url": "Deployment/Password-Self-Service-Deployment.html"
			}, {
				"title": "Security Management",
				"url": "Deployment/Security-Settings.html"
			}, {
				"title": "Directory Self-Service Deployment",
				"url": "Deployment/Directory-Self-Service.html"
			}, {
				"title": "One Identity Configuration",
				"url": "Deployment/One-Identity.html"
			}, ]
		}, {
			"title": "Know Your Product",
			"url": "Deployment/product-introduction.html",
			"children": [{
				"title": "Dashboard",
				"url": "Dashboard.html"
			}, {
				"title": "Reports",
				"url": "Reports/Reports.html",
				"children": [{
					"title": "User Report",
					"url": "Reports/User-Report.html",
					"children": [{
						"title": "Locked Out Users Report",
						"url": "Reports/LockedOutUsersReport.html"
					}, {
						"title": "Soon-To-Expire User Passwords",
						"url": "Reports/SoonToExpireUsersReport.html",
					}, {
						"title": "Password Expired Users Report",
						"url": "Reports/PasswordExpiredUsersReport.html",
					}]
				}, {
					"title": "Audit Reports",
					"url": "Reports/Audit-Report.html",
					"children": [{
						"title": "Reset Password Audit Report",
						"url": "Reports/ResetPasswordAuditReport.html"
					}, {
						"title": "Unlock Account Audit Report",
						"url": "Reports/UnlockAccountAuditReport.html"
					}, {
						"title": "Self-Update Audit Report",
						"url": "Reports/SelfUpdateAuditReport.html"
					}, {
						"title": "Change Password Audit Report",
						"url": "Reports/ChangePasswordAuditReport.html"
					}, {
						"title": "Notifications Delivery Report",
						"url": "Reports/NotificationDeliveryReport.html"
					}, {
						"title": "Identity Verification Failures Audit Report",
						"url": "Reports/IdentityVerificationFailureReport.html"
					}, {
						"title": "User Attempts Audit Report",
						"url": "Reports/UserAttemptsAuditReport.html"
					}, {
						"title": "Blocked Users Report",
						"url": "Reports/BlockedUsersReport.html"
					}]
				}, {
					"title": "Enrollment Reports",
					"url": "Reports/Enroll-Report.html",
					"children": [{
						"title": "Enrolled Users Report",
						"url": "Reports/EnrolledUsersReport.html"
					}, {
						"title": "Non-Enrolled Users Report",
						"url": "Reports/NonEnrolledUsersReport.html"
					}, {
						"title": "Licensed Users Report",
						"url": "Reports/LicensedUsersReport.html"
					}, {
						"title": "Security Questions Report",
						"url": "Reports/SecurityQuestionsReport.html"
					}, {
						"title": "Push Registered Devices Report",
						"url": "Reports/PushRegisteredDevicesReport.html"
					}]
				}, {
					"title": "Schedule Reports",
					"url": "Reports/schedule-reports.html"
				}]
			}, {
				"title": "Configuration",
				"url": "Configuration/configuration-tab.html",
				"children": [{
					"title": "Self-Service",
					"url": "Configuration/Self-Service/Self-Service-Tab.html",
					"children": [{
						"title": "Policy Configuration",
						"url": "Configuration/Self-Service/Policy-Configuration-Steps.html",
						"children": [{
							"title": "Advanced Configuration",
							"url": "Configuration/Self-Service/Advanced/Advanced.html",
							"children": [{
								"title": "Block Users",
								"url": "Configuration/Self-Service/Advanced/Block-User.html"
							}, {
								"title": "Reset Unlock",
								"url": "Configuration/Self-Service/Advanced/Reset-Unlock.html"
							}, {
								"title": "Password Sync",
								"url": "Configuration/Self-Service/Advanced/password-sync-settings.html"
							}, {
								"title": "Notification",
								"url": "Configuration/Self-Service/Advanced/Notification.html"
							}, {
								"title": "Automation",
								"url": "Configuration/Self-Service/Advanced/Automation.html"
							}, {
								"title": "General",
								"url": "Configuration/Self-Service/Advanced/General.html"
							}]
						}]
					}, {
						"title": "Multi-factor Authentication",
						"url": "Configuration/Self-Service/Identity-Verification-Steps.html",
						"children": [{
								"title": "MFA for Reset/Unlock",
								"url": "Configuration/Self-Service/mfa-for-password-reset-adselfservice-plus.html"
							}, {
								"title": "MFA for Applications",
								"url": "Configuration/Self-Service/enabling-mfa-for-applications.html"
							},  {
								"title": "MFA for Endpoints",
								"url": "Configuration/Self-Service/mfa-for-endpoints.html",
								"children": [{
									"title": "MFA for Windows, macOS, and Linux",
									"url": "Configuration/Self-Service/mfa-for-windows-macos-linux.html"
								}, {
									"title": "MFA for VPN",
									"url": "Configuration/Self-Service/steps-to-enable-mfa-for-vpn-logins.html"
								}, ]
							}, {
								"title": "Advanced Settings",
								"url": "Configuration/Self-Service/advanced.html"
							},
							{
								"title": "Authenticators",
								"url": "Configuration/Self-Service/supported-authenticators-for-mfa.html",
								"children": [{
									"title": "Security Questions and Answers",
									"url": "Configuration/Self-Service/question-answers.html"
								}, {
									"title": "Email Verification",
									"url": "Configuration/Self-Service/email-authentication.html"
								}, {
									"title": "SMS Verification",
									"url": "Configuration/Self-Service/sms-authentication.html"
								}, {
									"title": "Google Authenticator",
									"url": "Configuration/Self-Service/google-authenticator.html"
								}, {
									"title": "Microsoft Authenticator",
									"url": "Configuration/Self-Service/microsoft-authenticator.html"
								}, {
									"title": "Duo Security",
									"url": "Configuration/Self-Service/Duo-Security.html"
								}, {
									"title": "RSA SecurID",
									"url": "Configuration/Self-Service/RSASecurID.html"
								}, {
									"title": "RADIUS Authentication",
									"url": "Configuration/Self-Service/RADIUSAuthentication.html"
								}, {
									"title": "Push Notification Authentication",
									"url": "Configuration/Self-Service/push-authentication.html"
								}, {
									"title": "Fingerprint Authentication",
									"url": "Configuration/Self-Service/fingerprint-authentication.html"
								}, {
									"title": "QR Code-Based Authentication",
									"url": "Configuration/Self-Service/qrcode-authentication.html"
								}, {
									"title": "TOTP Authentication",
									"url": "Configuration/Self-Service/totp-authentication.html"
								}, {
									"title": "SAML Authentication",
									"url": "Configuration/Self-Service/saml-mfa-authentication.html"
								}, {
									"title": "AD Security Questions",
									"url": "Configuration/Self-Service/ad-security-questions.html"
								}, {
									"title": "YubiKey Authenticator",
									"url": "Configuration/Self-Service/yubiKey-authentication.html"
								}, {
									"title": "Zoho OneAuth TOTP Authenticator",
									"url": "Configuration/Self-Service/zoho-oneauth-totp-authenticator.html"
								}, {
									"title": "Smart Card Authentication",
									"url": "Configuration/Self-Service/smart-card-authentication.html"
								},{
									"title": "Custom TOTP Authenticator",
									"url": "Configuration/Self-Service/custom-totp-authenticator.html"
								}, ]
							},
						]
					}, {
						"title": "Password Expiry Notification",
						"url": "Configuration/Self-Service/Password-Expiry-Notification-Steps.html"
					}, {
						"title": "Password Policy Enforcer",
						"url": "Configuration/Self-Service/Password-Policy-Enforcer.html"
					}, {
				"title": "Password Sync/Single Sign-On",
				"url": "Application/application-home.html",
				"children": [{
					"title": "Password Synchronizer",
					"url": "Application/steps-to-enable-password-synchronizer.html",
					"children": [{
						"title": "389 Directory Server",
						"url": "Application/sync/password-synchronizer-dir389.html"
					}, {
						"title": "Active Directory",
						"url": "Application/sync/password-synchronizer-ad.html"
					}, {
						"title": "AD LDS",
						"url": "Application/sync/password-synchronizer-adlds.html"
					}, {
						"title": "G-Suite",
						"url": "Application/sync/password-synchronizer-google.html"
					}, {
						"title": "HP UX Directory Server",
						"url": "Application/sync/password-synchronizer-hpux.html"
					}, {
						"title": "IBM i/AS400 System",
						"url": "Application/sync/password-synchronizer-ibmas400.html"
					}, {
						"title": "Microsoft Dynamics CRM",
						"url": "Application/sync/password-synchronizer-dynamicscrm.html"
					}, {
						"title": "Microsoft SQL Server",
						"url": "Application/sync/password-synchronizer-mssql.html"
					}, {
						"title": "Office 365 / Azure",
						"url": "Application/sync/password-synchronizer-office365.html"
					}, {
						"title": "OpenLDAP",
						"url": "Application/sync/password-synchronizer-openldap.html"
					}, {
						"title": "Oracle Database",
						"url": "Application/sync/password-synchronizer-oradb.html"
					}, {
						"title": "Oracle E-business Suite",
						"url": "Application/sync/password-synchronizer-oraebs.html"
					}, {
						"title": "PostgreSQL Server",
						"url": "Application/sync/password-synchronizer-postgres.html"
					}, {
						"title": "Salesforce",
						"url": "Application/sync/password-synchronizer-salesforce.html"
					}, {
						"title": "SAP NetWeaver",
						"url": "Application/sync/password-synchronizer-sapnetweaver.html"
					}, {
						"title": "ServiceNow",
						"url": "Application/sync/password-synchronizer-servicenow.html"
					}, {
						"title": "Zendesk",
						"url": "Application/sync/password-synchronizer-zendesk.html"
					}, {
						"title": "Zoho",
						"url": "Application/sync/password-synchronizer-zoho.html"
					}, ]
				}, {
					"title": "Single Sign-On",
					"url": "Application/SSO.html"
				}]
			}, {
                "title": "Conditional Access",
                "url": "Configuration/Self-Service/conditional-access.html"
                }, {
                    "title": "Directory Self Service",
                    "url": "Configuration/Self-Service/directory-selfservice.html",
                    "children": [{
                        "title": "Self-Update Layout",
                        "url": "Configuration/Self-Service/sulayout/self-update-layout.html",
                        "children": [{
                            "title": "Field Customization",
                            "url": "Configuration/Self-Service/sulayout/field-customization.html"
                        }, {
                            "title": "Attribute List",
                            "url": "Configuration/Self-Service/sulayout/attribute-list.html"
                        }, {
                            "title": "Advanced Settings",
                            "url": "Configuration/Self-Service/sulayout/advanced.html"
                        }, {
                            "title": "How to",
                            "url": "Configuration/Self-Service/sulayout/layout-examples.html"
                        }, {
                            "title": "Modification Rules",
                            "url": "Configuration/Self-Service/sulayout/modification-rules.html"
                        }]
                    }, {
                        "title": "Employee Search",
                        "url": "Configuration/Self-Service/Employee-Search-Deployment-Steps.html"
                    }, {
                        "title": "Mail Group Subscription",
                        "url": "Configuration/Self-Service/mail-group-subscription.html"
                    }]
                }]
				}, {
					"title": "Administrative Tools",
					"url": "Configuration/Admin-Tools/Administrative-Tools.html",
					"children": [{
						"title": "Quick Enrollment",
						"url": "Configuration/Admin-Tools/Quick-Enrollment.html",
						"children": [{
							"title": "Force Enrollment",
							"url": "Configuration/Admin-Tools/Enrollment-Reminder-Steps.html"
						}, {
							"title": "Enrollment Notification",
							"url": "Configuration/Admin-Tools/Enrollment-Notification-Steps.html"
						}, {
							"title": "Auto Enrollment",
							"url": "Configuration/Admin-Tools/Auto-Enrollment-Steps.html"
						}, {
							"title": "External Data Sources",
							"url": "Configuration/Admin-Tools/External-Data-Sources-Steps.html"
						}]
					}, {
						"title": "Gina/Mac/Linux Installation",
						"url": "Configuration/Admin-Tools/GINA/GINA-Installation.html",
						"children": [{
							"title": "Gina/Mac/Linux Installation",
							"url": "Configuration/Admin-Tools/GINA/GINA-Mac-Linux-installation.html"
						}, {
							"title": "Gina/Mac/Linux Customization",
							"url": "Configuration/Admin-Tools/GINA/GINA-Customization.html"
						}, {
							"title": "Gina/Mac/Linux Schedulers",
							"url": "Configuration/Admin-Tools/GINA/GINA-Schedulers.html"
						}, {
							"title": "Updating Cached Credentials over VPN",
							"url": "Configuration/Admin-Tools/GINA/update-cached-crendentials.html"
						}]
					}, {
						"title": "Mobile App Deployment",
						"url": "Configuration/Admin-Tools/mobile-app-deployment.html"
					}, {
						"title": "Approval Workflow",
						"url": "Configuration/Admin-Tools/Self-Service-Approval.html"
					}, {
						"title": "Technician",
						"url": "Configuration/Admin-Tools/Technician-Steps.html"
					}]
				}, {
					"title": "Security Center",
					"url": "Configuration/Admin-Tools/Security-Center/Security-Center.html",
					"children": [{
						"title": "Password Strenghtheners",
						"url": "Configuration/Admin-Tools/Security-Center/Password-Strengtheners.html"
					}, {
						"title": "Security Q & A Strenghtheners",
						"url": "Configuration/Admin-Tools/Security-Center/Security-Strenghtheners.html"
					}, {
						"title": "Anti-Hacking System",
						"url": "Configuration/Admin-Tools/Security-Center/Anti-Hacking-System.html",
						"children": [{
							"title": "BruteForce/Dictionary Attack Preventers",
							"url": "Configuration/Admin-Tools/Security-Center/Brute-Force-Attack-Preventers.html"
						}, {
							"title": "Man-In-The-Middle Attack Preventers",
							"url": "Configuration/Admin-Tools/Security-Center/Man-In-The-Middle-Attack.html"
						}, {
							"title": "Safe-Guard Inactive Account Loopholes",
							"url": "Configuration/Admin-Tools/Security-Center/Safe-Guard-Inactive-Users.html"
						}]
					}]
				}]
			}, {
				"title": "Admin",
				"url": "Admin/admin-tab.html",
				"children": [{
						"title": "Customize",
						"url": "Admin/Customize.html",
						"children": [{
							"title": "Logon Settings",
							"url": "Admin/Logon-Settings.html",
							"children": [{
								"title": "SSO Settings",
								"url": "Admin/sso-settings.html"
							}, {
								"title": "Smart card Authentication",
								"url": "Admin/smart-card-authentication.html"
							}, ]
						}, {
							"title": "Personalize",
							"url": "Admin/Personalize.html"
						}]
					}, {
						"title": "Enterprise Essentials",
						"url": "Admin/enterprise-essentials.html",
						"children": [{
							"title": "High Availability",
							"url": "Admin/High-Availability.html"
						}, {
							"title": "Load Balancing",
							"url": "Admin/load-balancing-for-adselfservice-plus.html"
						}, {
							"title": "Reverse Proxy",
							"url": "Admin/reverse-proxy.html"
						}]
					}, {
						"title": "Product Settings",
						"url": "Admin/Product-Settings.html",
						"children": [{
							"title": "Connection",
							"url": "Admin/connection.html",
							"children": [{
								"title": "SSL Certification Tool",
								"url": "Admin/SSL-Tool-Guide.html"
							}, {
								"title": "Access Url",
								"url": "Admin/access-url.html"
							}, ]
						}, {
							"title": "Mail/SMS Settings",
							"url": "Admin/Server-Settings.html",
							"children": [{
								"title": "Mail Settings",
								"url": "Admin/server-settings/mail-server-settings.html"
							}, {
								"title": "SMS Settings",
								"url": "Admin/server-settings/sms-server-settings.html"
							}, ]
						}, {
							"title": "Dashboard Updater",
							"url": "Admin/Dashboard-Updater.html"
						}, {
							"title": "Automatic DB Backup",
							"url": "Admin/Automatic-DB-Backup.html"
						}, {
							"title": "Integration Settings",
							"url": "Admin/integration-settings.html"
						}, {
							"title": "Windows Service",
							"url": "Admin/Windows-Service.html"
						}, ]
					}, {
						"title": "License Management",
						"url": "Admin/License-Management.html",
						"children": [{
							"title": "Restrict Users",
							"url": "Admin/Restrict-Users.html"
						}]
					}
				]
			}]

		}, {
			"title": "Support",
			"url": "Admin/Support.html"
		}, {
			"title": "Troubleshooting Tips",
			"url": "troubleshooting.html",
			"children": [{
				"title": "Password Expiration Notification",
				"url": "how-to-enable-password-expiration-notification.html"
			}, {
				"title": "Gina login agent",
				"url": "gina-troubleshooting-tips.html"
			}, {
				"title": "macOS login agent",
				"url": "macOS-login-agent-troubleshooting-guide.html"
			}, {
				"title": "Linux login agent",
				"url": "linux-login-agent-troubleshooting-guide.html"
			}, {
				"title": "Password Sync Agent",
				"url": "password-sync-agent-troubleshooting-guide.html"
			}, {
				"title": "User portal",
				"url": "troubleshooting-guide-to-resolve-user-portal-issues.html"
			}]
		}
	];

	// build menus
	var currentUrl;

	function buildMenu(data) {
		if (data.length > 0) {
			var ulCon = $("<ul/>");
			for (var i = 0; i < data.length; i++) {
				var liCon = $("<li/>");
				var alink = $("<a/>");
				alink.text(data[i].title);
				alink.attr("title", data[i].title);
				alink.attr("href", data[i].url);
				alink.attr("data-href", data[i].url);

				// As SAML Application pages are not having left menu option, Need to set its parent SSO.html as default URL so that no issue would in left menu naviation. 
				var isSAMLAppPage = (location.href.indexOf("Application/sso/") != -1 && data[i].url.indexOf("Application/SSO.html") != -1);
				if (isSAMLAppPage || location.href.indexOf(data[i].url) != -1) {
					liCon.addClass("in");
					currentUrl = data[i].url;
				}
				liCon.append(alink);
				if (data[i].children && data[i].children.length > 0) {
					var childCon = buildMenu(data[i].children);
					liCon.append(childCon);
					liCon.addClass("arrow");
				} else {
					liCon.addClass("book");
				}
				ulCon.append(liCon);
			}
			return ulCon;
		}

	};
	// for exact url navigation
	$(document).on("click", ".vertical-menu li a", function (e) {
		$(this).attr("href",$(this).attr("data-href"));
		
		var isSAMLAppPage = location.href.indexOf("Application/sso/") != -1;
		if (isSAMLAppPage || location.href.indexOf(currentUrl) != -1) {
			var index = location.href.indexOf(currentUrl);
			if (isSAMLAppPage) {
				index = location.href.indexOf("Application/sso");
			}
			location.replace(location.href.slice(0, index) + $(this).attr("href"));
			e.preventDefault();
		}
		
		
	})

	//opens currect active page
	$(".lhs > div").html(buildMenu(nav).addClass("vertical-menu").attr("id", "vMenu"));

	$("#vMenu li.in").parents("li").addClass("in");

	$(".vertical-menu li a").contextmenu(function (e) {
		var futureUrl = $(this).attr("href");
		var baseUrl = "/admin-guide/";
		var isFutureURLISSet = (futureUrl.indexOf(baseUrl) == -1) ? false : true;
		var hostURL = window.location.href.substr(0, window.location.href.indexOf(baseUrl));
		if (!isFutureURLISSet) {
			$(this).attr("href", hostURL + baseUrl + futureUrl);
		}
	});
});
//ignorei18n_end