var oldUpdateTiles;

var portal = function() {

    //Global Variables	        
    //modify to add more dialogs
    var dialogNames = new Array("AddressName", "FindOnMap", "MySettings");
    var parentItems = new Array("firstlist");
    var contentPanels = new Array("UcNotification1_pnlNotificationResults",
    /*"UcNeighborhoodInformation2_pnlNeighborhoodInformation", */"pnlMapTools");
    //----------------------------------------------------
    var numberOfDialogs = dialogNames.length;
    var dialogPanels = new Array(numberOfDialogs);
    var showBtn = new Array(numberOfDialogs);
    var closeBtn = new Array(numberOfDialogs);
    var helpDialog, helpButton, doShowHelp = true;
    var relatedLinksDialog, relatedLinksButton;
    var identDialog, printDialog, printButton;
    var disclaimerDialog, layout, informationTabs;
    var printDialog;
    var routingDialog;
    var resultsDialog;
    var candidatesDialog;

    //Functions within the DOM
    return {
        init: function() {
            // fix IE javascript drag problem
            map.MapMouseMove = MapMouseMoveLocal;

            // sp2 show/hide loading graphics
            map.pendingTiles.add_onRequestsPending(ShowLoadingMap);
            map.pendingTiles.add_onRequestsCompleted(HideLoadingMap);

            // set up default tool for neighborhood map
            findNeighborhoodByClick();

            // set up identify mode for javascript
            map.ctrlMode = "MapIdentify";
            map.ctrlAction = "Point";
            map.ctrlCursor = "pointer";
            map.ctrlFunction = "MapIdClick(e)";

            // set up pre-exec function for full extent toolbar button
            Toolbars["Toolbar1"].items["FindByXY"].preExecFunction = "findNeighborhoodByClick()";

            // initialize state manager, we will use cookies                  
            state = YAHOO.ext.state.Manager;
            state.setProvider(new YAHOO.ext.state.CookieProvider());

            //###############################################
            // Set up the regions for the entire layout
            //###############################################
            //aspnetForm, 'divContainer'
            if (layout == null) {
                var viewWidth = YAHOO.util.Dom.getViewportWidth();
                layout = new YAHOO.ext.BorderLayout(document.body, {
                    north: {
                        initialSize: 59,
                        split: false,
                        titlebar: false,
                        autoScroll: false
                    },
                    east: {
                        initialSize: (viewWidth > 1024) ? (viewWidth - 750) : 350,
                        collapsible: true,
                        split: true,
                        minSize: 330,
                        titlebar: true,
                        autoScroll: false
                    },
                    center: {
                        autoScroll: true,
                        collapsible: true,
                        titlebar: false
                    }
                });
            }
            layout.beginUpdate();
            layout.add('north', new YAHOO.ext.ContentPanel('north', { fitToFrame: true }));
            layout.add('east', new YAHOO.ext.ContentPanel('east', { title: strInformationPanelTitle, fitToFrame: true }));

            var innerlayout = new YAHOO.ext.BorderLayout('mainarea', {
                north: {
                    autoScroll: true,
                    collapsible: false,
                    initialSize: 90,
                    split: false,
                    titlebar: true
                },
                center: {
                    autoScroll: true,
                    titlebar: true
                }
            });

            innerlayout.add('north', new YAHOO.ext.ContentPanel('north-center', { title: searchTitle }));
            innerlayout.add('center', new YAHOO.ext.ContentPanel('center', { title: mapTitle }));

            //Set up map & toolbar
            //Added by Marianne Cardwell on 12/12/08 to prevent toolbar from disappearing on small windows
            var mapinnerlayout = new YAHOO.ext.BorderLayout('center', {
                north: {
                    autoScroll: false,
                    collapsible: false,
                    initialSize: 24,
                    split: false,
                    titlebar: false,
                    border: false
                },
                center: {
                    autoScroll: true,
                    titlebar: false,
                    split: false,
                    border: false
                }
            });
            mapinnerlayout.add('north', new YAHOO.ext.ContentPanel('toolbarRegion'));
            mapinnerlayout.add('center', new YAHOO.ext.ContentPanel('mapRegion'));
            innerlayout.add('center', new YAHOO.ext.NestedLayoutPanel(mapinnerlayout));
            //End of added section by Marianne Cardwell
            
            layout.add('center', new YAHOO.ext.NestedLayoutPanel(innerlayout));
            //restore layout state
            layout.endUpdate();

            layout.on("regionresized", this.resizePanelWidth);

            var mapResizer = new YAHOO.ext.Resizable('mainMap', { minWidth: 300, minHeight: 300, maxWidth: 1000, maxHeight: 1000 });
            mapResizer.on('resize', function(o, w, h, e) { resizeMap(w, h); });

            //create the portal elements
            this.createPortalElements();

            // restore any state information
            this.restorePortalState();

            // style center panel
            getEl(getEl("center").dom.parentNode.id).addClass("BACKGROUND");

            // fix nav arrow if necessary
            this.fixNavArrow();

            if (getEl("loading")) getEl("loading").remove();

            //---------------------------------
            //Load the list of neighborhoods
            //Added by Akinmade 3/3/2008	                
            //getNeighborhoods();
            //---------------------------------

        }, //end init function

        //###############################################
        // Creates the portal elements
        //##############################################     			     
        createPortalElements: function() {
            //---------------------------------------------------
            // Set up the moveable dialogs
            //---------------------------------------------------
            //loop through and build all the panels                
            var i = 0;
            for (var i = 0; i < dialogNames.length; i++) {
                //store the panels                                            	    
                var dlgName = "dlg" + dialogNames[i] + "Container";
                //grab the associated container
                dialogPanels[i] = new YAHOO.ext.Element(dlgName);

                if (dialogPanels[i]) {
                    dialogPanels[i].autoDisplayMode = true;
                    dialogPanels[i].visibilityMode = YAHOO.ext.Element.DISPLAY;
                    dialogPanels[i].hide();
                }

                //get the show btn	
                var btnName = "btnShowDialog" + i;

                //get the show button
                showBtn[i] = new YAHOO.ext.Element(btnName);

                //get the close button
                btnName = "btnCloseDialog" + i;
                closeBtn[i] = new YAHOO.ext.Element(btnName);

                // attach to click event
                if (showBtn[i]) showBtn[i].on('click', this.showDialog.createDelegate(this, [i]));
                if (closeBtn[i]) closeBtn[i].on('click', this.closeDialog.createDelegate(this, [i]));

                dlgName = null;
                btnName = null;

            } //end for statement	       		
            i = null;

            //---------------------------------------------------
            // Set up the Tabs for the information display
            //---------------------------------------------------

            if (informationTabs == null) {
                informationTabs = new YAHOO.ext.TabPanel('pnlInformationTabs');
                informationTabs.addTab('divResults', strInformation_ResultsTabTitle);
                informationTabs.addTab('divMapTools', strInformation_MapToolsTabTitle);
                //                        informationTabs.addTab('divNeighborhoodInfo', strInformation_NeighborhoodTabTitle);                                       
                informationTabs.on('tabchange', function(tp, tab) {
                    state.set(tp.el.id + '-active', tab.id);
                });
            }

            //----------------------------------------------
            //Show the help dialog                                     
            //----------------------------------------------
            //add the show help button event
            helpButton = new YAHOO.ext.Element("UcHeader1_btnHelp");
            if (helpButton) helpButton.on('mousedown', portal.showHelp.createDelegate(this));
            //create the help dialog		                                
            this.createHelpDialog();

            //----------------------------------------------
            //Show the print dialog
            //----------------------------------------------
            //add the print button event
            printButton = new YAHOO.ext.Element("UcHeader1_btnPrint");
            if (printButton) printButton.on('mousedown', portal.showPrintDialog.createDelegate(this));
            // create the Print Dialog
            this.createPrintDialog();
            
            //----------------------------------------------
            //Show the routing dialog
            //----------------------------------------------
            this.createRoutingDialog();
            
            //----------------------------------------------
            //Show the layer results dialog
            //----------------------------------------------
            this.createResultsDialog();
            
            //----------------------------------------------
            //Show the candidates dialog
            //----------------------------------------------
            this.createCandidatesDialog();

            //----------------------------------------------
            //Show the related links dialog
            //----------------------------------------------
            //add the show related links button event
            relatedLinksButton = new YAHOO.ext.Element("UcHeader1_btnRelatedLinks");
            if (relatedLinksButton) relatedLinksButton.on('mousedown', portal.showRelatedLinks.createDelegate(this));
            //create the help dialog		                                
            this.createRelatedLinksDialog();
            //add events
            relatedLinksButton.on('hide', function() { state.set(relatedLinksButton.el.id + '-show-state', false); });
            relatedLinksDialog.getTabs().on('tabchange', function(tb, tab) {
                state.set(tb.el.id + '-active', tab.id);
            });

            // create the Identify Results dialog
            this.createIdentDialog();

            // create the passive disclaimer dialog
            this.createPassiveDisclaimerDialog();

            //create the active disclaimer dialog
            this.createActiveDisclaimerDialog();

            //-----------------------------------------------
            //Resize the Results Display
            //-----------------------------------------------
            this.resizePanelHeight();
        }, //end createPortalElements function

        showResultsTab: function() {
            informationTabs.activate('divResults');
            layout.getRegion('east').expand();
        },

        collapseEast: function() {
            layout.getRegion('east').collapse();
        },

        /*
        * when a user resizes the window, also resize the content panels in the information pane
        */
        resizePanelHeight: function() {
            // get the region of the table in the divResults panel
            var tableHeight = YAHOO.util.Dom.getViewportHeight() - 135;
            // set the height of the panel
            YAHOO.util.Dom.setStyle(contentPanels, "height", tableHeight + "px");
            // resize the TOC
            YAHOO.util.Dom.setStyle("mapTOC", "height", (tableHeight - 50) + "px");
        },

        resizePanelWidth: function(region, newWidth) {
            if (region.el.hasClass("ylayout-panel-east")) {
                if (YAHOO.ext.util.Browser.isIE) {
                    YAHOO.util.Dom.setStyle("mapTOC", "width", (newWidth - 32) + "px");
                }
            }
        },

        /*
        * due to css issues, we need to make this change for Gecko based browsers
        */
        fixNavArrow: function() {
            if (YAHOO.ext.util.Browser.isGecko) {
                var navArrow = document.getElementById("northArrow");
                YAHOO.util.Dom.setStyle(navArrow, "height", "0");
                YAHOO.util.Dom.setStyle(navArrow, "position", "relative");
            }
        },

        //############################
        // Create the Help Dialog
        //###########################			    
        createHelpDialog: function() {
            if (!helpDialog) {
                var offSet = 30;
                helpDialog = new YAHOO.ext.BasicDialog("dlgHelpContainer",
		               {
		                   autoTabs: true, modal: false, width: 300, height: 400,
		                   shadow: true, constraintoviewport: true, viewport: document.body,
		                   proxyDrag: true, resizable: true, closable: false,
		                   draggable: true, shim: true,
		                   animateTarget: new YAHOO.ext.Element("UcHeader1_btnHelp")
		               });
            }
            helpDialog.addListener("hide", function() {
                layout.layout();
            });
            this.createDialogCloseLink(helpDialog, dialogCloseLinkText);
        }, //end createHelpDialog

        //############################
        // Show the Help Dialog
        //###########################
        showHelp: function() {
            //show the dialog
            helpDialog.show();
        },
        hideHelp: function() {
            if (helpDialog.isVisible()) {
                helpDialog.hide();
            }
        },

        //############################
        // Create the Related Links Dialog
        //###########################			    
        createRelatedLinksDialog: function() {
            if (!relatedLinksDialog) {
                var offSet = 30;
                relatedLinksDialog = new YAHOO.ext.BasicDialog("dlgRelatedLinksContainer",
                        {
                            autoTabs: true, modal: false, width: 300, height: 400,
                            shadow: true, constraintoviewport: true, viewport: document.body,
                            proxyDrag: true, resizable: true, closable: false,
                            draggable: true, shim: true,
                            animateTarget: new YAHOO.ext.Element("UcHeader1_btnRelatedLinks")
                        });
            }
            relatedLinksDialog.addListener("hide", function() {
                state.set(relatedLinksDialog.el.id + '-show-state', false);
            });
            this.createDialogCloseLink(relatedLinksDialog, dialogCloseLinkText);
        }, //end createRelatedLinksDialog

        createDialogCloseLink: function(dialog, html) {
            var dh = YAHOO.ext.DomHelper;
            dialog.el.addClass('ydlg-closable');
            dialog.close = dh.append(dialog.el.dom, { tag: 'div', cls: 'ydlg-close2', html: html }, true);
            dialog.close.mon('click', function() {
                dialog.hide();
            }, dialog, true);
        },

        //############################
        // Show the Print Dialog
        //###########################
        createPrintDialog: function() {
            if (!printDialog) {
                var offSet = 30;
                printDialog = new YAHOO.ext.BasicDialog("dlgPrintContainer",
                {
                    autoTabs: true,
                    width: 500,
                    height:400,
                    shadow: true,
                    minWidth: 300,
                    minHeight: 250,
                    proxyDrag: true,
                    constraintoviewport: true,
                    closable: true,
                    viewport: document.body
                });
            }
            printDialog.addListener("hide",function() {
                state.set(printDialog.el.id + '-show-state', false);
            });
            //this.createDialogCloseLink(printDialog,dialogCloseLinkText);
        }, //end createPrintDialog

        //############################
        // Show the Routing Dialog
        //###########################
        createRoutingDialog: function() {
            if (!routingDialog) {
                var offSet = 30;
                routingDialog = new YAHOO.ext.BasicDialog("dlgRoutingContainer",
                {
                    constraintoviewport: true,
                    viewport: document.body,
                    proxyDrag: true,
                    modal: false,
                    resizable: true,
                    shim: true,
                    width: 710,
                    height: 470,
                    closable: true,
                    shadow: true
                });
            }
            routingDialog.addListener("hide",function() {
                state.set(routingDialog.el.id + '-show-state', false);
            });
        },
        
        //############################
        // Show the results dialog
        //############################
        createResultsDialog: function() {
            if (!resultsDialog) {
                var offSet = 30;
                resultsDialog = new YAHOO.ext.BasicDialog("dlgLayerResultsContainer",
                {
                    constraintoviewport: true,
                    viewport: document.body,
                    proxyDrag: true,
                    modal: false,
                    resizable: true,
                    shim: true,
                    width: 500,
                    height: 300,
                    closable: true,
                    shadow: true
                });
                resultsDialog.addListener("hide", function() {
                    state.set(resultsDialog.el.id + '-show-state', false);
                });
            }
        },
        
        //############################
        // Show the candidates dialog
        //############################
        createCandidatesDialog: function() {
            if (!candidatesDialog) {
                var offSet = 30;
                candidatesDialog = new YAHOO.ext.BasicDialog("pnlAddressCandidates",
                {
                    viewport: document.body,
                    constraintoviewport: true,
                    proxyDrag: true,
                    modal: true,
                    resizable: false,
                    shim: true,
                    width: 425,
                    height: 100,
                    closable: true
                });
                candidatesDialog.addListener("hide",function() {
                    state.set(candidatesDialog.el.id + '-show-state', false);
                    //Stop graphic in results frame
                    var f;
                    if (YAHOO.ext.isIE) {
                        f = d.frames ? d.frames['ResultsFrame'] : d.getElementById('ResultsFrame');
                    } else {
                        f = window.frames.ResultsFrame;
                    }
                    if (f) {
                        f.hideResultsLoading();
                    }
                });
            }
        },

        //############################
        // Show the Related Links Dialog
        //###########################
        showRelatedLinks: function() {
            //show the dialog
            relatedLinksDialog.show();
            state.set(relatedLinksDialog.el.id + '-show-state', true);
        },

        showPrintDialog: function() {
            printDialog.show();
            state.set(printDialog.el.id + '-show-state', true);
        },
        
        showRoutingDialog: function(from,to) {
            var url = "Routing.aspx?fromaddress=" + from + ",Indianapolis,IN&toaddress=" + to + ",Indianapolis,IN";
            document.getElementById("RoutingFrame").src = url;
            routingDialog.show();
            state.set(routingDialog.el.id + '-show-state', true);
        },
        
        showLayerResultsDialog: function(html) {
            //Find frame
            var f;
            if (document.frames) {
                f = document.frames['LayerResultsFrame'];
            } else {
                f = document.getElementById('LayerResultsFrame');
            }
            
            if (f)
            {
                if (f.document) {
                    f.document.getElementById('divContent').innerHTML = html;
                } else {
                    f.contentWindow.document.getElementById('divContent').innerHTML = html;
                }
                
                //show dialog
                resultsDialog.show();
                state.set(resultsDialog.el.id + '-show-state', true);
            }
        },
        
        showCandidatesDialog: function(candidates) {
            //Clear listbox
            var list = document.getElementById("ddlCandidates");
            for (var ii = list.options.length - 1; ii > -1; ii--) {
                list.options[ii] = null;
            }

            //Populate listbox
            var arrTexts = new Array();
            var arrValues = new Array();
            for (var ii = 0; ii < candidates.length; ii++) {
                var address = candidates[ii].Address;
                var x = candidates[ii].Xcoord;
                var y = candidates[ii].Ycoord;
                arrTexts[ii] = address + '||' + x + '||' + y;

            }
            arrTexts.sort();
            for (var jj = 0; jj < arrTexts.length; jj++) {
                var opt = document.createElement('option');
                var values = arrTexts[jj].split('||');
                opt.text = values[0];
                opt.value = arrTexts[jj];
                list.options[list.options.length] = opt;
            }
            
            //Show dialog
            candidatesDialog.show();
        },
        
        hideCandidatesDialog: function() {
            candidatesDialog.hide();
        },
        
        showIdentDialog: function() {
            document.getElementById("IdentifyLoading").style.display = "block";
            identDialog.show();
        },
        
        createIdentDialog: function() {
            if (!identDialog) {
                identDialog = new YAHOO.ext.BasicDialog("dlgIdentifyResultsContainer", {
                    viewport: document.body, proxyDrag: true, resizable: false, shim: true,
                    width: 330, height: 400, closable: false
                });
            }
            identDialog.addListener("hide", function() {
                // clear the identify list but only if the user hasn't already done it
                var clearLink = document.getElementById("TaskResults1").getElementsByTagName("a");
                if (clearLink.length > 0) {
                    TreeViewPlusObjects['TaskResults1'].clearAllNodes();
                }
                // remove IdentifyLocation
                var identLocation = document.getElementById("IdentifyLocation");
                if (identLocation) {
                    identLocation.parentNode.removeChild(identLocation);
                }
                HideLoadingMapForIdentify();
            });
            this.createDialogCloseLink(identDialog, dialogCloseLinkText);
        },

        createPassiveDisclaimerDialog: function() {
            if (!disclaimerDialog) {
                disclaimerDialog = new YAHOO.ext.BasicDialog("discbox_dlgDisclaimerBoxContainer", {
                    viewport: document.body, proxyDrag: true, resizable: false, shim: true,
                    width: 350, height: 300, closable: false
                });
            }
            this.createDialogCloseLink(disclaimerDialog, dialogCloseLinkText);
        },

        showPassiveDisclaimerDialog: function(content) {
            document.getElementById("dlgDisclaimerBoxContentContent").innerHTML = content;
            disclaimerDialog.show();
        },

        closePassiveDisclaimerDialog: function() {
            disclaimerDialog.hide();
        },

        createActiveDisclaimerDialog: function() {
            if (!disclaimerDialog) {
                disclaimerDialog = new YAHOO.ext.BasicDialog("discbox_dlgDisclaimerBoxContainer", {
                    viewport: document.body, proxyDrag: true, modal: true, resizable: false, shim: true,
                    width: 350, height: 300, closable: false
                });
            }
            this.createDialogCloseLink(disclaimerDialog, dialogCloseLinkText);
        },

        showActiveDisclaimerDialog: function(content) {
            document.getElementById("dlgDisclaimerBoxContentContent").innerHTML = content;
            disclaimerDialog.show();
        },

        closeActiveDisclaimerDialog: function() {
            disclaimerDialog.hide();
        },

        //###############################################    
        // Show dialog function 
        //###############################################    
        showDialog: function(num) {

            //hide the button
            var divButton = new YAHOO.ext.Element("divShowDialog" + num);
            if (divButton) {
                divButton.visibilityMode = YAHOO.ext.Element.DISPLAY;
                divButton.hide();
            }
            divButton = null;

            var dlgName;
            //show the dialog	
            if (dialogPanels[num]) {
                dlgName = "dlg" + dialogNames[num] + "Container";
                dialogPanels[num].visibilityMode = YAHOO.ext.Element.DISPLAY;
                dialogPanels[num].show();
                //manage the state
                state.set(dlgName + '-show-state', true);
            } //end if  
            dlgName = null;

        }, //end showDialog	

        //###############################################    
        // Close dialog function 
        //###############################################    
        closeDialog: function(num) {
            //hide the dialog			        	   
            if (dialogPanels[num]) {
                var dlgName = "dlg" + dialogNames[num] + "Container";
                dialogPanels[num].visibilityMode = YAHOO.ext.Element.DISPLAY;
                dialogPanels[num].hide();
                //manage the state
                state.set(dlgName + '-show-state', false);
                dlgName = null;
            }

            //show the button
            var divButton = new YAHOO.ext.Element("divShowDialog" + num);
            if (divButton) {
                divButton.visibilityMode = YAHOO.ext.Element.DISPLAY;
                divButton.show();
            }
            divButton = null;

        }, //end closeDialog	  
        //###############################################    
        // Restore previous states of elements
        //###############################################    
        restorePortalState: function() {
            var objState;
            //---------------------------------------                                                     
            //restore dialogs and show buttons 
            //---------------------------------------                    
            for (var num = 0; num < numberOfDialogs; num++) {
                //restore dialogs
                var dlgName = "dlg" + dialogNames[num] + "Container";
                //restores the visibility                         
                objState = state.get(dlgName + '-show-state');
                if (objState != null) {
                    (objState) ? this.showDialog(num) : this.closeDialog(num);
                } else {
                    //show the dialog by default
                    this.showDialog(num);
                }
            }
            //---------------------------------------                                       
            //restore the tabs                  
            informationTabs.activate(state.get(informationTabs.el.id + '-active', 'divResults'));
            //---------------------------------------
            // help dialog is on by default
            if (doShowHelp) {
                helpDialog.show();
                doShowHelp = false;
            }
            //---------------------------------------                       
            //restore related links
            relatedLinksDialog.restoreState();   //restores the size and position  
            //restore print dialog
            printDialog.restoreState(); 
            //restore routing dialog
            routingDialog.restoreState();
            //restore the active help tab                                                          
            relatedLinksDialog.getTabs().activate(state.get('dlgRelatedLinksBody-active', 'dlgLinksTab'));
            objState = state.get(relatedLinksDialog.el.id + '-show-state'); //restores the visibility
            if (objState != null) {
                (objState) ? relatedLinksDialog.show() : relatedLinksDialog.hide();
            } else {
                //default
                relatedLinksDialog.hide();
            }

            //----------------------------------------
            // Restore Map Size
            //----------------------------------------
            var mapWidth = state.get('map-size-width');
            var mapHeight = state.get('map-size-height');
            if (mapWidth) {
                resizeMap(mapWidth, mapHeight);
                var sel = document.getElementById("MapSizeDropDownList");
                var num = parseInt(mapWidth);
                if (num < 425) {
                    sel.selectedIndex = 0;
                } else if (num > 425) {
                    sel.selectedIndex = 2;
                } else {
                    sel.selectedIndex = 1;
                }
            }
            //----------------------------------------
            // Restore Nav Arrow
            //----------------------------------------                               
            var navState = state.get("settings-nav");
            if (navState != undefined) {
                document.getElementById("settings-nav").checked = navState;
                navShowHide(navState);
            }
            //clear state
            objState = null;

        }, //end restorePortalState   

        //###############################################    
        // Reset the Portal
        //###############################################    
        resetPortalState: function() {
            //clear the layout
            YAHOO.ext.state.Manager.clear(layout.id + '-layout-state');
            //clear the dialogs
            YAHOO.ext.state.Manager.clear(relatedLinksDialog.el.id + '-state');

            //clear the tabs
            YAHOO.ext.state.Manager.clear(informationTabs.el.id + '-active');

            //Loop through cookies and delete the ones that start with 'ys-'
            var ca = document.cookie.split(';');
            var nameEQ = "ys-";
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                //alert(c);
                while (c.charAt(0) == ' ') c = c.substring(1, c.length); //delete spaces
                if (c.indexOf(nameEQ) == 0) {
                    var value = "";
                    var days = -1;
                    var date = new Date();
                    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                    var expires = "; expires=" + date.toGMTString();
                    document.cookie = c + "=" + value + expires + "; path=/";
                }
                c = null;
            }
            i = null;

            //Reset Dialogs visibility
            for (var num = 0; num < numberOfDialogs; num++) {
                this.showDialog(num);
            }
            num = null;

            //Initialize the site
            this.init();

            // reset the map size select field index to zero
            document.getElementById('MapSizeDropDownList').selectedIndex = 1;
            //Resize Map to medium size
            resizeMap(425);

            //Resize Regions to Initial Size and Expand Them
            layout.getRegion('east').resizeTo(350);
            layout.getRegion('east').expand();

            var offSet = 30;
            helpDialog.x = new YAHOO.ext.Element("east").getX() + offSet;
            helpDialog.y = new YAHOO.ext.Element("east").getY() + offSet;
            portal.showHelp();

        }   //end resetPortalState  

} //end return  
    } ();

YAHOO.util.Event.on(window, 'load', portal.init, portal, true); 
YAHOO.util.Event.on(window, 'resize', portal.resizePanelHeight, portal, true);
