﻿//**************************************************************************************
//**************************************************************************************
//*  Copyright (c) 1996-2012 Swip Systems Incorporated.  All Rights Reserved.          *
//*  Warning:  This computer program is protected by copyright laws as described       *
//*  in the License Agreement.  Unauthorized reproduction or distribution of this      *
//*  program, or any portion of this program may result in severe civil and criminal   *
//*  penalties.  Violators will be prosecuted to the fullest extent of the law.        *
//**************************************************************************************
//**************************************************************************************

// this is used to trigger a key up event any where on a page for the hotkey functionality
document.onkeyup = OnPageKeyUp;
// default the grid sort direction to ascending  TSP 9/23/11
var gridSortDirection = 1;
var columnKey = "";

function ModalDialog() {
    this.popupID = '';
    this.iframeID = '';
    this.center = false;
    this.upperleft = false;
    this.lessheadermargin = false;
    this.moreleftmargin = false;
    this.playSound = false;
}

ModalDialog.prototype.Load = function(object) {
    this.popupID = object.popupID;
    this.iframeID = object.iframeID;
    this.center = object.center;
    this.lessheadermargin = object.lessheadermargin;
    this.moreleftmargin = object.moreleftmargin;
    this.upperleft = object.upperleft;
    this.playSound = object.playSound;

    if (this.popupID == undefined || this.popupID == null) {
        return false;
    }
    else {
        return true;
    }
}

ModalDialog.prototype.Show = function() {
    var divDisableBackground = $('#divDisableBackground');
    var ifrmDisableBackground = $('#ifrmDisableBackground');
    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();
    var modalDialog = $('#' + this.popupID);
    var modalIframe;
    if (this.iframeID == undefined || this.iframeID == null) {
        modalIframe = null;
    }
    else {
        modalIframe = $('#' + this.iframeID);
    }
    //Set height and width to mask to fill up the whole screen
    divDisableBackground.css({ 'width': $(document).width(), 'height': $(document).height() }); //, 'top': $(document).scrollTop(), 'left': $(document).scrollLeft() });
    ifrmDisableBackground.css({ 'width': $(document).width(), 'height': $(document).height() });
    // if the center flag IS set or the upper left flag is NOT set...
    if (this.center == true || this.upperleft == false) {
        //Set the popup window to center
        modalDialog.css('top', (winH / 2 - modalDialog.height() / 2) + $(document).scrollTop());
        modalDialog.css({ 'left': '50%', 'margin-left': $(document).scrollLeft() - (modalDialog.width() / 2) });
        if (modalIframe != null) {
            modalIframe.css('top', (winH / 2 - modalDialog.height() / 2) + $(document).scrollTop());
            modalIframe.css({ 'left': '50%', 'margin-left': $(document).scrollLeft() - (modalDialog.width() / 2) });
        }
    }
    // if the upper left flag IS set...
    else {
        // if the more left margin flag IS set...
        if (this.moreleftmargin == true) {
            modalDialog.css({ 'left': 40 + $(document).scrollLeft(), 'margin-left': 0 });
            if (modalIframe != null) {
                modalIframe.css({ 'left': 40 + $(document).scrollLeft(), 'margin-left': 0 });
            }
        }
        // if the more left margin flag is NOT set...
        else {
            modalDialog.css({ 'left': 20 + $(document).scrollLeft(), 'margin-left': 0 });
            if (modalIframe != null) {
                modalIframe.css({ 'left': 20 + $(document).scrollLeft(), 'margin-left': 0 });
            }
        }
        // if the less header margin flag IS set...
        if (this.lessheadermargin == true) {
            modalDialog.css('top', 60 + $(document).scrollTop());
            if (modalIframe != null) {
                modalIframe.css('top', 60 + $(document).scrollTop());
            }
        }
        // if the less header margin flag is NOT set...
        else {
            modalDialog.css('top', 115 + $(document).scrollTop());
            if (modalIframe != null) {
                modalIframe.css('top', 115 + $(document).scrollTop());
            }
        }
    }
    //transition effect
    divDisableBackground.show();
    ifrmDisableBackground.show();
    if (modalDialog.length == 0) {
        // do nothing
    }
    else {
        // if the popup IS positioned so that it would be partially hidden from the visible area...
        if (modalDialog[0].style.pixelTop + modalDialog.height() > $(window).scrollTop() + $(window).height()) {
            // do nothing
        }
        // if the popup is NOT positioned so that it would be partially hidden from the visible area...
        else {
            $("body").css("overflow", "hidden");
        }
        //transition effect
        modalDialog.show();
        if (modalIframe != null) {
            modalIframe.show();
        }
        // if the play alert sound flag IS set to true...
        if (this.playSound == true) {
            this.playSound = false;
            // play the alert sound
            playSSIPromptSound();
        }
        // if the play alert sound flag is NOT set to true...
        else {
            // do nothing
        }
    }
}
var objModalDialog = new ModalDialog();

function SetUniqueRadioButton(strControlGroupRegEx, strSelectedRadioButton)
/*********************************************************************
Developer:	Scott Smith
Date:		7/7/09
Purpose:	set one unique radio button in a group 
Inputs:		control name/group name regular expression, selected 
radiobutton
Returns:	nothing
Note:       this is a workaround for a bug in .NET that doesn't allow
you to specify GroupName within a datalist/repeater 
control - it unchecks all of the radio buttons in the
group and then checks the one you selected
QA:         TMS 8/24/09
*********************************************************************
* Developer:	Jason Casbourne & Torbin Pace
* Date:			5/5/11
* Note:         moved this function to here from the Members
*               SSI Global Javascript file in order to combine
*               into a single file
********************************************************************/
{
    // get a regular expression object using the handed in control/group reg ex
    rgxRegEx = new RegExp(strControlGroupRegEx);
    // for each element in the form...
    for (i = 0; i < document.forms[0].elements.length; i++) {
        // get the current element
        elmElement = document.forms[0].elements[i]
        // if the element IS a radio button...
        if (elmElement.type == 'radio') {
            // if the current element IS part of the specified group...
            if (rgxRegEx.test(elmElement.name)) {
                // uncheck the element
                elmElement.checked = false;
            }
            // if the current element is NOT part of the specified group...
            else {
                // do nothing
            }
        }
        // if the element is NOT a radio button...
        else {
            // do nothing
        }
    }
    // check the selected radio button
    strSelectedRadioButton.checked = true;
}

function playSSIPromptSound() {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		8/10/10
    Purpose:	play a sound for alerting the user that the SSIPrompt is visible
    Inputs:		div id, bit to show / hide, relative to element
    Returns:	nothing
    Note:       
    *********************************************************************/

    if (document.all && document.getElementById) {
        document.getElementById("ssipromptsound").src = "" //reset first in case of problems
        document.getElementById("ssipromptsound").src = "../Common/alert.wav"
    }
    else {
        var audio = document.createElement('audio');
        audio.setAttribute('autoplay', 'autoplay');
        var source = document.createElement('source');
        source.setAttribute('src', '../Common/alert.wav');
        source.setAttribute('type', 'audio/wav');
        audio.appendChild(source);
        document.getElementsByTagName('body')[0].appendChild(audio);

        //        var embed = document.createElement('object');
        //        embed.setAttribute('type', 'audio/wav');
        //        embed.setAttribute('data', '../Common/alert.wav');
        //        embed.setAttribute('autostart', true);
        //        document.getElementsByTagName('body')[0].appendChild(embed);
    }
}

function FixGetBoxObjectFor() {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		4/1/10
    Purpose:	fixes issue with broken backwards compatability in firefox
    3.6 for infragistics grid controls
    Inputs:		none
    Returns:	nothing
    Note:       copied from infragistics community forum: http://community.infragistics.com/forums/p/36753/216134.aspx
    QA:         TMS 12/9/10
    ********************************************************************/
    if (!document.getBoxObjectFor) {
        document.getBoxObjectFor = function(el) {
            var pos = {};

            pos.x = el.offsetLeft;
            pos.y = el.offsetTop;
            parent = el.offsetParent;
            if (parent != el) {
                while (parent) {
                    pos.x += parent.offsetLeft;
                    pos.y += parent.offsetTop;
                    parent = parent.offsetParent;
                }
            }

            parent = el.offsetParent;
            while (parent && parent != document.body) {
                pos.x -= parent.scrollLeft;
                if (parent.tagName != 'TR') {
                    pos.y -= parent.scrollTop;
                }
                parent = parent.offsetParent;
            }

            return pos;
        };
    }
}
function EnterKeyTabToControl(mozEvent, strNextControlID) {
    /*********************************************************************
    Developer:	TJ McDowell
    Date:		5/13/09
    Purpose:	set focus to the next control when enter is pressed
    Inputs:		next control id
    Returns:	false if focus is set, otherwise true
    Note:       based on an example from http://www.faqts.com/knowledge_base/view.phtml/aid/6793
    QA:         TMS 12/9/10
    ********************************************************************/
    var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually   
    var intKey;

    // if the browser is IE...
    if (window.event) {
        intKey = ev.keyCode;
    }
    // if the browser is Netscape, Firefox or Opera...
    else if (e.which) {
        intKey = ev.which;
    }
    // if the user pressed enter...
    if (intKey == 13) {
        // set focus to the next control
        document.getElementById(strNextControlID).focus();
        //Cancel the event
        ev.cancelBubble = true;
        ev.returnValue = false;
        return false;
    }
    else {
        ev.cancelBubble = false;
        ev.returnValue = true;
        // do not set focus to the next control
        return true;
    }
}

function ExpandCollapsePanels(strPanelIDs, blnExpand) {
    /*********************************************************************
    Developer:	TJ McDowell
    Date:		8/14/08
    Purpose:	expand or collapse all the panels in the list
    Inputs:		comma delimited list of panel id's, expand flag
    Returns:	nothing
    Note:     
    QA:         TMS 12/9/10
    ********************************************************************/
    var aryPanelID;
    var intX;

    if (strPanelIDs == "") {
        // do nothing - do not expand or collapse
    }
    else {
        aryPanelID = strPanelIDs.split(",");
        for (intX = 0; intX < aryPanelID.length; intX++) {
            igpnl_getPanelById(aryPanelID[intX]).setExpanded(blnExpand);
        }
    }
}

function GetStringValueFromGridCell(objCell)
/*********************************************************************
Developer:	TJ McDowell
Date:		1/29/08
Purpose:	gets a cell's value from a grid cell
Inputs:		cell from an infragistics grid
Returns:	string value of the cell
Note:     
QA:         TMS 12/9/10
********************************************************************/
{
    // if the cell is null (we probably couldn't find the cell by name)...
    if (objCell == null) {
        return "";
    }
    // if the cell is NOT null...
    else {
        // if the value in the cell is null...
        if (objCell.getValue() == null) {
            return "";
        }
        // if the value in the cell is NOT null...
        else {
            // return the cell value
            return objCell.getValue();
        }
    }
}

function SetFocus(varFieldToSetFocusTo)
/*********************************************************************
Developer:	Jason Casbourne
Date:		6/15/07
Purpose:	set focus to the field handed in (this function should only
be needed when using the setTimeout javascript function
because it requires a function call)
Inputs:		field to set focus to
Returns:	nothing
Note:     
QA:         TMS 12/9/10
********************************************************************/
{
    // set focus to the field handed in
    varFieldToSetFocusTo.focus();
}

function LeftPadWithCharacters(objControl, varCharacterToPadWith, varLengthAfterPad)
/*********************************************************************
Developer:	Jason Casbourne
Date:		9/18/06
Purpose:	Pad the text in a given field with a given character for a 
given length
Inputs:		control to pad, character to pad with, length to pad
Returns:	Nothing
Note:         
QA:         TMS 12/9/10
********************************************************************/
{
    var varControlLength;
    var varControlValue;
    var varCounter;

    // if the length of the control handed in is NOT zero...
    if (objControl.value.length != 0) {
        // initialize the control value and length variables
        varControlValue = objControl.value;
        varControlLength = objControl.value.length;
        // loop through for as many times as we need to, until the control is the length handed in
        for (varCounter = varControlLength; varCounter < varLengthAfterPad; varCounter++) {
            // append the character handed in to the left of the text in the control
            varControlValue = varCharacterToPadWith + varControlValue;
        }
        // set the value of the control to the new text (with leading characters appended)
        objControl.value = varControlValue;
    }
}

function ConvertToStandardDate(varDate)
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/06
Purpose:	converts a date value to a string value
Inputs:		javascript date value
Returns:	date as a string
Note:         
QA:         TMS 12/13/10
********************************************************************/
{
    return (varDate.getMonth() + 1) + "/" + varDate.getDate() + "/" + varDate.getFullYear();
}

function ConvertToSeconds(varDateTime)
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/06
Purpose:	returns the number of seconds since the start of the day
Inputs:		date time value
Returns:	integer number of seconds
Note:         
QA:         TMS 12/9/10
********************************************************************/
{
    return (varDateTime.getHours() * 60 * 60) + (varDateTime.getMinutes() * 60) + (varDateTime.getSeconds());
}

function ShowHideDivWithIFrame(strDivControlID, strIFrameControlID, blnDisplay, blnRepositionPopupToUpperLeft, blnLessSpacingFromHeader, blnMoreSpacingFromLeftMargin)
/*********************************************************************
Developer:	TJ McDowell
Date:		9/26/07
Purpose:	show / hide the div control and iframe handed in
Inputs:		div control, iframe control, boolean to show / hide the div control
Returns:	nothing
Note:      
QA:         TMS 6/16/10 
********************************************************************
Developer:	TJ McDowell
Date:		2/23/09
Note:       added the reposition popup to upper left flag
********************************************************************/
{
    var intMainTableHeight;
    var intMainTableWidth;
    var intBrowserHeight;
    var intBrowserWidth;
    var intMaxHeight;
    var intMaxWidth;
    var intPopupTop;

    // if TRUE was handed in for the display property (we want to SHOW the div)...
    if (blnDisplay == true) {
        // show the div control by setting the display to blank (clearing the display None)
        document.getElementById(strDivControlID).style.display = "";
        // set the iframe's height and width to the the parent div's height and width 
        document.getElementById(strIFrameControlID).style.height = document.getElementById(strDivControlID).clientHeight + "px";
        document.getElementById(strIFrameControlID).style.width = document.getElementById(strDivControlID).clientWidth + "px";
        // get the height and width of the main table in header.master (add a little extra to compensate for padding)  TLM 3/19/08
        intMainTableWidth = document.getElementById("tblMain").clientWidth + 15;
        intMainTableHeight = document.getElementById("tblMain").clientHeight + 30;

        // if the page DOES have a scroll position greater than 0
        if (document.documentElement.scrollTop > 0) {
            intPopupTop = document.documentElement.scrollTop;
        }
        else {
            intPopupTop = 0;
        }
        // if the page HAS a scroll height that is greater than the visible browser area...  TSP 6/15/10
        if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
            // store the scroll height   TSP 6/15/10
            intBrowserHeight = document.documentElement.scrollHeight;
        }
        // if the page does NOT have a scroll height that is greater than the visible browser area...  TSP 6/15/10
        else {
            // store the browser height  TSP 6/15/10
            intBrowserHeight = document.documentElement.clientHeight;
        }
        // if the page HAS a scroll width that is greater than the visible browser area...  TSP 6/15/10
        if (document.documentElement.scrollWidth > document.documentElement.clientWidth) {
            // store the scroll width   TSP 6/15/10
            intBrowserWidth = document.documentElement.scrollWidth;
        }
        // if the page does NOT have a scroll width that is greater than the visible browser area...  TSP 6/15/10
        else {
            // store the browser width  TSP 6/15/10
            intBrowserWidth = document.documentElement.clientWidth;
        }
        // if the main table height is greater than the browser height...  TLM 3/19/08
        if (intMainTableHeight > intBrowserHeight) {
            // set the max height to the main table height  TLM 3/19/08
            intMaxHeight = intMainTableHeight;
        }
        // if the main table height is NOT greater than the browser height...  TLM 3/19/08
        else {
            // set the max height to the browser height  TLM 3/19/08
            intMaxHeight = intBrowserHeight;
        }
        // if the main table width is greater than the browser width...  TLM 3/19/08
        if (intMainTableWidth > intBrowserWidth) {
            // set the max width to the main table width  TLM 3/19/08
            intMaxWidth = intMainTableWidth;
        }
        // if the main table width is NOT greater than the browser width...  TLM 3/19/08
        else {
            // set the max width to the browser width  TLM 3/19/08
            intMaxWidth = intBrowserWidth;
        }
        // wrap the iframe with a border  TMS, TSP & JMC 6/16/10
        document.getElementById(strDivControlID).style.border = "1px solid black";
        // set the main 'disabled' div and iframe height and width to the values calculated above (so it covers the entire screen)  TLM 3/19/08
        document.getElementById("ifrmDisableBackground").style.width = intMaxWidth + "px";
        document.getElementById("ifrmDisableBackground").style.height = intMaxHeight + "px";
        document.getElementById("divDisableBackground").style.width = intMaxWidth + "px";
        document.getElementById("divDisableBackground").style.height = intMaxHeight + "px";
        // if the popup NEEDS to be repositioned to the upper left...  TLM 2/23/09
        if (blnRepositionPopupToUpperLeft) {
            // if the more spacing from the left margin bit IS set...  TMS, JMC & TSP 6/18/10
            if (blnMoreSpacingFromLeftMargin == true) {
                // position the div and iframe that we are displaying in the upper left hand corner of the browser  TLM 3/17/08
                document.getElementById(strDivControlID).style.left = "40px";
                document.getElementById(strIFrameControlID).style.left = "40px";
            }
            // if the more spacing from the left margin bit is NOT set...  TMS, JMC & TSP 6/18/10
            else {
                document.getElementById(strDivControlID).style.left = "20px";
                document.getElementById(strIFrameControlID).style.left = "20px";
            }
            // if the less spacing from the top bit IS set...  TMS, JMC & TSP 6/16/10
            if (blnLessSpacingFromHeader == true) {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 60).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 60).toString() + "px";
            }
            // if the less spacing from the top bit is NOT set...  TMS, JMC & TSP 6/16/10
            else {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 115).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 115).toString() + "px";
            }
        }
        // if the popup does NOT need to be repositioned to the upper left...  TLM 2/23/09
        else {
            // '### test - need to look at this funtion when blnRepositionPopupToUpperLeft is handed in as False
            // do NOT reposition the popup or iframe  TLM 2/23/09
        }
    }
    // if FALSE was handed in for the display property (we want to HIDE the div)...
    else {
        // hide the div control
        document.getElementById(strDivControlID).style.display = "none";
        document.getElementById(strIFrameControlID).style.width = "0px";
        document.getElementById(strIFrameControlID).style.height = "0px";
        // hide the disable background by setting its width and height to 0  TLM 2/23/09
        document.getElementById("ifrmDisableBackground").style.width = "0px";
        document.getElementById("ifrmDisableBackground").style.height = "0px";
        document.getElementById("divDisableBackground").style.width = "0px";
        document.getElementById("divDisableBackground").style.height = "0px";
    }
}


function ShowHideDivWithIFrameCentered(strDivControlID, strIFrameControlID, blnDisplay, blnRepositionPopupToUpperLeft, blnLessSpacingFromHeader, blnMoreSpacingFromLeftMargin)
/*********************************************************************
Developer:	TJ McDowell
Date:		9/26/07
Purpose:	show / hide the div control and iframe handed in
Inputs:		div control, iframe control, boolean to show / hide the div control
Returns:	nothing
Note:      
QA:         TMS 6/16/10 
********************************************************************
Developer:	TJ McDowell
Date:		2/23/09
Note:       added the reposition popup to upper left flag
********************************************************************
Developer:	Paul Benner & Torbin Pace
Date:	    7/20/10
Note:       copied from SSIGlobalJavascript and modified to center 
the popup in the browser
********************************************************************/
{
    var intMainTableHeight;
    var intMainTableWidth;
    var intBrowserHeight;
    var intBrowserWidth;
    var intMaxHeight;
    var intMaxWidth;
    var intPopupTop;

    // if TRUE was handed in for the display property (we want to SHOW the div)...
    if (blnDisplay == true) {
        // show the div control by setting the display to blank (clearing the display None)
        document.getElementById(strDivControlID).style.display = "";
        // set the iframe's height and width to the the parent div's height and width 
        document.getElementById(strIFrameControlID).style.height = document.getElementById(strDivControlID).clientHeight + "px";
        document.getElementById(strIFrameControlID).style.width = document.getElementById(strDivControlID).clientWidth + "px";
        // get the height and width of the main table in header.master (add a little extra to compensate for padding)  TLM 3/19/08
        intMainTableWidth = document.getElementById("tblMain").clientWidth + 15;
        intMainTableHeight = document.getElementById("tblMain").clientHeight + 30;

        // if the page DOES have a scroll position greater than 0
        if (document.body.scrollTop > 0) {
            intPopupTop = document.body.scrollTop;
        }
        else {
            intPopupTop = 0;
        }
        // if the page HAS a scroll height that is greater than the visible browser area...  TSP 6/15/10
        if (document.body.scrollHeight > document.body.clientHeight) {
            // store the scroll height   TSP 6/15/10
            intBrowserHeight = document.body.scrollHeight;
        }
        // if the page does NOT have a scroll height that is greater than the visible browser area...  TSP 6/15/10
        else {
            // store the browser height  TSP 6/15/10
            intBrowserHeight = document.body.clientHeight;
        }
        // if the page HAS a scroll width that is greater than the visible browser area...  TSP 6/15/10
        if (document.body.scrollWidth > document.body.clientWidth) {
            // store the scroll width   TSP 6/15/10
            intBrowserWidth = document.body.scrollWidth;
        }
        // if the page does NOT have a scroll width that is greater than the visible browser area...  TSP 6/15/10
        else {
            // store the browser width  TSP 6/15/10
            intBrowserWidth = document.body.clientWidth;
        }
        // if the main table height is greater than the browser height...  TLM 3/19/08
        if (intMainTableHeight > intBrowserHeight) {
            // set the max height to the main table height  TLM 3/19/08
            intMaxHeight = intMainTableHeight;
        }
        // if the main table height is NOT greater than the browser height...  TLM 3/19/08
        else {
            // set the max height to the browser height  TLM 3/19/08
            intMaxHeight = intBrowserHeight;
        }
        // if the main table width is greater than the browser width...  TLM 3/19/08
        if (intMainTableWidth > intBrowserWidth) {
            // set the max width to the main table width  TLM 3/19/08
            intMaxWidth = intMainTableWidth;
        }
        // if the main table width is NOT greater than the browser width...  TLM 3/19/08
        else {
            // set the max width to the browser width  TLM 3/19/08
            intMaxWidth = intBrowserWidth;
        }
        // wrap the iframe with a border  TMS, TSP & JMC 6/16/10
        document.getElementById(strDivControlID).style.border = "1px solid black";
        // set the main 'disabled' div and iframe height and width to the values calculated above (so it covers the entire screen)  TLM 3/19/08
        document.getElementById("ifrmDisableBackground").style.width = intMaxWidth + "px";
        document.getElementById("ifrmDisableBackground").style.height = intMaxHeight + "px";
        document.getElementById("divDisableBackground").style.width = intMaxWidth + "px";
        document.getElementById("divDisableBackground").style.height = intMaxHeight + "px";
        // if the popup NEEDS to be repositioned to the upper left...  TLM 2/23/09
        if (blnRepositionPopupToUpperLeft) {
            // if the more spacing from the left margin bit IS set...  TMS, JMC & TSP 6/18/10
            if (blnMoreSpacingFromLeftMargin == true) {
                // position the div and iframe that we are displaying in the upper left hand corner of the browser  TLM 3/17/08
                document.getElementById(strDivControlID).style.left = "40px";
                document.getElementById(strIFrameControlID).style.left = "40px";
            }
            // if the more spacing from the left margin bit is NOT set...  TMS, JMC & TSP 6/18/10
            else {
                document.getElementById(strDivControlID).style.left = "20px";
                document.getElementById(strIFrameControlID).style.left = "20px";
            }
            // if the less spacing from the top bit IS set...  TMS, JMC & TSP 6/16/10
            if (blnLessSpacingFromHeader == true) {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 60).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 60).toString() + "px";
            }
            // if the less spacing from the top bit is NOT set...  TMS, JMC & TSP 6/16/10
            else {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 115).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 115).toString() + "px";
            }
        }
        // if the popup does NOT need to be repositioned to the upper left...  TLM 2/23/09
        else {
            // center the popup horizontally in the browser  PBB 7/20/10
            document.getElementById(strDivControlID).style.left = ((intMaxWidth - document.getElementById(strDivControlID).clientWidth) / 2) + "px";
            document.getElementById(strIFrameControlID).style.left = ((intMaxWidth - document.getElementById(strIFrameControlID).clientWidth) / 2) + "px";
            // if the less spacing from the top bit IS set...  PBB 7/20/10
            if (blnLessSpacingFromHeader == true) {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 60).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 60).toString() + "px";
            }
            // if the less spacing from the top bit is NOT set...  PBB 7/20/10
            else {
                document.getElementById(strDivControlID).style.top = (intPopupTop + 115).toString() + "px";
                document.getElementById(strIFrameControlID).style.top = (intPopupTop + 115).toString() + "px";
            }
        }
    }
    // if FALSE was handed in for the display property (we want to HIDE the div)...
    else {
        // hide the div control
        document.getElementById(strDivControlID).style.display = "none";
        document.getElementById(strIFrameControlID).style.width = "0px";
        document.getElementById(strIFrameControlID).style.height = "0px";
        // hide the disable background by setting its width and height to 0  TLM 2/23/09
        document.getElementById("ifrmDisableBackground").style.width = "0px";
        document.getElementById("ifrmDisableBackground").style.height = "0px";
        document.getElementById("divDisableBackground").style.width = "0px";
        document.getElementById("divDisableBackground").style.height = "0px";
    }
}

function SetSizePopupIframe(strHeight, strWidth) {
    /*********************************************************************
    Developer:	TJ McDowell
    Date:		11/13/08
    Purpose:	set the popup iframe width and height
    Inputs:		none
    Returns:	nothing
    Note:       
    QA:         TMS 6/16/10
    ********************************************************************/

    // set the height and width of the iframe popup
    parent.document.getElementById('ctl00_ifrmPopupPage').style.width = strWidth;
    parent.document.getElementById('ctl00_ifrmPopupPage').style.height = strHeight;
    // set the disable background so it covers the entire screen
    document.getElementById("ifrmDisableBackground").style.width = strWidth;
    document.getElementById("ifrmDisableBackground").style.height = strHeight;
    document.getElementById("divDisableBackground").style.width = strWidth;
    document.getElementById("divDisableBackground").style.height = strHeight;

}

function AutoFitPopupIframe(blnCenter)
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/08
Purpose:	fit the popup iframe based on content
Inputs:		none
Returns:	nothing
Note:       original concepts from http://www.devpapers.com/article/200
QA:         TMS 12/9/10
********************************************************************
Developer:	Paul Benner
Date:	    6/17/10
Note:       modified to center the popup if the center flag handed in
is true
********************************************************************/
{
    // if the disable background iframe is NOT visible - ifrmDisableBackground width is 0px (the user clicked the back button in the browser)...  PBB 6/21/10
    if (parent.document.getElementById("ifrmDisableBackground").style.width == "0px") {
        // do NOT show the popup page  PBB 6/21/10
    }
    // if the disable background iframe IS visible (width is NOT 0px)...  PBB 6/21/10
    else {
        // give the iframe a height and width - this must be done before AutoFitPopupIframe can be called
        parent.document.getElementById("ctl00_ifrmPopupPage").style.width = "1px";
        parent.document.getElementById("ctl00_ifrmPopupPage").style.height = "1px";
        // removed the check for if offsetWidth and offsetHeight should be used  TSP 3/14/11
        // set the height and width of the iframe to fit the page
        parent.document.getElementById('ctl00_ifrmPopupPage').style.width = (this.document.body.scrollWidth + 30) + "px";
        parent.document.getElementById('ctl00_ifrmPopupPage').style.height = (this.document.body.scrollHeight + 50) + "px";
        // if the popup page width IS set to 30 pixels...
        if (parent.document.getElementById('ctl00_ifrmPopupPage').style.width == "30px") {
            parent.document.getElementById('ctl00_ifrmPopupPage').style.width = "970px";
        }
        this.document.body.style.backgroundColor = "white";

        // if the iframe SHOULD be centered...  PBB 6/17/10
        if (blnCenter == "True") {
            // center the popup horizontally on the page  PBB 6/17/10
            parent.document.getElementById("ctl00_ifrmPopupPage").style.left = ((parent.document.getElementById("ifrmDisableBackground").style.width.replace("px", "") / 2) - (parent.document.getElementById("ctl00_ifrmPopupPage").style.width.replace("px", "") / 2)) + "px";
        }
        // if the iframe should NOT be centered...  PBB 6/17/10
        else {
            // do nothing  PBB 6/17/10
        }
    }
}

function HidePopupIFrame()
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/08
Purpose:	hide the popup iframe
Inputs:		none
Returns:	nothing
Note:       
QA:         TMS 12/9/10
********************************************************************/
{
    // clear the iframe source and hide the iframe
    parent.document.getElementById("ctl00_ifrmPopupPage").src = "";
    parent.document.getElementById("ctl00_ifrmPopupPage").style.width = "0px";
    parent.document.getElementById("ctl00_ifrmPopupPage").style.height = "0px";
    // hide the iframe border
    parent.document.getElementById("ctl00_ifrmPopupPage").style.border = "0px";
    // re-enable the page content by taking away the disable background
    parent.document.getElementById("ifrmDisableBackground").style.width = "0px";
    parent.document.getElementById("ifrmDisableBackground").style.height = "0px";
    parent.document.getElementById("divDisableBackground").style.width = "0px";
    parent.document.getElementById("divDisableBackground").style.height = "0px";
}

function ShowPopupIFrame(strURL)
/*********************************************************************
Developer:	TJ McDowell
Date:		11/12/08
Purpose:	show the popup iframe loaded with the page handed in
Inputs:		url to show in the popup
Returns:	nothing
Note:       
QA:         TMS 12/9/10
********************************************************************/
{
    var intPopupTop;
    // if the page DOES have a scroll position greater than 0
    if (document.documentElement.scrollTop > 0) {
        intPopupTop = document.documentElement.scrollTop;
    }
    else {
        intPopupTop = 0;
    }
    // set the popup iframe source
    document.getElementById("ctl00_ifrmPopupPage").src = strURL;
    // show the iframe border
    document.getElementById("ctl00_ifrmPopupPage").style.border = "1px solid black";
    // set the left and top of the iframe popup
    document.getElementById("ctl00_ifrmPopupPage").style.left = "20px";
    document.getElementById("ctl00_ifrmPopupPage").style.top = (intPopupTop + 115).toString() + "px";
    // disable the background so the user can only interact with the iframe popup  TLM 11/13/08
    DisableBackground();
}

function SetPopupPositionForPageScroll() {
    var intPopupTop;
    // if the page DOES have a scroll position greater than 0
    if (document.documentElement.scrollTop > 0) {
        intPopupTop = document.documentElement.scrollTop;
    }
    else {
        intPopupTop = 0;
    }
    document.getElementById("ctl00_ifrmPopupPage").style.top = (intPopupTop + 115).toString() + "px";
}

// '### release - this function needs to be merged with DisableBackground  JMC & TSP 5/5/11
function DisableBackgroundContainer()
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/08
Purpose:	disable the background so the user can only interact with
the popup
Inputs:		none
Returns:	nothing
Note 1:     copied from ShowHideDivWithIFrameForSSIPromptControl and modified
Note 2:     extra steps need to be taken if the user should not be able
to get to background content - this disable is only to make
it clear which part of the page the user should be interacting with
*********************************************************************
Developer:	Jason Casbourne & Torbin Pace
Date:		5/5/11
Note:       moved to here from the Members SSI Global Javascript file and 
renamed from DisableBackground to DisableBackgroundContainer
********************************************************************/
{
    var intMainTableWidth;
    var intMainTableHeight;
    var intBrowserHeight;
    var intBrowserWidth;
    var intClientWidth;
    var intClientHeight;
    var intMaxWidth;
    var intMaxHeight;

    // get the main table height and width (plus a little extra to compensate for padding)  TLM 3/19/08
    intMainTableWidth = document.getElementById("container").clientWidth + 15;
    intMainTableHeight = document.getElementById("container").clientHeight + 30;

    // if the page HAS a scroll height that is greater than the visible browser area...  TSP 6/15/10
    if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
        // store the scroll height   TSP 6/15/10
        intBrowserHeight = document.documentElement.scrollHeight;
    }
    // if the page does NOT have a scroll height that is greater than the visible browser area...  TSP 6/15/10
    else {
        // store the browser height  TSP 6/15/10
        intBrowserHeight = document.documentElement.clientHeight;
    }
    // if the page HAS a scroll width that is greater than the visible browser area...  TSP 6/15/10
    if (document.documentElement.scrollWidth > document.documentElement.clientWidth) {
        // store the scroll width   TSP 6/15/10
        intBrowserWidth = document.documentElement.scrollWidth;
    }
    // if the page does NOT have a scroll width that is greater than the visible browser area...  TSP 6/15/10
    else {
        // store the browser width  TSP 6/15/10
        intBrowserWidth = document.documentElement.clientWidth;
    }
    // if the main table height is greater than the browser height...  TLM 3/19/08
    if (intMainTableHeight > intBrowserHeight) {
        // set the max height to the main table height  TLM 3/19/08
        intMaxHeight = intMainTableHeight;
    }
    // if the main table height is NOT greater than the browser height...  TLM 3/19/08
    else {
        // set the max height to the browser height  TLM 3/19/08
        intMaxHeight = intBrowserHeight;
    }
    // if the main table width is greater than the browser width...  TLM 3/19/08
    if (intMainTableWidth > intBrowserWidth) {
        // set the max width to the main table width  TLM 3/19/08
        intMaxWidth = intMainTableWidth;
    }
    // if the main table width is NOT greater than the browser width...  TLM 3/19/08
    else {
        // set the max width to the browser width  TLM 3/19/08
        intMaxWidth = intBrowserWidth;
    }
    // set the main 'disabled' div and iframe height and width to the values calculated above (so it covers the entire screen)  TLM 3/19/08
    document.getElementById("ifrmDisableBackground").style.width = intMaxWidth + "px";
    document.getElementById("ifrmDisableBackground").style.height = intMaxHeight + "px";
    document.getElementById("divDisableBackground").style.width = intMaxWidth + "px";
    document.getElementById("divDisableBackground").style.height = intMaxHeight + "px";
}

function DisableBackground()
/*********************************************************************
Developer:	TJ McDowell
Date:		11/13/08
Purpose:	disable the background so the user can only interact with
the popup
Inputs:		none
Returns:	nothing
Note 1:     copied from ShowHideDivWithIFrameForSSIPromptControl and modified
Note 2:     extra steps need to be taken if the user should not be able
to get to background content - this disable is only to make
it clear which part of the page the user should be interacting with
QA:         TMS 12/9/10
********************************************************************/
{
    var intMainTableWidth;
    var intMainTableHeight;
    var intBrowserWidth;
    var intBrowserHeight;
    var intMaxWidth;
    var intMaxHeight;

    // get the main table height and width (plus a little extra to compensate for padding)  TLM 3/19/08
    intMainTableWidth = document.getElementById("tblMain").clientWidth + 15;
    intMainTableHeight = document.getElementById("tblMain").clientHeight + 30;
    // get the height and width of the browser window  TLM 3/19/08
    // if the page DOES have a scroll height that is greater than the visible window area...  TSP 6/15/10
    if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
        intBrowserHeight = document.documentElement.scrollHeight;
    }
    // if the page does NOT have a scroll height that is greater than the visible window area...  TSP 6/15/10
    else {
        intBrowserHeight = document.documentElement.clientHeight;
    }
    // if the page DOES have a scroll width that is greater than the visible window area...  TSP 6/15/10
    if (document.documentElement.scrollWidth > document.documentElement.clientWidth) {
        intBrowserWidth = document.documentElement.scrollWidth;
    }
    // if the page does NOT have a scroll width that is greater than the visible window area...  TSP 6/15/10
    else {
        intBrowserWidth = document.documentElement.clientWidth;
    }
    // if the main table height is greater than the client height...  TLM 3/19/08
    if (intMainTableHeight > intBrowserHeight) {
        // set the max height to the main table height  TLM 3/19/08
        intMaxHeight = intMainTableHeight;
    }
    // if the main table height is NOT greater than the client height...  TLM 3/19/08
    else {
        // set the max height to the client height  TLM 3/19/08
        intMaxHeight = intBrowserHeight;
    }
    // if the main table width is greater than the client width...  TLM 3/19/08
    if (intMainTableWidth > intBrowserWidth) {
        // set the max width to the main table width  TLM 3/19/08
        intMaxWidth = intMainTableWidth;
    }
    // if the main table width is NOT greater than the client width...  TLM 3/19/08
    else {
        // set the max width to the client width  TLM 3/19/08
        intMaxWidth = intBrowserWidth;
    }
    // set the disable background so it covers the entire screen  TLM 3/19/08
    document.getElementById("ifrmDisableBackground").style.width = intMaxWidth + "px";
    document.getElementById("ifrmDisableBackground").style.height = intMaxHeight + "px";
    document.getElementById("divDisableBackground").style.width = intMaxWidth + "px";
    document.getElementById("divDisableBackground").style.height = intMaxHeight + "px";
}

// '### release - this function needs to be merged with ShowHideDivWithIFrameForSSIPromptControl  JMC & TSP 5/5/11
function ShowHideDivWithIFrameForSSIPromptControlContainer(strDivControlID, strIFrameControlID)
/*********************************************************************
Developer:	TJ McDowell
Date:		8/27/08
Purpose:	show / hide the div control and iframe handed in
Inputs:		div control, iframe control
Returns:	nothing
Note:       copied from ShowHideDivWithIFrame and modified
*********************************************************************
Developer:	Jason Casbourne & Torbin Pace
Date:		5/5/11
Note:       copied from the Members SSI Global Javascript file to here and
renamed from ShowHideDivWithIFrameForSSIPromptControl to 
ShowHideDivWithIFrameForSSIPromptControlContainer
QA:         TMS 5/9/11
********************************************************************/
{
    // show the div control
    document.getElementById(strDivControlID).style.display = "";
    // iframe's width and height should be the same as the div
    document.getElementById(strIFrameControlID).style.height = (document.getElementById(strDivControlID).clientHeight - 10) + "px";
    // subtracted 30 off the client width calculation  TLM 4/2/08
    document.getElementById(strIFrameControlID).style.width = (document.getElementById(strDivControlID).clientWidth - 10) + "px";
    // changed to call DisableBackgroundContainer instead of DisableBackground in order to combine the javascript files into a single global file  JMC & TSP 5/5/11
    // disable the background so the user can only interact with the popup  TLM 11/13/08
    DisableBackgroundContainer();
}


function ShowHideDivWithIFrameForSSIPromptControl(strDivControlID, strIFrameControlID)
/*********************************************************************
Developer:	TJ McDowell
Date:		8/27/08
Purpose:	show / hide the div control and iframe handed in
Inputs:		div control, iframe control
Returns:	nothing
Note:       copied from ShowHideDivWithIFrame and modified
QA:         TMS 12/9/10
********************************************************************/
{
    var intPopupTop;
    // if the page DOES have a scroll position greater than 0
    if (document.documentElement.scrollTop > 0) {
        intPopupTop = document.documentElement.scrollTop;
    }
    else {
        intPopupTop = 0;
    }

    // show the div control
    document.getElementById(strDivControlID).style.display = "";
    // iframe's width and height should be the same as the div
    document.getElementById(strIFrameControlID).style.height = (document.getElementById(strDivControlID).clientHeight - 10) + "px";
    // subtracted 30 off the client width calculation  TLM 4/2/08
    document.getElementById(strIFrameControlID).style.width = (document.getElementById(strDivControlID).clientWidth - 10) + "px";
    // set the top position of the div and iframe based on the scroll position of the browser
    document.getElementById(strDivControlID).style.top = (intPopupTop + 115).toString() + "px";
    document.getElementById(strIFrameControlID).style.top = (intPopupTop + 115).toString() + "px";
    // disable the background so the user can only interact with the popup  TLM 11/13/08
    DisableBackground();
    // play the alert sound
    playSSIPromptSound();
}

function onKeyPressed(event, objControl)
/*********************************************************************
Developer:	Brian Ziegler
Date:		4/5/10
Purpose:	handles the F2 or F8 shortcut key events  
Inputs:		event and control (this)
Returns:	nothing
Note:       
QA:         TMS 12/9/10
********************************************************************/
{
    // if the event is null or undefined...
    if (event != null || event != undefined) {
        // if F2 or F8 is NOT pressed...
        if (event.keyCode != 113 && event.keyCode != 119) {
            // do nothing
        }
        else {
            // if the control is SOMETHING...
            if (objControl) {
                // if F2 IS pressed...
                if (event.keyCode == 113) {
                    if (event.cancelBubble != undefined)
                        event.cancelBubble = true;
                    // if the control that fired the key down event is player number textbox...
                    if (objControl.id == "ctl00_cplhMainContent_TeamRosterControl1_txtPlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 1 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch1Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 1 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch1Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 2 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch2Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 2 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch2Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 3 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch3Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 3 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch3Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 4 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch4Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 4 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch4Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 5 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch5Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 5 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch5Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 6 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch6Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 6 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch6Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 7 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch7Player1PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is match 7 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch7Player2PlayerNumber") {
                        objControl.value = "";
                    }
                    // if the control that fired the key down event is host location textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtHostLocation") {
                        objControl.value = "";
                    }
                    else {
                        // do nothing
                    }
                }
                // if F8 IS pressed...
                else if (event.keyCode == 119) {
                    if (event.cancelBubble != undefined)
                        event.cancelBubble = true;
                    // if the control that fired the key down event is player number textbox...
                    if (objControl.id == "ctl00_cplhMainContent_TeamRosterControl1_txtPlayerNumber") {
                        // 'do a post back passing in a custom action to load and show the player find control
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey', document.getElementById('ctl00_cplhMainContent_TeamRosterControl1_txtPlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 1 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch1Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch1Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch1Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 1 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch1Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch1Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch1Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 2 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch2Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch2Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch2Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 2 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch2Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch2Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch2Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 3 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch3Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch3Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch3Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 3 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch3Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch3Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch3Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 4 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch4Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch4Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch4Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 4 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch4Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch4Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch4Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 5 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch5Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch5Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch5Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 5 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch5Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch5Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch5Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 6 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch6Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch6Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch6Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 6 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch6Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch6Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch6Player2PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 7 player 1 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch7Player1PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch7Player1PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch7Player1PlayerNumber').value)
                    }
                    // if the control that fired the key down event is match 7 player 2 player number textbox...
                    else if (objControl.id == "ctl00_cplhMainContent_txtMatch7Player2PlayerNumber") {
                        __doPostBack('loadAndShowPlayerFindControlForF8HotKey^txtMatch7Player2PlayerNumber', document.getElementById('ctl00_cplhMainContent_txtMatch7Player2PlayerNumber').value)
                    }
                    else {
                        //do nothing
                    }
                }
            }
            // if the control is NOTHING...
            else {
                //do nothing
            }
        }
    }
    else {
        // 'do nothing
    }
}

function OnPageKeyUp(evt)
/*********************************************************************
Developer:	Brian Ziegler
Date:		BJZ 4/21/10
Purpose:	handles when a ctrl + key shortcut is triggered 
Inputs:		event and control (this)
Returns:	nothing
Note:       
QA:         TMS 12/9/10
********************************************************************/
{
    // cross browser event check
    evt = (evt) ? evt : ((window.event) ? event : null);
    // get the physical path of the current page
    var strPath = window.location.pathname;
    // parse out just the page name
    var strPage = strPath.substring(strPath.lastIndexOf('/') + 1);

    // if the event is SOMETHING...
    if (evt) {
        // if the Ctrl + A key WAS pressed...
        if (evt.ctrlKey && evt.keyCode == 65) {
            // if the page that ctrl + a was pressed is host location find...
            if (strPage == 'HostLocationFind.aspx') {
                document.getElementById('ctl00_cplhMainContent_btnAddHostLocation').click();
            }
            // if the page that ctrl + a was pressed is division find...
            else if (strPage == 'DivisionFind.aspx') {
                document.getElementById('ctl00_cplhMainContent_btnAdd').click();
            }
            // if the page that ctrl + a was pressed is player find...
            else if (strPage == 'PlayerFind.aspx') {
                document.getElementById('ctl00_cplhMainContent_btnAddPlayer').click();
            }
            // if the page that ctrl + a was pressed is division teams popup...
            else if (strPage == 'Division.aspx') {
                document.getElementById('ctl00_cplhMainContent_btnEditTeams').click();
            }
            // if the page that ctrl + a was pressed is division teams popup...
            else if (strPage == 'TournamentTeamFind.aspx') {
                document.getElementById('ctl00_cplhMainContent_btnAdd').click();
            }
            // if its any other page
            else {
                // do nothing
            }
        }
        // if the Ctrl + A key was NOT pressed...
        else {
            // 'do nothing
        }
    }
    // if the event is NOTHING...
    else {
        // 'do nothing
    }
}

function Help_Clicked(intMapNumber)
/*********************************************************************
Developer:	Brian Ziegler
Date:		8/11/10
Purpose:	displays the context sensitive help window and the help topic
determined by the map number
Inputs:		sender, args
Returns:	nothing
Note:       called from the main menu bar on the master page
QA:         TMS 12/9/10
********************************************************************/
{
    // '### release - comment in
    RH_ShowHelp(0, "https://reports.poolplayers.com/robohelp/RH/server/general/projects/NexusBasicTrainingManual/NexusBasicTrainingManual.htm", 15, intMapNumber);
    // '### release - comment out
    // RH_ShowHelp(0, "http://localhost/robohelp/RH/server/general/projects/NexusBasicTrainingManual/NexusBasicTrainingManual.htm", 15, parseInt(intMapNumber));
    return false;
}

function UltraWebGrid_InitializeLayoutHandler(gridName)
/*********************************************************************
Developer:	Torbin Pace
Date:		9/16/11
Purpose:	handles initialize layout event for infragistics grids
Inputs:		grid name
Returns:	nothing
Note:       
QA:         TMS 9/26/11
********************************************************************/
{
    // store the grid object for the grid name handed in
    var grid = igtbl_getGridById(gridName);
    // set the grid to use a custom client-side sorting algorithm
    grid.SortingAlgorithm = 5;
    // set the custom sorting algorithm handler for the grid
    grid.SortImplementation = CustomUltraWebGridSort;
}

function CustomUltraWebGridSort(cln, array, colInfo)
/*********************************************************************
Developer:	Torbin Pace
Date:		9/16/11
Purpose:	handles custom sorting for infragistics grids
Inputs:		
Returns:	nothing
Note:       called by the client side sort of a grid
QA:         TMS 9/26/11
********************************************************************/
{
    // if we ARE sorting the same column as the last sort  TMS & TSP 9/26/11
    if (columnKey == colInfo[0].Key) {
        // do nothing  TMS & TSP 9/26/11
    }
    // if we are NOT sorting the same column as the last sort  TMS & TSP 9/26/11
    else {
        // store the new column name and reset the sort direction  TMS & TSP 9/26/11
        columnKey = colInfo[0].Key;
        gridSortDirection = 1;
    }
    // sort the handed in array of column values using the function below
    array.sort(function(a, b) {
        // store the column values handed in
        var compA = a[1];
        var compB = b[1];
        // if the column being sorted IS a string field (8)...
        if (colInfo[0].DataType == 8) {
            // if the first column value IS null or undefined...
            if (compA == null || compA == undefined) {
                compA = '';
            }
            // if the second column value IS null or undefined...
            if (compB == null || compB == undefined) {
                compB = '';
            }
            // if the first and second values handed in ARE both eight characters in length (this could be a date)...
            if (compA.length == 8 && compB.length == 8) {
                // split the first value on '/'
                var aryDateA = compA.split('/');
                // split the second value on '/'
                var aryDateB = compB.split('/');
                // if both values ARE in the standard date format (##/##/##)...
                if (aryDateA.length == 3 && aryDateB.length == 3) {
                    // convert the values handed in to date objects so that they will be ordered correctly
                    compA = new Date(compA);
                    compB = new Date(compB);
                }
                else {
                    // do nothing
                }
            }
        }
        // if the column being sorted IS a date field (7)...
        else if (colInfo[0].DataType == 7) {
            // if the first column value IS null or undefined...
            if (compA == null || compA == undefined) {
                compA = new Date('1/1/1800');
            }
            else {
                compA = new Date(compA);
            }
            // if the second column value IS null or undefined...
            if (compB == null || compB == undefined) {
                compB = new Date('1/1/1800');
            }
            else {
                compB = new Date(compB);
            }
        }
        // if the column being sorted is NOT a string or date field (assume it is numeric)...
        else {
            // if the first column value IS null or undefined...
            if (compA == null || compA == undefined) {
                compA = 0;
            }
            // if the second column value IS null or undefined...
            if (compB == null || compB == undefined) {
                compB = 0;
            }
        }
        // if the column IS being sorted in ascending order...
        if (gridSortDirection == 1) {
            // if the first column value IS less than the second column value 
            if (compA < compB) {
                return -1;
            }
            else {
                // if the two columns are equal
                if (compA > compB) {
                    return 1;
                }
                else {
                    return 0;
                }
            }
        }
        // if the column is NOT being sorted in ascending order...
        else {
            // if the second column value IS less than the first column value 
            if (compB < compA) {
                return -1;
            }
            else {
                // if the two columns are equal
                if (compB > compA) {
                    return 1;
                }
                else {
                    return 0;
                }
            }
        }
    });
    // if the grid sort direction IS set to 1 (ASCENDING)...
    if (gridSortDirection == 1) {
        // set the new grid sort direction to descending
        gridSortDirection = 2;
    }
    // if the grid sort direction is NOT set to 1 (DESCENDING)...
    else {
        // set the new grid sort direction to ascending
        gridSortDirection = 1;
    }
}


function showModalPopup(varModalDialogObject) {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		9/27/11
    Purpose:	show a modal popup using jQuery for cross browser compatability
    Inputs:		
    Returns:	nothing
    Note:       
    QA:         TMS 10/6/11
    ********************************************************************/

    if (objModalDialog.Load(varModalDialogObject) == true) {
        // create an event handler for the window resize event
        $(window).bind('resize', function() {
            // if the disable background div tag is NOT visible...
            if ($('#divDisableBackground').filter(':visible').length == 0) {
                // do nothing
            }
            // if the disable background div tag IS visible...
            else {
                objModalDialog.Show();
            }
        });

        objModalDialog.Show();
        return true;
    }
    else {
        return false;
    }
}

function hideModalPopup(varDivID, varIFrameID) {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		9/27/11
    Purpose:	hide a modal popup using jQuery for cross browser compatability
    Inputs:		
    Returns:	nothing
    Note:       
    QA:         TMS 10/6/11
    ********************************************************************/
    $(window).unbind('resize');
    $('#' + objModalDialog.iframeID).hide();
    $('#' + objModalDialog.popupID).hide();
    $('#ifrmDisableBackground').hide();
    $('#divDisableBackground').hide();
    $("body").css("overflow", "auto");
    objModalDialog = new ModalDialog();
}

function checkMaxLength(event, varMaxLength) {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		2/21/12
    Purpose:	check a textbox control for if the value has gone over the
                max length value and prevent any additional keyboard input
    Inputs:		
    Returns:	nothing
    Note:       
    QA:         TSP & TMS 2/21/12
    ********************************************************************/

    var objTextbox;
    // if the srcElement property IS set...
    if (event.srcElement) {
        // store the control that triggered the event
        objTextbox = event.srcElement;
    }
    // if the srcElement property is NOT set...
    else {
        // store the the control that triggered the event
        objTextbox = event.originalTarget;
    }
    // if the current length IS less than the max length...
    if (objTextbox.value.length < varMaxLength) {
        return true;
    }
    // if the current length is NOT less than the max length...
    else {
        // if the key pressed IS less than 48 (ZERO) and NOT EQUAL to 32 (SPACE) or 13 (ENTER)...
        if (event.keyCode < 48 && event.keyCode != 32 && event.keyCode != 13) {
            return true;
        }
        // if the key pressed is anything else...
        else {
            // if the ctrl key IS being pressed....
            if (event.ctrlKey == true) {
                return true;
            }
            // if the ctrl key is NOT being pressed....
            else {
                // cancel the event
                if (event.cancelBubble != undefined) {
                    event.cancelBubble = true;
                }
                return false;
            }
        }
    }
}


function checkMaxPasteLength(event, varMaxLength) {
    /*********************************************************************
    Developer:	Torbin Pace
    Date:		2/21/12
    Purpose:	check a textbox control for if the value has gone over the
    max length value and prevent any additional keyboard input
    Inputs:		
    Returns:	nothing
    Note:       
    QA:         TSP & TMS 2/21/12
    ********************************************************************/

    var objTextbox;
    // if the srcElement property IS set...
    if (event.srcElement) {
        // store the control that triggered the event
        objTextbox = event.srcElement;
    }
    // if the srcElement property is NOT set...
    else {
        // store the the control that triggered the event
        objTextbox = event.originalTarget;
    }
    // if the clipboard IS accessible (IE only)...
    if (window.clipboardData) {
        // if the current length of the entered text plus the value being pasted IS less than the allowed max length...
        if (objTextbox.value.length + window.clipboardData.getData('Text').length < varMaxLength) {
            return true;
        }
        // if the current length of the entered text plus the value being pasted is NOT less than the allowed max length...
        else {
            // cancel the event
            if (event.cancelBubble != undefined) {
                event.cancelBubble = true;
            }
            return false;
        }
    }
    // if the clipboard is NOT accessible (Firefox/Chrome etc.)...
    else {
        return true;
    }
}
