    //  -------------
    //  Global Events
    //  -------------
        if ( typeof hideAllMenus != 'undefined' )
        {
            document.onclick    = hideAllMenus;
        }


    //  -------------------------
    //  Global Pointers/Variables
    //  -------------------------
        var oLoginForm          = null;
        var oMyAccountWindow    = null;
        var oHelpWindow         = null;
        var sVisibleTableStyle  = ( is_ie ) ? 'block' : 'table';


    //  ----------------------
    //  Initialisation Methods
    //  ----------------------
        function init()
        {
            //  Hide the loading message
            var oLoadingDiv = document.getElementById( 'div_loading' );
            if ( oLoadingDiv != null )
            {
                oLoadingDiv.style.display  = 'none';
            }

            //  Get the login form pointer
            oLoginForm  = document.forms[ 'login' ];
            if ( oLoginForm != null && ( window.location.href.indexOf('samples_screen_sized.jsp') == -1) )
            {
                oLoginForm.j_username.focus();
            }

            //  If there is a pageInit() function defined, call it
            if ( typeof pageInit != 'undefined' )
            {
                pageInit();
            }

            //  If there is a menuInit() function defined, call it
            if ( typeof menuInit != 'undefined' )
            {
                menuInit();
            }
        }


    //  -----------------
    //  Utility Functions
    //  -----------------
        function returnFalse()
        {
            return false;
        }
        function getLeft( oSource )
        {
            var iReturnCoord = 0;

            while ( oSource != null )
            {
                iReturnCoord += oSource.offsetLeft;
                oSource = oSource.offsetParent;
            }

            return iReturnCoord;
        }
        function getTop( oSource )
        {
            var iReturnCoord = 0;

            while ( oSource != null )
            {
                iReturnCoord += oSource.offsetTop;
                oSource = oSource.offsetParent;
            }

            return iReturnCoord;
        }
        function debug( sMessage )
        {
            var oToday      = new Date();
            var sTimestamp  = oToday.getHours() + ':' + oToday.getMinutes() + ':' + oToday.getSeconds();

            //  Get the textarea, or create if it doesn't exist
            var oDebugTextarea  = document.getElementById( 'textarea_debug' );
            if ( oDebugTextarea == null )
            {
                //  Make the textarea
                var oNewTextarea    = document.createElement( 'TEXTAREA' );
                oNewTextarea.id     = 'textarea_debug';

                //  Add the textarea to the page and setup the pointer
                document.body.appendChild( oNewTextarea );
                oDebugTextarea  = document.getElementById( 'textarea_debug' );
            }

            //  Style the textarea
            with ( oDebugTextarea.style )
            {
                display     = 'block';
                width       = '175px';
                height      = '454px';
                position    = 'absolute';
                left        = '785px';
                fontFamily  = 'arial';
                fontSize    = '11px';
                top         = '71px';
            }

            //  Add the text and scroll to the bottom
            oDebugTextarea.value    = sTimestamp + ' > ' + sMessage + '\n' + oDebugTextarea.value;
        }
        function debugProps( object )
        {
            for ( prop in object )
                debug( 'object.' + prop + ' = \'' + eval('object.'+prop) + '\'' );
        }
        function deleteCookie( sName )
        {
            document.cookie = sName + '=; path=/; expires=Fri, 31 Dec 1999 23:59:59 GMT;';
        }
        function setCookie( sName, sValue )
        {
            document.cookie = sName + '=' + escape(sValue) + '; path=/';
        }
        function getCookie( sName )
        {
            var cookieVar       = document.cookie;
            var cookieName      = sName + '=';
            var cookieLength    = cookieVar.length;
            var cookieBegin     = 0;

            while ( cookieBegin < cookieLength )
            {
                var valueLength = cookieBegin + cookieName.length;

                if ( cookieVar.substring(cookieBegin, valueLength) == cookieName )
                {
                    var valueEnd    = cookieVar.indexOf( ';', valueLength );
                    if ( valueEnd == -1 )
                        valueEnd = cookieLength;
                    return unescape( cookieVar.substring(valueLength, valueEnd) );
                }

                cookieBegin = cookieVar.indexOf( ' ', cookieBegin ) + 1;
                if (cookieBegin == 0)
                    break;
            }

            return null;
        }

        function swapImage( original, switched )
        {
            eval('document.getElementById("' + original + '").src = ' + switched + '.src;');
        }


    //  -------------------
    //  Logged-In Functions
    //  -------------------
        function doMyAccountPopUp()
        {
            oMyAccountWindow    = window.open( 'myaccount.jsp', 'myaccount', 'width=530,height=310,left=200,top=200,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=0' );
        }
        function doHelpPopUp( sHelpDocAnchor )
        {
            var sHelpUrl = 'help.jsp';
            if ( sHelpDocAnchor != undefined && sHelpDocAnchor != '' )
            {
            	sHelpUrl += sHelpDocAnchor;
            }
            oHelpWindow = window.open( sHelpUrl, 'help', 'width=550,height=500,left=200,top=200,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=0' );
        }
        function logout()
        {
            if ( confirm('Are you sure you wish to log out?\n\nIf you are in the middle of an order, you will\nhave to restart that order from the beginning.\n\n') )
            {
                doLogout();
                window.location.href    = '/goview/';
            }
        }
        function doLogout()
        {
            deleteCookie( COOKIENAME_LOGIN );
            deleteCookie( COOKIENAME_LOGGEDINUSER );
            deleteCookie( COOKIENAME_ENCRYPTEDCOOKIE );
            deleteCookie( COOKIENAME_LOGINSOURCE );
            deleteCookie( COOKIENAME_M25 );
            deleteCookie( COOKIENAME_MEASUREMENTS );
            deleteCookie( COOKIENAME_PRICES );
            deleteCookie( COOKIENAME_ROYALTY );
        }
        function getUserProperty( sProperty )
        {
            // Setup Vars
            var aArguments    = new Array();
            var aValuePairs   = getCookie( COOKIENAME_LOGGEDINUSER ).split( '|' );
            var sReturnValue  = '';
            var bValueFound   = false;

            // Fill Arguments Array
            for ( var iPair = 0; iPair < aValuePairs.length; iPair++ )
            {
                var sPair                       = aValuePairs[iPair]
                var iFirstEquals                = sPair.indexOf( '=' );
                aArguments[aArguments.length]   = sPair.substring( 0, iFirstEquals++ );
                aArguments[aArguments.length]   = sPair.substr( iFirstEquals );
            }

            // Find Value (if it exists)
            for (var iArg = 0; iArg < aArguments.length; iArg++)
            {
                if ( aArguments[iArg++] == sProperty && !bValueFound ) // Only get first instance
                {
                    sReturnValue  = aArguments[iArg];
                    bValueFound   = true;
                }
            }

            return sReturnValue; // Returns '' if not found
        }
