<%
/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%>

<c:if test="<%= themeDisplay.isSignedIn() && !PropsValues.SESSION_DISABLED %>">

	<%
	String autoRememberMe = CookieKeys.getCookie(request, CookieKeys.REMEMBER_ME);
	%>

	<c:if test="<%= Validator.isNull(autoRememberMe) %>">

		<%
		int sessionTimeout = PropsValues.SESSION_TIMEOUT;
		int sessionTimeoutMinute = sessionTimeout * (int)Time.MINUTE;
		int sessionTimeoutWarning = PropsValues.SESSION_TIMEOUT_WARNING;
		int sessionTimeoutWarningMinute = sessionTimeoutWarning * (int)Time.MINUTE;
		int timeoutDiff = (sessionTimeout - sessionTimeoutWarning) * (int)Time.MINUTE;

		Calendar sessionTimeoutCal = CalendarFactoryUtil.getCalendar(timeZone);

		sessionTimeoutCal.add(Calendar.MILLISECOND, sessionTimeoutMinute);
		%>

		<c:if test="<%= sessionTimeoutWarning > 0 %>">
			<aui:script use="liferay-session">
				Liferay.Session.init(
					{
						autoExtend: <%= PropsValues.SESSION_TIMEOUT_AUTO_EXTEND %>,
						timeout: <%= sessionTimeout %>,
						timeoutWarning: <%= sessionTimeoutWarning %>,
						redirectOnExpire: <%= PropsValues.SESSION_TIMEOUT_REDIRECT_ON_EXPIRE %>
					}
				);
			</aui:script>
		</c:if>
	</c:if>
</c:if>