/*
* Application Timeout 30min
* Prompt with 10min Remaining w/Modal
* Prompt all Windows with 5min Remaining
* Redirect when Time is up
* Created by Jon Lokken 2/17/2011
* - Updated 3/8/2011 (JLL)
* Accounted for the possibility of multiple window.onload calls
* - Updated 3/14/2011 (JLL)
* Added the HTML Include for the response back to the page
* Added method for logout
* - Updated 3/28-31/2011 (JLL)
* Completed logout code
* - Updated 3/31/2011 (JLL)
* Added Logging Debug Windows
* - Updated 4/7/2011 (JLL)
* Added Application Session End Page Call if Needed
* - Updated 4/21/2011 (JLL)
* Fixed Local Development Error
* - Updated 5/2/2011 (JLL)
* Fixed IE8.0 AJAX Browser Cache
* - Updated 5/5/2011 (JLL)
* Fixed DOM Loading Slowly on SharePoint
* - Updated 5/17/2011 (JLL)
* Fixed AJAX Call in SP Not Removing FedAuth Cookie
* check/Fix Window.Close Prompt in IE For Non-Opened Windows
* Added Login-As Logout
* Added Default Homepage that can added by each application
* - Updated 6/10/2011 (JLL)
* Added the focus feature to account for only partial implementation
* Added a feature to extend the session timeout via an ajax call or an iframe
* This resolves redirect issues in authentication
* Added a feature to refresh an array of cookies on session extend
* - TODO Feature Enhancements
* Interim Hold Message on Session Timeout
* Update the User Interface & Messages
* Externalize Application Timeout, Alert Time, Critical Time, and Monitor Time
* Externalize Prod Domain Setting
* Externalize Session End Sub-Domains
* Externalize Cookie Name, SiteMinder Cookie Name, Login-As Cookie Name
*/
var appTimeout = (0 * 60000) + (30 * 1000);
var appAlertTime = (0 * 60000) + (20 * 1000);
var appCriticalTime = (0 * 60000) + (5 * 1000);
var appMonitorTime = (0 * 60000) + (1 * 1000);
var appWindowNameReg = new RegExp("\\d{10,}", "i");
/* On init
* "focus_"+window.name, "i"
* "prompt_"+window.name, "i"
* "logout_"+window.name, "i"
*/
var appFocusReg;
var appPromptReg;
var appLogoutReg;
var appTimer = new Date();
var appLoaded = false;
var loggingDebug = false;
var logoutSelectedPreInit = false;
/*
* Respect others call for window.onload, but plan for the worst
* Don't assume others will respect my window.onload so schedule
* a task to handle others overwriting mine.
* TODO: Onload register focus just in case someone else overode my doFocus event
* Just like the window situation.
*/
var previousWindowOnload = window.onload;
window.onload = windowInit;
window.onfocus = doFocus;
var ajaxCallComplete = false;
/*
* Applications should have their own extend pages
* Eventually this could be moved to a Unicorn service call
*/
var domainReg = new RegExp("(\\w+\\.{1}\\w+)$");
var subDomainReg = new RegExp("^(\\w+)\\.{1}\\w+\\.{1}\\w+$");
var queryParamReg = new RegExp("\\?");
var prodDomainReg = new RegExp("partnersonline", "i");
var sessionEndSubDomains = ["www", "na", "devpol", "tstpol", "stgpol", "xycpol", "prdpol", "pol"];
var validDomain = domainReg.test(window.location.hostname);
var domain = (validDomain) ? (domainReg.exec(window.location.hostname))[1] : window.location.hostname;
var subDomain = (subDomainReg.test(window.location.hostname)) ? (subDomainReg.exec(window.location.hostname)[1]) : "na";
var prodEnvironment = (prodDomainReg.test(domain));
/*
* This needs to be updated to a page for SharePoint dev vs. prod in logoutUrl
* sessionExtendUrl should be set per application
*/
var applicationStartUrl = window.location.protocol + "//" + window.location.host + "/";
var sessionExtendUrl = window.location.protocol + "//" + window.location.host + "/";
var logoutUrl = prodEnvironment ? window.location : window.location.protocol + "//" + window.location.host + "/";
var sessionExtendIframe = false;
var sessionExtendCookiesRefresh = new Array();
var forceEndApplicationSession = false;
var endApplicationSessionUrl = window.location.protocol + "//" + window.location.host + "/";
/*
* Cookie Timeout is 30minutes
*/
var cookieTimeout = (30 * 60000);
var cookieName = "TGTVENDOR";
var cookieSMName = "SMSESSION";
var cookieSMLoginAsName = "SMSAVEDSESSION";
var cookieDelimiter = "&";
var cookieDomain = "." + domain;
var cookiePath = "/";
var cookieTimeReg = new RegExp("time_(\\d*)", "i");
var cookieFocusReg = new RegExp("focus_(\\d*)", "i");
var cookiePromptReg = new RegExp("prompt_(\\d*)", "i");
var cookieLogoutReg = new RegExp("logout_(\\d*)", "i");
var cookieForceLogoutReg = new RegExp("forcelogout_(true)", "i");
var cookieLogoutSubDomain = new RegExp("subdomain_([a-zA-Z0-9]+)", "i");
/* Impersonation Code */
var impersonating = (readCookie(cookieSMLoginAsName) == null) ? false : true;
var endLoginAsUrl = window.location.protocol + "//" + window.location.host + "/";
/*
* Methods takes care of multiple window.onload methods
*/
function windowInit() {
if (typeof (previousWindowOnload) == "function") {
previousWindowOnload();
}
if (appLoaded == false) {
init();
}
}
/*
* Schedules a check in case someone else overwrote my window.onload
*/
function javaScriptInit() {
if (document.readyState != "complete" && document.readyState != null && document.readyState != "undefined") {
setTimeout("javaScriptInit()", appMonitorTime);
} else {
if (appLoaded == false) {
init();
}
}
}
/*
* Initialization event
*/
function init() {
appLoaded = true;
/* If the application has not added their session extend page then let them know */
if (prodEnvironment) {
typeof (setSessionExtendUrl) == "function" ? setSessionExtendUrl() : alert("Session Extend Url Missing");
if (typeof (setApplicationStartUrl) == "function") { setApplicationStartUrl();logoutUrl = applicationStartUrl; }
} else {
if (typeof (setSessionExtendUrl) == "function") setSessionExtendUrl();
if (typeof (setLogoutUrl) == "function") setLogoutUrl();
}
if (typeof (setEndApplicationSessionPage) == "function") {
forceEndApplicationSession = true;
setEndApplicationSessionPage();
}
if (typeof (setSessionExtendCookieRefreshList) == "function") setSessionExtendCookieRefreshList();
if (typeof (setSessionExtendIframe) == "function") setSessionExtendIframe();
if (typeof (setEndLoginAsUrl) == "function") setEndLoginAsUrl();
if (typeof (setLoggingDebug) == "function") setLoggingDebug();
if (getQuerystring("loggingDebug") == "true") loggingDebug = true;
initmb();
if (loggingDebug) initLogging();
if (loggingDebug) statusMessage("Preset");
/* Create the cookie if it's not there */
if (readCookie(cookieName) == "" || readCookie(cookieName) == null) {
createCookie(cookieName);
}
/* My window name will be the current time in Milliseconds
This is needed to determine who has focus and if that's me */
if (!appWindowNameReg.test(window.name)) {
window.name = appTimer.valueOf();
}
/* Create Regular expressions with my window name */
appFocusReg = new RegExp("focus_" + window.name, "i");
appPromptReg = new RegExp("prompt_" + window.name, "i");
appLogoutReg = new RegExp("logout_" + window.name, "i");
/* Set the cookie time since I just loaded and schedule a timer */
setCookieTime(cookieName, window.name, appTimer.valueOf());
setTimeout("myDetails()", appMonitorTime);
/* Added to handle logout selected Pre-Init */
if (logoutSelectedPreInit) logout();
}
/*
* Onfocus method call
* Set the cookie with the focused window
*/
function doFocus() {
setCookieFocus(cookieName, window.name, false);
}
/* Common window open method */
function openNewWindow(winURL) {
var winAttrib = "height=400,width=500,ScreenX=0,screenY=400,left=0,top=0,resizable,toolbar=yes,menubar=yes,location=no,scrollbars=yes,status=no";
var winTitle = new Date().valueOf();
window.open(winURL, winTitle, winAttrib);
}
/*
* Common Logout call were behavior can be centrally located
* All application except POL just close the window
* But they need to confirm the logout in the action window &
*/
function logout() {
if (loggingDebug) statusMessage("In Logout");
/* Check for the page being loaded */
if (appLoaded) {
setCookieLogout(cookieName, window.name, false);
if (isSessionEndSubDomain(subDomain)) {
sm(logoutHTML, 200, 200, true);
} else {
sm(closeHTML, 200, 200, true);
}
} else {
logoutSelectedPreInit = true;
}
}
/*
* Go through the list of sub domains that should end the entire session
*/
function isSessionEndSubDomain(myDomain) {
for (var i = 0; i < sessionEndSubDomains.length; i++) {
if (sessionEndSubDomains[i] == myDomain) {
return true;
}
}
return false;
}
/* Cancel the logout */
function cancelLogoutSelected() {
setCookieFocus(cookieName, window.name, true);
hm();
}
/*
* Common Logout Selected call were behavior can be centrally located
* All application except POL just close the window
*/
function logoutSelected() {
setCookieLogout(cookieName, window.name, true);
if (isSessionEndSubDomain(subDomain)) {
if (loggingDebug) statusMessage("Ending SiteMinder Session & Redirecting to Same Page or Dev Page");
if (forceEndApplicationSession) {
ajaxCallComplete = false;
ajaxCall(endApplicationSessionUrl);
logoutSelectedSessionEnd();
} else {
if (impersonating) {
redirect(endLoginAsUrl);
} else {
deleteCookie(cookieSMName);
redirect(logoutUrl);
}
}
} else {
if (loggingDebug) statusMessage("Ending " + subDomain + " Session by closing the window.");
if (forceEndApplicationSession) {
ajaxCallComplete = false;
ajaxCall(endApplicationSessionUrl);
logoutSelectedEnd();
} else {
if (window.opener != undefined) {
window.close();
}
if (impersonating) {
redirect(endLoginAsUrl);
} else {
redirect(logoutUrl);
}
}
}
}
/*
* From the session end I selected to logout instead of
* continuing my session
*/
function logoutSelectedSessionEnd() {
if (ajaxCallComplete) {
if (loggingDebug) alert("Ajax Call Complete - Finish Logout");
if (impersonating) {
redirect(endLoginAsUrl);
} else {
deleteCookie(cookieSMName);
redirect(logoutUrl);
}
} else {
setTimeout("logoutSelectedSessionEnd()", appMonitorTime);
}
}
/*
* Logout was selected - Shutting Down...
*/
function logoutSelectedEnd() {
if (ajaxCallComplete) {
if (loggingDebug) alert("Ajax Call Complete - Finish Logout");
if (window.opener != undefined) {
window.close();
}
if (impersonating) {
redirect(endLoginAsUrl);
} else {
redirect(logoutUrl);
}
if (window.opener != undefined) {
window.close();
}
redirect(logoutUrl);
} else {
setTimeout("logoutSelectedEnd()", appMonitorTime);
}
}
/*
* Session Continued
*/
function okSelected() {
if (loggingDebug) statusMessage("Session Continued!");
appTimer = new Date();
setCookieTime(cookieName, window.name, appTimer.valueOf());
if (sessionExtendCookiesRefresh.length > 0) {
for (var i = 0; i < sessionExtendCookiesRefresh.length; i++) {
if (loggingDebug) alert("Deleting Cookie:" + sessionExtendCookiesRefresh[i]);
deleteCookie(sessionExtendCookiesRefresh[i]);
}
}
sessionExtendIframe ? iFrameCall(sessionExtendUrl) : ajaxCall(sessionExtendUrl);
}
/*
* This is where all the logic happens
* - Check for time remaining
* If it's less than alert time and I have focus then alert
* If it's less than critical time then prompt in all windows
*/
function myDetails() {
var currentCookie = readCookie(cookieName);
if (currentCookie == null) { createCookie(cookieName); }
var timeNow = new Date();
var cookieTime = parseInt(cookieTimeReg.exec(currentCookie)[1]);
var timeRemaining = appTimeout - ((timeNow.valueOf()) - (appTimer.valueOf()));
var forceLogout = cookieLogoutReg.test(readCookie(cookieName));
if (timeRemaining > 0) {
if (timeRemaining < appCriticalTime) {
/* Check for others updating cookie */
if (!((timeNow - cookieTime) > (appTimeout - appAlertTime))) {
if (loggingDebug) statusMessage("Extending Session");
sessionExtendIframe ? iFrameCall(sessionExtendUrl) : ajaxCall(sessionExtendUrl);
appTimer = new Date(cookieTime);
hm();
} else {
/* All Prompt */
sm(sessionHTML, 200, 200, true);
}
} else if (timeRemaining < appAlertTime) {
/* Does action need to happen? */
if ((timeNow - cookieTime) > (appTimeout - appAlertTime)) {
if (loggingDebug) statusMessage("Action Needs to Happen");
/* Has someone taken action? - It could even be me */
if (!cookiePromptReg.test(currentCookie)) {
if (loggingDebug) statusMessage("No Cookie Activity");
/* If I have focus - Take Action */
if (appFocusReg.test(currentCookie)) {
if (loggingDebug) statusMessage("--Taking Control and prompting.--");
setCookiePrompt(cookieName, window.name);
sm(sessionHTML, 200, 200, true);
window.focus();
}
}
} else {
if (loggingDebug) statusMessage("Extending Session");
sessionExtendIframe ? iFrameCall(sessionExtendUrl) : ajaxCall(sessionExtendUrl);
appTimer = new Date(cookieTime);
}
} else {
if (forceLogout) {
/* Is it a main domain or my domain? */
var currentSubDomain = (cookieLogoutSubDomain.test(readCookie(cookieName))) ? (cookieLogoutSubDomain.exec(readCookie(cookieName))[1]) : "";
var currentLogoutWindow = cookieLogoutReg.exec(readCookie(cookieName))[1];
if (currentLogoutWindow == window.name) {
/* I am the prompting window */
} else if (isSessionEndSubDomain(currentSubDomain) || currentSubDomain == subDomain) {
sm("", 200, 200, false);
if (cookieForceLogoutReg.test(readCookie(cookieName))) {
if (window.opener == undefined) {
redirect(logoutUrl);
} else {
window.close();
redirect(logoutUrl);
}
}
}
} else {
hm();
}
}
var timeLeftDays = Math.floor(timeRemaining / 86400000);
timeRemaining = timeRemaining - (timeLeftDays * 86400000);
var timeLeftHours = Math.floor(timeRemaining / 3600000);
timeRemaining = timeRemaining - (timeLeftHours * 3600000);
var timeLeftMin = Math.floor(timeRemaining / 60000);
timeRemaining = timeRemaining - (timeLeftMin * 60000);
var timeLeftSeconds = Math.floor(timeRemaining / 1000);
if (loggingDebug) document.getElementById("appactivetimeout").innerHTML = timeLeftDays + " " + timeLeftHours + ":" + timeLeftMin + ":" + timeLeftSeconds;
setTimeout("myDetails()", appMonitorTime);
} else {
/* Check Cookie one last time before closing */
if (!((timeNow - cookieTime) > (appTimeout - appAlertTime))) {
if (loggingDebug) statusMessage("Extending Session");
sessionExtendIframe ? iFrameCall(sessionExtendUrl) : ajaxCall(sessionExtendUrl);
appTimer = new Date(cookieTime);
hm();
setTimeout("myDetails()", appMonitorTime);
} else {
if (loggingDebug) document.getElementById("appactivetimeout").innerHTML = "Session Ended!";
deleteCookie(cookieSMName);
redirect(logoutUrl);
}
}
}
/*
* Redirect to the logoff page
*/
function redirect(redirectUrl) {
if (window.location == redirectUrl) {
if (loggingDebug) statusMessage("Reloading the current page.");
window.location.reload();
} else {
if (loggingDebug) statusMessage("Redirecting to " + redirectUrl);
window.location = redirectUrl;
}
}
/*
* Create a hidden iframe with a url and then get rid of it after loading
*/
function iFrameCall(iframeUrl) {
var iframeHttpTime = new Date().valueOf();
var iframeHttpUrl = queryParamReg.test(iframeUrl) ? iframeUrl + "&iframeTime=" + iframeHttpTime : iframeUrl + "?iframeTime=" + iframeHttpTime;
var myBody = document.getElementsByTagName("body")[0];
var myIframe = document.getElementById("sessioniframe");
if (myIframe == null || myIframe == undefined) {
myIframe = document.createElement("iframe");
myIframe.setAttribute("id", "sessioniframe");
myIframe.setAttribute("src", iframeHttpUrl);
if (loggingDebug) {
myIframe.setAttribute("width", "300");
myIframe.setAttribute("height", "300");
myIframe.setAttribute("style", "position:absolute;left:0px;top:0px;z-index:10;");
} else {
myIframe.setAttribute("width", "1");
myIframe.setAttribute("height", "1");
myIframe.setAttribute("style", "visibility:hidden;position:absolute;left:0px;top:0px;z-index:10;");
}
myBody.appendChild(myIframe);
} else {
myIframe.src = iframeHttpUrl;
}
}
/*
* Make a browser ajax call to any url (within your domain *Note cross subdomain doesn't work)
* - Return the html, but discard it as we don't care
*/
function ajaxCall(ajaxUrl) {
var xmlHttp;
var xmlHttpTime = new Date().valueOf();
var xmlHttpUrl = queryParamReg.test(ajaxUrl) ? ajaxUrl + "&ajaxTime=" + xmlHttpTime : ajaxUrl + "?ajaxTime=" + xmlHttpTime;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (loggingDebug) statusMessage("Server Page Call:" + xmlHttp.responseText);
ajaxCallComplete = true;
}
}
xmlHttp.open("GET", xmlHttpUrl, true);
xmlHttp.send(null);
}
/*
* Debugging Method
*/
function statusMessage(myMessage) {
var logTime = new Date();
var statusMessage = "-------------" + myMessage + "-------------
";
statusMessage = statusMessage + "Time:" + logTime.toUTCString() + "
";
statusMessage = statusMessage + "Window Name:" + window.name + "
";
statusMessage = statusMessage + "My Cookie:" + readCookie(cookieName) + "
";
statusMessage = statusMessage + "All Cookies:" + document.cookie + "
";
document.getElementById("debugMessages").innerHTML = statusMessage + document.getElementById("debugMessages").innerHTML;
}
/*
* Cookie Pattern
* Cookie Update Timestamp = time_(Date Milliseconds)
* Focused Window = focus_(Window Name)
* Prompting Window = prompt_(Window Name)
* Delimiter = &
* OnFocus = Change the focus window
* OnLoad = Update the last timestamp in cookie & the window focus
* Countdown reached for all windows - Update prompt
*/
function createCookie(cName) {
var cExpire = new Date((appTimer.valueOf()) + cookieTimeout);
document.cookie = validDomain ? cName + "=time_" + appTimer.valueOf() + " ;expires=" + cExpire.toUTCString() + " ;domain=" + cookieDomain + " ;path=" + cookiePath : cName + "=time_" + appTimer.valueOf();
if (loggingDebug) statusMessage("Cookie Created");
}
/*
* Read a single cookie by name
*/
function readCookie(cName) {
var cookieMatch = cName + "=";
var myRegExp = new RegExp(cName + "=[^;]*", "i");
if (myRegExp.test(document.cookie)) {
return document.cookie.match(myRegExp);
}
return null;
}
/*
* Delete a single cookie by name
*/
function deleteCookie(cName) {
document.cookie = validDomain ? cName + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT;domain=" + cookieDomain + " ;path=" + cookiePath : cName + "=";
}
/*
* Update the cookie time and focus
* - This is the same as an onload event
*/
function setCookieTime(cName, windowName, cAppTime) {
var cExpire = new Date(cAppTime + cookieTimeout);
document.cookie = validDomain ? cName + "=time_" + cAppTime + "&focus_" + windowName + " ;expires=" + cExpire.toUTCString() + " ;domain=" + cookieDomain + " ;path=" + cookiePath : cName + "=time_" + cAppTime + "&focus_" + windowName;
if (loggingDebug) statusMessage("Cookie Time Set");
}
/*
* Keep the original cookie time and prompt if available
* - Setting the focus doesn't update the time or the prompt
* - The timeout prompt may have already occurred
*/
function setCookieFocus(cName, windowName, clearLogout) {
var cExpire = new Date((new Date().valueOf()) + cookieTimeout);
var cookieString = cName;
if (cookieTimeReg.test(readCookie(cName))) {
cookieString += "=time_" + cookieTimeReg.exec(readCookie(cName))[1];
} else {
cookieString += "=time_" + appTimer.valueOf();
}
cookieString += "&focus_" + windowName;
if (cookiePromptReg.test(readCookie(cName))) {
cookieString += "&prompt_" + cookiePromptReg.exec(readCookie(cName))[1];
}
if (!clearLogout) {
if (cookieLogoutReg.test(readCookie(cName))) {
cookieString += "&logout_" + cookieLogoutReg.exec(readCookie(cName))[1];
}
if (cookieLogoutSubDomain.test(readCookie(cName))) {
cookieString += "&subdomain_" + cookieLogoutSubDomain.exec(readCookie(cName))[1];
}
if (cookieForceLogoutReg.test(readCookie(cName))) {
cookieString += "&forcelogout_" + cookieForceLogoutReg.exec(readCookie(cName))[1];
}
}
if (validDomain) { cookieString += " ;expires=" + cExpire.toUTCString() + " ;domain=" + cookieDomain + " ;path=" + cookiePath; }
document.cookie = cookieString;
if (loggingDebug) statusMessage("Cookie Focus Set");
}
/*
* Set the fact that I am prompting for global session timeout
* - Current time stays the same
* - I should have prompted because I have focus, but can't guarantee that
*/
function setCookiePrompt(cName, windowName) {
var cExpire = new Date((new Date().valueOf()) + cookieTimeout);
var cookieString = cName;
if (cookieTimeReg.test(readCookie(cName))) {
cookieString += "=time_" + cookieTimeReg.exec(readCookie(cName))[1];
} else {
cookieString += "=time_" + appTimer.valueOf();
}
if (cookieFocusReg.test(readCookie(cName))) {
cookieString += "&focus_" + cookieFocusReg.exec(readCookie(cName))[1];
} else {
cookieString += "&focus_" + windowName;
}
cookieString += "&prompt_" + windowName;
if (validDomain) { cookieString += " ;expires=" + cExpire.toUTCString() + " ;domain=" + cookieDomain + " ;path=" + cookiePath; }
document.cookie = cookieString;
if (loggingDebug) statusMessage("Cookie Prompt Set");
}
/*
* Set the fact that the main window wants to logout
* - Current time stays the same
* - I should have focus, but may not so I will utilize what's in the cookie
* - Other windows should grey out
*/
function setCookieLogout(cName, windowName, forceLogout) {
var cExpire = new Date((new Date().valueOf()) + cookieTimeout);
var cookieString = cName;
if (cookieTimeReg.test(readCookie(cName))) {
cookieString += "=time_" + cookieTimeReg.exec(readCookie(cName))[1];
} else {
cookieString += "=time_" + appTimer.valueOf();
}
if (cookieFocusReg.test(readCookie(cName))) {
cookieString += "&focus_" + cookieFocusReg.exec(readCookie(cName))[1];
} else {
cookieString += "&focus_" + windowName;
}
cookieString += "&logout_" + windowName;
cookieString += "&subdomain_" + subDomain;
if (forceLogout) {
cookieString += "&forcelogout_true";
}
if (validDomain) { cookieString += " ;expires=" + cExpire.toUTCString() + " ;domain=" + cookieDomain + " ;path=" + cookiePath; }
document.cookie = cookieString;
if (loggingDebug) statusMessage("Cookie Logout Set|subDomain:" + subDomain);
}
/*
* Helper methods to determine the height, width, and position
*/
function pageWidth() {
return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
function posLeft() {
return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function posTop() {
return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
/*
* Determine the scroll position of the 'ol' div
*/
function scrollFix() {
var obol = document.getElementById('ol');
obol.style.top = posTop() + 'px';
obol.style.left = posLeft() + 'px'
}
/*
* Helper method to determine the position of the 'ol' div
*/
function sizeFix() {
var obol = document.getElementById('ol');
obol.style.height = pageHeight() + 'px';
obol.style.width = pageWidth() + 'px';
}
/*
* Hiding/Show select, iframe, and objects on page as they cause problems
*/
function inf(h) {
tag = document.getElementsByTagName('select');
for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
tag = document.getElementsByTagName('iframe');
for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
tag = document.getElementsByTagName('object');
for (i = tag.length - 1; i >= 0; i--) tag[i].style.visibility = h;
}
/*
* Show the modal window message box
* - Expand the "ol" div with the semi-transparent background image to the full page and show it
* - Show the "mbox" and...
* - Replace the innerHTML of the "mbd" with the html of the "obl" input parameter
* - Added blackout so no dialog shows
*/
function sm(obl, wd, ht, showModal) {
var h = 'hidden';
var b = 'block';
var p = 'px';
var obol = document.getElementById('ol');
obol.style.height = pageHeight() + p;
obol.style.width = pageWidth() + p;
obol.style.top = posTop() + p;
obol.style.left = posLeft() + p;
obol.style.display = b;
var tp = posTop() + ((pageHeight() - ht) / 2) - 12;
var lt = posLeft() + ((pageWidth() - wd) / 2) - 12;
if (showModal) {
var obbxd = document.getElementById('mbd');
obbxd.innerHTML = obl;
var obbx = document.getElementById('mbox');
obbx.style.top = (tp < 0 ? 0 : tp) + p;
obbx.style.left = (lt < 0 ? 0 : lt) + p;
obbx.style.width = wd + p;
obbx.style.height = ht + p;
inf(h);
obbx.style.display = b;
}
return false;
}
/*
* Hide the modal window message box
*/
function hm() {
var n = 'none';
var v = 'visible';
document.getElementById('ol').style.display = n;
document.getElementById('mbox').style.display = n;
inf(v);
}
/*
* Create the following HTML onload in the begining of the document
* HTML for Modal Window
*