// JScript source code
//--------------------------------------------------------

if ( debugTrace ) document.write("Step 4<br>");  


        function containerObject ()
        {
            this.first = null;
            this.last = null;
            this.showFocus = false;
            this.count = 0;
        }


        containerObject.prototype = new baseObject ();

        containerObject.prototype.start = function ( element ) {
        
            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;
            this.innerElement = this.outerElement;

            this.savedClass = this.outerElement.className;
            this.hoverClass = this.outerElement.getAttribute ( this.manager.attributePrefix + "HoverClass" );
	        this.traverseChildren ( this.innerElement );
        }
        
        containerObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );
        
//			this.manager.setGlobalFocus ( this.manager, this );
        }

        containerObject.prototype.append = function ( o ) {
    
            o.parent = this;
            
            if
                ( this.count == 0 )
            {
                this.first = o;
                this.last = o;

                o.previous = null;
                o.next = null;
            }
            else
            {
                o.previous = this.last;
                o.next = null;
                
                this.last.next = o;
                this.last = o;
            }
            
            this.count++;
        }

        containerObject.prototype.remove = function ( object ) {

            var o = this.first;
            var last = null;

            while ( o != null ) {

                if ( o == object ) {

                    if ( last != null ) {

                        last.next = o.next;
                    }
                    else
                    {
                        this.first = o.next;
                    }

                    if ( o.next != null ) {

                        o.next.previous = last;
                    }
                    else
                    {
                        this.last = o.previous;
                    }

                    this.count--;

                    break;
                }

                last = o;
                o = o.next;
            }
        }

        containerObject.prototype.getFirstEditableControl = function () {

            var o = this.first;

            while ( o != null ) {

                if ( o.editableControl ) {

                    return o;
                }

                o = o.next;
            }

            return null;
        }

        containerObject.prototype.traverseChildren = function ( element ) {
            //children--childNodes
            var children = element.childNodes;
            /*if ( !children )
            {
                children = element.childNodes;
            }*/
            if ( children.length != 0 )
            {
                // Make a copy of the child list because the 'live' one could change during processing...

                var coll = new Array ();
                var l = children.length;

                for ( var i = 0; i < l; i++ ) {

                    coll[ coll.length ] = children[ i ];
                }

                for ( var i = 0; i < l; i++ ) {
                    var e = coll [ i ];
                    
                    if ( e.nodeType == 3 || e.nodeType == 8 )
                    {
                        continue;
                    }
                
                    var objectClass;
                    if ( e.getAttribute )
                    {
                        objectClass = e.getAttribute( this.manager.attributePrefix + "Class" );
                    }
                    else
                    if ( e.getAttributeNode )
                    {
                        objectClass = e.getAttributeNode( this.manager.attributePrefix + "Class" );
                    }
                    else
                    {
                        alert( alertObjProp( e ) );
                        return;
                    }
                    
                    if ( objectClass != null )
                    {
                        var handle = e.getAttribute ( "objectHandle" );

                        if ( handle == null ) {

                            var o = this.manager.create ( objectClass );
                            
                            if ( o != null )
                            {
                                this.append ( o );
                                o.start ( e, objectClass, this );
                            }
                        }
                    }
                    else
                    {
                        this.traverseChildren ( e )
                    }
                }
            }
        }

        containerObject.prototype.hoverIn = function () {

            if ( ! this.hover ) {

                this.hover = true;

                if ( this.hoverClass != null ) {

                    this.outerElement.className = this.hoverClass;
                }
            }
        }

        containerObject.prototype.hoverOut = function () {

            if ( this.hover ) {

                this.hover = false;

                if ( this.hoverClass != null ) {

                    this.outerElement.className = this.savedClass;
                }
            }
        }
        containerObject.prototype.fnMoveSelection = function ( el, numDelta ) {
            var numIndex = el.sourceIndex;
            //document.all
            var arrayAll = document.all;
            //var arrayAll = document.body.getElementsByTagName('*');
            while ( true ) {
                numIndex += numDelta;
                el = arrayAll [ numIndex ];
                if ( el == null ) {
                    break;
                } else if ( el.objectHandle != null ) {
                    var obHandler = this.manager.getObject ( el.objectHandle );
                    if ( obHandler != null ) {
                        if ( obHandler.hoverIn != null ) {
                            if ( obHandler.parent == this.parent ) {
                                this.manager.setSelectedObject ( obHandler );
                                this.manager.scrollIntoView ( el );
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        }
        containerObject.prototype.fnGetParentHasFocus = function () {
            var obFocus = this.manager.getGlobalFocus ();
            if ( obFocus != null ) {
                var el = this.outerElement;
                while ( true ) {
                    if ( el.objectHandle != null ) {
                        var obP = this.manager.getObject ( el.objectHandle );
                        if ( obP == obFocus ) return true;
                    }
                    el = el.parentNode;
                    if ( el == document.body ) break;
                }
            }
            return false;
        }
        containerObject.prototype.fnAskParentForMore = function ( bUp ) {
            var el = this.outerElement;
            while ( true ) {
                if ( el.objectHandle != null ) {
                    var obP = this.manager.getObject ( el.objectHandle );
                    if ( obP != null ) {
                        if ( obP.fnExternalRequestMore != null ) {
                            var fnCallback = this.createCallback ( bUp ? "fnMoveUpOneCallback" : "fnMoveDownOneCallback" );
                            return obP.fnExternalRequestMore ( bUp, fnCallback );
                        }
                    }
                }
                el = el.parentNode;
                if ( el == document.body ) break;
            }
            return false;
        }
        containerObject.prototype.fnMoveUpOneCallback = function () {
            if ( this.manager.selectedObject == this ) {
                this.fnMoveSelection ( this.outerElement, -1 );
            }
        }
        containerObject.prototype.fnMoveDownOneCallback = function () {
            if ( this.manager.selectedObject == this ) {
                this.fnMoveSelection ( this.outerElement, 1 );
            }
        }
        containerObject.prototype.onKeyDown = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if ( this.fnGetParentHasFocus () ) {
                if
                    ( code == 38 )
                {
                    var bDone = this.fnMoveSelection ( this.outerElement, -1 );
                    if ( ! bDone ) {
                        bDone = this.fnAskParentForMore ( true );
                    }
                    return bDone;
                }
                else
                if
                    ( code == 40 )
                {
                    var bDone = this.fnMoveSelection ( this.outerElement, 1 );
                    if ( ! bDone ) {
                        bDone = this.fnAskParentForMore ( false );
                    }
                    return bDone;
                }
                else
                if
                    ( code == 37 )
                {
                    // Left arrow
                }
                else
                if
                    ( code == 39 )
                {
                    // Right arrow
                    this.tryToSelect ();
                    return true;
                }
                else
                if
                    ( code == 13 )
                {
                    // Enter
                    this.tryToSelect ();
                    return true;
                }
                else
                if
                    ( code == 9 )
                {
                    // Tab key
                }
            }
            return false;
        }
        containerObject.prototype.selectable = function () {
            if ( this.outerElement != document.body ) {
                return true;
            }
            return false;
        }
        containerObject.prototype.fnHierarchySearch = function ( el, fnTest ) {
            if ( fnTest ( el ) ) {
                return el;
            } else if ( el.nodeType == 1 ) {
                for ( var elChild = el.firstChild; elChild != null; elChild = elChild.nextSibling ) {
                    var elResult = this.fnHierarchySearch ( elChild, fnTest );
                    if ( elResult != null ) return elResult;
                }
            }
            return null;
        }
        containerObject.prototype.tryToSelect = function () {
            var fnTest = function ( el ) {
                if ( el.onclick != null ) return true;
                if ( el.href != null ) return true;
                return false;
            }
            var el = this.fnHierarchySearch ( this.outerElement, fnTest );
            if ( el != null ) {
                el.click ();
            }
        }

    //--------------------------------------------------------

        function controlManagerObject ()
        {
            this.active = false;
            this.lastValue = null;
            this.showHover = true;
            this.editable = true;
        }

        
        controlManagerObject.prototype = new baseObject ();

        controlManagerObject.prototype.suppressedAdvice = {
            "InComplete" : true,
            "StringTooShort" : true,
            "BadDay" : true,
            "BadMonth" : true,
            "BadYear" : true,
            "InvalidDay" : true,
            "InvalidMonth" : true,
            "InvalidYear" : true
        }
    
        controlManagerObject.prototype.start = function ( element ) {

            this.outerElement = element;
            element.objectHandle = this.handle;

            this.effectElement = null;
            this.localFocusElement = null;
            this.pluginElement = null;

            var controls = this.manager.findControls ( this.outerElement );
            var properties = {};
            
            if
                ( controls.length == 1 )
            {
                this.pluginElement = controls [ 0 ];
                this.localFocusElement = this.pluginElement;
                this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
                this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
                this.savedClassName = this.pluginElement.className;
                this.effectElement = this.pluginElement;

                if
                    ( this.pluginElement.tagName == "SELECT" )
                {
                    var value = this.pluginElement.getAttribute ( this.manager.attributePrefix + "Value" );
                    var options = this.pluginElement.options;

                    this.textLookup = new Object ();

                    // Fixup the value of selects...

                    if
                        ( value != null )
                    {
                        this.pluginElement.value = value;
                    }

                    // Setup the map

                    for ( var i = 0; i < options.length; i++ ) {

                        var option = options [ i ];

                        this.textLookup [ option.value ] = option.text;
                    }

                    properties [ "textLookup" ] = this.textLookup;

                    // No effects for selects...

                    this.effectElement = null;
                }

                if
                    ( this.pluginElement.type.toLowerCase () == "checkbox" )
                {
                    this.checkbox = true;
                    this.checkboxChecked = this.pluginElement.checked;
                    this.checkboxIndeterminate = this.pluginElement.indeterminate;

                    properties.checkboxChecked = this.checkboxChecked;
                    properties.checkboxIndeterminate = this.checkboxIndeterminate;
                }

                var tabIndex = this.getInheritedAttribute ( this.manager.attributePrefix + "TabIndex" );

                if
                    ( tabIndex != null )
                {
                    this.pluginElement.tabIndex = tabIndex;
                }

                this.fieldName = this.manager.findName ( this.outerElement );

                if
                    ( this.fieldName != null )
                {
                    properties.value = this.pluginElement.value;
                    this.manager.registerFieldType ( this.fieldName, this.outerElement );
                    this.manager.registerFieldProperties ( this.fieldName, properties );
                }

                this.manager.attatch ( this, false );

                this.obTypeAssistDB = this.manager.findNamedObject ( "typeAssistDatabase" );

                if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "SuppressCommonAdvice" ) == "1" ) {
                    this.bSuppressCommonAdvice = true;
                }
                if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "TabKeyForTextEdit" ) == "1" ) {
                    this.bTabKeyForTextEdit = true;
                }
            }
            else
            {
                alert ( "controlManagerObject error: unable to find control" );
                this.outerElement.innerHTML = "???";
            }
        }
        
        controlManagerObject.prototype.notifyChange = function () {

            var disabled = this.oInterface.read ( this.fieldName, "disabled" );
            var valid = this.oInterface.read ( this.fieldName, "valid" );

            if
                ( disabled != null )
            {
                if
                    ( this.pluginElement.disabled != disabled )
                {
                    this.pluginElement.disabled = disabled;
                }
            }

            this.editableControl = ! disabled;

            if
                ( this.checkbox )
            {
                var checked = this.oInterface.read ( this.fieldName, "checkboxChecked" );
                var indeterminate = this.oInterface.read ( this.fieldName, "checkboxIndeterminate" );

                if ( this.pluginElement.checked != checked ) this.pluginElement.checked = checked;
                if ( this.pluginElement.indeterminate != indeterminate ) this.pluginElement.indeterminate = indeterminate;

                this.checkboxChecked = checked;
                this.checkboxIndeterminate = indeterminate;
            }
            
            if
                ( valid != null )
            {
                var value = this.oInterface.read ( this.fieldName, "value" );
                var advice = this.oInterface.read ( this.fieldName, "advice" );

                if ( this.suppressedAdvice [ advice ] ) {
                    if ( this.bSuppressCommonAdvice || ( ! this.oInterface.read ( this.fieldName, "changed" ) ) ) {
                            advice = null;
                    }
                }

                if
                    ( value != null )
                {
                    if
                        ( this.pluginElement.value != value )
                    {
                        this.manager.setControlToNewValue ( this.pluginElement, value );
                    }

                    if
                        ( this.pluginElement.tagName == "TEXTAREA" )
                    {
                        var doResize = this.pluginElement.getAttribute ( this.manager.attributePrefix + "AutoSize" );

                        if ( doResize != 0 ) {

                            var height = this.pluginElement.scrollHeight;

                            if
                                ( height != this.pluginElement.clientHeight )
                            {
                                this.pluginElement.style.pixelHeight = height;

                                var delta = height - this.pluginElement.clientHeight;

                                this.pluginElement.style.pixelHeight += delta;

                                this.manager.updateFocusRectangle ();
                                this.manager.updateHoverRectangle ();
                            }

                            this.pluginElement.style.overflow = "hidden";
                        }
                    }

                    if
                        ( ( this.disabled != disabled ) || ( this.valid != valid ) )
                    {
                        this.disabled = disabled;
                        this.valid = valid;

                        if
                            ( this.effectElement != null )
                        {
                            if
                                ( ( ! this.valid ) && ( ! this.disabled ) )
                            {
                                this.effectElement.className = "plugin-invalid";
                            }
                            else
                            {
                                this.effectElement.className = this.savedClassName;
                            }
                        }
                    }

                    if
                        ( this.advice != advice )
                    {
                        this.advice = advice;

                        if
                            ( this.active )
                        {
                            this.manager.updateFocus ();
                        }

                        if ( this.pluginElement.getAttribute ( this.manager.attributePrefix + "DisableToolTip" ) != "1" ) {
                            if ( advice == null ) advice = "";
                            if ( advice != "" ) advice = this.manager.translateAdvice ( advice );
                            this.pluginElement.title = advice;
                        }
                    }
                }
            }

            this.manager.viewUpdated ();
        }

        controlManagerObject.prototype.focusIn = function () {

            if
                ( ! this.active )
            {
                if
                    ( this.pluginElement != null )
                {
                    this.lastValue = this.pluginElement.value;
                    this.manager.addImperativeTask ( this.createCallback ( "watchdog" ) );
                }

                this.showFloatingList ();

                this.active = true;
            }
        }
    
        controlManagerObject.prototype.callControlFocus = function () {

            if
                ( this.pluginElement != null )
            {
                if ( this.pluginElement.focus != null ) {

                    if ( ! this.pluginElement.disabled ) {

                        return this.manager.trySetFocus ( this.pluginElement );
                    }
                }
            }
            return true;
        }

        controlManagerObject.prototype.focusOut = function () {
        
            this.hideFloatingList ();
            this.active = false;
        }

        controlManagerObject.prototype.insertText = function ( text ) {

            if ( this.lastSelection != null ) {

                if ( document.activeElement != this.pluginElement ) {

                    this.manager.addImperativeTask ( this.createCallback ( "doActualFocus" ) );
                }

                this.lastSelection.text = text;
            }
        }

        controlManagerObject.prototype.doActualFocus = function () {

            this.pluginElement.focus ();
        }

        controlManagerObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );
        }

        controlManagerObject.prototype.watchdog = function () {

            if
                ( this.active )
            {
                if
                    ( this.checkbox )
                {
                    var checked = this.pluginElement.checked;
                    var indeterminate = this.pluginElement.indeterminate;

                    if
                        ( ( checked != this.checkboxChecked ) || ( indeterminate != this.checkboxIndeterminate ) )
                    {
                        var update = new updateObject ();

                        update.write ( this.fieldName, "checkboxChecked", checked );
                        update.write ( this.fieldName, "checkboxIndeterminate", indeterminate );

                        this.oInterface.syncUpdate ( update );
                    }
                }
                else
                {
                    var value = this.pluginElement.value;

                    if ( document.activeElement == this.pluginElement ) {
                        this.lastSelection = document.selection.createRange ();
                    }

                    if ( this.obTypeAssistDB != null ) {
                        if ( this.lastValue != value ) {
                            if ( this.typeHistory != null ) {
                                var result = this.obTypeAssistDB.test ( this.typeHistory );
                                if ( result != null ) {
                                    var textRange = document.selection.createRange ();
                                    textRange.moveStart ( "character", -1 * result.from.length );
                                    if ( textRange.text == result.from ) {
                                        textRange.text = result.to;
                                        this.lastTypeAssist = result;
                                        value = this.pluginElement.value;
                                    }
                                    this.typeHistory = "";
                                }
                            }
                        }
                    }

                    if
                        ( this.lastValue != value )
                    {
                        var update = new updateObject ();

                        update.write ( this.fieldName, "value", value );
                        update.write ( this.fieldName, "checked", false );

                        this.oInterface.syncUpdate ( update );

                        this.lastValue = this.pluginElement.value;

                        if ( this.floatingList ) {

                            this.setDirection ();
                        }
                    }
                }

                return "repeat";
            }

            return false;
        }

        controlManagerObject.prototype.showFloatingList = function () {

            if ( this.floatingList != null ) {

                this.floatingList.show ();
            }
            else
            {
                var hintsPath = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsPath" );

                if ( hintsPath != null ) {

                    var hints = this.manager.fetchEnumResource ( hintsPath );
                    var list = [];

                    for ( var i = 0; i < hints.length; i++ ) {

                        list [ list.length ] = hints [ i ].text;
                    }

                    var sort = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsSort" );
                    if ( sort == "0" )
                    {
                        this.silo = { index:0, list:list };
                    }
                    else
                    {
                        this.setStrings ( list );
                    }

                    var view = this.getInheritedAttribute ( this.manager.attributePrefix + "HintsView" );
                    if ( view == "full" )
                    {
                        var container = this.manager.getContainer();
                        var rectangle = container.getRectangle();
                        var height = hints.length * 30 + 25;
                        this.floatingList = this.manager.topManager().create ( "floatingElement" );
                        this.floatingList.setRectangle ( rectangle.x, rectangle.y + rectangle.height - this.pluginElement.offsetHeight - this.pluginElement.clientHeight, 600, height );
                        this.floatingList.setFontSize  ( null );
                    }
                    else
                    {
                        this.floatingList = this.manager.create ( "floatingElement" );
                        this.floatingList.setRectangle ( 0, this.pluginElement.clientHeight + 10, 600, 100 );
                    }

                    this.floatingList.setReferenceObject ( this );
                    this.floatingList.setServer ( this );
                    this.floatingList.focusOnClick = false;

                    this.floatingList.start ();

                    this.floatingList.show ();
                    this.pluginElement.onkeydown = this.createCallback ( "keyDown" );
                }
            }
        }

        controlManagerObject.prototype.hideFloatingList = function () {

            if
                ( this.floatingList )
            {
                this.floatingList.hide ();
//				this.floatingList.close ();
            }
        }

        controlManagerObject.prototype.setStrings = function ( list ) {

            var f = function ( a, b ) {
            
                a = a.toLowerCase ();
                b = b.toLowerCase ();
                
                if ( a < b ) return - 1;
                if ( a > b ) return 1;

                return 0;
            }

            this.silo = { index:0, list:list.sort ( f ) };
        }

        controlManagerObject.prototype.getMoreUp = function ( floatingList ) {
        }

        controlManagerObject.prototype.getMoreDown = function ( floatingList ) {

            with ( this.silo ) {

                if ( index < list.length ) {

                    var text = list [ index ];

                    if ( text == "" ) {

                        index++;

                        this.getMoreDown ( floatingList );
                    }
                    else
                    {
                        var style = "";
                        if ( floatingList.fontSize != null ) style = " style='font-size:" + floatingList.fontSize + "'";
                        floatingList.insertItem ( "end", "<NOBR" + style + ">" + text + "</NOBR>", index );

                        index++;
                    }
                }
            }
        }

        controlManagerObject.prototype.selectionMade = function ( value, context ) {

            if ( value != null ) {

                this.pluginElement.value = this.silo.list [ value ];
                this.direction = null;
                this.pluginElement.focus ();
            }
        }

        controlManagerObject.prototype.listDirection = function () {

            var text = this.floatingList.selectedText ();
            
            if ( text != null ) {
            
                var value = this.pluginElement.value.toLowerCase ();
                text = text.toLowerCase ();

                if ( text < value ) return "down";
                if ( text > value ) return "up";
                return "correct";
            }

            return null;
        }

        controlManagerObject.prototype.setDirection = function () {

            this.direction = this.listDirection ();
            this.moveSelection ();
        }

        controlManagerObject.prototype.selectionChanged = function ( value, context ) {

            if ( this.direction == null ) {

                this.selectionMade ( value, context );
            }
            else
            {
                this.manager.addTask ( this.createCallback ( "moveSelection" ) );
            }
        }

        controlManagerObject.prototype.moveSelection = function () {

            var direction = this.listDirection ();

            if ( this.direction == "correct" ) {

                this.direction = null;
            }
            else
            {
                if ( direction != this.direction ) {

                    var text = this.floatingList.selectedText ().toLowerCase ();
                    var value = this.pluginElement.value.toLowerCase ();

                    if ( value.length < text.length ) {

                        if ( text.slice ( 0, value.length ) == value ) {

                            this.direction = null;

                            return;
                        }
                    }

                    this.direction = "correct";
                }

                if ( direction == "down" ) this.floatingList.moveDown ();
                if ( direction == "up" ) this.floatingList.moveUp ();
            }
        }

        controlManagerObject.prototype.keyDown = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if ( this.floatingList ) {
                if 
                    ( code == 13 )
                {
                    // Enter...
                    this.floatingList.makeSelection ();
                    return true;
                }
                else
                if
                    ( code == 38 )
                {
                    // Up arrow
                    this.direction = null;
                    this.floatingList.moveUp ();
                    return true;
                }
                else
                if
                    ( code == 40 )
                {
                    // Down arrow
                    this.direction = null;
                    this.floatingList.moveDown ();
                    return true;
                }
            }
            return false;
        }

        controlManagerObject.prototype.onKeyPress = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if ( this.obTypeAssistDB != null ) {
                if ( this.typeHistory == null ) this.typeHistory = "";
                this.typeHistory = ( String.fromCharCode ( code ) + this.typeHistory ).toString ().slice ( 0, 30 );
            }
            if ( ( code == 9 ) && this.bTabKeyForTextEdit ) {
                // Tab
                return true;
            }
            return false;
        }
        controlManagerObject.prototype.onKeyDown = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if ( this.obTypeAssistDB != null ) {
                var lastTypeAssist = this.lastTypeAssist;
                this.lastTypeAssist = null;
                if ( code == 8 ) {
                    // Backspace
                    if ( lastTypeAssist != null ) {
                        var textRange = document.selection.createRange ();
                        textRange.moveStart ( "character", -1 * lastTypeAssist.to.length );
                        if ( textRange.text == lastTypeAssist.to ) {
                            textRange.text = lastTypeAssist.from;
                        }
                        return true;
                    }
                }
            }
			this.bTabKeyForTextEdit = false;
            if ( ( code == 9 ) && this.bTabKeyForTextEdit ) {
                // Tab
                var obRange = document.selection.createRange ();
                if ( obRange.parentElement () == this.pluginElement ) {
                    var boolShift = e.shiftKey;
                    var obRange = document.selection.createRange ();
                    if ( obRange.text != "" ) {
                        while ( true ) {
                            var text = obRange.text;
                            if ( text == "" ) break;
                            obRange.moveEnd ( "character", -1 );
                            if ( obRange.text != text ) {
                                obRange.moveEnd ( "character", 1 );
                                break;
                            }
                        }
                        obRange.select ();
                        var arrayText = obRange.text.split ( "\n" );
                        for ( var numIndex = 0; numIndex < arrayText.length; numIndex++ ) {
                            var strLine = arrayText [ numIndex ];
                            if ( strLine.match ( /^\s*$/ ) != null ) {
                                arrayText [ numIndex ] = "";
                            } else {
                                if ( ! boolShift ) {
                                    arrayText [ numIndex ] = "\t" + strLine;
                                } else {
                                    if ( strLine.charAt ( 0 ) == "\t" ) {
                                        arrayText [ numIndex ] = strLine.slice ( 1 );
                                    }
                                }
                            }
                        }
                        var obStartRange = obRange.duplicate ();
                        var obEndRange = obRange.duplicate ();
                        obStartRange.collapse ( true );
                        obEndRange.collapse ( false );
                        obRange.text = arrayText.join ( "\n" );
                        obRange.setEndPoint ( "StartToStart", obStartRange );
                        obRange.setEndPoint ( "EndToEnd", obEndRange );
                        obRange.select ();
                        return true;
                    } else {
                        if ( ! boolShift ) {
                            obRange.text = "\t";
                            obRange.collapse ( false );
                            obRange.select ();
                            return true;
                        }
                    }
                }
            }
            return false;
        }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 5<br>");  


        function echoObject ()
        {
            this.propertyName = "value";
        }

        
        echoObject.prototype = new baseObject ();
    
        echoObject.prototype.start = function ( element, objectClass ) {

            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;

            var propertyName = this.outerElement.getAttribute ( this.manager.attributePrefix + "PropertyName" );
            var value = this.outerElement.getAttribute ( this.manager.attributePrefix + "Value" );
            var setValue = this.outerElement.getAttribute ( this.manager.attributePrefix + "SetValue" );

            if
                ( propertyName != null )
            {
                this.propertyName = propertyName;
            }

            this.fieldName = this.manager.findName ( this.outerElement );

            if
                ( this.fieldName != null )
            {
                if
                    ( setValue == 1 )
                {
                    var properties = new Object ();

                    if
                        ( value == null )
                    {
                        properties.value = this.outerElement.innerText;
                    }
                    else
                    {
                        properties.value = value;
                        properties.textLookup = new Object ();
                        properties.textLookup [ value ] = this.outerElement.innerText;
                    }

                    this.manager.registerFieldProperties ( this.fieldName, properties );
                }

                this.manager.attatch ( this, false );
            }
        }
        
        echoObject.prototype.notifyChange = function () {

            var property = this.propertyName;

            var value = this.oInterface.read ( this.fieldName, property );

            if ( value == null ) value = "";

            if
                ( property == "value" )
            {
                var lookup = this.oInterface.read ( this.fieldName, "textLookup" );

                if
                    ( lookup != null )
                {
                    value = lookup [ value ];
                }
            }

            this.outerElement.innerText = value;

            if ( this.outerElement.getAttribute ( this.manager.attributePrefix + "DisableToolTip" ) != "1" ) {
                var advice = this.oInterface.read ( this.fieldName, "advice" );
                if ( advice == null ) advice = "";
                if ( advice != "" ) advice = this.manager.translateAdvice ( advice );
                this.outerElement.title = advice;
            }

            this.manager.viewUpdated ();
        }

        echoObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );
        }

//--------------------------------------------------------

        function formManagerObject ()
        {
            this.showHover = false;
        }

        
        formManagerObject.prototype = new baseObject ();

            formManagerObject.prototype.start = function ( element, strClass, obContainer ) {
                this.outerElement = element;
                element.objectHandle = this.handle;
                this.localFocusElement = null;
                this.formName = this.manager.findName ( this.outerElement );
                obContainer.traverseChildren ( element ); // Recurse binding to child elements.
                if
                    ( this.formName == null )
                {
                    alert ( "formManagerObject error : managed forms must have a name" );
                } else {
                    var update = new updateObject ();
                    update.write ( this.formName, "valid", true );
                    this.manager.oInterface.syncUpdate ( update );
                    this.manager.attatch ( this, true ); // Read-write (like a validator).
                }
            }

            formManagerObject.prototype.getFieldNames = function () {
                var l = this.manager.allBoundObjects ( this.outerElement );
                var result = [];
                for ( var i = 0; i < l.length; i++ ) {
                    var o = l [ i ];
                    if ( o.fieldName != null ) {
                        result [ result.length ] = o.fieldName;
                    }
                }
                return result;
            }
            formManagerObject.prototype.notifyChange = function () {
                var names = this.getFieldNames ();
                var valid = true;
                for ( var i = 0; i < names.length; i++ ) {
                    var fieldName = names [ i ];
                    if
                        ( this.oInterface.read ( fieldName, "valid" ) == false )
                    {
                        if
                            ( this.oInterface.read ( fieldName, "disabled" ) != true )
                        {
                            valid = false;
                            break;
                        }
                    }
                }
                this.oInterface.write ( this.formName, "valid", valid );
            }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 6<br>");  


        function submitManagerObject ()
        {
            this.showHover = true;
            this.disabled = false;
        }
        
        
        submitManagerObject.prototype = new baseObject ();
    
        submitManagerObject.prototype.start = function ( element ) {

            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;

            var controls = this.manager.findControls ( this.outerElement );
            
            if
                ( controls.length == 1 )
            {
                this.localFocusElement = controls [ 0 ];
                this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
                this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );

                var tabIndex = this.getInheritedAttribute ( this.manager.attributePrefix + "TabIndex" );

                if
                    ( tabIndex != null )
                {
                    this.localFocusElement.tabIndex = tabIndex;
                }
                
                this.manager.attatch ( this, false );
            }
            else
            {
                alert ( "submitManagerObject error: unable to find control" );
                this.OuterElement.innerHTML = "???";
            }
            this.formName = this.outerElement.getAttribute ( this.manager.attributePrefix + "FormName" );
            var e = this.outerElement;
            while ( e != null ) {
                if ( e.tagName == "FORM" ) break;
                e = e.parentNode;
            }
            if ( e != null ) {
                if ( this.formName != null ) {
                    alert ( "submitManagerObject error: can't specify a target form name for a submit control INSIDE a form" );
                }
                this.eForm = e;
                this.oldOnSubmit = e.onsubmit;
                e.onsubmit = this.createCallback ( "checkSubmit" );
            }
            // Default DelaySubmit to always true to ensure we catch all pages that have a problem with immediate form submits
            this.bDelaySubmit = true;
            if ( this.outerElement.getAttribute ( this.manager.attributePrefix + "SuppressDelaySubmit" ) == "1" ) {
                this.bDelaySubmit = false;
            }
        }

        submitManagerObject.prototype.getFieldNames = function () {

            var e = this.eForm;
            if ( e == null ) {
                return this.oInterface.observedFieldNames ();
            }
            else
            {
                var l = this.manager.allBoundObjects ( e );
                var result = [];

                for ( var i = 0; i < l.length; i++ ) {

                    var o = l [ i ];

                    if ( o.fieldName != null ) {

                        result [ result.length ] = o.fieldName;
                    }
                }

                return result;
            }
        }

        submitManagerObject.prototype.checkSubmit = function (e) {//lcorbeil check call to this function
            if (!e) e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );

            if ( this.disabled ) {
                return false;
            }
            else
            {
                var bDoIt = true;
                if ( this.oldOnSubmit != null ) {
                    bDoIt = this.oldOnSubmit ();
                    if ( bDoIt == null ) {
                        bDoIt = true;
                    } else if ( bDoIt === ( void 0 ) ) {
                        bDoIt = true;
                    }
                    if ( e.returnValue == false ) {
                        bDoIt = false;
                    }
                }
                if ( this.bDelaySubmit ) {
                    if ( bDoIt ) {
                        this.manager.addImperativeTask ( this.createCallback ( "submitManagerObject_doSubmit" ) );
                    }
                    return false;
                } else {
                    return bDoIt;
                }
            }
        }

        // Renamed doSubmit to submitManagerObject_doSubmit to avoid a name clash on some ACQ pages
        submitManagerObject.prototype.submitManagerObject_doSubmit = function () {
            if ( this.eForm != null ) {
                this.eForm.submit ();
            }
        }

        submitManagerObject.prototype.notifyChange = function () {

            var disabled = false;

            if ( ( this.eForm == null ) && ( this.formName != null ) ) {
                disabled = this.oInterface.read ( this.formName, "valid" ) != true;
            } else {
                var names = this.getFieldNames ();
                for ( var i = 0; i < names.length; i++ ) {

                    var fieldName = names [ i ];

                    if
                        ( this.oInterface.read ( fieldName, "valid" ) == false )
                    {
                        if
                            ( this.oInterface.read ( fieldName, "disabled" ) != true )
                        {
                            disabled = true;
                            break;
                        }
                    }
                }
            }
            
            if
                ( disabled != this.disabled )
            {
                this.disabled = disabled;
                this.localFocusElement.disabled = disabled;

                if
                    ( disabled )
                {
                    this.localFocusElement.style.cursor = "";
                }
                else
                {
                    this.localFocusElement.style.cursor = "hand";
                }
            }

            this.manager.viewUpdated ();
        }

        submitManagerObject.prototype.onKeyPress = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if
                ( code == 13 )
            {
//				return true;
            }
        }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 7<br>");  

        function linkManagerObject ()
        {
            this.showHover = true;
        }
        
        
        linkManagerObject.prototype = new baseObject ();
    
        linkManagerObject.prototype.start = function ( element ) {

            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;

            if
                ( element.focus != null )
            {
                this.localFocusElement = element;
                this.localFocusElement.onfocus = new Function ( "documentManager.controlGetsFocus(" + this.handle + ");" );
                this.localFocusElement.onblur = new Function ( "documentManager.controlLoosesFocus(" + this.handle + ");" );
            }
        }

        linkManagerObject.prototype.onKeyPress = function (e) {
            if (!e) e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if
                ( code == 13 )
            {
                return true;
            }
        }

//--------------------------------------------------------
        function floatingFrameObject ()
        {
            this.disabled = false;

            this.rectangle = new Object ();

            this.rectangle.x = 0;
            this.rectangle.y = 0;
            this.rectangle.width = 0;
            this.rectangle.height = 0;

            this.frameLoaded = false;
            this.sizeAdjusted = false;
			this.ready = false;
			
			this.safeRectangle = false;
			
			
        }

        floatingFrameObject.prototype = new baseObject ();

		function DOM_InsertAdjacentHTML(elem,where,htmlStr)
		{
			var r = document.createRange();
			
			r.setStartBefore(elem);
			var parsedHTML = r.createContextualFragment(htmlStr);
			document.body.appendChild(parsedHTML);
		}
	

        floatingFrameObject.store = { id:0, list:[] };

        floatingFrameObject.prototype.createFrame = function () {

            trace("","floatingFrameObject.createFrame called");
            var store = floatingFrameObject.store;
            var id = "floatingFrame" + store.id++;
            var element;
//            var html = "<iframe src='about:blank' style='display:none; position:absolute; width:0; height:0;filter:progid:DXImageTransform.Microsoft.Shadow(color=#888888, Direction=135, Strength=5)' frameborder=no id='" + id + "' name='"+id+"'></iframe>";

			// although this works on firefox and IE, we need to do it differently for Firefox.
			
            var html = "<iframe src='about:blank' style='position:absolute;left:1px;top:1px;width:1px;height:1px;border:0 0 0 0;background:white;' frameborder='no' id='" + id + "' name='"+id+"' onload='setReadyState( this );'></iframe>";
			
			if 
				(document.body.insertAdjacentHTML)
			{
				document.body.insertAdjacentHTML ( "beforeEnd", html );
			}
			else
			{
				DOM_InsertAdjacentHTML(document.body,"beforeEnd",html);
			}
			
			/* // so we will try doing it with DOM. 
             var nf = document.createElement("IFRAME");
             nf.setAttribute("style","position:absolute;left:10;top:10;border:0 0 0 0;background:white;");
             //nf.style.display = "none";
             nf.setAttribute("id",id);
			 nf.setAttribute("frameborder","no");
             nf.setAttribute("src","/blank.html");
             nf.setAttribute("width","1");
             nf.setAttribute("height","1");
			 nf.setAttribute("onload","alert('fish');setReadyState(this);");
             document.body.appendChild(nf);

//var html = '<div style="background-color:red;position:absolute;left:10;top:10;width:100;height:100;">red bg</div>'
*/

            //
//            document.body.innerHTML = document.body.innerHTML + html;

//            element = getElementById( id );//document.all [ id ];
            element = xGetElementById( id );//document.all [ id ];
			
            var newItem = { free:false, element:element, id:id };
            
            store.list [ store.list.length ] = newItem;

            return newItem;
        }

        floatingFrameObject.prototype.disableDropShadow = function () {
            this.frameElement.style.filter = "";
        }

        floatingFrameObject.prototype.allocateFrame = function () {

            var store = floatingFrameObject.store;

            for ( var i = 0; i < store.list.length; i++ ) {

                with ( store.list [ i ] ) {

                    if ( free ) {

                        free = false;
                        trace("Found an free frame to use");
                        return store.list [ i ];
                    }
                }
            }

            return this.createFrame ();
        }

        floatingFrameObject.prototype.start = function () {

            var zIndex = this.manager.nextZIndex ();

            this.frameItem = this.allocateFrame ();

            this.outerElement = this.frameItem.element;
            this.frameElement = this.frameItem.element;

            this.localFocusElement = null;
			//alert(this.handle);
            this.manager.windows [ this.handle ] = frames [ this.frameItem.id ];//document.getObject( this.frameItem.id );//
			
			
            this.outerElement.objectHandle = this.handle;
            
			//alert( this.outerElement.objectHandle );
			
			this.outerElement.style.zIndex = zIndex;
        }

        floatingFrameObject.prototype.doRectangle = function () {
            trace("doRectangle called");
            
            if ( this.outerElement != null )
            {
            	
            	if
            		( this.safeRectangle)
            	{
            		this.safeRectangle = false;
				
	            	if ( this.rectangle.x + this.rectangle.width+10  > this.outerElement.ownerDocument.documentElement.offsetWidth ) 
	            	{
	            		// it's too wide, we need to adjust it's width a little.
	            		if 
	            			( this.rectangle.width + 40 >  this.outerElement.ownerDocument.documentElement.offsetWidth )
	            		{
							  this.rectangle.width = this.outerElement.ownerDocument.documentElement.offsetWidth - 20;
							  this.rectangle.x = 5;
							  
							  if ( this.rectangle.width < 200 )
							  {
							  	// minimum 200 pixels wide.
							  	
							  	this.rectangle.width = 200;
							  }							  
	            		}
	            	}

            		
        		}
            	
                if ( this.outerElement.style.pixelLeft )
                {
                    trace("pixelLeft brance used ");
                    this.outerElement.style.pixelLeft = this.rectangle.x;
                    this.outerElement.style.pixelTop = this.rectangle.y;
                    this.outerElement.style.pixelWidth = this.rectangle.width+10;
                    this.outerElement.style.pixelHeight = this.rectangle.height+10;
                    this.outerElement.style.visibility = "visible";
//                    this.outerElement.style.display = "";
                }
                else
				
                {
                    
                    // this is Mozilla case.
                    trace("non pixelLeft brance used ");
                    
                    this.outerElement.style.left = this.rectangle.x + "px";
                    this.outerElement.style.top = this.rectangle.y + "px";
                    this.outerElement.style.width = (this.rectangle.width)+ "px";
                    this.outerElement.style.height = (this.rectangle.height)+ "px";
                    this.outerElement.style.visibility = "visible" ;
                    //alert( alertObjProp(this.outerElement.style ) );
                }
            }
        }

        floatingFrameObject.prototype.setRectangle = function ( x, y, width, height ) {

            this.rectangle.x = x;
            this.rectangle.y = y;
            this.rectangle.width = width;
            this.rectangle.height = height;
			this.safeRectangle = false;

            this.doRectangle ();
        }
	
		floatingFrameObject.prototype.safeSetRectangle = function ( x, y, width, height ) {
			
       		/* this is a new version of the set rectangle, which will look the window in which it's
			   created */
			
            this.rectangle.x = x;
            this.rectangle.y = y;
            this.rectangle.width = width;
            this.rectangle.height = height;
			this.safeRectangle = true;
            this.doRectangle ();
        }
        

        floatingFrameObject.prototype.getRectangle = function () {

            with ( this.rectangle )
            {
                return { x:x, y:y, width:width, height:height };
            }
        }

        floatingFrameObject.prototype.move = function ( dx, dy ) {

            this.rectangle.x += dx;
            this.rectangle.y += dy;

            this.doRectangle ();
        }

        floatingFrameObject.prototype.size = function ( dx, dy ) {

            if
                ( ( dx == null ) && ( dy == null ) )
            {
			    this.sizeAdjusted = false;
                this.adjustSize ();
            }
            else
            {
                this.rectangle.width += dx;
                this.rectangle.height += dy;

                this.doRectangle ();
                this.manager.addTask ( this.createCallback ( "adjustSize" ) );
            }
        }

        floatingFrameObject.prototype.load = function ( url ) {
            trace("floatingFrame.load "+url+ " called");
            this.frameLoaded = false;
            this.ready = false;
            this.url = url;
            this.checkLoaded ();
        }

        floatingFrameObject.prototype.checkLoaded = function () {
            trace("checkLoaded");
			
			//window.status = 'checkLoaded '+new Date();
            if ( ! this.frameLoaded ) {
				trace("frameNotLoaded");
			
                if ( ! this.bIsClosed ) {
                    if ( this.loadRetryCount == null ) {
                        this.loadRetryCount = 0;
                    }
                    this.loadRetryCount++;
                    if ( this.loadRetryCount == 4 ) {
                        this.rectangle.height = 500;
                        this.rectangle.width = 500;
                        this.doRectangle ();
                        alert ( "Frame failed to load" );
                    } else {
                        trace("floatingFrame check load called");

                        var timeToWait = this.loadRetryCount * 5000;
                        this.frameElement.src = this.url;
                        window.setTimeout ( this.createCallback ( "checkLoaded" ), timeToWait );
                    }
                }
            }
            else
            {
			    if (!this.sizeAdjusted)
				{
					this.adjustSize();
				}
				trace("set retry count to null");
                this.loadRetryCount = null;
            }
        }

        floatingFrameObject.prototype.loaded = function ( childWindow ) {

			
            trace("floating frame loaded called");
            this.childWindow = childWindow;
		
            this.doRectangle ();
          
			this.manager.addTask ( this.createCallback ( "adjustSize" ) );
            
			this.frameLoaded = true;
			
            this.manager.resetGlobalFocus ();
			
		}

        floatingFrameObject.prototype.adjustSize = function () {
			this.sizeAdjusted = true;
            if
                ( this.frameLoaded && ( ! this.frameItem.free ) )
            {
                trace("floating adjust size called");            
                var width = this.childWindow.document.body.scrollWidth;
                var height = this.childWindow.document.body.scrollHeight;
                var clientHeight = this.childWindow.document.body.clientHeight;

                

                if ( browserVersion < 5 ) {

                    if ( clientHeight > height ) height = clientHeight;
                }
                else
                {
                    var delta = Math.abs ( height - clientHeight );

                    /*
                    	Causes double scrollbar on firefox....
                    	if ( delta <= 2 ) height = clientHeight;
                    */
                }
                
                
                
                
                
                this.childWindow.document.body.scrollTop = 0;

                this.rectangle.height = height;

                if ( width > this.rectangle.width ) {

                    this.rectangle.width = width;
                }

                trace("trying to resize to ("+width+","+height+")");            

                
                this.doRectangle ();

                if
                    ( ! this.ready )
                {
                    this.ready = true;

                    if
                        ( this.onLoad != null )
                    {
                        this.onLoad ();
                    }
                }
            }
        }

        floatingFrameObject.prototype.addOnClose = function ( f ) {

            //    Functions to be called when this object is closed.
            //    These functions will ONLY GET CALLED IF THE OBJECT IS CLOSED,
            //    they will not get called if the object's frame is
            //    re-loaded or re-navigated etc...

            if ( this.shutdowns == null ) this.shutdowns = [];

            this.shutdowns [ this.shutdowns.length ] = f;
        }

        floatingFrameObject.prototype.close = function () {

            trace("","Floating frame close called");
            
            if ( ! this.bIsClosed ) {

				trace("","frame not closed - so closing it");
				
                var childManager = this.childWindow.documentManager;

                if ( childManager != null ) {
                    
                    if ( this.shutdowns != null ) {
                    
                       childManager.doFunctions ( this.shutdowns );
                    }

                    childManager.doFunctions ( childManager.shutdowns );

                    childManager.shutdowns = [];
                }
                trace("","Creating kill frame callback");
                this.manager.addTask ( this.createCallback ( "killFrame" ) );
                trace("","Calling remove later");
                this.manager.removeLater ( this.handle );

                this.bIsClosed = true;
            }
			else 
			{
				//alert(this);
				trace("frame already closed so do nothing");
			}
        }

        floatingFrameObject.prototype.getIsClosed = function () {
            if ( ! this.bIsClosed ) {
                return false;
            }
            return true;
        }

        floatingFrameObject.prototype.killFrame = function () {

			trace("Kill Frame called");
            //so at this point - it seems as though we still 
            //have references to stuff inside this frame.
            
            var childManager = this.childWindow.documentManager;
            if (childManager != null)
            {
                childManager.detatch();
            }
            this.frameElement.src = "about:blank";
		    this.bIsClosed = false;
            this.manager.windows [ this.handle ] = null;
            
            // do not recycle frames for now.- this is a workaround - becuase recycled frames don't seem to work.
            
            //this.frameItem.free = true;
            
            this.outerElement.style.display = "none";
        }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 8<br>");  

        function listItemManagerObject ()
        {
            this.selected = false;
        }
        
        
        listItemManagerObject.prototype = new baseObject ();
    
        listItemManagerObject.prototype.start = function ( element ) {

            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;

            this.outerElement.onselectstart = new Function ( "return false;" );
            this.outerElement.ondragstart = new Function ( "return false;" );

            this.savedClassName = this.outerElement.className;
        }

        listItemManagerObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );

            this.container.itemClicked ( this.handleInContainer );
        }

        listItemManagerObject.prototype.hoverIn = function () {

            this.container.itemHovered ( this.handleInContainer );
        }

        listItemManagerObject.prototype.setSelection = function ( selected ) {

            if
                ( selected != this.selected )
            {
                this.selected = selected;

                if
                    ( this.selected )
                {
                    this.outerElement.className = "list-item-selected";
                }
                else
                {
                    this.outerElement.className = "list-item-not-selected";
                }
            }
        }

        listItemManagerObject.prototype.asText = function () {

            return this.outerElement.innerText;
        }

        listItemManagerObject.prototype.close = function () {

            this.outerElement.style.display = "none";
            this.outerElement.innerHTML = "";
            this.manager.removeLater ( this.handle );
        }

//--------------------------------------------------------
        function floatingElementObject ()
        {
            this.showHover = false;
            this.disabled = false;
            this.active = false;
            this.visible = false;
            this.fontSize = "larger";

            this.rectangle = new Object ();

            this.rectangle.x = 0;
            this.rectangle.y = 0;
            this.rectangle.width = 0;
            this.rectangle.height = 0;
            this.rectangle.maxWidth = 0;
            this.rectangle.maxHeight = 0;

            this.count = 0;
            this.indexToObject = new Object ();
            this.valueToObject = new Object ();

            this.dragMode = "start";
            
            this.referenceObject = null;

            this.autoSelect = true;
            this.selectOnHover = false;
            this.focusOnClick = true;
        }

        floatingElementObject.prototype = new baseObject ();

        floatingElementObject.store = { id:0, list:new Array () };


		
 	floatingElementObject.prototype.newDiv = function () {

            var store = floatingElementObject.store;
            var id = "floatingElement" + store.id++;
            var element;

            html = "<DIV style='border:1 black solid; display:none; position:absolute; width:0; height:0;' id=" + id + "><DIV style='background-color:silver;'></DIV><DIV style='overflow:hidden; height:0'></DIV></DIV>";

            //document.body.insertAdjacentHTML ( "beforeEnd", html );
            //document.body.innerHTML = document.body.innerHTML + html;

			DOM_InsertAdjacentHTML(document.body, "beforeEnd", html);
			
            element = xGetElementById( id );//ddocument.all [ id ];

            ////children--childNodes
            store.list [ store.list.length ] = { free:false, element:element, listElement:element.childNodes [ 1 ], headElement:element.childNodes [ 0 ] };

            element.onselectstart = new Function ( "return false;" );
            element.ondragstart = new Function ( "return false;" );

            return store.list [ store.list.length - 1 ];
        }

        floatingElementObject.prototype.allocateDiv = function () {

            var store = floatingElementObject.store;

            for ( var i = 0; i < store.list.length; i++ ) {

                with ( store.list [ i ] ) {

                    if ( free ) {

                        free = false;
                        return store.list [ i ];
                    }
                }
            }

            return this.newDiv ();
        }

        floatingElementObject.prototype.freeDiv = function ( outerElement ) {

            var store = floatingElementObject.store;

            for ( var i = 0; i < store.list.length; i++ ) {

                with ( store.list [ i ] ) {

                    if ( ! free ) {

                        if ( outerElement == element ) {

                            free = true;
                            listElement.innerHTML = "";
                            element.style.display = "none";

                            return;
                        }
                    }
                }
            }
        }

        floatingElementObject.prototype.start = function ( element ) {

            var zIndex = this.manager.nextZIndex ();

            if
                ( element == null )
            {
                var newDiv = this.allocateDiv ();

                this.outerElement = newDiv.element;
                this.listElement = newDiv.listElement;

                var eTable = document.createElement ( "table" );
                var eRow = eTable.insertRow ();
                var eLeft = eRow.insertCell ();
                var eRight = eRow.insertCell ();
                var eInput = document.createElement ( "input" );
                var eButton = document.createElement ( "button" );
                var eImage = document.createElement ( "img" );

                eButton.appendChild ( eImage );

                eLeft.appendChild ( eInput );
                eRight.appendChild ( eButton );

                eTable.cellPadding = 0;
                eTable.cellSpacing = 3;
                eTable.style.width = "100%";

                eInput.style.border = "none";
                eInput.style.fontFamily = "arial";
                eInput.style.fontSize = "80%";

                eRight.align = "right";
                eRight.vAlign = "top";
                eRight.style.paddingRight = "3px";

                eImage.src = "/script/sde/bitmaps/close.gif";
                eImage.width = 16;
                eImage.height = 16;

                eButton.style.border = "none";
                eButton.style.width = "16px";
                eButton.style.height = "16px";

                newDiv.headElement.innerHTML = "";
                newDiv.headElement.appendChild ( eTable );

                this.inputElement = eInput;

                this.allowBackSpace = true;
                this.inputElement.onkeyup = this.createCallback ( "newInput" );

                eButton.onclick = this.createCallback ( "doCancel" );
            }
            else
            {
                this.outerElement = element;
                this.listElement = this.outerElement;
                this.fixedPosition = true;
            }

            this.outerElement.style.zIndex = zIndex;

            this.localFocusElement = null;
            this.outerElement.objectHandle = this.handle;

            this.outerElement.onselectstart = new Function ( "return false;" );
            this.outerElement.ondragstart = new Function ( "return false;" );
        }

        floatingElementObject.prototype.show = function () {

            if ( ! this.visible ) {

                this.visible = true;
                this.doRectangle ();
                this.manager.addTask ( this.createCallback ( "dynamicSize" ), 3 );
            }
        }

        floatingElementObject.prototype.hide = function () {

            if ( this.visible ) {

                this.visible = false;
                this.outerElement.style.display = "none";
            }
        }

        floatingElementObject.prototype.dynamicSize = function () {

            if
                ( this.visible )
            {
                var height = this.listElement.scrollHeight + this.listElement.offsetTop;
                var width = this.outerElement.scrollWidth + 2;
                var more = false;

                if
                    ( height > this.rectangle.maxHeight )
                {
                    height = this.rectangle.maxHeight;
                }
                else
                {
                    more = true;
                }

                if
                    ( width > this.rectangle.maxWidth )
                {
                    width = this.rectangle.maxWidth;
                }

                if ( width < 10 ) width = 10;
                if ( height < 10 ) height = 10;

                if
                    ( width != this.rectangle.width || height != this.rectangle.height )
                {
                    if
                        ( this.active )
                    {
                        this.manager.hideFocus ();
                    }

                    this.rectangle.width = width;
                    this.rectangle.height = height;

                    this.doRectangle ();

                    this.manager.scrollIntoView ( this.outerElement );

                    if
                        ( this.active )
                    {
                        if ( this.inputElement != null ) {

                            this.inputElement.focus ();
                        }
                        else
                        {
                            this.outerElement.focus ();
                        }
                    }

                    if
                        ( more )
                    {
                        var count = this.count;

                        if
                            ( this.server != null )
                        {
                            this.server.getMoreDown ( this );
                        }

                        if
                            ( count != this.count )
                        {
                            if
                                ( this.selectedIndex == null )
                            {
                                if
                                    ( this.count != 0 )
                                {
                                    if
                                        ( this.autoSelect )
                                    {
                                        this.select ( this.lowIndex, true );
                                    }
                                }
                            }

                            this.manager.addTask ( this.createCallback ( "dynamicSize" ), 3 );

                            return;
                        }
                    }

                    this.manager.updateFocus ();
                }
            }
        }

        floatingElementObject.prototype.setFontSize = function ( size ) {

            this.fontSize = size;

            if
                ( this.visible )
            {
                this.doRectangle;
            }
        }

        floatingElementObject.prototype.setReferenceObject = function ( object ) {
        
            this.referenceObject = object;

            if
                ( this.visible )
            {
                this.doRectangle;
            }
        }

        floatingElementObject.prototype.setRectangle = function ( x, y, width, height ) {

            this.rectangle.x = x;
            this.rectangle.y = y;
            this.rectangle.maxWidth = width;
            this.rectangle.maxHeight = height;
        }

       

        floatingElementObject.prototype.doRectangle = function () {

            if
                ( this.outerElement != null )
            {
                if
                    ( this.fixedPosition )
                {
                    var offset = this.manager.getAbsoluteBodyOffset ( this.outerElement );

                    this.rectangle.x = offset.x;
                    this.rectangle.y = offset.y;
                }

                var x = this.rectangle.x;
                var y = this.rectangle.y;
                
                if
                    ( this.referenceObject != null )
                {
                    var element = this.referenceObject.outerElement;

                    if ( element == null ) {

                        if ( this.referenceObject.getFocusElement != null ) {
                    
                             element = this.referenceObject.getFocusElement ();
                        }
                    }

                    if
                        ( element != null )
                    {
                        var offset = this.manager.getOffset ( this.outerElement, element );
                        x += offset.x;
                        y += offset.y;
                    }
                }
                
                this.outerElement.style.pixelLeft = x;
                this.outerElement.style.pixelTop = y;
                this.outerElement.style.pixelWidth = this.rectangle.width;
                this.outerElement.style.pixelHeight = this.rectangle.height;
                this.outerElement.style.display = "";

                if ( this.inputElement != null ) {

                    var w = this.rectangle.width - 40;
                    if ( w < 100 ) w = 100;

                    this.inputElement.style.pixelWidth = w;
                }

                if ( this.outerElement != this.listElement ) {

                    this.listElement.style.pixelHeight = this.rectangle.height - this.listElement.offsetTop;
                }
            }
        }

        floatingElementObject.prototype.move = function ( dx, dy ) {

            if
                ( ! this.fixedPosition )
            {
                this.rectangle.x += dx;
                this.rectangle.y += dy;

                this.doRectangle ();
            }
        }

        floatingElementObject.prototype.size = function ( dx, dy ) {

            this.rectangle.width += dx;
            this.rectangle.height += dy;

            this.doRectangle ();
        }

        floatingElementObject.prototype.remove = function ( position, number ) {

            if
                ( this.count > 0 )
            {
                if
                    ( position == "start" )
                {
                    startIndex = this.lowIndex;
                    endIndex = startIndex + number - 1;
                }
                else
                {
                    startIndex = ( this.highIndex - number ) + 1;
                    endIndex = this.highIndex;
                }

                if ( startIndex < this.lowIndex ) startIndex = this.lowIndex;
                if ( endIndex > this.highIndex ) endIndex = this.highIndex;

                for ( var i = startIndex; i <= endIndex; i++ ) {

                    var object = this.indexToObject [ i ];

                    if
                        ( i == this.selectedIndex )
                    {
                        this.selectedIndex = null;
                    }

                    if
                        ( object != null )
                    {
                        var value = object.valueInContainer;

                        if
                            ( this.valueToObject [ value ] == object )
                        {
                            delete this.valueToObject [ value ];
                        }

                        delete this.indexToObject [ i ];
                        object.close ();
                    }

                    this.count--;
                }

                if
                    ( position == "start" )
                {
                    this.lowIndex = endIndex + 1;
                }
                else
                {
                    this.highIndex = startIndex - 1;
                }

                if
                    ( this.visible )
                {
                    this.manager.addTask ( this.createCallback ( "dynamicSize" ) );
                }
            }
        }

        floatingElementObject.prototype.startDrag = function () {
            trace("","floatingElement.startDrag called");
            this.dragMode = "start";
            this.dx = 0;
            this.dy = 0;
        }

        floatingElementObject.prototype.stopDrag = function () {
            trace("","floatingElement.stopDrag called");
            this.dragMode = "start";
//			this.outerElement.style.filter = "";
            if
                ( this.active )
            {
                this.manager.updateFocus ();
            }
        }

        floatingElementObject.prototype.doDrag = function ( dx, dy ) {
            trace("","floatingElement.doDrag called");
            if
                ( this.dragMode == "start" )
            {
                this.dx += dx;
                this.dy += dy;

                if
                    ( ( Math.abs ( this.dx ) > 5 ) || ( Math.abs ( this.dy ) > 5 ) )
                {
                    if
                        ( Math.abs ( this.dx ) > 5 )
                    {
                        this.dragMode = "move";
                        dx = this.dx;
                        dy = this.dy;
                    }
                    else
                    {
                        this.dragMode = "scroll";
                    }

                    ////////// Force move mode for now...

                    this.dragMode = "move";

                    if
                        ( this.active )
                    {
                        this.manager.hideFocus ();
                    }
                }
            }

            if
                ( this.dragMode != "start" )
            {
                if
                    ( Math.abs ( dx ) > Math.abs ( dy ) )
                {
                    this.dragMode = "move";
                }

                if
                    ( this.dragMode == "move" )
                {
//					this.outerElement.style.filter = "alpha(opacity=" + "50" + ")";

                    this.move ( dx, dy );
                }
                else
                {
                    var amount = Math.pow ( Math.abs ( dy ), 1.5 );

                    if ( dy < 0 ) amount = - amount;

                    this.listElement.scrollTop -= amount;
                }
            }
        }

        floatingElementObject.prototype.insertItem = function ( position, html, value, referenceObject ) {

            var objectClass = "listItem";

            var object = this.manager.create ( objectClass );
            var element;
            var index;
            var markup = "<DIV class='list-item-not-selected'>" + html + "</DIV>";

            if
                ( position == "start" )
            {
//                this.listElement.insertAdjacentHTML ( "afterBegin", markup );
                this.listElement.innerHTML = markup + this.listElement.innerHTML;
                //children--childNodes
                element = this.listElement.childNodes [ 0 ];

                if
                    ( this.count == 0 )
                {
                    this.lowIndex = 0;
                    this.highIndex = 0;
                    index = 0;
                }
                else
                {
                    this.lowIndex--;
                    index = this.lowIndex;
                }
            }
            else
            {
//                this.listElement.insertAdjacentHTML ( "beforeEnd", markup );
                this.listElement.innerHTML = this.listElement.innerHTML + markup;
                //children--childNodes
                element = this.listElement.childNodes [ this.listElement.childNodes.length - 1 ];

                if
                    ( this.count == 0 )
                {
                    this.lowIndex = 0;
                    this.highIndex = 0;
                    index = 0;
                }
                else
                {
                    this.highIndex++;
                    index = this.highIndex;
                }
            }

            this.count++;
            this.indexToObject [ index ] = object

            if
                ( value != null )
            {
                this.valueToObject [ value ] = object;
            }

            object.container = this;
            object.handleInContainer = index;
            object.valueInContainer = value;
            object.referenceObject = referenceObject;

            object.start ( element, objectClass );

            if
                ( this.visible )
            {
                this.manager.addTask ( this.createCallback ( "dynamicSize" ) );
            }
        }

        floatingElementObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );

            if
                ( this.dragMode == "start" )
            {
                if ( this.focusOnClick ) this.manager.setGlobalFocus ( this.manager, this );
            }
        }

        floatingElementObject.prototype.itemClicked = function ( index ) {

            if
                ( this.dragMode == "start" )
            {
                this.onClick();
                this.select ( index );
                this.selectionCallback ();
            }
        }

        floatingElementObject.prototype.itemHovered = function ( index ) {

            if
                ( this.active || this.selectOnHover )
            {
                this.select ( index );
            }
        }

        floatingElementObject.prototype.focusIn = function () {
        
            this.active = true;
        }

        floatingElementObject.prototype.focusOut = function () {
        
            this.active = false;

            if
                ( this.referenceObject )
            {
//				this.referenceObject.selectionMade ( null );
            }
        }

        floatingElementObject.prototype.select = function ( index, dontReport ) {

            if
                ( index != this.selectedIndex )
            {
                var oldObject = null;
                var newObject = null;
                
                if
                    ( this.selectedIndex != null )
                {
                    oldObject = this.indexToObject [ this.selectedIndex ];
                }

                this.selectedIndex = index;

                if
                    ( index != null )
                {
                    newObject = this.indexToObject [ index ];
                }

                if ( oldObject != null ) oldObject.setSelection ( false );

                if ( newObject != null ) {
                
                    newObject.setSelection ( true );

                    var top = this.listElement.scrollTop;
                    var bottom = top + this.listElement.offsetHeight;
                    var itemTop = newObject.outerElement.offsetTop;
                    var itemBottom = itemTop + newObject.outerElement.offsetHeight;

                    if
                        ( itemTop < top )
                    {
                        this.listElement.scrollTop = itemTop;
                    }
                    else
                    if
                        ( itemBottom > bottom )
                    {
                        this.listElement.scrollTop += ( itemBottom - bottom );
                    }
                }

                if
                    ( ! dontReport )
                {
                    this.selectionChangedCallback ();
                }
            }
        }

        floatingElementObject.prototype.selectionOffsetFromTop = function () {

            if
                ( this.selectedIndex != null )
            {
                var o = this.indexToObject [ this.selectedIndex ];
                var result = o.outerElement.offsetTop;
                var scrollTop = this.listElement.scrollTop;

                if
                    ( scrollTop != null )
                {
                    result -= scrollTop;
                }

                return result;
            }

            return null;
        }

        floatingElementObject.prototype.setValue = function ( value ) {

            var object = this.valueToObject [ value ];

            if
                ( object != null )
            {
                this.select ( object.handleInContainer );
            }
        }

        floatingElementObject.prototype.getValue = function () {

            if
                ( this.selectedIndex != null )
            {
                var object = this.indexToObject [ value ];

                return object.valueInContainer;
            }

            return null;
        }

        floatingElementObject.prototype.getHTML = function () {

            if
                ( this.selectedIndex != null )
            {
                var object = this.indexToObject [ value ];

                return object.outerElement.innerHTML;
            }

            return "";
        }

        floatingElementObject.prototype.setNoMoreUp = function () {

            this.noMoreUp = true;
        }

        floatingElementObject.prototype.setNoMoreDown = function () {

            this.noMoreDown = true;
        }

        floatingElementObject.prototype.moveUp = function () {

            if
                ( this.selectedIndex == null )
            {
                if
                    ( this.count == 0 )
                {
                    if ( this.noMoreUp ) return false;

                    if
                        ( this.server != null )
                    {
                        this.server.getMoreUp ( this );
                    }
                }

                if
                    ( this.count != 0 )
                {
                    this.select ( this.highIndex );
                }
            }
            else
            {
                if
                    ( this.selectedIndex == this.lowIndex )
                {
                    if ( this.noMoreUp ) return false;

                    if
                        ( this.server != null )
                    {
                        this.server.getMoreUp ( this );
                    }
                }

                if
                    ( this.selectedIndex > this.lowIndex )
                {
                    this.select ( this.selectedIndex - 1 );
                }
            }

            return true;
        }

        floatingElementObject.prototype.moveDown = function () {

            if
                ( this.selectedIndex == null )
            {
                if
                    ( this.count == 0 )
                {

                    if ( this.noMoreDown ) return false;

                    if
                        ( this.server != null )
                    {
                        this.server.getMoreDown ( this );
                    }
                }

                if
                    ( this.count != 0 )
                {
                    this.select ( this.lowIndex );
                }
            }
            else
            {
                if
                    ( this.selectedIndex == this.highIndex )
                {
                    if ( this.noMoreDown ) return false;

                    if
                        ( this.server != null )
                    {
                        this.server.getMoreDown ( this );
                    }
                }

                if
                    ( this.selectedIndex < this.highIndex )
                {
                    this.select ( parseInt ( this.selectedIndex ) + 1 );
                }
            }

            return true;
        }

        floatingElementObject.prototype.makeSelection = function () {

            this.selectionCallback ();
        }

        floatingElementObject.prototype.onKeyDown = function (e) {
            if (!e) var e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if
                ( ( code == 37 ) && ( this.inputElement == null ) )
            {
                this.doCancel ();
                
                return true;
            }
            else
            if
                ( ( code == 39 ) && ( this.inputElement == null ) )
            {
                this.selectionCallback ();
                
                return true;
            }
            else
            if
                ( code == 38 )
            {
                // Up arrow

                this.moveUp ();

                return true;
            }
            else
            if
                ( code == 40 )
            {
                // Down arrow

                this.moveDown ();

                return true;
            }
            
            return false;
        }

        floatingElementObject.prototype.selectionCallback = function () {

            if ( this.inputElement != null ) {

                if ( ! this.inputIsPrefix () ) {

                    return;
                }
            }

            if
                ( this.referenceObject )
            {
                if
                    ( this.selectedIndex != null )
                {
                    var object = this.indexToObject [ this.selectedIndex ]
                    
                    this.referenceObject.selectionMade ( object.valueInContainer, object.referenceObject );
                }
            }
        }

        floatingElementObject.prototype.selectedText = function () {

            if
                ( this.selectedIndex != null )
            {
                var object = this.indexToObject [ this.selectedIndex ]

                return object.asText ();
            }

            return null;
        }

        floatingElementObject.prototype.selectionChangedCallback = function () {

            if ( this.inputElement != null ) {

                if ( this.direction != null ) {

                    this.manager.addTask ( this.createCallback ( "moveSelection" ) );
                }
                else
                {
                    this.inputElement.value = this.selectedText ();
                }
            }

            if
                ( this.referenceObject )
            {
                if
                    ( this.referenceObject.selectionChanged != null )
                {
                    if
                        ( this.selectedIndex != null )
                    {
                        var object = this.indexToObject [ this.selectedIndex ]
                        
                        this.referenceObject.selectionChanged ( object.valueInContainer, object.referenceObject );
                    }
                }
            }
        }

        floatingElementObject.prototype.doCancel = function () {

            if
                ( this.referenceObject )
            {
                this.referenceObject.selectionMade ( null );
            }
        }

        floatingElementObject.prototype.onKeyPress = function (e) {
            if (!e) var e = window.event;
            var element = getTargetElement( e );
            var code = getKeyCode( e );

            if
                ( code == 27 )
            {
                this.doCancel ();
                
                return true;
            }
            else
            if
                ( code == 13 )
            {
                this.selectionCallback ();
                
                return true;
            }
            
            return false;
        }

        floatingElementObject.prototype.setServer = function ( server ) {

            this.server = server;
        }

        floatingElementObject.prototype.close = function () {

            this.visible = false;

            for ( var i in this.indexToObject ) {

                this.manager.remove ( this.indexToObject [ i ].handle );
            }

            this.freeDiv ( this.outerElement );
            this.manager.removeLater ( this.handle );
        }

        floatingElementObject.prototype.setInput = function ( text ) {

            if ( this.inputElement != null ) {

                this.inputElement.focus ();

                this.inputElement.value = text;

                this.newInput ();
            }
        }

        floatingElementObject.prototype.newInput = function () {

            var value = this.inputElement.value;

            if ( this.lastInputValue != value ) {

                this.lastInputValue = value;
                this.setDirection ();
            }
        }

        floatingElementObject.prototype.listDirection = function () {

            var text = this.selectedText ();
            
            if ( text != null ) {
            
                var value = this.inputElement.value.toString ().split ( " " ).join ( "" ).toLowerCase ();
                text = text.toString ().split ( " " ).join ( "" ).toLowerCase ();

                if ( text < value ) return "down";
                if ( text > value ) return "up";
                return "correct";
            }

            return "down";
        }

        floatingElementObject.prototype.setDirection = function () {

            this.direction = this.listDirection ();
            this.moveSelection ();
        }

        floatingElementObject.prototype.inputIsPrefix = function () {

            var text = this.selectedText ().toString ().split ( " " ).join ( "" ).toLowerCase ();
            var value = this.inputElement.value.toString ().split ( " " ).join ( "" ).toLowerCase ();

            if ( value.length <= text.length ) {

                if ( text.slice ( 0, value.length ) == value ) {

                    return true;
                }
            }

            return false;
        }

        floatingElementObject.prototype.moveSelection = function () {

            if ( this.direction == "correct" ) {

                this.direction = null;
            }
            else
            {
                var direction = this.listDirection ();

                if ( direction != this.direction ) {

                    if ( this.inputIsPrefix () ) {

                        this.direction = null;

                        return;
                    }

                    this.direction = "correct";
                }

                if ( direction == "down" ) {

                    if ( ! this.moveDown () ) {

                        this.direction = null;
                    }
                }
                
                if ( direction == "up" ) {

                    if ( ! this.moveUp () ) {

                        this.direction = null;
                    }
                }
            }
        }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 9<br>");  

        function floatingElementObject2 ()
        {
        }

        floatingElementObject2.prototype = new baseObject ();


            floatingElementObject2.prototype.start = function () {
            }
            floatingElementObject2.prototype.fnInitialise = function ( arrayItems, obOwner, elPosition ) {
                var elDiv = document.createElement ( "div" );
                var elTable = document.createElement ( "table" );
                var elBody = document.createElement ( "div" );
                var elRow = elTable.insertRow ();
                var elLeft = elRow.insertCell ();
                var elRight = elRow.insertCell ();
                var elInput = document.createElement ( "input" );
                var elButton = document.createElement ( "button" );
                var elImage = document.createElement ( "img" );
                this.obOwner = obOwner;
                this.elParent = document.body;
                this.elDiv = elDiv;
                this.elBody = elBody;
                this.elInput = elInput;
                this.elParent.appendChild ( elDiv );
                this.elButton = elButton;
                elDiv.appendChild ( elTable );
                elDiv.appendChild ( elBody );
                elLeft.appendChild ( elInput );
                elRight.appendChild ( elButton );
                elButton.appendChild ( elImage );
                elTable.cellPadding = 0;
                elTable.cellSpacing = 0;
                elTable.style.padding = "0.1em";
                elRight.align = "right";
                elRight.vAlign = "top";
                elImage.src = "/script/sde/bitmaps/close.gif";
                elImage.style.width = "16px";
                elImage.style.height = "16px";
                elButton.style.border = "none";
                elButton.style.width = "16px";
                elButton.style.height = "16px";
                elButton.onclick = this.createCallback ( "fnUserCancel" );//lcorbeil maybe add event to function
                elDiv.onresize = this.createCallback ( "fnOnResize" );
                elInput.style.fontFamily = "arial";
                elInput.style.fontSize = "80%";
                elInput.style.border = "1 black solid";
                elInput.style.width = "10em";
                elDiv.style.border = "1 gray solid";
                elDiv.style.padding = "0.1em";
                elDiv.style.position = "absolute";
                elDiv.style.backgroundColor = "window";
                elBody.style.fontFamily = "arial";
                elBody.style.fontSize = "80%";
                elBody.style.paddingRight = "3em";
                if ( elPosition != null ) {
                    var offset = this.manager.getOffset ( this.elDiv, elPosition );
                    var numDelta = elPosition.offsetHeight + 2;
                    this.elDiv.style.pixelLeft = offset.x + numDelta;
                    this.elDiv.style.pixelTop = offset.y + numDelta;
                }
                this.numMax = 10;
                this.numTop = 0;
                this.numSelected = null;
                this.arrayItems = arrayItems;
                arrayItems.sort ();
                this.fnRedraw ();

                this.allowBackSpace = true;
                this.outerElement = elDiv;
                this.outerElement.style.zIndex = this.manager.nextZIndex ();
                this.localFocusElement = null;
                this.outerElement.objectHandle = this.handle;
                this.outerElement.onselectstart = new Function ( "event.returnValue = false; return false;" );//lcorbeil problem here fix it "event"
                this.elInput.focus ();
                this.manager.scrollIntoView ( elDiv );
            }
            floatingElementObject2.prototype.fnRemove = function () {
                this.elButton.onclick = null;
                this.elDiv.onresize = null;
                if ( this.elInput == document.activeElement ) {
                    window.focus ();
                }
                this.elParent.removeChild ( this.elDiv );
                this.manager.removeLater ( this.handle );
            }
            floatingElementObject2.prototype.fnRedraw = function () {
                while ( this.elBody.firstChild != null ) {
                    this.elBody.removeChild ( this.elBody.firstChild );
                }
                for ( var numIndex = 0; numIndex < this.numMax; numIndex++ ) {
                    var numItem = this.numTop + numIndex;
                    var obItem = this.arrayItems [ numItem ];
                    if ( obItem != null ) {
                        this.fnAddToEnd ( obItem, numItem );
                    }
                }
                this.fnShowSelected ();
            }
            floatingElementObject2.prototype.fnGetElementForItem = function ( numItem ) {
                return this.elBody.childNodes [ numItem - this.numTop ];
            }
            floatingElementObject2.prototype.fnShowSelected = function () {
                if ( this.numSelected != null ) {
                    var el = this.fnGetElementForItem ( this.numSelected );
                    if ( el != null ) {
                        el.style.backgroundColor = "highlight";
                        el.style.color = "highlighttext";
                    }
                }
            }
            floatingElementObject2.prototype.fnHideSelected = function () {
                var el = this.fnGetElementForItem ( this.numSelected );
                if ( el != null ) {
                    el.style.backgroundColor = "window";
                    el.style.color = "windowtext";
                }
            }
            floatingElementObject2.prototype.fnItemClicked = function ( numIndex ) {
                if ( numIndex != null ) {
                    if ( this.numSelected != numIndex ) {
                        this.fnHideSelected ();
                        this.numSelected = numIndex;
                        this.fnPositionSelected ();
                        this.fnShowSelected ();
                        this.fnSetStem ();
                    }
                }
                if ( document.activeElement != this.elInput ) {
                    this.elInput.focus ();
                }
                return true;
            }
            floatingElementObject2.prototype.fnNewStemValueEvent = function () {
                if ( this.strLastStem != this.elInput.value ) {
                    this.fnPositionOnNewStem ( this.elInput.value );
                    this.elInput.style.pixelWidth = "4";
                    var numWidth = this.elInput.scrollWidth + 10;
                    if ( numWidth < 100 ) numWidth = 100;
                    this.elInput.style.pixelWidth = numWidth;
                }
                this.strLastStem = this.elInput.value;
            }
            floatingElementObject2.prototype.fnPositionOnNewStem = function ( strStem ) {
                var numItem = this.fnFindIndexForStem ( strStem );
                if ( numItem != null ) {
                    this.fnHideSelected ();
                    this.numSelected = numItem;
                    this.fnPositionSelected ();
                    this.fnShowSelected ();
                }
            }
            floatingElementObject2.prototype.fnSetStem = function () {
                if ( this.numSelected != null ) {
                    var obItem = this.arrayItems [ this.numSelected ];
                    if ( obItem != null ) {
                        var strText = obItem.fnGetText ();
                        this.elInput.value = strText;
                    }
                }
            }
            floatingElementObject2.prototype.fnFindIndexForStem = function ( strStem ) {
                var arr = this.arrayItems;
                if ( arr.length == 0 ) {
                    return null;
                } else {
                    var numMin = 0;
                    var numMax = arr.length - 1;
                    strStem = strStem.toLowerCase ();
                    while ( true ) {
                        if ( numMax == numMin ) {
                            break;
                        } else {
                            var numIndex = Math.floor ( ( numMax + numMin ) / 2 );
                            var strText = arr [ numIndex ].toString ();
                            if ( strStem < strText ) {
                                if ( numIndex == numMin ) {
                                    numMax = numMin;
                                } else {
                                    numMax = numIndex;
                                }
                            } else if ( strText.indexOf ( strStem ) == 0 ) {
                                numMax = numMin = numIndex;
                            } else {
                                if ( numIndex == numMax ) {
                                    numMin = numMax;
                                } else {
                                    numMin = numIndex + 1;
                                }
                            }
                        }
                    }
                    return numMin;
                }
            }
            floatingElementObject2.prototype.fnRenderItem = function ( obItem, numIndex ) {
                var elOuter = document.createElement ( "div" );
                var elInner = document.createElement ( "nobr" );
                elOuter.appendChild ( elInner );
                elInner.style.padding = "0.1em";
                obItem.fnRender ( elInner );
                elOuter._numIndex = numIndex;
                return elOuter;
            }
            floatingElementObject2.prototype.fnAddToEnd = function ( obItem, numIndex ) {
                var elNew = this.fnRenderItem ( obItem, numIndex );
                this.elBody.appendChild ( elNew );
            }
            floatingElementObject2.prototype.fnAddToStart = function ( obItem, numIndex ) {
                var elNew = this.fnRenderItem ( obItem, numIndex );
                this.elBody.insertBefore ( elNew, this.elBody.firstChild );
            }
            floatingElementObject2.prototype.fnMoveDown = function ( numDelta ) {
                if ( this.numSelected == null ) {
                    if ( this.arrayItems.length != 0 ) {
                        this.numSelected = this.numTop;
                    }
                } else {
                    var numNew = this.numSelected + numDelta;
                    if ( numNew >= this.arrayItems.length ) {
                        numNew = this.arrayItems.length - 1;
                    }
                    if ( this.numSelected == numNew ) {
                        return;
                    } else {
                        this.fnHideSelected ();
                        this.numSelected = numNew;
                    }
                }
                this.fnPositionSelected ();
                this.fnShowSelected ();
                this.fnSetStem ();
            }
            floatingElementObject2.prototype.fnMoveUp = function ( numDelta ) {
                if ( this.numSelected == null ) {
                    if ( this.arrayItems.length != 0 ) {
                        this.numSelected = this.numTop;
                    }
                } else {
                    var numNew = this.numSelected - numDelta;
                    if ( numNew < 0 ) {
                        numNew = 0 ;
                    }
                    if ( this.numSelected == numNew ) {
                        return;
                    } else {
                        this.fnHideSelected ();
                        this.numSelected = numNew;
                    }
                }
                this.fnPositionSelected ();
                this.fnShowSelected ();
                this.fnSetStem ();
            }
            floatingElementObject2.prototype.fnPositionSelected = function () {
                var el = this.fnGetElementForItem ( this.numSelected );
                if ( el == null ) {
                    if ( ( this.numSelected - this.numTop ) == this.numMax ) {
                        this.elBody.removeChild ( this.elBody.firstChild );
                        this.fnAddToEnd ( this.arrayItems [ this.numSelected ], this.numSelected );
                        this.numTop++;
                    } else if ( ( this.numTop - this.numSelected ) == 1 ) {
                        this.elBody.removeChild ( this.elBody.lastChild );
                        this.fnAddToStart ( this.arrayItems [ this.numSelected ], this.numSelected );
                        this.numTop--;
                    } else {
                        var numTotal = this.arrayItems.length;
                        if ( numTotal - this.numSelected > this.numMax ) {
                            this.numTop = this.numSelected;
                        } else {
                            this.numTop = numTotal - this.numMax;
                        }
                        if ( this.numTop < 0 ) this.numTop = 0;
                        this.fnRedraw ();
                    }
                }
            }
            floatingElementObject2.prototype.fnUserCancel = function () {
                this.obOwner.selectionMade ( null );
            }
            floatingElementObject2.prototype.fnOnResize = function () {
                if ( this.bActive ) {
                    this.manager.updateFocus ();
                }
            }
            //--------------------------------------------------------
            floatingElementObject2.prototype.onKeyDown = function (e) {
                if (!e) var e = window.event;
                var element = getTargetElement( e );
                var code = getKeyCode( e );

                if ( code == 40 ) {
                    this.fnMoveDown ( 1 );
                    return true;
                }
                if ( code == 38 ) {
                    this.fnMoveUp ( 1 );
                    return true;
                }
                return false;
            }
            floatingElementObject2.prototype.onKeyPress = function (e) {
                if (!e) var e = window.event;
                var element = getTargetElement( e );
                var code = getKeyCode( e );

                if ( code == 27 ) {
                    this.fnUserCancel ();
                    return true;
                }
                if ( code == 13 ) {
                    if ( this.numSelected != null ) {
                        var strStem = this.elInput.value.toString ().toLowerCase ();
                        if ( this.arrayItems [ this.numSelected ].toString ().indexOf ( strStem ) == 0 ) {
                            var obItem = this.arrayItems [ this.numSelected ];
                            this.obOwner.selectionMade ( true, obItem );
                        }
                    }
                    return true;
                }
                return false;
            }
            floatingElementObject2.prototype.onKeyUp = function () {
                this.fnNewStemValueEvent ();
            }
            floatingElementObject2.prototype.focusIn = function () {
                if ( document.activeElement != this.elInput ) {
                    this.elInput.focus ();
                }
                this.bActive = true;
            }
            floatingElementObject2.prototype.focusOut = function () {
                this.bActive = true;
            }
            floatingElementObject2.prototype.onClick = function ( e ) {
                if (!e) var e = window.event;
                var element = getTargetElement( e );
//                var code = getKeyCode( e );

                this.manager.setGlobalFocus ( this.manager, this );
                while ( element != this.outerElement ) {
                    if ( element._numIndex != null ) {
                        this.fnItemClicked ( element._numIndex );
                        break;
                    }//lcorbeil:verify parentNode, is it IE specific?
                    element = element.parentNode;
                }
                return true;
            }
            floatingElementObject2.prototype.startDrag = function () {
            }
            floatingElementObject2.prototype.stopDrag = function () {
                if ( this.bActive ) {
                    this.manager.updateFocus ();
                }
            }
            floatingElementObject2.prototype.doDrag = function ( dx, dy ) {
                this.elDiv.style.pixelLeft += dx;
                this.elDiv.style.pixelTop += dy;
                if ( this.bActive ) {
                    this.manager.hideFocus ();
                }
            }
            //--------------------------------------------------------
            floatingElementObject2.prototype.close = function () {
                this.fnRemove ();
            }
            floatingElementObject2.prototype.setInput = function ( strStem ) {
                if ( document.activeElement != this.elInput ) {
                    this.elInput.focus ();
                }
                this.elInput.value = strStem;
                var obRange = this.elInput.createTextRange ();
                obRange.collapse ( false );
                obRange.select ();
            }

//--------------------------------------------------------

if ( debugTrace ) document.write("Step 10<br>");  


//--------------------------------------------------------
    function processBaseObject () {
    }

    processBaseObject.prototype.read = function ( fieldName, propertyName ) {

        return this.oInterface.read ( fieldName, propertyName );
    }

    processBaseObject.prototype.write = function ( fieldName, propertyName, value ) {

        this.oInterface.write ( fieldName, propertyName, value );
    }

    processBaseObject.prototype.notifyChange = function () {
    }

//--------------------------------------------------------

    function transactionBaseObject ( updates, database ) {

        this.updates = updates;
        this.database = database;
    }

    transactionBaseObject.prototype.newFieldName = function () {

        return this.database.newFieldName ();
    }

    transactionBaseObject.prototype.read = function ( fieldName, propertyName ) {

        if ( this.updates.isWriteDefined ( fieldName, propertyName ) ) {
            return this.updates.peekWrite ( fieldName, propertyName );
        }
        return this.database.read ( fieldName, propertyName );
    }

    transactionBaseObject.prototype.write = function ( fieldName, propertyName, value ) {

        this.updates.write ( fieldName, propertyName, value );
    }

//--------------------------------------------------------

    var validatorGlobals = new Object ();

    function validatorBaseObject () {

        this.globals = validatorGlobals;
    }

    validatorBaseObject.prototype.read = function ( propertyName ) {

        return this.oInterface.read ( this.fieldName, propertyName );
    }

    validatorBaseObject.prototype.write = function ( propertyName, value ) {

        this.oInterface.write ( this.fieldName, propertyName, value );

        if
            ( value == "" )
        {
            if
                ( propertyName == "value" )
            {
                this.blank = true;
            }
        }
    }

    validatorBaseObject.prototype.notifyChange = function () {

        if
            ( this.oInterface.read ( this.fieldName, "checked" ) == false )
        {
            var value = this.oInterface.read ( this.fieldName, "value" );

            if
                ( value != null )
            {
                this.oInterface.write ( this.fieldName, "checked", true );
                this.oInterface.write ( this.fieldName, "valid", true );
                this.oInterface.write ( this.fieldName, "advice", "" );
                this.blank = false;

                this.validate ( value );

                if
                    ( this.blank && ( this.booleanTrue ( this.parameters.AllowBlank ) ) )
                {
                    this.oInterface.write ( this.fieldName, "valid", true );
                    this.oInterface.write ( this.fieldName, "advice", "" );
                }
            }
        }
    }

    validatorBaseObject.prototype.booleanTrue = function ( value ) {

        if
            ( value != null )
        {
            if
                ( value != 0 )
            {
                if
                    ( value.toLowerCase () != "false" )
                {
                    return true;
                }
            }
        }

        return false;
    }

    validatorBaseObject.prototype.initialise = function () {
    }
    validatorBaseObject.prototype.validate = function () {
    }

//--------------------------------------------------------

    function defaultValidatorObject () {

        this.parameters = new Object ();
    }

    defaultValidatorObject.prototype = new validatorBaseObject ();


//--------------------------------------------------------

    function stringValidatorObject () {

        this.parameters = new Object ();

        this.parameters.Type = null;
        this.parameters.MinimumLength = 0;
        this.parameters.MaximumLength = null;
        this.parameters.RequiredCase = "either";
        this.parameters.ForceInvalid = 0;
        this.parameters.DisallowLeadingWhiteSpace = 0;
        this.parameters.Pattern = null;
    }

    stringValidatorObject.prototype = new validatorBaseObject ();


    stringValidatorObject.prototype.validate = function ( value ) {

        var p = this.parameters;

        if
            ( this.booleanTrue( p.DisallowLeadingWhiteSpace ) )
        {
            // Remove leading white space
            var newValue = value.replace( /^\s+/g, "" );
            if
                ( newValue != value )
            {
                value = newValue;
                this.write ( "value", value );
            }
        }

        if
            ( p.Pattern != null )
        {
            var re = new RegExp( "" + p.Pattern, "g" );
            var arr = value.match( re );
            var newValue;
            if ( arr )
                newValue = arr[0];
            else
                newValue = "";
            if
                ( newValue != value )
            {
                value = newValue;
                this.write ( "value", value );
            }
        }

        if
            (p.RequiredCase == "upper")
        {
            var newValue = value.toUpperCase();
            if
                ( newValue != value )
            {
                value = newValue;
                this.write ( "value", value );
            }
        }
        else
        if
            ( p.RequiredCase == "lower" )
        {
            var newValue = value.toLowerCase();
            if
                ( newValue != value )
            {
                value = newValue;
                this.write ( "value", value );
            }
        }

        if
            ( p.MaximumLength != null )
        {
            if
                ( value.length > p.MaximumLength )
            {
                value = value.slice ( 0, p.MaximumLength );
                this.write ( "value", value );
            }
        }

        if
            ( p.MinimumLength != null )
        {
            if
                ( value.length < p.MinimumLength )
            {
                this.write ( "valid", false );
                this.write ( "advice", "StringTooShort" );
            }
        }

        if
            ( this.booleanTrue( p.ForceInvalid ) )
        {
            this.write ( "valid", false );
        }
    }

//--------------------------------------------------------

    function numberValidatorObject () {

        this.parameters = new Object ();

        this.parameters.Type = null;
        this.parameters.LowerBound = 0;
        this.parameters.UpperBound = null;
        this.parameters.DecimalPlaces = 0;
        this.parameters.AllowBlank = null;
    }

    numberValidatorObject.prototype = new validatorBaseObject ();


    numberValidatorObject.prototype.validate = function ( value ) {

        var p = this.parameters;

        var result = "";
        var foundPoint = false;
        var foundNumber = false;
        var foundMinus = false;
        var places = 0;

        var result = "";

        for
            ( var i = 0; i < value.length; i++ )
        {
            var c = value.charAt ( i );

            if
                ( ( c >= "0" ) && ( c <= "9" ) )
            {
                foundNumber = true;

                if
                    ( foundPoint )
                {
                    places++;

                    if
                        ( places > p.DecimalPlaces )
                    {
                        break;
                    }
                }
            }
            else
            if
                ( c == "." )
            {
                if
                    ( p.DecimalPlaces == 0 )
                {
                    break;
                }
                if
                    ( foundPoint )
                {
                    break;
                }
                foundPoint = true;
            }
            else
            if
                ( c == "-" )
            {
                if
                    ( foundNumber )
                {
                    break;
                }
                if
                    ( foundMinus )
                {
                    break;
                }
                foundMinus = true;
            }
            else
            {
                break;
            }

            result += c;
        }

        value = result;

        if
            ( ! foundNumber )
        {
            this.write ( "valid", false );
            this.write ( "advice", "NotANumber" );
        }
        else
        {
            if
                ( p.UpperBound != null )
            {
                if
                    ( parseFloat ( value ) > parseFloat ( p.UpperBound ) )
                {
                    this.write ( "valid", false );
                    this.write ( "advice", "NumberTooLarge" );
                }
            }

            if
                ( parseFloat ( value ) < parseFloat ( p.LowerBound ) )
            {
                this.write ( "valid", false );
                this.write ( "advice", "NumberTooSmall" );
            }
        }

        this.write ( "value", value );
    }

//--------------------------------------------------------

    function dateValidatorObject () {

        this.parameters = new Object ();

        this.parameters.Type = null;
        this.parameters.LowerBound = null;
        this.parameters.UpperBound = null;
        this.parameters.AllowBlank = null;
    }

    dateValidatorObject.prototype = new validatorBaseObject ();


    dateValidatorObject.prototype.today = function () {

        return this.control.TodayDay + '/' + this.control.CurrentMonth + '/' + this.control.CurrentYear;
    }

    dateValidatorObject.prototype.initialise = function () {

        if
            ( this.control == null )
        {
            var controlId = "ALSiDateCheckerControl";

            this.control = xGetElementById( controlId );//document.all [ controlId ];

            if
                ( this.control == null )
            {
//                document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " classid='CLSID:0A4B7BA2-26BA-11D2-BC93-00A024A86646' width=0 height=0></OBJECT>" );
                this.listElement.innerHTML = this.listElement.innerHTML + "<OBJECT id=" + controlId + " classid='CLSID:0A4B7BA2-26BA-11D2-BC93-00A024A86646' width=0 height=0></OBJECT>";

                this.control = xGetElementById( controlId );//document.all [ controlId ];
                dateValidatorObject.control = this.control;
            }
        }

        if
            ( this.control != null )
        {
            if
                ( this.parameters.LowerBound != null )
            {
                if
                    ( this.parameters.LowerBound.toLowerCase () == "today" )
                {
                    this.parameters.LowerBound = this.today ();
                }
            }
            else
            {
                this.parameters.LowerBound = "01/01/1900";
            }

            if
                ( this.parameters.UpperBound != null )
            {
                if
                    ( this.parameters.UpperBound.toLowerCase () == "today" )
                {
                    this.parameters.UpperBound = this.today ();
                }
            }
            else
            {
                this.parameters.UpperBound = "31/12/9999";
            }
        }
    }

    dateValidatorObject.prototype.validate = function ( value ) {

        if
            ( this.control != null )
        {
            this.control.HBound = this.parameters.UpperBound;
            this.control.LBound = this.parameters.LowerBound;

            this.control.DateStr = value;

            var partial_form = this.control.ValidInput;
            var full_form = this.control.DateStr;

            // We need to go through this to overcome a strange problem with the control...

            this.control.LBound = "01/01/1900";
            this.control.HBound = "01/01/1900";
            this.control.DateStr = "01/01/1900";

            this.control.HBound = this.parameters.UpperBound;
            this.control.LBound = this.parameters.LowerBound;
            this.control.DateStr = full_form;

            // 

            if
                ( this.control.Completed == 0 )
            {
                this.write ( "valid", false );
                this.write ( "advice", this.control.StateAsStr );
            }

            if
                ( this.read ( "edit" ) == false )
            {
                this.write ( "value", full_form );
            }
            else
            {
                if
                    ( partial_form != value )
                {
                    var done = false;

                    if
                        ( partial_form.charAt ( partial_form.length - 1 ) == "/" )
                    {
                        if
                            ( ( partial_form.length - value.length ) == 1 )
                        {
                            done = true;
                        }
                        else
                        if
                            ( partial_form.length == value.length )
                        {
                            {
                                value = partial_form + value.charAt ( value.length - 1 );
                                done = true;
                            }
                        }
                    }

                    if
                        ( ! done )
                    {
                        value = partial_form;
                    }
                }

                this.write ( "value", value );
            }
        }
    }

//--------------------------------------------------------

    function controlNumberValidatorObject () {

        this.parameters = new Object ();

        this.parameters.Type = null;
        this.parameters.AllowBlank = null;
    }

    controlNumberValidatorObject.prototype = new validatorBaseObject ();


    controlNumberValidatorObject.prototype.initialise = function () {

        if
            ( this.control == null )
        {
            var controlId = "ALSiControlNumberCheckerControl";

            this.control = xGetElementById( controlId );//document.all [ controlId ];

            if
                ( this.control == null )
            {
//                document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " CLASSID='CLSID:80E620E0-F631-11D1-A71C-000021750386' width=0 height=0></OBJECT>" );
                document.body.innerHTML = document.body.innerHTML + "<OBJECT id=" + controlId + " CLASSID='CLSID:80E620E0-F631-11D1-A71C-000021750386' width=0 height=0></OBJECT>";
                this.control = xGetElementById( controlId );//document.all [ controlId ];

                if
                    ( this.control != null )
                {
                    var fail = false;

                    if
                        ( this.globals.BFormat != null )
                    {
                        this.control.BFormat = this.globals.BFormat;
                    }
                    else
                    {
                        fail = true
                    }
                    if
                        ( this.globals.LFormat != null )
                    {
                        this.control.LFormat = this.globals.LFormat;
                    }
                    else
                    {
                        fail = true
                    }
                    if
                        ( this.globals.CFormats != null )
                    {
                        this.control.CFormats = this.globals.CFormats;
                    }
                    else
                    {
                        fail = true
                    }
                    if
                        ( this.globals.AutoCalculateCheckDigit != null )
                    {
                        this.control.AutoCalculateCheckDigit = this.globals.AutoCalculateCheckDigit;
                    }
                    else
                    {
                        fail = true
                    }

                    if
                        ( fail )
                    {
                        alert ( "Warning: some control number formats not specified." );
                    }
                }
            }
        }
    }

    controlNumberValidatorObject.prototype.validate = function ( value ) {

        if
            ( this.control != null )
        {
            var p = this.parameters;

            this.control.TypeAsStr = p.Type;
            this.control.Value = value;

            if
                ( this.control.Completed == 0 )
            {
                this.write ( "valid", false );
                this.write ( "advice", this.control.StateAsStr );

                if
                    ( this.read ( "edit" ) == true )
                {
                    this.write ( "value", this.control.Value );
                }
                else
                {
                    this.write ( "value", value );
                }
            }
            else
            {
                if ( this.control.StateAsStr.toUpperCase() != "DONE" )
                    this.write ( "advice", this.control.StateAsStr );
                this.write ( "value", this.control.Value );
            }
        }
    }

//--------------------------------------------------------

    function currencyValidatorObject () {

        this.parameters = new Object ();

        this.parameters.Type = null;
        this.parameters.UpperBound = null;
        this.parameters.LowerBound = null;
        this.parameters.AllowBlank = null;
        this.parameters.ShowSymbol = null;
    }

    currencyValidatorObject.prototype = new validatorBaseObject ();


    currencyValidatorObject.prototype.initialise = function () {

        if
            ( this.control == null )
        {
            var controlId = "ALSiCurrencyCheckerControl";

            this.control = xGetElementById( controlId );//document.all [ controlId ];

            if
                ( this.control == null )
            {
//                document.body.insertAdjacentHTML ( "beforeEnd", "<OBJECT id=" + controlId + " CLASSID='CLSID:920B385F-1BDF-11D2-BC87-00A024A86646' width=0 height=0></OBJECT>" );
                document.body.innerHTML = document.body.innerHTML + "<OBJECT id=" + controlId + " CLASSID='CLSID:920B385F-1BDF-11D2-BC87-00A024A86646' width=0 height=0></OBJECT>";
                this.control = xGetElementById( controlId );//document.all [ controlId ];

                if
                    ( this.control != null )
                {
                    currencyValidatorObject.control = this.control;

                    if
                        ( this.globals.EuroExchangeRateComment != null )
                    {
                        this.control.EuroExchangeRateComment = this.globals.EuroExchangeRateComment;
                    }

                    if
                        ( this.globals.SetCurrencyRates != null )
                    {
                        this.globals.SetCurrencyRates ( this.control );
                    }

                    if
                        ( this.globals.DefaultCurrency == null )
                    {
                        this.globals.DefaultCurrency = "DEM";

                        alert ( "Warning: currency type defaulting to " + this.globals.DefaultCurrency + "." );
                    }
                }
            }
        }

        if
            ( this.control != null )
        {
            if
                ( this.parameters.UpperBound == null )
            {
                this.parameters.UpperBound = "";
            }
            
            if
                ( this.parameters.LowerBound == null )
            {
                this.parameters.LowerBound = "";
            }

            if
                ( this.parameters.ShowSymbol == null )
            {
                this.parameters.ShowSymbol = "true";
            }

            this.defaultType = this.globals.DefaultCurrency;
        }
    }
//Here TODO CurType always GBP?  No way!
    currencyValidatorObject.prototype.validate = function ( value ) {

        if
            ( this.control != null )
        {
            this.control.CurType = "GBP"; // Ensures decimal point notation for ranges...
            this.control.HRange = this.parameters.UpperBound;
            this.control.LRange = this.parameters.LowerBound;

            this.control.CurType = this.defaultType;
            this.control.Value = value;

            if
                ( this.read ( "edit" ) == false )
            {
                if
                    ( value != "" )
                {
                    if
                        ( this.booleanTrue( this.parameters.ShowSymbol ) )
                    {
                        this.write ( "value", this.control.Value );
                    }
                    else
                    {
                        this.write ( "value", this.control.ValueAsStringWithFixedDP );
                    }
                }
                else
                {
                    this.write ( "valid", false );
                    this.write ( "euroValue", null );
                    return;
                }
            }
            else
            {
                this.write ( "value", this.control.ValidInput );
            }

            if
                ( this.control.Completed == 0 )
            {
                this.write ( "valid", false );
                this.write ( "advice", this.control.StateAsStr );
            }
            else
            {
                if
                    ( this.globals.AltCurrency != null && this.globals.AltCurrency != "" )
                {
                    var normalType = this.control.ISOCurrencyType;
                    this.control.ISOCurrencyType = this.globals.AltCurrency;
                    var altValue   = this.control.Format ( 1, -1, "" );
                    this.control.ISOCurrencyType = normalType;
                    this.write ( "advice", altValue );
                }

                if
                    ( this.control.IsNegative )
                {
                    // Change colour ???
                }
            }
        }
    }

    function submitAllFormElements ( formElement ) {

        if
            ( formElement != null )
        {
            var elements = formElement.elements;

            var fixed = [];

            for ( var i = 0; i < elements.length; i++ ) {

                var element = elements [ i ];

                if
                    ( element.disabled )
                {
                    fixed [ fixed.length ] = element;

                    element.disabled = false;
                }
            }

            formElement.submit ();

            for ( var i = 0; i < fixed.length; i++ ) {

                fixed [ i ].disabled = true;
            }
        }
    }

//--------------------------------------------------------
//Here TODO Use MS specific activeX.  Need re-work.

if ( debugTrace ) document.write("Step 12<br>");  

    function cPersistentStorageManager ( strStore ) {
        this.strStore = strStore;
    }

        cPersistentStorageManager.prototype.fnGetPersistTag = function () {
            var strID = "elPersistData";
            var el = xGetElementById( strID );//document.all [ strID ];
            if ( el == null ) {
                if ( browserVersion < 5.5 ) {
//                    document.body.insertAdjacentHTML ( "beforeEnd", '<div style="display:none;behavior:url(#default#userdata)" id="' + strID + '"></div>' );
                    document.body.innerHTML = document.body.innerHTML + '<div style="display:none;behavior:url(#default#userdata)" id="' + strID + '"></div>';
                    el = xGetElementById( strID );//document.all [ strID ];
                } else {
                    el = document.createElement ( "DIV" );
                    el.style.display = "none";
                    el.style.behavior = "url(#default#userdata)";
                    el.id = strID;
                    document.body.appendChild ( el );
                }
            }
            return el;
        }
        cPersistentStorageManager.prototype.fnGetPersistDocument = function () {
            var doc = new ActiveXObject ( "MSXML.DOMDocument" );
            var el = this.fnGetPersistTag ();
            try {
                el.load ( this.strStore );
            }
            catch ( obError ) {
                var numCode = obError.number & 0xFFFF;
                if ( numCode == 70 ) {
                    // Permission denied
                } else {
                    throw ( obError );
                }
            }
            var strXML = el.getAttribute ( "_xml" );
            if ( strXML != null ) {
                if ( doc.loadXML ( strXML ) ) {
                    return doc;
                }
            }
            doc.appendChild ( doc.createElement ( "ROOT" ) );
            return doc;
        }
        cPersistentStorageManager.prototype.fnSetPersistDocument = function ( doc ) {
            var el = this.fnGetPersistTag ();
            el.setAttribute ( "_xml", doc.xml );
            try {
                el.save ( this.strStore );
            }
            catch ( obError ) {
                var numCode = obError.number & 0xFFFF;
                if ( numCode == 70 ) {
                    // Permission denied
                } else {
                    throw ( obError );
                }
            }
        }
        //--- PUBLIC ---
        cPersistentStorageManager.prototype.fnGetField = function ( strName ) {
            var elDoc = this.fnGetPersistDocument ().documentElement;
            return elDoc.getAttribute ( strName );
        }
        cPersistentStorageManager.prototype.fnRemoveField = function ( strName ) {
            var doc = this.fnGetPersistDocument ();
            doc.documentElement.removeAttribute ( strName );
            this.fnSetPersistDocument ( doc );
        }
        cPersistentStorageManager.prototype.fnSetField = function ( strName, strValue ) {
            var doc = this.fnGetPersistDocument ();
            doc.documentElement.setAttribute ( strName, strValue );
            this.fnSetPersistDocument ( doc );
        }
        cPersistentStorageManager.prototype.fnClearAll = function () {
            var doc = new ActiveXObject ( "MSXML.DOMDocument" );
            doc.appendChild ( doc.createElement ( "ROOT" ) );
            this.fnSetPersistDocument ( doc );
        }

if ( debugTrace ) document.write("Step 13<br>");  

function fxBack_DoFSCommand(command,args){
                 document.location.href = args;
}
function fxHome_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxMyZone_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxSearchZone_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxKidsZone_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxWordSurfer_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxGlobalSearch_DoFSCommand(command,args){
                 document.location.href = args;
}

function fxCorpSearch_DoFSCommand(command,args){
                 document.location.href = args;
}

if ( debugTrace ) document.write("Step 14<br>");  


//---END SCREEN-BUTTON EFFECT WORKAROUND---

    function cHttpFetcher ( bUseScript ) {
	
		var t = new cScriptHttpFetcher2();
		
		if
			(t.haveXMLHttpRequest == false ) // WJP (true) // force use of iFrame based fetcher 
		{
			trace("Using iFrame based http fetcher")
			// use iFrame based implementation.
			this.obScriptFetcher = new cScriptHttpFetcher ();
		}
		else
		{
			// use  XMLHttpRequest based implementation.
			trace("Using XMLHttpRequest based implementation")
			this.obScriptFetcher = t;
		}
            
    }
        cHttpFetcher.prototype.fnMakeActiveXAppServer = function () {
            var strID = "obAppServer" + ( new Date () ).getTime ();
//            document.body.insertAdjacentHTML ( "afterBegin", "<OBJECT id='" + strID + "' classid='clsid:A6DCA047-3979-41C8-A5B6-57013B4EC57C' style='display:none'></OBJECT>" );
            document.body.innerHTML = "<OBJECT id='" + strID + "' classid='clsid:A6DCA047-3979-41C8-A5B6-57013B4EC57C' style='display:none'></OBJECT>" + document.body.innerHTML;
            return window [ strID ];
        }
        //--------------------------------------------------------
        cHttpFetcher.prototype.IsAsyncWaiting = function () {
            if ( this.obAppServer != null ) {
                return this.obAppServer.AsyncWaiting;
            } else {
                return this.obScriptFetcher.IsAsyncWaiting ();
            }
        }
        cHttpFetcher.prototype.IsAsyncReady = function () {
            if ( this.obAppServer != null ) {
                return this.obAppServer.AsyncReady;
            } else {
                return this.obScriptFetcher.IsAsyncReady ();
            }
        }
        cHttpFetcher.prototype.IsParsedOK = function () {
            if ( this.obAppServer != null ) {
                return this.obAppServer.ParsedOK
            } else {
                return this.obScriptFetcher.IsParsedOK ();
            }
        }
        cHttpFetcher.prototype.GetResponseBody = function () {
            if ( this.obAppServer != null ) {
                return this.obAppServer.ResponseBody;
            } else {
                return this.obScriptFetcher.GetResponseBody ();
            }
        }
        cHttpFetcher.prototype.RspGet = function ( strKey, strDefault ) {
            if ( this.obAppServer != null ) {
                return this.obAppServer.RspGet ( strKey, strDefault );
            } else {
                return this.obScriptFetcher.RspGet ( strKey, strDefault );
            }
        }
        cHttpFetcher.prototype.ClearCmd = function () {
            if ( this.obAppServer != null ) {
                this.obAppServer.ClearCmd ();
            } else {
                this.obScriptFetcher.ClearCmd ();
            }
        }
        cHttpFetcher.prototype.SetUseUTF8Request = function ( bSet ) {
            if ( this.obAppServer != null ) {
                this.obAppServer.UseUTF8Request = bSet;
            } else {
                this.obScriptFetcher.SetUseUTF8Request ( bSet );
            }
        }
        cHttpFetcher.prototype.SetCmdPrefix = function ( strPrefix ) {
            if ( this.obAppServer != null ) {
                this.obAppServer.CmdPrefix = strPrefix;
            } else {
                this.obScriptFetcher.SetCmdPrefix ( strPrefix );
            }
        }
        cHttpFetcher.prototype.CmdSet = function ( strKey, strValue ) {
            if ( this.obAppServer != null ) {
                this.obAppServer.CmdSet ( strKey, strValue );
            } else {
                this.obScriptFetcher.CmdSet ( strKey, strValue );
            }
        }
        cHttpFetcher.prototype.SetUseMSXMLHTTPRequest = function ( bSet ) {
            if ( this.obAppServer != null ) {
                this.obAppServer.UseMSXMLHTTPRequest = bSet;
            } else {
                this.obScriptFetcher.SetUseMSXMLHTTPRequest ( bSet );
            }
        }
        cHttpFetcher.prototype.DoCmdAsync = function () {
            if ( this.obAppServer != null ) {
                this.obAppServer.DoCmdAsync ();
            } else {
                this.obScriptFetcher.DoCmdAsync ();
            }
        }

	
	/* old version */
	
	function cScriptHttpFetcher () {
        this.strIdBase = ( new Date () ).getTime ();
        this.numFrameCount = 0;
    }
        cScriptHttpFetcher.prototype.fnGetUrl = function () {
            var strArgs = "";
            for ( var strKey in this.mapCmd ) {
                var strValue = this.mapCmd [ strKey ];
                if ( strArgs != "" ) {
                    strArgs += "&";
                }
                if ( this.bUseUtf8Request || true ) {
                    strValue = fnToUtf8 ( strValue );
                }
                strArgs += strKey + "=" + strValue;
            }
            var strSep = this.strPrefix.indexOf ( "?" ) == -1 ? "?" : "&";
            return this.strPrefix + strSep + strArgs;
        }
        cScriptHttpFetcher.prototype.parseError = {};
        cScriptHttpFetcher.prototype.fnParseVarmap = function ( strMap, i ) {
            var vmp = strMap;
            var root = {};
            var wantName = true;
            var name = "";

            for (; i < vmp.length; i++)
            {
                switch (vmp.charAt (i))
                {
                    case ' ':
                    case '\t':
                    case '\n':
                    case '\r':
                    case '=':
                        break;


                    case '}':
                        var ret = {};
                        ret['i'] = i;
                        ret['value'] = root;
                        return ret;
                        break;


                    case '{':
                        if (wantName)
                        { // special case for the first brace
                        }
                        else
                        {
                            var result = this.fnParseVarmap (vmp, i + 1);
                            if ( result == this.parseError ) {
                                return this.parseError;
                            }
                            i = result['i'];
                            root[name] = result['value'];
                            wantName = true;
                        }
                        break;


                    case '"':
                    var token = new String ();
                    i++;
                    for (; i < vmp.length && vmp.charAt (i) != '"'; i++)
                    {
                        if (vmp.charAt (i) == "\\")
                        {
                            i++;
                            if (i < vmp.length)
                            {
                                switch (vmp.charAt(i))
                                {
                                    case 'r':
                                    token += '\r';
                                    break;

                                    case 'n':
                                    token += '\n';
                                    break;

                                    default:
                                    token += vmp.charAt(i);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            token += vmp.charAt(i);
                        }
                    }

                    if (wantName)
                    {
                        name = token;
                    }
                    else
                    {
                        root[name] = new String(token);
                    }
                    wantName = !wantName;
                    break;


                    default:
                        var token = ""
                        for (; i < vmp.length && (' \t\r\n={}').indexOf (vmp.charAt (i)) == -1; i++)
                        {
                            token += vmp.charAt(i);
                        }
                        if (vmp.charAt (i) == '{' || vmp.charAt (i) == '}')
                        {
                            i--;
                        }

                        if (wantName)
                        {
                            name = token;
                        }
                        else
                        {
                            root[name] = new String (token);
                        }
                        wantName = !wantName;
                        break;
                }

            }
            return this.parseError;
        }
        cScriptHttpFetcher.prototype.fnFromMarkup = function ( str ) {
            str = str.replace ( /&amp;/g, "&" );
            str = str.replace ( /&lt;/g, "<" );
            str = str.replace ( /&gt;/g, ">" );
            return str;
        }

        //--------------------------------------------------------
        cScriptHttpFetcher.prototype.IsAsyncWaiting = function () {
            return this.bWaiting;
        }
        cScriptHttpFetcher.prototype.fnAddToResponseMap = function ( mapResponse, strPrefix, mapData ) {
            for ( var strKey in mapData ) {
                var obValue = mapData [ strKey ];
                var strPath = strKey;
                if ( strPrefix != "" ) {
                    strPath = strPrefix + "." + strPath;
                }
                if ( obValue.constructor == String ) {
                    mapResponse [ strPath ] = this.fnFromMarkup ( obValue );
                } else {
                    this.fnAddToResponseMap ( mapResponse, strPath, obValue );
                }
            }
        }
        cScriptHttpFetcher.prototype.fnIsReasonableResponse = function ( strMap ) {
            
            var strSpace = " \t\r\n";
            for ( var i = 0; i < strMap.length; i++ )
            {
                var ch = strMap.charAt ( i );
                if ( ! (strSpace.indexOf ( ch ) >= 0) ) {
                    if ( ch == '{' ) {
                        return true;
                    } else {
                        break;
                    }
                }
            }
            return false;
        }
        cScriptHttpFetcher.prototype.IsAsyncReady = function () {
            
            if ( this.elFrameID != null ) {
				var elFrame = document.getElementById( this.elFrameID );
				
                if ( elFrame.parentNode != null ) {
                    if ( elFrame.contentWindow != null ) {
                        var obWindow = elFrame.contentWindow;
                        if ( obWindow.document != null ) {
                            var obDoc = obWindow.document;
                            // we will simulate a readyState for firefox so this is ok.
                            
                            if ( obDoc.readyState == "complete" ) {
                                
                                
                                
                                if ( obDoc.body != null ) {
                                    
                                    
                                    var elBody = obDoc.body;
                                    var strResponse = null;
                                    if ( elBody.firstChild != null ) {
                                        var elChild = elBody.firstChild;
                                        if ( elChild.tagName == "PRE" ) {
                                            if
                                                (elChild.innerText)
                                            {
                                                // use the inner text property if it exists
                                                strResponse = elChild.innerText;
                                            }
                                            else
                                            {
                                                // since it does not exist use the inner HTML instead - this seems to be the
                                                // firefox case.
                                                strResponse = elChild.innerHTML;
                                            }
                                        }
                                    }
                                    if ( strResponse == null ) {
                                        
                                        strResponse = elBody.innerHTML;
                                    }
                                    
                                    var obResult = this.parseError;
                                    
                                    
                                    if ( this.fnIsReasonableResponse ( strResponse ) ) {
                                        
                                        obResult = this.fnParseVarmap ( strResponse, 0 );
                                        
                                    }
                                    if ( obResult == this.parseError ) {
										this.strBody = strResponse;
										this.mapResponse = {};
                                    } else {
                                        this.strBody = strResponse.slice ( obResult.i + 1 );
                                        this.mapResponse = {};
                                        this.fnAddToResponseMap ( this.mapResponse, "", obResult.value );
                                    }
                                    this.bWaiting = false;
 
                                    return true;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }
        cScriptHttpFetcher.prototype.IsParsedOK = function () {
            if (this.elFrameID )
			{
				var elFrame = document.getElementById(this.elFrameID);
				
				if ( elFrame.parentNode != null ) {
                
                return this.mapResponse != null;
				}
			}
            
            return false;
        }
        cScriptHttpFetcher.prototype.GetResponseBody = function () {
            return this.strBody;
        }
        cScriptHttpFetcher.prototype.RspGet = function ( strKey, strDefault ) {
            if(this.mapResponse){
                            var strResult = this.mapResponse [ strKey ];
            }
                        if ( strResult == null ) {
                strResult = strDefault;
            }
            return strResult;
        }
        cScriptHttpFetcher.prototype.ClearCmd = function () {
            
			if ( this.elFrameID != null ) {
				var elFrame = document.getElementById( this.elFrameID );
                RemoveNode(elFrame);
                this.elFrameID = null;
                this.bWaiting = false;
            }
            this.strPrefix = "";
            this.mapCmd = {};
			this.strBody = null;
            this.mapResponse = null;
        }
        cScriptHttpFetcher.prototype.SetUseUTF8Request = function ( bSet ) {
            this.bUseUtf8Request = ( bSet == "1" ) || ( bSet == true );
        }
        cScriptHttpFetcher.prototype.SetCmdPrefix = function ( strPrefix ) {
            this.strPrefix = strPrefix;
        }
        cScriptHttpFetcher.prototype.CmdSet = function ( strKey, strValue ) {
            this.mapCmd [ strKey ] = strValue;
        }
        cScriptHttpFetcher.prototype.SetUseMSXMLHTTPRequest = function ( bSet ) {
        }
        cScriptHttpFetcher.prototype.DoCmdAsync = function () {
            
            this.mapResponse = null;
            this.strBody = null;
            if ( this.elFrameID == null ) {
                var strId = "_frame_" + this.strIdBase + "_" + this.numFrameCount++;
                
                //var strMarkup = "<IFRAME src='" + this.fnGetUrl () + "' style='display:none' id='" + strId + "' name='"+strId+"'></IFRAME>";
                // document.body.insertAdjacentHTML ( "beforeEnd", strMarkup );
                
                // err this replacement is a bit simplistic, and seems to result in very bad things happening
                //document.body.innerHTML = document.body.innerHTML + strMarkup;
                
                // so we will try doing it with DOM. 
                var nf = document.createElement("IFRAME");
                nf.setAttribute("style","display:none");
                nf.style.display = "none";
                nf.setAttribute("id",strId);
                nf.setAttribute("src",this.fnGetUrl());
                nf.setAttribute("width","1");
                nf.setAttribute("height","1");
                document.body.appendChild(nf);
                
                // try to prevent responses from being re-used.
                this.mapResponse = null;
                this.strBody = null;
                this.elFrameID = strId ;
                this.bWaiting = true;
            }
        }

		/* end of old version */
		

	
	/* so it begins */
	
	
	
    function cScriptHttpFetcher2 () {
        this.req = false;
		this.haveXMLHttpRequest = false;
	    // branch for native XMLHttpRequest object
		
		// maybe check this for ie7.
		
	    if(window.XMLHttpRequest) {
	    	try {
				
				this.req = new XMLHttpRequest();
				this.haveXMLHttpRequest = true;
	        } catch(e) {
			    //alert("no native XMLHttpRequestSupport");
				this.req = false;
	        }
	    // branch for IE/Windows ActiveX version
	    } else if(window.ActiveXObject) {
	       	try {
	        	this.req = new ActiveXObject("Msxml2.XMLHTTP");
				this.haveXMLHttpRequest = true;
	      	} catch(e) {
	        	try {
	          		this.req = new ActiveXObject("Microsoft.XMLHTTP");
					this.haveXMLHttpRequest = true;
	        	} catch(e) {
	          		this.req = false;
					//alert("no activeX XMLHttpRequestSupport");
				
				}
			}
	    }
		
		if (!this.req) 
		{
			//alert("No XMLHTTP request implementation found");
		}
		//alert(this.haveXMLHttpRequest);
    }
        cScriptHttpFetcher2.prototype.fnGetUrl = function () {
            var strArgs = "";
            for ( var strKey in this.mapCmd ) {
                var strValue = this.mapCmd [ strKey ];
                if ( strArgs != "" ) {
                    strArgs += "&";
                }
                if ( this.bUseUtf8Request || true ) {
                    strValue = fnToUtf8 ( strValue );
                }
                strArgs += strKey + "=" + strValue;
            }
            var strSep = this.strPrefix.indexOf ( "?" ) == -1 ? "?" : "&";
            return this.strPrefix + strSep + strArgs;
        }
        cScriptHttpFetcher2.prototype.parseError = {};
        cScriptHttpFetcher2.prototype.fnParseVarmap = function ( strMap, i ) {
            var vmp = strMap;
            var root = {};
            var wantName = true;
            var name = "";

            for (; i < vmp.length; i++)
            {
                switch (vmp.charAt (i))
                {
                    case ' ':
                    case '\t':
                    case '\n':
                    case '\r':
                    case '=':
                        break;


                    case '}':
                        var ret = {};
                        ret['i'] = i;
                        ret['value'] = root;
                        return ret;
                        break;


                    case '{':
                        if (wantName)
                        { // special case for the first brace
                        }
                        else
                        {
                            var result = this.fnParseVarmap (vmp, i + 1);
                            if ( result == this.parseError ) {
                                return this.parseError;
                            }
                            i = result['i'];
                            root[name] = result['value'];
                            wantName = true;
                        }
                        break;


                    case '"':
                    var token = new String ();
                    i++;
                    for (; i < vmp.length && vmp.charAt (i) != '"'; i++)
                    {
                        if (vmp.charAt (i) == "\\")
                        {
                            i++;
                            if (i < vmp.length)
                            {
                                switch (vmp.charAt(i))
                                {
                                    case 'r':
                                    token += '\r';
                                    break;

                                    case 'n':
                                    token += '\n';
                                    break;

                                    default:
                                    token += vmp.charAt(i);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            token += vmp.charAt(i);
                        }
                    }

                    if (wantName)
                    {
                        name = token;
                    }
                    else
                    {
                        root[name] = new String(token);
                    }
                    wantName = !wantName;
                    break;


                    default:
                        var token = ""
                        for (; i < vmp.length && (' \t\r\n={}').indexOf (vmp.charAt (i)) == -1; i++)
                        {
                            token += vmp.charAt(i);
                        }
                        if (vmp.charAt (i) == '{' || vmp.charAt (i) == '}')
                        {
                            i--;
                        }

                        if (wantName)
                        {
                            name = token;
                        }
                        else
                        {
                            root[name] = new String (token);
                        }
                        wantName = !wantName;
                        break;
                }

            }
            return this.parseError;
        }
        cScriptHttpFetcher2.prototype.fnFromMarkup = function ( str ) {
            str = str.replace ( /&amp;/g, "&" );
            str = str.replace ( /&lt;/g, "<" );
            str = str.replace ( /&gt;/g, ">" );
            return str;
        }

        //--------------------------------------------------------
        cScriptHttpFetcher2.prototype.IsAsyncWaiting = function () {
            return this.bWaiting;
        }
        cScriptHttpFetcher2.prototype.fnAddToResponseMap = function ( mapResponse, strPrefix, mapData ) {
            for ( var strKey in mapData ) {
                var obValue = mapData [ strKey ];
                var strPath = strKey;
                if ( strPrefix != "" ) {
                    strPath = strPrefix + "." + strPath;
                }
                if ( obValue.constructor == String ) {
                    mapResponse [ strPath ] = this.fnFromMarkup ( obValue );
                } else {
                    this.fnAddToResponseMap ( mapResponse, strPath, obValue );
                }
            }
        }
        cScriptHttpFetcher2.prototype.fnIsReasonableResponse = function ( strMap ) {
            
            var strSpace = " \t\r\n";
            for ( var i = 0; i < strMap.length; i++ )
            {
                var ch = strMap.charAt ( i );
                if ( ! (strSpace.indexOf ( ch ) >= 0) ) {
                    if ( ch == '{' ) {
                        return true;
                    } else {
                        break;
                    }
                }
            }
            return false;
        }
        cScriptHttpFetcher2.prototype.IsAsyncReady = function () {
            
            if ( this.req ) {

				if (this.req.readyState != 4 )
				{
					return false;
				}
				
				if
					(this.req.status != 200 )
				{
					this.bWaiting = false;

    				this.strBody = this.req.responseText;
					this.mapResponse = {
						errorOccured : 1,
						errorLevel : "HTTP",
						errorNumber : 20000+this.req.status, 
						errorDescription : "HTTP request status "+ this.req.status
					};

					trace("request status is "+ this.req.status );										 
					return true;
				}
		
				if
					(this.req.responseText.indexOf("<span id=\"ThisIsObjectNoFoundPage\"") != -1)
				{
					this.bWaiting = false;

    				this.strBody = this.req.responseText;
					this.mapResponse = {
						errorOccured : 1,
						errorLevel : "STOP",
						errorNumber : 21000, 
						errorDescription : "Session Closed"
					};

					trace("recieved object not found response" );										 
					return true;
				}
				
				this.bWaiting = false;
				
				var txt = this.req.responseText;
				
				var index = txt.indexOf("<body onload=");
				
				txt = txt.substr(index+13);
				
				index = txt.indexOf(">")
				
				txt = txt.substr(index+1);
				
				if
				    (txt.indexOf("<pre>")==0)
				{
					txt = txt.substr(5);
					havePre = true;
					index= txt.lastIndexOf("</pre>");
					txt = txt.substr( 0, index );
				}
				else
				{
					index = txt.indexOf("\n");
					txt = txt.substr(index+1);
					index= txt.lastIndexOf("</body>");
					txt = txt.substr( 0, index );
				}
				
				var strResponse = txt;
				
				if ( strResponse != null ) {
                                        
                   this.bWaiting = false;
                   var obResult = this.parseError;
                                    
					
                   if ( this.fnIsReasonableResponse ( strResponse ) ) {                     
						
						obResult = this.fnParseVarmap ( strResponse, 0 );                     
                   }
                   
				   if ( obResult == this.parseError ) {
						trace("Parse error on response");
        				this.strBody = strResponse;
						this.mapResponse = {};
					} else {
						this.strBody = strResponse.slice ( obResult.i + 1 );
						this.mapResponse = {};
						this.fnAddToResponseMap ( this.mapResponse, "", obResult.value );
					}
					return true;
				}
			}
			return false;
        }
        cScriptHttpFetcher2.prototype.IsParsedOK = function () {
            
            if ( this.req.readyState == 4  ) {
                return this.mapResponse != null;
            }
            else 
			{
				//alert("Called parsed ok - when ready state is not 4 ");
			}
            return false;
        }
        cScriptHttpFetcher2.prototype.GetResponseBody = function () {
            return this.strBody;
        }
        cScriptHttpFetcher2.prototype.RspGet = function ( strKey, strDefault ) {
            if(this.mapResponse){
                            var strResult = this.mapResponse [ strKey ];
            }
                        if ( strResult == null ) {
                strResult = strDefault;
            }
            return strResult;
        }
        cScriptHttpFetcher2.prototype.ClearCmd = function () {
            if ( this.elFrame != null ) {
                RemoveNode(this.elFrame);
                this.elFrame = null;
                this.bWaiting = false;
            }
            this.strPrefix = "";
            this.mapCmd = {};
            this.mapResponse = null;
        }
        cScriptHttpFetcher2.prototype.SetUseUTF8Request = function ( bSet ) {
            this.bUseUtf8Request = ( bSet == "1" ) || ( bSet == true );
        }
        cScriptHttpFetcher2.prototype.SetCmdPrefix = function ( strPrefix ) {
            this.strPrefix = strPrefix;
        }
        cScriptHttpFetcher2.prototype.CmdSet = function ( strKey, strValue ) {
            this.mapCmd [ strKey ] = strValue;
        }
        cScriptHttpFetcher2.prototype.SetUseMSXMLHTTPRequest = function ( bSet ) {
        }
		
		cScriptHttpFetcher2.prototype.processReqChange = function () {
		}

        cScriptHttpFetcher2.prototype.DoCmdAsync = function () {
			if (this.bWaiting)
			{
				this.bWaiting = false;
				this.req.abort();
			}
			if (this.req) {
				this.req.onreadystatechange = this.processReqChange;
				this.req.open("GET", this.fnGetUrl(), true);
				this.req.send("");
				this.bWaiting = true;
			}
        }

    function fnToUtf8( str) {
        var strUtf8 = "";
        for ( var i = 0; i < str.length; i++ )
        {
            var numCode = str.charCodeAt ( i );
            if ( numCode < 0x80 ) {
                strUtf8 += String.fromCharCode ( numCode );
            } else if ( numCode < 0x800 ) {
                strUtf8 += String.fromCharCode ( ( numCode >> 6 ) | 0xc0 );
                strUtf8 += String.fromCharCode ( ( numCode & 0x3f ) | 0x80 );
            } else {
                strUtf8 += String.fromCharCode ( ( numCode >> 12 ) | 0xe0 );
                strUtf8 += String.fromCharCode ( ( ( numCode >> 6 ) & 0x3f ) | 0x80 );
                strUtf8 += String.fromCharCode ( ( numCode & 0x3f ) | 0x80 );
            }
        }
        return strUtf8;
	}


        function dragHandleObject ()
        {
        }
        
        
        dragHandleObject.prototype = new baseObject ();
    
        dragHandleObject.prototype.start = function ( element, objectClass ) {

            trace("dragHandle.start called");
            this.outerElement = element;
            element.objectHandle = this.handle;

            this.localFocusElement = null;

            this.outerElement.onselectstart = new Function ( "return false;" );
            this.outerElement.ondragstart = new Function ( "return false;" );

            this.stype = this.getInheritedAttribute ( this.manager.attributePrefix + "Type" );
            
            this.handler = this.getInheritedAttribute ( this.manager.attributePrefix + "Handler" );
        }
        
        dragHandleObject.prototype.onClick = function ( e ) {
//            if (!e) var e = window.event;
//            var element = getTargetElement( e );
//            var code = getKeyCode( e );

            if
                ( this.stype.toLowerCase () == "close" )
            {
                this.manager.addImperativeTask ( new Function ( "documentManager.close();" ) );
            }
        }

        dragHandleObject.prototype.doDrag = function ( dx, dy ) {

            var method = this.stype.toLowerCase ();
            trace("","dragHandle doDrag called ("+dx+","+dy+")"); 
            if ( method != "close" ) {

                var handler = this.handler;

                if ( this.handler == null ) {

                    handler = "documentManager";
                }

                this.manager.addImperativeTask ( new Function ( handler + "." + method + " ( " + dx + ", " + dy + " );" ) );
            }
        }


      function xDocManClasses_Startup()
      {
            documentManager.registerClass ( "dragHandle", dragHandleObject );
            documentManager.registerClass ( "container", containerObject );
            documentManager.registerClass ( "control", controlManagerObject );
            documentManager.registerClass ( "echo", echoObject );
            documentManager.registerClass ( "form", formManagerObject );
            documentManager.registerClass ( "submit", submitManagerObject );
            documentManager.registerClass ( "link", linkManagerObject );
            documentManager.registerClass ( "floatingFrame", floatingFrameObject );
            documentManager.registerClass ( "listItem", listItemManagerObject );
            documentManager.registerClass ( "floatingElement", floatingElementObject );
            documentManager.registerClass ( "floatingElement2", floatingElementObject2 );

            documentManager.registerType ( "Currency", currencyValidatorObject );
            documentManager.registerType ( "default", defaultValidatorObject );
            documentManager.registerType ( "String", stringValidatorObject );
            documentManager.registerType ( "LongString", stringValidatorObject );
            documentManager.registerType ( "Numeric", numberValidatorObject );
            documentManager.registerType ( "Date", dateValidatorObject );

            documentManager.registerType ( "ItemNo", controlNumberValidatorObject );
            documentManager.registerType ( "BrwrNo", controlNumberValidatorObject );
            documentManager.registerType ( "BacNo", controlNumberValidatorObject );
            documentManager.registerType ( "ReservationNo", controlNumberValidatorObject );
            documentManager.registerType ( "ControlNo", controlNumberValidatorObject );
            documentManager.registerType ( "PrdNo", controlNumberValidatorObject );
            documentManager.registerType ( "ISBN", controlNumberValidatorObject );
            documentManager.registerType ( "RecPtr", controlNumberValidatorObject );
            documentManager.registerType ( "AcqRecPtr", controlNumberValidatorObject );

      }