
    // GLOBALS

    var APP_NAME = '';
    var g_arDaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

    var isIE  = true;   // RESET IN THE HEADER OF EACH
    var isNN4 = false;  // PAGE AFTER BROWSER DETECTED
    var isNN6 = false;  

    // VALIDATION MARKERS
    mrk_invalid = new Image();
    mrk_invalid.src="../images/invalid_brown.gif";
    mrk_blank = new Image();
    mrk_blank.src="../images/blank_brown.gif";


    var layerNotation = new String();
    var styleNotation = new String();


    function doPageLoad()
    {
        checkBrowser();
        adjustMenuBar();
    }
  
    function checkBrowser()
    {
        var strUserAgent = navigator.userAgent;
        strUserAgent = strUserAgent.toLowerCase();

        if (strUserAgent.search("msie") > -1) {
            isIE = true;
            layerNotation = ".all";
            styleNotation = ".style";
        }
        else if (strUserAgent.search("gecko") > -1) {
            isNN6 = true;
            layerNotation = ".layers";
            styleNotation = "";
        }
        else if (strUserAgent.search("mozilla") > -1)
        {
            isNN4 = true;
            layerNotation = ".layers";
            styleNotation = "";
        }
    }


    function adjustMenuBar()
    {

        var strBaseName = document.URL.substring(document.URL.lastIndexOf('/') + 1, document.URL.length);
        var strCellName = 'td_' + strBaseName.substring(0, strBaseName.indexOf('.'));  
        var strLinkName = 'lnk_' + strBaseName.substring(0, strBaseName.indexOf('.'));

        if (isIE) {
            if (typeof(document.all[strCellName]) == "undefined")
              return;
            document.all[strCellName].style.backgroundColor = '#dfd4c7';
            document.all[strLinkName].href = "javascript:void(0)";
            document.all[strLinkName].onmouseover = "";
            document.all[strLinkName].onmouseout = "";
        }
    }


    function makeLayerVisible(layerRef, visible)
    {
        eval("document" + layerNotation + "['" + layerRef + "']" + styleNotation + ".visibility = '" + (visible ? 'visible' : 'hidden') + "'");
    }

    function toggleLinkActive(strLinkName, bMakeItActive)
    {

        var strCellName = 'td_' + strLinkName.substring(strLinkName.search('_') + 1);
        var clrBackground = bMakeItActive ? 'green' : '#96744b';

        if (isIE == true) {
            if (typeof(document.all[strCellName]) == "undefined")
                return;
            document.all[strCellName].style.backgroundColor = clrBackground;
        }
    }

    function toggleSubMenuActive(strLinkName, bMakeItActive)
    {

        var strForeground = bMakeItActive ? 'green' : '#794f1b';
        var strTextDecoration = bMakeItActive ? 'underline' : 'none';
        var strTextTransform = bMakeItActive ? 'capitalize' : 'none';

        if (isIE == true) {
            if (typeof(document.all[strLinkName]) == "undefined")
                return;
            document.all[strLinkName].style.color = strForeground;
            document.all[strLinkName].style.textDecoration = strTextDecoration;
            document.all[strLinkName].style.textTransform = strTextTransform;
        }
        else if (isNN4 == true || isNN6 == true) {
            if (typeof(document.links[strLinkName]) == "undefined")
                return;
            document.links[strLinkName].color = strForeground;
            document.links[strLinkName].textDecoration = strTextDecoration;
            document.links[strLinkName].textTransform = strTextTransform;

        }
    }


    function insertFish() {

        var strTag = "";

        checkBrowser();
        if (isNN)
          return;
        else
          strTag = "div";

        document.write("<" + strTag + " id='fishdiv' name='fishdiv' style='position: absolute; visibility: hidden; z-index: 0; top: 478; left: 2'>\n"
                     + "<img id='fishimg' name='fishimg' border='0' src='images/fish_left.gif' width='60' height='25'>\n"
                     + "</" + strTag + ">\n");

        setTimeout("startFish()", 3000);
    }

    function startFish() {

        document.all["fishdiv"].style.visibility = "visible";
        swimFish();
    }

    function swimFish() {

      var retCode;

      retCode = moveFish(fishX, fishY);

      if (retCode == "top") {
        fishY = 0;
        fishX = 2;
        moveFish(fishX, fishY); }
      else if (retCode == "bottom") {
        document.images["fishimg"].src = "images/fish_right.gif";
        fishY = 0 - fishY;
        moveFish(fishX, fishY); }
      else if (retCode == "left") {
        fishPasses += 1;
        fishOnTop = (fishOnTop == 2) ? 0 : 2;
        document.all["fishdiv"].style.zIndex = fishOnTop;
        fishX = 0;
        fishY = 2;
        moveFish(fishX, fishY); }
      else if (retCode == "right") {
        document.images["fishimg"].src = "images/fish_left.gif";
        fishX = 0 - fishX;
        moveFish(fishX, fishY); }

      if (fishPasses > 2) {
        fishPasses = 0;
        document.all["fishdiv"].style.visibility = "hidden";        
        setTimeout("startFish()", 60000); }
      else
        setTimeout("swimFish()", 3);

    }

    function moveFish(offsetX, offsetY) {

        if (parseInt(document.all["fishdiv"].style.top) + offsetY <= 10)
          return "top";

        if (parseInt(document.all["fishdiv"].style.top) + offsetY >= 480)
          return "bottom";

        if (parseInt(document.all["fishdiv"].style.left) + offsetX >= 480)
          return "right";

        if (parseInt(document.all["fishdiv"].style.left) + offsetX <= 1)
          return "left";

        document.all["fishdiv"].style.pixelLeft += offsetX;
        document.all["fishdiv"].style.pixelTop += offsetY;

        return '';

    }
    
    
    

    // FUNCTIONS

    function checkForFrames(windowObj, sPageURL)
    {
        //CHECKS TO SEE IF CURRENT PAGE IS LOADING
        //IN THE CONTEXT OF A FRAME.  ALL THE PAGES
        //SHOULD BE IN A FRAME EXCEPT DEFAULT.ASP
        if (windowObj.frames.length == 0) {
            with (windowObj.document.location) {
                windowObj.location = protocol + '//' + host + sPageURL;
            }
        }
    }


    function checkForTopWin(windowObj, sPageURL)
    {
        //CHECKS THAT PAGE IS LOADING IN TOP WINDOW
        if (windowObj.frames.length != 0) {
            with (windowObj.document.location) {
                windowObj.location = protocol + '//' + host + sPageURL;
            }
        }
    }

    function reloadFrame(frameName)
    {
        top.frames(frameName).window.reload();
    }


    function rollImg(img, imgState)
    {
        var strBaseName = new String(img.name);
        img.src = eval(strBaseName.substr(strBaseName.indexOf('_') + 1) + '_' + imgState + '.src');
    }


    function setStatusMsg(strMsg)
    {
        if (isNN4) {
            var lyr = document.layers['status_msg'];
            lyr.visibility = 'hidden';
            lyr.document.open();
            lyr.document.write('<p class="statusmsg">' + strMsg + '</p>');
            lyr.document.close();
            lyr.position = 'absolute';
            lyr.top = STATUSMSG_TOP; lyr.left = STATUSMSG_LEFT;
            lyr.visibility = 'visible';
        }
        else if (isNN6||isIE) {
            var newText = document.createTextNode(strMsg);
            var cell = document.getElementById('status_msg');
            cell.replaceChild(newText, cell.childNodes[0]);
            document.getElementById('status_msg').style.fontSize = '8pt';
            document.getElementById('status_msg').style.fontWeight = 'bold';
            document.getElementById('status_msg').style.color = '#cc3300';
        }
    }


    // TRIM A STRING OF SPACES IN FRONT AND BACK
    function trimString(strInput)
    {
        return strInput.replace(/(^\s*)|(\s*$)/g, '');
    }



    // CHECK A STRING FOR VALID USERID
    function isUserID(strInput)
    {
        var rexUserID = /^[a-z\d]{4,10}$/i;

        return (rexUserID.test(strInput))
    }



    // CHECK A STRING FOR VALID USERID
    function isPasswd(strInput)
    {
        var rexPasswd = /^[a-z\d]{6,15}$/i;

        return (rexPasswd.test(strInput))
    }


    function isEmail(strInput)
    {
        var rexEmail = /^([a-z0-9]+[\.-]?[a-z0-9]+)+@([a-z0-9]+[\.-]?[a-z0-9]+)+\.(com|org|net|info|us|info|biz|name|cc|ws)$/i;

        return (rexEmail.test(strInput));
    }


    function isName(strInput)
    {
        var rexName = /^[a-z\. *]{1,30}$/i;

        return (rexName.test(trimString(strInput)))
    }


    // CHECK A STRING FOR VALID SSN INPUT
    function isSSN(strInput)
    {
        // REG EXPRESSSION TO MATCH 9 DIGITS OR
        // THE 999-99-9999 PATTERN
        var rexSSN = /(^\d\d\d-\d\d-\d\d\d\d *$)|(^\d{9} *$)/;

        return (rexSSN.test(strInput))
    }

    // IS THE YEAR A LEAP YEAR
    function isLeapYear(nYearNum)
    {
        return (nYearNum % 100 == 0 && nYearNum % 400 == 0) || (nYearNum % 100 != 0 && nYearNum % 4 == 0) ? true : false;
    }

    // CHECK A STRING FOR VALID DATE INPUT
    function isDate(strInput)
    {
        // SOME REGULAR EXPRESSIONS TO MATCH THE DATE
        // AND STRIP LEADING AND TRAILING SPACES
        var rexDate = /^\d?\d[\/-]\d?\d[\/-]\d?\d?\d\d$/;
        var rexDelim = /[\/-]/;

        var strDate = trimString(strInput);

        if (!rexDate.test(strDate))
            return false;

        // SPLIT INTO THE DIFFERENT PARTS
        var arDateParts = strDate.split(rexDelim,3);

        // CHECK THE YEAR
        var nYearNum = parseInt(arDateParts[2],10);
        if (0 <= nYearNum && nYearNum <= 99)
            nYearNum += 2000;
        else if (100 <= nYearNum && nYearNum <= 1900)
            return false;
        else if (0 > nYearNum || nYearNum > 2099)
            return false;

        // ADJUST MONTHS FOR LEAR YEARS
        g_arDaysInMonth[1] = isLeapYear(nYearNum) ? 29 : 28;

        // CHECK THE MONTH
        var nMonthNum = parseInt(arDateParts[0],10) - 1;
        if (0 > nMonthNum || nMonthNum > 12)
            return false;

        // CHECK THE DAY
        var nDateNum = parseInt(arDateParts[1],10);
        if (0 > nDateNum || nDateNum > g_arDaysInMonth[nMonthNum])
            return false;

        // LOOKS OKAY
        return true;            
    }


    function isTime(strInput)
    {

        // SOME REGULAR EXPRESSIONS TO MATCH THE DATE
        // AND STRIP LEADING AND TRAILING SPACES
        var rexTime = /^(\d{1,2}:\d\d)( (am|pm|a\.m\.|p\.m\. )?)?$/i;
        var rexDelim = /(:)|( )/;

        var strTime = trimString(strInput);

        if (!rexTime.test(strTime))
            return false;

        // SPLIT INTO THE DIFFERENT PARTS
        var arTimeParts = strTime.split(rexDelim,3);

        // CHECK THE YEAR
        var nHourNum = parseInt(arTimeParts[0],10);
        if (nHourNum > 24)
            return false;

        // CHECK THE MINUTES
        var nMinuteNum = parseInt(arTimeParts[1],10);
        if (nMinuteNum > 59)
            return false;

        return true;
    }

