﻿<!--
// Help system code

// constants
var getCMS_HelpWindowName = "getCMS_HelpWindow";
var getCMS_HelpPageDisplay = "/helpdisplay.aspx?helppage=";
var getCMS_HelpPageWindowBaseDecs = "directories=0, location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0,";
var getCMS_HelpPageWindowDecs = "";
var getCMS_HelpPageWidth = 250;
var getCMS_HelpWindowXSpacing = 10;
var getCMS_HelpWindowYSpacing = 0;

var getCMS_HelpCurrentWindowWidth;
var getCMS_HelpCurrentWindowHeight;

var getCMS_HelpWindowReference;

function getCMS_HelpOpenHelp(HelpPageID)
{
    // resizes and positions the current window and opens the help window
    
    // resize window
    
    // save current sizes - used when window closes to restore sizes
    getCMS_HelpCurrentWindowWidth = getCMS_clientWidth();
    getCMS_HelpCurrentWindowHeight = getCMS_clientHeight();
    var OrignalWindowQueryString = "&owidth=" + getCMS_HelpCurrentWindowWidth + "&oheight=" + getCMS_HelpCurrentWindowHeight;
    
    // work out new window size
    var NewWindowWidth = getCMS_screenAvailableWidth() - getCMS_HelpPageWidth - getCMS_HelpWindowXSpacing;
    var NewWindowHeight = getCMS_screenAvailableHeight() - getCMS_HelpWindowYSpacing;
    
    // work out help window top left corner coords
    var HelpWindowTopLeftX = getCMS_screenAvailableWidth() - getCMS_HelpPageWidth;
    var HelpWindowTopLeftY = 0;
    getCMS_HelpPageWindowDecs = getCMS_HelpPageWindowBaseDecs +
                                "width=250,height=" + NewWindowHeight +
                                ",top=0,screenY=" + HelpWindowTopLeftY +
                                ",left=" + HelpWindowTopLeftX + ",sceenX=" + HelpWindowTopLeftX;
    
    // move and resize existing window
    window.moveTo(0,0);
    window.resizeTo(NewWindowWidth, NewWindowHeight);
    
    // open help window
    getCMS_HelpWindowReference = window.open(getCMS_HelpPageDisplay + HelpPageID + OrignalWindowQueryString,
                                            getCMS_HelpWindowName, getCMS_HelpPageWindowDecs,true);
    
    
    
}

function getCMS_HelpCloseHelp(OriginalWidth, OriginalHeight)
{
    window.opener.getCMS_HelpRestoreSize(OriginalWidth, OriginalHeight);
    window.close();
}

function getCMS_HelpRestoreSize(OriginalWidth, OriginalHeight)
{
    if ((OriginalWidth != -1) && (OriginalHeight != -1))
    {
        // resize existing window to its origianl dimensions
        window.resizeTo(OriginalWidth, getCMS_screenAvailableHeight());
    }
}

function getCMS_clientWidth() {
	return getCMS_filterScreenParamsResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function getCMS_clientHeight() {
	return getCMS_filterScreenParamsResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function getCMS_scrollLeft() {
	return getCMS_filterScreenParamsResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function getCMS_scrollTop() {
	return getCMS_filterScreenParamsResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function getCMS_screenAvailableWidth()
{
    return (window.screen.availWidth);
}
function getCMS_screenAvailableHeight()
{
    return (window.screen.availHeight);
}

function getCMS_filterScreenParamsResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}






//-->