/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : SavedSearch
    Summary	 : Contains all the scripts to handle the entire client side functionality for the
                  NRT MySite Saved Search functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    08/10/2006	dboyce	Initial Creation

###########################################################################################################################*/

NRT.MySite.SavedSearch = function ()
{	
    var _linkSelected;

    return {    
        /*******************************************************************************************************************
        *									P U B L I C   P R O P E R T I E S
        *******************************************************************************************************************/
        /*==================================================================================
            Property	: getLinkSelected
            Summary		: Returns the save search link flag.
            Author		: Dale Lawless
            Create Date	: 11/20/2007
        ====================================================================================*/
        getLinkSelected: function ()
        {
            return _linkSelected;
        },
        
        /*==================================================================================
            Property	: setLinkSelected
            Summary		: Sets the save search link flag to indicate that the save search link
                          has been selected. 
            Author		: Dale Lawless
            Create Date	: 11/20/2007
        ====================================================================================*/
        setLinkSelected: function (value)
        {
            _linkSelected = value;
        },

    
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: closeWindow
            Summary		: Closes the Save Search layered page.
            Author		: Dale Lawless
            Create Date	: 12/06/2007
        ====================================================================================*/
        closeWindow: function () 
        {
            var DialogID = null;
            
            try
            {
                DialogID = "Dialog_" + _WinTitle_SaveSearch.replace(" ","_");
                _oUtility.closeLayeredPage(DialogID); 
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch.closeWindow', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                														
        /*==================================================================================
            Method		: setAlertTextStyle
            Summary		: Called when a saved seach alert checkbox is clicked. Will bold or 
                          remove the bolding of the text for the alert name.
            Author		: Dale Lawless
            Create Date	: 01/28/2007
        ====================================================================================*/
        setAlertTextStyle: function (control)
        {    
            var str = null;
            var temp = null; 
            var divAlertName = null;
             
            try
            {
                str = control.id;
                temp = str.replace(/chkSearchAlert/, 'divSearchAlertText');
                
                divAlertName = _oUtility.getElementByTagNameAndID(temp,'DIV');
                if (divAlertName !== null && typeof divAlertName !== 'undefined')
                {
                    // Determine how do display the text
                    if (control.checked) 
                    {
                        divAlertName.style.fontWeight='bold'; 
                    } else {
                        divAlertName.style.fontWeight='';
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch.setAlertTextStyle', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: update
            Summary		: Updates the saved search for the user logged in. 
                          Note: the search has already been saved but not yet assigned saved
                          with a name and any alert options.
            Author		: Doug Boyce
            Create Date	: 12/12/2006
        ====================================================================================*/
        update: function ()
        {     
            var SearchName = null;
            var ConsumerSearchID = null; 
            var ConsumerID = null;
            var SearchXml = null;
            var AlertIDs = null; 
            var status = null;
            var DialogID = null;
            
            try
            {
                NRT.MySite.SavedSearch._clearMessages();
                
                // Check for empty saved search name
                SearchName = _oUtility.getElementByTagNameAndID('txtSaveSearchName','INPUT').value;
                if (!SearchName)
                {
                    NRT.MySite.SavedSearch._showErrorMessage(NRT.MySite.Validation.MESSAGE_SAVESEARCH_SEARCHNAME_REQUIRED);
                    return;
                } else if (!NRT.MySite.Validation.Utility.validSearchName(SearchName))
                {
                    NRT.MySite.Validation.Utility.displayInvalidSaveSearchNameMessage(SearchName);
                    return;
                }
                
                ConsumerSearchID = _oUtility.getElementByTagNameAndID('hdnConsumerSearchID','INPUT').value;
                ConsumerID = NRT.MySite.Authentication.getConsumerID();
                SearchXml = MySiteProvider.GetSavedSearchXml(_WebsiteID, ConsumerSearchID).value;
                AlertIDs = NRT.MySite.SavedSearch._getSelectedAlertIds();
                                                
                // Update Saved Search
                status = MySiteProvider.UpdateSavedSearch(_WebsiteID, ConsumerSearchID, ConsumerID, SearchName, SearchXml, AlertIDs, true);
                
                // Check status to show which Div
                switch (status.value)
                {
                    case 0:
                        //Failed
                        //Show Error Div 
                        document.getElementById('divSaveSearchFailed').style.display = 'inline';
                        document.getElementById('divSaveSearchEnter').style.display = 'none';
                        break;
                    case 1:
                        // Success
                        //Show Confirmation Layerd Window
                        NRT.MySite.SavedSearch.closeWindow();
                        NRT.MySite.Authentication.fillSavedSearchDropDownList(ConsumerID);	
                        NRT.MySite.UI.showConfirmationLayeredWindow(_ConfirmationType_SavedSearches, ConsumerID);
                        break;
                    case 4:
                        // Duplicate Search Name
                        //Show Duplicate Search Name Message
                        NRT.MySite.SavedSearch._showErrorMessage(NRT.MySite.Validation.MESSAGE_SAVESEARCH_SEARCHNAME_DUPLICATE);
                        break;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch.update', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: view
            Summary		: Views a selected saved search from the saved search panel after 
                          selecting from the saved searches and search options dropdowns 
                          and clicking Go.
            Author		: Dale Lawless
            Create Date	: 03/07/2007
        ====================================================================================*/
        view: function ()
        {     
            var iConsumerSearchID = 0;
            var iSearchOptionID = 0; 
            var oSelectionErrMessage = null;
            
            try
            {
                iConsumerSearchID = parseInt(NRT.MySite.Authentication.getSavedSearchID(),10);
                iSearchOptionID = parseInt(NRT.MySite.Authentication.getSearchOptionID(),10);
                
                if (iConsumerSearchID === 0)
                {
                    oSelectionErrMessage = eval(document.getElementById('spnSelectionErrMessage'));
                    oSelectionErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_AUTHENTICATIION_SAVEDSEARCH_NOTSELECTED;
                    oSelectionErrMessage.style.display='inline';
                    return;
                }
                                
                NRT.MySite.UI.redirectToPropertyResultsPage(iConsumerSearchID, iSearchOptionID);
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch.view', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
                
        /******************************************************************************************************************
        *								P R I V A T E   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: _clearMessages
            Summary		: Clears all of the validation messages.
            Author		: Dale lawless
            Create Date	: 02/28/2007
        ====================================================================================*/
        _clearMessages: function ()
        {
            try
            {
                document.getElementById('divSearchNameErrMessage').innerHTML = '';
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch._clearMessages', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: _getSelectedAlertIds
            Summary		: Returns a comma-delimited string of all selected alerts.
            Author		: Dale Lawless
            Create Date	: 01/23/2007
        ====================================================================================*/
        _getSelectedAlertIds: function ()
        {     
            var sSelectedAlertIds = ''; 
            var allInputs = null;
            var x = 0;
                 
            try
            {
                allInputs = _oUtility.getElementsByTagNameAndID('chkSearchAlert','INPUT');
                
                for (x=0; x < allInputs.length; x += 1)
                {
                    // Make sure it's a checkbox box
                    if (allInputs[x].type === 'checkbox')
                    {
                        // Make sure it was checked
                        if (allInputs[x].checked === true) 
                        {
                            sSelectedAlertIds += allInputs[x].value + ',';
                        }
                    }
                }
                return sSelectedAlertIds;
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch._getSelectedAlertIds', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: _showErrorMessage
            Summary		: Displays the search name error message
            Author		: Dale Lawless
            Create Date	: 02/18/2007
        ====================================================================================*/		
        _showErrorMessage: function (sMessage)
        {  
            var divMessage = null;
            
            try
            {
                // Display message on page
                divMessage = document.getElementById('divSearchNameErrMessage');
                if (divMessage !== null && typeof divMessage !== 'undefined')
                {
                    divMessage.innerHTML = sMessage;
                    divMessage.style.display = 'inline';
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearch._showErrorMessage', _oErrorHandler.ERRORTYPE_JS, err);
            }
        }
    };
}();
/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : SavedSearches
    Summary	  : Contains all the scripts to handle the entire client side functionality for the
                NRT MySite Saved Searches functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    01/20/2007	dlawless	Initial Creation

###########################################################################################################################*/

NRT.MySite.SavedSearches = function ()
{
    return {
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: deleteSavedSearches
            Summary		: Deletes all of the selected saved searches from the Limit Reached 
                          page and then opens the saved search page in a layered window.
            Author		: Dale Lawless
            Create Date	: 01/05/2007
        ====================================================================================*/
        deleteSavedSearches: function ()
        {   
            var arrSavedSearchesCheckBoxes = [];
            var sConsumerSearchIDs = null; 
            var oHdnConsumerSearchID = null;
            var oHdnEnableJustListed = null;
            var i = 0;
            var oStatus = null;
            var iConsumerID = 0;
            var bResult = false;
            var iConsumerSearchID = 0;  
            var bEnableJustListed = false; 
            var sQueryString = '';
               
            try
            {
                NRT.MySite.SavedSearches._clearMessages();
            
                // Get an array selected saved searches
                arrSavedSearchesCheckBoxes = NRT.MySite.UI.getSelectedCheckBoxes('chkSavedSearch');
            
                if (arrSavedSearchesCheckBoxes !== null && arrSavedSearchesCheckBoxes.length > 0)
                {						
                    // Loop through array of checkboxes 
                    for (i=0; i < arrSavedSearchesCheckBoxes.length; i += 1)
                    {
                        if (sConsumerSearchIDs === null || typeof sConsumerSearchIDs === 'undefined') 
                        {
                            sConsumerSearchIDs = arrSavedSearchesCheckBoxes[i].value + ','; 
                        } else {
                            sConsumerSearchIDs = sConsumerSearchIDs + arrSavedSearchesCheckBoxes[i].value + ',';
                        }                 
                    }

                    // Deletes the Saved Searches from DB
                    oStatus = MySiteProvider.DeleteSavedSearches(_WebsiteID, sConsumerSearchIDs);
                    //SavedSearchStatus - Deleted
                    if (oStatus.value === 3)
                    {
                        // Show Save Search layered page only if the maximum number of saved searches has not yet been met.
                        iConsumerID = NRT.MySite.Authentication.getConsumerID();
                        bResult = MySiteProvider.HasMaxSavedSearches(_MaxSavedSearches, iConsumerID).value;
                        if (!bResult)
                        {
                            oHdnConsumerSearchID = _oUtility.getElementByTagNameAndID('hdnConsumerSearchID','INPUT');
                            if (oHdnConsumerSearchID !== null && oHdnConsumerSearchID !== 'undefined')
                            {
                              iConsumerSearchID =   oHdnConsumerSearchID.value;
                            }
                            
                            oHdnEnableJustListed = _oUtility.getElementByTagNameAndID('hdnEnableJustListed','INPUT');
                            if (oHdnEnableJustListed !== null && oHdnEnableJustListed !== 'undefined')
                            {
                              bEnableJustListed =   oHdnEnableJustListed.value;
                            }  

                            sQueryString = 'controlType=SaveSearch&ConsumerSearchID=' + iConsumerSearchID + '&ConsumerID=' + iConsumerID + '&EnableJustListed=' + bEnableJustListed;
                            _oUtility.closeLayeredPage();
                            _oUtility.showLayeredPage(sQueryString, _WinW_SaveSearch, _WinTitle_SaveSearch, _DefFocusItemID_SaveSearch, _DefFocusItemType_SaveSearch);
                        }
                        return;
                    }
                }
                else
                {
                    NRT.MySite.SavedSearches._showErrorMessage(NRT.MySite.Validation.MESSAGE_LIMITREACHED_SS_NONESELECTED);
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches.deleteSavedSearches', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: remove
            Summary		: Deletes a saved search from the my saved searches.
            Author		: Dale Lawless
            Create Date	: 02/6/2007
        ====================================================================================*/
        remove: function (consumerSearchID)
        {                   
            var oStatus = null;
            try
            {
                // Confirm that they want to delete the search
                if (confirm(NRT.MySite.Validation.MESSAGE_DELETE_MY_SAVED_SEARCH))
                {
                    oStatus = MySiteProvider.DeleteSavedSearches(_WebsiteID, consumerSearchID);
                    //SavedSearchStatus - Deleted
                    if (oStatus.value === 3)
                    {
                        // Remove the saved search from the authentication panel dropdown
                        NRT.MySite.Authentication.removeSavedSearchFromDropDown(consumerSearchID);
                        
                        // Refresh Saved Searches Window
                        NRT.MySite.UI.redirectToMySavedSearches();
                    } 
                } 
            } 
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches.remove', _oErrorHandler.ERRORTYPE_JS, err);
            } 
        },

        /*==================================================================================
            Method		: saveAlertInfo
            Summary		: Saves the alert settings for the search specified by searchID
            Author		: Ed Glogowski
            Create Date	: 01/24/2007
        ====================================================================================*/
        saveAlertInfo: function (searchID, consumerID,numAlerts)
        {     
            var alertFrequency = null;
            var emailRecipients = null;
            var copyToAgent = null;
            var nameID = null; 
            var alertList = '';
            var chkbox = null;
            var x = 1;	
            var dropDown = null;
            var recipients = null;
            var copyAgent = null;
            var status = null;
            
            try
            {
                // Get Alerts
                for (x = 1; x <= numAlerts; x += 1)
                {
                    nameID = 'alert_' + searchID + '_' + x;
                    chkbox = document.getElementById(nameID); 
                    
                    // Make sure it's a checkbox box
                    if (chkbox !== null && typeof chkbox !== 'undefined')
                    {
                        // Add Alert
                        if (chkbox.checked)
                        {
                            if (alertList === '')
                            {
                                alertList = alertList + chkbox.value;
                            } else {
                                alertList = alertList + ',' + chkbox.value;
                            } 
                            
                        } 
                        
                    } 
                } 
            
                // Get Frequency
                nameID = 'alertFrequency_' + searchID;
                dropDown = document.getElementById(nameID);
                
                // Make sure it's a checkbox box
                if (dropDown !== null && typeof dropDown !== 'undefined')
                {
                    alertFrequency = dropDown.options[dropDown.selectedIndex].value;
                }

                // Get Email Recipients
                nameID = 'emailRecipients_' + searchID;
                recipients = document.getElementById(nameID);
                if (recipients !== null && typeof recipients !== 'undefined')
                {
                    emailRecipients = recipients.value;
                }

                // get Copy To Agent Flag
                nameID = 'copyToAgent_' + searchID;
                copyAgent = document.getElementById(nameID);
                if (copyAgent !== null && typeof copyAgent !== 'undefined')
                {
                    copyToAgent = copyAgent.checked;
                }
                
                // Validate Alert Info
                if (NRT.MySite.SavedSearches.validateSaveAlertInfo(emailRecipients)) 
                {
                    status = MySiteProvider.SaveSearchAlertInfo(_WebsiteID, searchID,consumerID, alertList, alertFrequency, emailRecipients, copyToAgent);
                    // Save Now
               
                //SavedSearchStatus - Success 
                    if (status.value === 1)
                    {
                        alert(NRT.MySite.Validation.MESSAGE_MY_ALERT_PREFERENCES_SAVED);  
                    } else {
                        alert(NRT.MySite.Validation.MESSAGE_MY_ALERT_PREFERENCES_ERROR);
                    }
               
                }
                
                return;
                
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches.saveAlertInfo', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            } 
        },
        
        /*==================================================================================
            Method		: validateSaveAlertInfo
            Summary		: Validates the alert settings passed in (just the emails for now) 
            Author		: Ed Glogowski
            Create Date	: 01/25/2007
        ====================================================================================*/
        validateSaveAlertInfo: function (recipients)
        {    
            var Query = '';
            var bReturn = true;  
            var emails = [];  
            var x = 0;
            var test ='';
            
            try
            {
               Query = _oUtility.trimString(recipients);
                
                // Check If We Have Anything
                if (Query === '')
                {
                    return true;
                }
                
                // Remove extra comma if at end of list
                if (recipients.lastIndexOf(',') === Query.length -1)
                {
                    Query = Query.substring(0,Query.length -1);
                }
                
                // Split up emails
                emails = Query.split(',');
                
                //Check for limit of email recipients
                if (emails.length > _MaxAdditionalRecipients)
                {
                    _oUtility.showMessage(NRT.MySite.Validation.MESSAGE_EMAIL_RECIPIENTS_MAX);
                    return;
                }

                // Loop thru them
                for (x = 0; x < emails.length; x += 1)
                {
                    // Check Email
                    if (!NRT.MySite.Validation.Utility.validEmail(emails[x])) // && (emails[x].replace(/[^@]/g,'').length === 1)
                    {
                        NRT.MySite.Validation.Utility.displayInvalidEmailMessage(emails[x]);
                        return false;
                    }
                    test = emails[x];
                    if (test.replace(/[^@]/g,'').length > 1){
                       
                       NRT.MySite.Validation.Utility.displayInvalidEmailMessage(emails[x]);
                        return false;
                    }
                } 

                return bReturn;
                
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches.validateSaveAlertInfo', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /******************************************************************************************************************
        *								P R I V A T E   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: _clearMessages
            Summary		: Clears all of the validation messages.
            Author		: Dale lawless
            Create Date	: 02/28/2007
        ====================================================================================*/
        _clearMessages: function ()
        {
            try
            {
                document.getElementById('divLimitReachedErrMessage').innerHTML = '';
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches._clearMessages', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: _showErrorMessage
            Summary		: Displays the limit reached error message
            Author		: Dale Lawless
            Create Date	: 11/30/2007
        ====================================================================================*/		
        _showErrorMessage: function (sMessage)
        {  
            var divMessage = null;
            
            try
            {
                // Display message on page
                divMessage = document.getElementById('divLimitReachedErrMessage');
                if (divMessage !== null && typeof divMessage !== 'undefined')
                {
                    divMessage.innerHTML = sMessage;
                    divMessage.style.display = 'inline';
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedSearches._showErrorMessage', _oErrorHandler.ERRORTYPE_JS, err);
            }
        }        
    };
}();
/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : SaveProperty
    Summary	 : Contains all the scripts to handle the entire client side functionality for the
                  NRT MySite Save Property functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    02/10/2007	DLawless	Initial Creation

###########################################################################################################################*/

NRT.MySite.SaveProperty = function ()
{
    return {
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/	
        /*==================================================================================
            Method		: closeWindow
            Summary		: Closes the Save Property layered page.
            Author		: Dale Lawless
            Create Date	: 12/06/2007
        ====================================================================================*/
        closeWindow: function () 
        {
            var DialogID = null;
            
            try
            {
                DialogID = "Dialog_" + _WinTitle_SaveProperty.replace(" ","_");
                _oUtility.closeLayeredPage(DialogID); 
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.closeWindow', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                
        /*==================================================================================
            Method		: checkForDuplicate
            Summary		: Checks if the propertyID is a duplicate and returns true if users
                             elects to continue saving the property to the my saved properties.
            Author		: Dale Lawless
            Create Date	: 04/17/2007
        ====================================================================================*/
        checkForDuplicate: function (consumerID, propertyID)
        {   
            var oDuplicateStatus = null;
            var oDeleteStatus = null;
            
            try
            {
                oDuplicateStatus = MySiteProvider.SavedPropertyExists(_WebsiteID, consumerID, propertyID);
                if (oDuplicateStatus.value)
                {
                    // Prompt user if they want to overwrite the property.
                    if (confirm(NRT.MySite.Validation.MESSAGE_SAVEPROPERTY_PROPERTY_DUPLICATE))
                    {
                        oDeleteStatus = MySiteProvider.DeleteSavedProperty(_WebsiteID, consumerID, propertyID);
                        //SavedPropertyStatus - Deleted
                        if (oDeleteStatus.value === 3)
                        {
                            return true;
                        } else {
                            _oUtility.showMessage(NRT.MySite.Validation.MESSAGE_SAVEPROPERTY_PROPERTY_DELETE_ERROR);
                            //Failed to Delete
                            return false;
                        }
                    } else {
                        return false;
                    }
                }
                return true;
            } 
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.checkForDuplicate', _oErrorHandler.ERRORTYPE_JS, err);
            } 
        },
                                                    
        /*==================================================================================
            Method		: process
            Summary		: Called when a saved property alert checkbox is clicked. Will bold or 
                          remove the bolding of the text for the alert name.
            Author		: Dale Lawless
            Create Date	: 01/28/2007
        ====================================================================================*/
        process: function ()
        {   
            var iConsumerID = 0;
            var iPropertyID = 0;
               
            try
            {
                // Verify the User is Logged In.
                if (NRT.MySite.Authentication.validateUser())
                {
                    iConsumerID = NRT.MySite.Authentication.getConsumerID();
                    iPropertyID = _oUtility.getElementByTagNameAndID('hdnPropertyID','INPUT').value;

                    if (NRT.MySite.SaveProperty.checkForDuplicate(iConsumerID,iPropertyID))
                    {
                        NRT.MySite.SaveProperty.show();
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.process', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: Save
            Summary		: Saves the property to the users my saved properties for the user 
                          that has logged in. 
            Author		: Dale Lawless
            Create Date	: 01/25/2007
        ====================================================================================*/
        save: function ()
        {     
            var iConsumerID = 0;  
            var iPropertyID = 0;
            var sMLSNumber = ''; 
            var sAddress = '';
            var sCityNM = '';
            var sStateCD = '';
            var sZip = '';
            var sAlertIDs = '';
            var oConsumerPropID = null;
                            
            try
            {	
                iConsumerID = NRT.MySite.Authentication.getConsumerID();
                iPropertyID = _oUtility.getElementByTagNameAndID('hdnPropertyID','INPUT').value;
                sMLSNumber = _oUtility.getElementByTagNameAndID('hdnMLSNumber','INPUT').value;
                sAddress = _oUtility.getElementByTagNameAndID('hdnAddress','INPUT').value;
                sCityNM = _oUtility.getElementByTagNameAndID('hdnCityNM','INPUT').value;
                sStateCD = _oUtility.getElementByTagNameAndID('hdnStateCD','INPUT').value;
                sZip = _oUtility.getElementByTagNameAndID('hdnZip','INPUT').value;
                
                sAlertIDs = NRT.MySite.SaveProperty._getSelectedAlertIds();
                if (sAlertIDs === '') 
                {
                    sAlertIDs = 0;
                }
                
                // Save Property
                oConsumerPropID = MySiteProvider.CreateSavedProperty(_WebsiteID, iConsumerID, iPropertyID, sMLSNumber, sAddress, sCityNM, sStateCD, sZip, sAlertIDs);
                if (oConsumerPropID !== null && typeof oConsumerPropID !== 'undefined')
                {
                    // Failed
                    if (oConsumerPropID.value === '-1')
                    {
                        //Show Error Div
                        document.getElementById('divSavePropertyEnter').style.display = 'none';
                        document.getElementById('divSavePropertyFailed').style.display = 'inline';
                    } else {
                        //Show Confirmation Layerd Window
                        NRT.MySite.SaveProperty.closeWindow();                        
                        NRT.MySite.UI.showConfirmationLayeredWindow(_ConfirmationType_SavedProperties, null);
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.save', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: setAlertTextStyle
            Summary		: Called when a saved property alert checkbox is clicked. Will bold or 
                          remove the bolding of the text for the alert name.
            Author		: Dale Lawless
            Create Date	: 01/28/2007
        ====================================================================================*/
        
        setAlertTextStyle: function (control)
        {    
            var sString = ''; 
            var sTemp = ''; 
            var oDivAlertName = null;
            
            try
            {
                sString = control.id;
                sTemp = sString.replace(/chkPropertyAlert/, 'divPropertyAlertText');
                
                oDivAlertName = _oUtility.getElementByTagNameAndID(sTemp,'DIV');
                if (oDivAlertName !== null && typeof divAlertName !== 'undefined')
                {
                    // Determine how do display the text
                    if (control.checked) 
                    {
                        oDivAlertName.style.fontWeight='bold'; 
                    } else {
                        oDivAlertName.style.fontWeight='';
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.setAlertTextStyle', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: show
            Summary		: Checks if the maximum number of saved properties. If the max has
                          been reached. A saved properties limit reached window is displayed 
                          to require the user to deleted a saved properties before saving the 
                          property to their saved properties. If the max has not been reached
                          the user is redirected to the Save Property layered window.
            Author		: Dale Lawless
            Create Date	: 01/27/2007
        ====================================================================================*/
        show: function ()
        {   
            var iPropertyID = 0; 
            var sPrice = '';
            var oEncodePrice = null; 
            var sMLSNumber = ''; 
            var oEncodeMLS = null;
            var sAddress = ''; 
            var oEncodeAddress = null;
            var sCityNM = '';  
            var sStateCD  ='';
            var sZip = ''; 
            var iConsumerID = 0; 
            var bResult = false; 
            var sQueryString = '';
             
            try
            {
                // Hidden controls on the Property Details page		
                iPropertyID = _oUtility.getElementByTagNameAndID('hdnPropertyID','INPUT').value;
                sPrice = _oUtility.getElementByTagNameAndID('hdnPrice','INPUT').value;
                sMLSNumber = _oUtility.getElementByTagNameAndID('hdnMLSNumber','INPUT').value;
                sAddress = _oUtility.getElementByTagNameAndID('hdnAddress','INPUT').value;
                sCityNM = _oUtility.getElementByTagNameAndID('hdnCityNM','INPUT').value;
                sStateCD = _oUtility.getElementByTagNameAndID('hdnStateCD','INPUT').value;
                sZip = _oUtility.getElementByTagNameAndID('hdnZip','INPUT').value;
                
                iConsumerID = NRT.MySite.Authentication.getConsumerID();
                
                // Encode property address and listing number to pass through querystring
                oEncodeAddress = _oUtility.encodeURL(sAddress);
                oEncodePrice = _oUtility.encodeURL(sPrice);
                oEncodeMLS = _oUtility.encodeURL(sMLSNumber);

                // Check # of Saved Properties
                bResult = MySiteProvider.HasMaxSavedProperties(_MaxSavedProperties, iConsumerID).value;
                if (bResult)
                {
                    // Show the Saved Properties (Limit Reached) layered page
                    sQueryString = 'controlType=SavePropertyLimitReached&ConsumerID=' + iConsumerID + '&PropertyID=' + iPropertyID + '&MLSNumber=' + oEncodeMLS + '&Address=' + oEncodeAddress + '&CityNM=' + sCityNM + '&StateCD=' + sStateCD + '&Zip=' + sZip;	
                    _oUtility.showLayeredPage(sQueryString, _WinW_SaveProperty_LimitReached, _WinTitle_SaveProperty_LimitReached, _DefFocusItemID_SaveProperty_LimitReached, _DefFocusItemType_SaveProperty_LimitReached);
                } else {
                    // Show the Save Property layered page
                    sQueryString = 'controlType=SaveProperty&ConsumerID=' + iConsumerID + '&PropertyID=' + iPropertyID + '&Price=' + oEncodePrice + '&MLSNumber=' + oEncodeMLS + '&Address=' + oEncodeAddress + '&CityNM=' + sCityNM + '&StateCD=' + sStateCD + '&Zip=' + sZip;
                    _oUtility.showLayeredPage(sQueryString, _WinW_SaveProperty, _WinTitle_SaveProperty, _DefFocusItemID_SaveProperty, _DefFocusItemType_SaveProperty);
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty.show', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        
        /******************************************************************************************************************
        *								P R I V A T E   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: _getSelectedAlertIds
            Summary		: Returns a comma-delimited string of all selected alerts.
            Author		: Dale Lawless
            Create Date	: 01/23/2007
        ====================================================================================*/
        _getSelectedAlertIds: function ()
        {   
            var sSelectedAlertIds = '';
            var oAllInputs = null;
            var x = 0;
                        
            try
            {
                oAllInputs = _oUtility.getElementsByTagNameAndID('chkPropertyAlert','INPUT');
                
                for (x = 0; x < oAllInputs.length; x += 1)
                {
                    // Make sure it's a checkbox box
                    if (oAllInputs[x].type === 'checkbox')
                    {
                        // Make sure it was checked
                        if (oAllInputs[x].checked === true) 
                        {
                            sSelectedAlertIds += oAllInputs[x].value + ',';
                        }
                    }
                }
                return sSelectedAlertIds;
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SaveProperty._getSelectedAlertIds', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        }
    };
}();/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : SavedProperties
    Summary	 : Contains all the scripts to handle the entire client side functionality for the
                  NRT MySite Saved Properties functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    01/20/2007	dlawless	Initial Creation

###########################################################################################################################*/

NRT.MySite.SavedProperties = function ()
{
    return {
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/		
        /*==================================================================================
            Method		: remove
            Summary		: Deletes a property from the my saved properties.
            Author		: Dale Lawless
            Create Date	: 02/6/2007
        ====================================================================================*/
        remove: function (consumerPropertyID)
        {    
            var oStatus = null;
            
            try
            {
                // Confirm that they want to delete the property
                if (confirm(NRT.MySite.Validation.MESSAGE_DELETE_MY_SAVED_PROPERTY))
                {
                    oStatus = MySiteProvider.DeleteSavedProperties(_WebsiteID, consumerPropertyID);
                    //SavedPropertyStatus - Deleted
                    if (oStatus.value === 3)
                    {
                        // Refresh Saved Searches Window
                        NRT.MySite.UI.redirectToMySavedProperties();
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedProperties.remove', _oErrorHandler.ERRORTYPE_JS, err);
            } 
        },
        
        /*==================================================================================
            Method		: removeSelected
            Summary		: Removes all of the selected saved properties from the Limit Reached 
                          page and then opens the saved property page in a layered window.
            Author		: Dale Lawless
            Create Date	: 01/25/2007
        ====================================================================================*/
        removeSelected: function ()
        {       
            var arrSavedPropertiesCheckBoxes = [];  
            var ConsumerPropertyIDs = null;
            var i = 0;
            var oStatus = null;
            
            try
            {
                // Get an array selected saved properties   
                arrSavedPropertiesCheckBoxes = NRT.MySite.UI.getSelectedCheckBoxes('chkSavedProperty');
            
                if (arrSavedPropertiesCheckBoxes !== null && arrSavedPropertiesCheckBoxes.length > 0)
                {						
                    // Loop through array of checkboxes 
                    for (i = 0; i < arrSavedPropertiesCheckBoxes.length; i += 1)
                    {
                        if (ConsumerPropertyIDs === null || typeof ConsumerPropertyIDs === 'undefined')
                        {
                            ConsumerPropertyIDs = arrSavedPropertiesCheckBoxes[i].value + ','; 
                        } else {
                            ConsumerPropertyIDs = ConsumerPropertyIDs + arrSavedPropertiesCheckBoxes[i].value + ','; 
                        }
                    }

                    // Deletes the Saved Properties from DB
                    oStatus = MySiteProvider.DeleteSavedProperties(_WebsiteID, ConsumerPropertyIDs);
                    //SavedPropertyStatus - Deleted
                    if (oStatus.value === 3)
                    {
                        _oUtility.closeLayeredPage();

                        // Show Save Property layered window
                        NRT.MySite.SaveProperty.show();
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedProperties.removeSelected', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: saveAlertInfo
            Summary		: Saves the alert settings for the property specified by propertyID
            Author		: Ed Glogowski
            Create Date	: 02/06/2007
        ====================================================================================*/
        saveAlertInfo: function (propertyID,consumerID,numAlerts)
        {      
            var alertFrequency = null;
            var emailRecipients = null;
            var copyToAgent = null;
            var nameID = null;
            var alertList = '';
            var chkbox = null;
            var dropDown = null;
            var recipients = null;  
            var copyAgent = null; 
            var status = null;
            var x = 1;
            
            try
            {
                // Get Alerts
                for (x=1;x <= numAlerts; x += 1)
                {
                    nameID = 'alert_' + propertyID + '_' + x;
                    chkbox = document.getElementById(nameID); 
                    
                    // Make sure it's a checkbox box
                    if (chkbox !== null && typeof chkbox !== 'undefined')
                    {
                        // Add Alert
                        if (chkbox.checked)
                        {
                            if (alertList === '') 
                            {
                                alertList = alertList + chkbox.value;
                            } else {
                                alertList = alertList + ',' + chkbox.value;
                            }
                        } 
                    } 
                } 
            
                // Get Frequency
                nameID = 'alertFrequency_' + propertyID;
                dropDown = document.getElementById(nameID);
                
                // Make sure it's a checkbox box
                if (dropDown !== null && typeof dropDown !== 'undefined')
                {
                    alertFrequency = dropDown.options[dropDown.selectedIndex].value;
                }

                // Get Email Recipients
                nameID = 'emailRecipients_' + propertyID;
                recipients = document.getElementById(nameID);
                if (recipients !== null && typeof recipients !== 'undefined')
                {
                    emailRecipients = recipients.value;
                }

                // get Copy To Agent Flag
                nameID = 'copyToAgent_' + propertyID;
                copyAgent = document.getElementById(nameID);
                if (copyAgent !== null && typeof copyAgent !== 'undefined')
                {
                    copyToAgent = copyAgent.checked;
                }
                
                // Validate Alert Info
                if (!NRT.MySite.SavedProperties.validateSaveAlertInfo(emailRecipients)) 
                {
                    return;
                }

                // Save Now
                status = MySiteProvider.SavePropertyAlertInfo(_WebsiteID, propertyID, consumerID, alertList, alertFrequency, emailRecipients, copyToAgent);
                //SavedSearchStatus - Success
                if (status.value === 1)
                {
                    alert(NRT.MySite.Validation.MESSAGE_MY_ALERT_PREFERENCES_SAVED);
                } else {
                    alert(NRT.MySite.Validation.MESSAGE_MY_ALERT_PREFERENCES_ERROR); 
                }
                    
                return;
            } 
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedProperties.saveAlertInfo', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            } 
        },

        /*==================================================================================
            Method		: validateSaveAlertInfo
            Summary		: Validates the alert settings passed in (just the emails for now) 
            Author		: Ed Glogowski
            Create Date	: 02/06/2007
        ====================================================================================*/
        validateSaveAlertInfo: function (recipients)
        {   
            var emails = {};
            var x = 0;
            
            try
            {
                // Check If We Have Anything
                if (recipients !== null && recipients !== '' && typeof recipients !== 'undefined')
                {    
                    // Split up emails
                    emails = recipients.split(',');
                    
                    //Check for limit of email recipients
                    if (emails.length > _MaxAdditionalRecipients)
                    {
                        _oUtility.showMessage(NRT.MySite.Validation.MESSAGE_EMAIL_RECIPIENTS_MAX);
                        return;
                    }
                    
                    // Loop thru them
                    for (x = 0; x < emails.length ; x += 1)
                    {
                        // Check Email
                        if (!NRT.MySite.Validation.Utility.validEmail(emails[x]))
                        {
                            NRT.MySite.Validation.Utility.displayInvalidEmailMessage(emails[x]);
                            return false;
                        } 
                        test = emails[x];
                        if (test.replace(/[^@]/g,'').length > 1){
                           
                           NRT.MySite.Validation.Utility.displayInvalidEmailMessage(emails[x]);
                            return false;
                        }
                    } 
                }

                return true;
            } 
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.SavedProperties.validateSaveAlertInfo', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            } 
        }
    };
}();/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : MyAccount
    Summary	 : Contains all the scripts to handle the entire client side functionality for the
                  NRT MySite Registration functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    08/10/2006	dboyce	Initial Creation

###########################################################################################################################*/

NRT.MySite.MyAccount = function ()
{
    /*******************************************************************************************************************
    *								V A R I A B L E S
    *******************************************************************************************************************/
    var oEmail = null;
    var oFirstName = null;
    var oLastName = null;
    var oAddress = null;
    var oCity = null;
    var oState = null;
    var oZipCode = null;
    var oContactPhone = null;
    var oDaytimePhone = null;
    var oEveningPhone = null;
    var oPassword = null;
    var oPasswordConfirm = null;
    var oPreferredAgent = null;
    var oPreferredTeam = null;
    var oRememberMe = null;
    var oIsNonUSResident = null;
        
    return {
        /*******************************************************************************************************************
        *									P R I V A T E   P R O P E R T I E S
        *******************************************************************************************************************/
        _getEmailAddressTextbox: function () {
            oEmail = _oUtility.getElementByTagNameAndID('txtMyAccountEmail','INPUT');                
            if (oEmail !== null && typeof oEmail !== 'undefined') {    
                return oEmail;  
            } else { return null; }     
        },
                
        _getEmailAddress: function () {
            if (this._getEmailAddressTextbox() !== null) {
                return this._getEmailAddressTextbox().value;
            }          
        },

        _getFirstNameTextbox: function () {
            oFirstName = _oUtility.getElementByTagNameAndID('txtFirstName','INPUT');                
            if (oFirstName !== null && typeof oFirstName !== 'undefined') {    
                return oFirstName;  
            } else { return null; }
        },
                                        
        _getFirstName: function () {
            if (this._getFirstNameTextbox() !== null) {
                return this._getFirstNameTextbox().value;
            }         
        },

        _getLastNameTextbox: function () {
            oLastName = _oUtility.getElementByTagNameAndID('txtLastName','INPUT');                
            if (oLastName !== null && typeof oLastName !== 'undefined') {    
                return oLastName;  
            } else { return null; }
        },
                
        _getLastName: function () {
            if (this._getLastNameTextbox() !== null) {
                return this._getLastNameTextbox().value;
            }         
        },

        _getAddressTextbox: function ()	{
            oAddress = _oUtility.getElementByTagNameAndID('txtAddress','INPUT');                
            if (oAddress !== null && typeof oAddress !== 'undefined') {    
                return oAddress;  
            } else { return null; }
        },
        
        _getAddress: function () {
            if (this._getAddressTextbox() !== null) {
                return this._getAddressTextbox().value;
            }       
        },

        _getCityTextbox: function () {
            oCity = _oUtility.getElementByTagNameAndID('txtCity','INPUT');                
            if (oCity !== null && typeof oCity !== 'undefined') {    
                return oCity;  
            } else { return null; }
        },
        
        _getCity: function () {
            if (this._getCityTextbox() !== null) {
                return this._getCityTextbox().value;
            }       
        },

        _getStateDropdown: function () {
            oState = _oUtility.getElementByTagNameAndID('ddlState','SELECT');                
            if (oState !== null && typeof oState !== 'undefined') {    
                return oState;  
            } else { return null; }
        },
                
        _getState: function () {
            if (this._getStateDropdown() !== null) {
                return this._getStateDropdown().value;
            }       
        },

        _getZipCodeTextbox: function ()	{
            oZipCode = _oUtility.getElementByTagNameAndID('txtZipCode','INPUT');                
            if (oZipCode !== null && typeof oZipCode !== 'undefined') {    
                return oZipCode;  
            } else { return null; }
        },
        
        _getZipCode: function () {
            if (this._getZipCodeTextbox() !== null) {
                return this._getZipCodeTextbox().value;
            }       
        },

        _getContactPhoneTextbox: function () {
            oContactPhone = _oUtility.getElementByTagNameAndID('txtContactPhone','INPUT');                
            if (oContactPhone !== null && typeof oContactPhone !== 'undefined') {    
                return oContactPhone;  
            } else { return null; }
        },
        
        _getContactPhone: function () {
            if (this._getContactPhoneTextbox() !== null) {
                return this._getContactPhoneTextbox().value;
            }       
        },

        _getDaytimePhoneTextbox: function () {
            oDaytimePhone = _oUtility.getElementByTagNameAndID('txtDaytimePhone','INPUT');                
            if (oDaytimePhone !== null && typeof oDaytimePhone !== 'undefined') {    
                return oDaytimePhone;  
            } else { return null; }
        },
        
        _getDaytimePhone: function () {
            if (this._getDaytimePhoneTextbox() !== null) {
                return this._getDaytimePhoneTextbox().value;
            }       
        },

        _getEveningPhoneTextbox: function () {
            oEveningPhone = _oUtility.getElementByTagNameAndID('txtEveningPhone','INPUT');                
            if (oEveningPhone !== null && typeof oEveningPhone !== 'undefined') {    
                return oEveningPhone;  
            } else { return null; }
        },
                
        _getEveningPhone: function () {
            if (this._getEveningPhoneTextbox() !== null) {
                return this._getEveningPhoneTextbox().value;
            }       
        },

        _getPasswordTextbox: function () {
            oPassword = _oUtility.getElementByTagNameAndID('txtMyAccountPassword','INPUT');                
            if (oPassword !== null && typeof oPassword !== 'undefined') {    
                return oPassword;  
            } else { return null; }
        },
                                                
        _getPassword: function () {
            if (this._getPasswordTextbox() !== null) {
                return this._getPasswordTextbox().value;
            }         
        },

        _getPasswordConfirmTextbox: function () {
            oPasswordConfirm = _oUtility.getElementByTagNameAndID('txtMyAccountPasswordConfirm','INPUT');                
            if (oPasswordConfirm !== null && typeof oPasswordConfirm !== 'undefined') {    
                return oPasswordConfirm;  
            } else { return null; }
        },
                
        _getPasswordConfirm: function () {
            if (this._getPasswordConfirmTextbox() !== null) {
                return this._getPasswordConfirmTextbox().value;
            }         
        },

        _getPreferredAgentHidden: function () {
            oPreferredAgent = _oUtility.getElementByTagNameAndID('hdnAgentID','INPUT');                
            if (oPreferredAgent !== null && typeof oPreferredAgent !== 'undefined') {    
                return oPreferredAgent;  
            } else { return null; }
        },
        
        _getPreferredAgentID: function () {
            if (this._getPreferredAgentHidden() !== null) {
                return this._getPreferredAgentHidden().value;
            }         
        },

        _getPreferredTeamHidden: function () {
            oPreferredTeam = _oUtility.getElementByTagNameAndID('hdnTeamID','INPUT');                
            if (oPreferredTeam !== null && typeof oPreferredTeam !== 'undefined') {    
                return oPreferredTeam;  
            } else { return null; }
        },
        
        _getPreferredTeamID: function () {
            if (this._getPreferredTeamHidden() !== null) {
                return this._getPreferredTeamHidden().value;
            }         
        },
        
        _getRememberMeCheckbox: function () {
            oRememberMe = _oUtility.getElementByTagNameAndID('chkMyAccountRememberMe','INPUT');                
            if (oRememberMe !== null && typeof oRememberMe !== 'undefined') {    
                return oRememberMe;  
            } else { return null; }
        },
                
        _getRememberMe: function ()	{
            if ( this._getRememberMeCheckbox() !== null) {
                return this._getRememberMeCheckbox().checked;
            } else { return true; }        
        },

        _getIsNonUSResidentCheckbox: function () {
            oIsNonUSResident = _oUtility.getElementByTagNameAndID('chkOutsideUS','INPUT');                
            if (oIsNonUSResident !== null && typeof oIsNonUSResident !== 'undefined') {    
                return oIsNonUSResident;  
            } else { return null; }
        },
        
        _getIsNonUSResident: function () {
            if (this._getIsNonUSResidentCheckbox() !== null) {
                return this._getIsNonUSResidentCheckbox().checked;
            } else { return true; }
        },
        
        _getUserID: function ()
        {
            return _oUtility.getElementByTagNameAndID('hdnUserID','INPUT').value;
        },

    
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: disableAccount
            Summary		: Disables the user account.
            Author		: Dale Lawless
            Create Date	: 01/17/2007
        ====================================================================================*/
        disableAccount: function ()
        {   
            var bDisableAccount = false;
            var iUserID = 0; 
            var oStatus = null;
            
            try {
                // Prompt user if they are sure to remove preferred agent
                bDisableAccount = confirm(NRT.MySite.Validation.MESSAGE_MYACCOUNT_DISABLE);
                if (bDisableAccount === true) {
                    // Disable the user account
                    iUserID = this._getUserID();
                    oStatus = MySiteProvider.DisableAccount(_WebsiteID, iUserID);
                    if (oStatus.value === 3) {      //AccountStatus - Disabled
                        NRT.MySite.Authentication.logout();
                        NRT.MySite.UI.redirectToHomePage();
                    }
                }
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.removePreferAgent', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
                
        /*==================================================================================
            Method		: removePreferredAgent
            Summary		: Removes the preferred agent assigned to the user account.
            Author		: Dale Lawless
            Create Date	: 01/16/2007
        ====================================================================================*/
        removePreferredAgent: function ()
        {   
            var bRemoveAgent = false; 
            var iUserID = 0;
            var oStatus = null;
            
            try {
                // Prompt user if they are sure to remove preferred agent
                bRemoveAgent = confirm(NRT.MySite.Validation.MESSAGE_MYACCOUNT_REMOVEPREFERAGENT);
                if (bRemoveAgent === true) {
                    // Remove the preferred agent for the user
                    iUserID = this._getUserID();
                    oStatus = MySiteProvider.RemovePreferredAgent(_WebsiteID, iUserID);
                    //AccountStatus - PrefAgentDeleted
                    if (oStatus.value === 2) {
                        // Refresh Page
                        NRT.MySite.UI.redirectToMyAccount();
                    }
                }
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.removePreferAgent', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: removePreferredTeam
            Summary		: Removes the preferred team assigned to the user account.
            Author		: Dale Lawless
            Create Date	: 10/27/2007
        ====================================================================================*/
        removePreferredTeam: function ()
        {   
            var bRemoveTeam = false; 
            var iUserID = 0;
            var oStatus = null;
            
            try {
                // Prompt user if they are sure to remove preferred agent
                bRemoveTeam = confirm(NRT.MySite.Validation.MESSAGE_MYACCOUNT_REMOVEPREFERTEAM);
                if (bRemoveTeam === true) {
                    // Remove the preferred agent for the user
                    iUserID = this._getUserID();
                    oStatus = MySiteProvider.RemovePreferredTeam(_WebsiteID, iUserID);
                    //AccountStatus - PrefTeamDeleted
                    if (oStatus.value === 6) {
                        // Refresh Page
                        NRT.MySite.UI.redirectToMyAccount();
                    }
                }
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.removePreferAgent', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
                          
        /*==================================================================================
            Method		: updateUser
            Summary		: Updates the user account information.
            Author		: Dale lawless
            Create Date	: 01/16/2007
        ====================================================================================*/
        updateUser: function ()
        {    
            var UserID = this._getUserID();
            var EmailAddress = this._getEmailAddress();
            var FirstName = this._getFirstName(); 
            var LastName = this._getLastName();
            var Password = this._getPassword(); 
            var PreferredAgentID = 0; 
            var PreferredTeamID = 0; 
            var RememberMe = this._getRememberMe();
            var IsBuyerWatch = false;
                      
            try {
                // Clear message text
                document.getElementById('spnMessage').innerHTML = '';
                
                // Validate controls
                if (!this.validate()) {
                    return;
                }
                
                // Check if the user has previously removed their preferred agent.
                if (this._getPreferredAgentID() !== '') {
                    PreferredAgentID = this._getPreferredAgentID();
                }
                if (this._getPreferredTeamID() !== '') {
                    PreferredTeamID = this._getPreferredTeamID();
                } 
                                               
                MySiteProvider.UpdateUser_v1(_WebsiteID, UserID, FirstName, LastName, EmailAddress, Password, PreferredAgentID, PreferredTeamID, RememberMe, IsBuyerWatch, this._updateUser_Callback);
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.updateUser', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: updateUserExtended
            Summary		: Updates the user account information.
            Author		: Uma Chandrasekar
            Create Date	: 05/31/2007
        ====================================================================================*/				 							
        updateUserExtended: function () 
        {
            var UserID = this._getUserID();;
            var Email = this._getEmailAddress();								
            var FirstName = this._getFirstName();						
            var LastName = this._getLastName();	
            var Address = this._getAddress();	
            var City = this._getCity();
            var State = this._getState();	
            var ZipCode = this._getZipCode();
            var IsNonUSResident = this._getIsNonUSResident();
            var DaytimePhone = this._getDaytimePhone();	
            var EveningPhone = this._getEveningPhone();
            var ContactPhone = this._getContactPhone();
            var Password = this._getPassword();		
            var PreferredAgentID = 0;
            var PreferredTeamID = 0;			
            var RememberMe = this._getRememberMe();	
            var IsBuyerWatch = false;
            var AreasOfInterest = '';
            var allInputs = null;
            var x = 0;
            
            try {
                // Clear message text
                document.getElementById('spnMessage').innerHTML = '';
                
                // Validate controls
				if (!this.validate()) {
					return;
				}
                
                allInputs = _oUtility.getElementsByTagNameAndID('chkAreasOfInterest','INPUT');
                
                for (x = 0; x < allInputs.length; x += 1) {
                    // Make sure it's a checkbox box
                    if (allInputs[x].type === 'checkbox') {
                        // Make sure it was checked
                        if (allInputs[x].checked === true) {
                            AreasOfInterest += allInputs[x].value + ',';
                        }
                    }
                }
                                    
                // Check if the user has previously removed their preferred agent.
                if (this._getPreferredAgentID() !== '') {
                    PreferredAgentID = this._getPreferredAgentID();
                }
                if (this._getPreferredTeamID() !== '') {
                    PreferredTeamID = this._getPreferredTeamID();
                } 
                                
                //Note: Both UpdateUser and UpdateUserExtended calls the same _updateUser_Callback and it is perfectly okay!
                MySiteProvider.UpdateUserExtended_v2(_WebsiteID, UserID, FirstName, LastName, Email, Address, City, State, ZipCode, IsNonUSResident, DaytimePhone, EveningPhone, Password, PreferredAgentID, PreferredTeamID, RememberMe, IsBuyerWatch, AreasOfInterest, ContactPhone, this._updateUser_Callback);			                
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.updateUserExtended', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: validate
            Summary		: Validates the data entry on the my account tab.
            Author		: Dale Lawless
            Create Date	: 01/16/2007
        ====================================================================================*/
        validate: function ()
        {   
            var bReturn = true;
            var oDivEmailErrMessage = null;
            var oDivFirstNameErrMessage = null;
            var oDivLastNameErrMessage = null;
            var oDivAddressErrMessage = null;
            var oDivCityErrMessage = null;
            var oDivZipCodeErrMessage = null;
            var oDivDaytimePhoneErrMessage = null;
            var oDivEveningPhoneErrMessage = null;
            var oDivContactPhoneErrMessage = null;
            var oDivPasswordErrMessage = null; 
            var oDivPasswordConfirmErrMessage = null;            
            
            try {
                // Email - Always Required
                if (this._getEmailAddressTextbox() !== null && typeof this._getEmailAddressTextbox() !== 'undefined') {          
                    oDivEmailErrMessage = eval(document.getElementById('divEmailErrMessage'));
                    if (oDivEmailErrMessage !== null && typeof oDivLastNameErrMessage !== 'undefined') {                                
                        if (!this._getEmailAddress()) {
                            oDivEmailErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_EMAIL_REQUIRED;
                            oDivEmailErrMessage.style.display = 'block';
                            bReturn =  false;
                        } else if (!NRT.MySite.Validation.Utility.validEmail(this._getEmailAddress())) {
                            oDivEmailErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_EMAIL_INVALID;
                            oDivEmailErrMessage.style.display = 'block';
                            bReturn =  false;
                        } else {
                            oDivEmailErrMessage.innerHTML = '';
                            oDivEmailErrMessage.style.display = 'none';
                        }
                    }                              
                }
                
                // First Name - Always Required
                if (this._getFirstNameTextbox() !== null && typeof this._getFirstNameTextbox() !== 'undefined') {          
                    oDivFirstNameErrMessage = eval(document.getElementById('divFirstNameErrMessage'));
                    if (oDivFirstNameErrMessage !== null && typeof oDivFirstNameErrMessage !== 'undefined') {                
                        if (!this._getFirstName()) {
                            oDivFirstNameErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_FIRSTNAME_REQUIRED;
                            oDivFirstNameErrMessage.style.display = 'block';
                            bReturn =  false;
                        } else {
                            oDivFirstNameErrMessage.innerHTML = '';
                            oDivFirstNameErrMessage.style.display = 'none';
                        }
                    }
                }

                // Last Name - Always Required
                if (this._getLastNameTextbox() !== null && typeof this._getLastNameTextbox() !== 'undefined') {                          
                    oDivLastNameErrMessage = eval(document.getElementById('divLastNameErrMessage'));
                    if (oDivLastNameErrMessage !== null && typeof oDivLastNameErrMessage !== 'undefined') {
                        if (!this._getLastName()) {
                            oDivLastNameErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_LASTNAME_REQUIRED;
                            oDivLastNameErrMessage.style.display = 'block';
                            bReturn =  false;
                        } else {
                            oDivFirstNameErrMessage.innerHTML = '';
                            oDivFirstNameErrMessage.style.display = 'none';
                        }                    
                    }                                
                }

                // Address - Required if shown
                if (this._getAddressTextbox() !== null && typeof this._getAddressTextbox() !== 'undefined') { 
                    if (this._getAddressTextbox().style.visibility !== "hidden" || this._getAddressTextbox().style.display  !== "none" || this._getAddressTextbox().disabled !== true) {
                        oDivAddressErrMessage = eval(document.getElementById('divAddressErrMessage'));
                        if (oDivAddressErrMessage !== null && typeof oDivAddressErrMessage !== 'undefined') {
                            if (!this._getAddress()) {
                                oDivAddressErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_ADDRESS_REQUIRED;
                                oDivAddressErrMessage.style.display = 'block';
                                bReturn =  false;
                            } else {
                                oDivAddressErrMessage.innerHTML = '';
                                oDivAddressErrMessage.style.display = 'none';
                            }                    
                        }                                
                    }
                }

                // City - Required if shown
                if (this._getCityTextbox() !== null && typeof this._getCityTextbox() !== 'undefined') { 
                    if (this._getCityTextbox().style.visibility !== "hidden" || this._getCityTextbox().style.display  !== "none" || this._getCityTextbox().disabled !== true) {
                        oDivCityErrMessage = eval(document.getElementById('divCityErrMessage'));
                        if (oDivCityErrMessage !== null && typeof oDivCityErrMessage !== 'undefined') {
                            if (!this._getCity()) {
                                oDivCityErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_CITY_REQUIRED;
                                oDivCityErrMessage.style.display = 'block';
                                bReturn =  false;
                            } else {
                                oDivCityErrMessage.innerHTML = '';
                                oDivCityErrMessage.style.display = 'none';
                            }                    
                        }                                
                    }
                }
                                
                // Zip Code - Required if shown
                if (this._getZipCodeTextbox() !== null && typeof this._getZipCodeTextbox() !== 'undefined') { 
                    if (this._getZipCodeTextbox().style.visibility !== "hidden" || this._getZipCodeTextbox().style.display  !== "none" || this._getZipCodeTextbox().disabled !== true) {
                        // Make sure the Reside Outside US check box isn't checked - if shown
                        if (this._getIsNonUSResidentCheckbox() !== null && typeof this._getIsNonUSResidentCheckbox() !== 'undefined') { 
                            if (this._getIsNonUSResidentCheckbox().style.visibility !== "hidden" || this._getIsNonUSResidentCheckbox().style.display  !== "none" || this._getIsNonUSResidentCheckbox().disabled !== true) {
                                if (!this._getIsNonUSResident()) {
                                     oDivZipCodeErrMessage = eval(document.getElementById('divZipCodeErrMessage'));
                                    if (!this._getZipCode()) {
                                        oDivZipCodeErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_ZIPCODE_OR_ZIP_CHECKBOX_REQUIRED;
                                        oDivZipCodeErrMessage.style.display = 'block';
                                        bReturn =  false;
                                    } else if (!NRT.MySite.Validation.Utility.validZipCode(this._getZipCode())) {
                                        oDivZipCodeErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_ZIPCODE_INVALID;
                                        oDivZipCodeErrMessage.style.display = 'block';
                                        bReturn =  false;
                                    } else {
                                        oDivZipCodeErrMessage.innerHTML = '';
                                        oDivZipCodeErrMessage.style.display = 'none';
                                    }
                                }
                            }
                        } else { // Zipcode Required - ResideOutsideUS checkbox is not shown
                            oDivZipCodeErrMessage = eval(document.getElementById('divZipCodeErrMessage'));
                            if (!this._getZipCode()) {
                                oDivZipCodeErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_ZIPCODE_REQUIRED;
                                oDivZipCodeErrMessage.style.display = 'block';
                                bReturn =  false;
                            } else if (!NRT.MySite.Validation.Utility.validZipCode(this._getZipCode())) {
                                oDivZipCodeErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_ZIPCODE_INVALID;
                                oDivZipCodeErrMessage.style.display = 'block';
                                bReturn =  false;
                            } else {
                                oDivZipCodeErrMessage.innerHTML = '';
                                oDivZipCodeErrMessage.style.display = 'none';
                            }                        
                        }
                    }                
                }

                // DaytimePhone - Check format if something was entered
                if (this._getDaytimePhoneTextbox() !== null && typeof this._getDaytimePhoneTextbox() !== 'undefined') { 
                    if (this._getDaytimePhoneTextbox().style.visibility !== "hidden" || this._getDaytimePhoneTextbox().style.display  !== "none" || this._getDaytimePhoneTextbox().disabled !== true) {
                        if (this._getDaytimePhone() !== '') { // something was entered
                            oDivDaytimePhoneErrMessage = eval(document.getElementById('divDaytimePhoneErrMessage'));
                            if (oDivDaytimePhoneErrMessage !== null && typeof oDivDaytimePhoneErrMessage !== 'undefined') {
                                if (!NRT.MySite.Validation.Utility.validPhoneNumber(this._getDaytimePhone())) {
                                    oDivDaytimePhoneErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PHONENUMBER_INVALID;
                                    oDivDaytimePhoneErrMessage.style.display = 'block';
                                    bReturn =  false;
                                } else {
                                    oDivDaytimePhoneErrMessage.innerHTML = '';
                                    oDivDaytimePhoneErrMessage.style.display = 'none';
                                }                    
                            }                         
                        }                               
                    }
                }
                
                // EveningPhone - Check format if something was entered
                if (this._getEveningPhoneTextbox() !== null && typeof this._getEveningPhoneTextbox() !== 'undefined') { 
                    if (this._getEveningPhoneTextbox().style.visibility !== "hidden" || this._getEveningPhoneTextbox().style.display  !== "none" || this._getEveningPhoneTextbox().disabled !== true) {
                        if (this._getEveningPhone() !== '') { // something was entered
                            oDivEveningPhoneErrMessage = eval(document.getElementById('divEveningPhoneErrMessage'));
                            if (oDivEveningPhoneErrMessage !== null && typeof oDivEveningPhoneErrMessage !== 'undefined') {
                                if (!NRT.MySite.Validation.Utility.validPhoneNumber(this._getEveningPhone())) {
                                    oDivEveningPhoneErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PHONENUMBER_INVALID;
                                    oDivEveningPhoneErrMessage.style.display = 'block';
                                    bReturn =  false;
                                } else {
                                    oDivEveningPhoneErrMessage.innerHTML = '';
                                    oDivEveningPhoneErrMessage.style.display = 'none';
                                }                    
                            }                        
                        }                                
                    }
                }

                // ContactPhone - Check format if something was entered
                if (this._getContactPhoneTextbox() !== null && typeof this._getContactPhoneTextbox() !== 'undefined') { 
                    if (this._getContactPhoneTextbox().style.visibility !== "hidden" || this._getContactPhoneTextbox().style.display  !== "none" || this._getEveningPhoneTextbox().disabled !== true) {
                        if (this._getContactPhone() !== '') { // something was entered
                            oDivContactPhoneErrMessage = eval(document.getElementById('divContactPhoneErrMessage'));
                            if (oDivContactPhoneErrMessage !== null && typeof oDivContactPhoneErrMessage !== 'undefined') {
                                if (!NRT.MySite.Validation.Utility.validPhoneNumber(this._getContactPhone())) {
                                    oDivContactPhoneErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PHONENUMBER_INVALID;
                                    oDivContactPhoneErrMessage.style.display = 'block';
                                    bReturn =  false;
                                } else {
                                    oDivContactPhoneErrMessage.innerHTML = '';
                                    oDivContactPhoneErrMessage.style.display = 'none';
                                }                    
                            }                        
                        }                                
                    }
                }

                // Password - Always Required
                if (this._getPasswordTextbox() !== null && typeof this._getPasswordTextbox() !== 'undefined') {
                    oDivPasswordErrMessage = eval(document.getElementById('divPasswordErrMessage'));
                    if (!this._getPassword()) {
                        oDivPasswordErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PASSWORD_REQUIRED;
                        oDivPasswordErrMessage.style.display = 'block';
                        bReturn =  false;
                    } else if (!NRT.MySite.Validation.Utility.validPassword(this._getPassword())) {
                        oDivPasswordErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PASSWORD_INVALID;
                        oDivPasswordErrMessage.style.display = 'block';
                        bReturn =  false;
                    } else {
                        oDivPasswordErrMessage.innerHTML = '';
                        oDivPasswordErrMessage.style.display = 'none';
                    }
                }
                
                // Password Confirmation - Always Required
                if (this._getPasswordConfirmTextbox() !== null && typeof this._getPasswordConfirmTextbox() !== 'undefined') {
                    oDivPasswordConfirmErrMessage = eval(document.getElementById('divPasswordConfirmErrMessage'));					
                    if (!this._getPasswordConfirm()) {
                        oDivPasswordConfirmErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PASSWORDCONFIRM_REQUIRED;
                        oDivPasswordConfirmErrMessage.style.display = 'block';
                        bReturn =  false;
                    } else if (this._getPassword() !== this._getPasswordConfirm()) {
                        oDivPasswordConfirmErrMessage.innerHTML = NRT.MySite.Validation.MESSAGE_PASSWORDCONFIRM_NOMATCH;
                        oDivPasswordConfirmErrMessage.style.display = 'block';
                        bReturn =  false;
                    } else {
                        oDivPasswordConfirmErrMessage.innerHTML = '';
                        oDivPasswordConfirmErrMessage.style.display = 'none';
                    }
                }
                
                return bReturn;
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount.validate', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /******************************************************************************************************************
        *									A J A X   M E T H O D S
        *******************************************************************************************************************/				
        /*==================================================================================
            Method		: _updateUser_Callback
            Summary		: Ajax call back from the update user account method.
            Author		: Dale Lawless
            Create Date	: 01/16/2007
        ====================================================================================*/
        _updateUser_Callback: function (response)
        {   
            var oAccountInfo = null;
            var sCookie = null;
            var sPrefillEmail = null;
            
            try {
                if (response.error !== null) {
                    _oErrorHandler.ResponseError('NRT.MySite.MyAccount._updateUser_Callback',response);
                    return; 
                } else {
                    if (response !== null && response.value !== null) {
                        oAccountInfo = response.value.split(',');
                        if (oAccountInfo.length > 0) {
                            if (oAccountInfo[0] === 'Success') {
                                // Create Cookie  
                                sCookie = oAccountInfo[1] + '~' + oAccountInfo[2] + '~' + oAccountInfo[3];
                                if (oAccountInfo[3] === 'True') {
                                    NRT.MySite.Authentication.createCookie(sCookie, _CookieExpireDays, null);
                                }
                            
                                // Create MySite Email Cookie for prefilling the email address
                                sPrefillEmail = oAccountInfo[4];
                                if (sPrefillEmail === null || typeof sPrefillEmail === 'undefined') {
                                    sPrefillEmail = '';
                                }
                                NRT.MySite.Authentication.createEmailCookie(sPrefillEmail, _CookieExpireDays);

                                // Show Success Message
                                _oUtility.showMessage(NRT.MySite.Validation.MESSAGE_MYACCOUNT_SAVESUCCESSFULL);
                               
                               // Refresh Page
                               NRT.MySite.UI.redirectToMyAccount();
                            } else {
                                // Update failed
                                _oUtility.showMessage(NRT.MySite.Validation.MESSAGE_MYACCOUNT_SAVEFAILED);
                            }
                        }
                    }
                }
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.MyAccount._updateUser_Callback', _oErrorHandler.ERRORTYPE_AJAX, err);
            }
        }
    };
}();/* ##########################################################################################################################

    Namespace : NRT.Property.Search
    Classes   : TabCaptions
    Summary	  : This file contains a series of properties and methods for all of the MySite tab captions.
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		Description
    -------------------------------------------------------------------------------------------------------------------------
    11/29/2006	dlawless	Initial Creation

###########################################################################################################################*/
NRT.MySite.TabCaptions = function ()
{
    var _tabCaptions = [];
    var _defaultTab = null;

    return {
        /*******************************************************************************************************************
        *									P U B L I C   P R O P E R T I E S
        *******************************************************************************************************************/
        /*==================================================================================
            Property	: getTabCaptions
            Summary		: Returns the tab caption array.
            Author		: Dale Lawless
            Create Date	: 11/27/2006
        ====================================================================================*/
        getTabCaptions: function() 
        {
            return _tabCaptions;
        },

        /*==================================================================================
            Property	: setTabCaptions
            Summary		: Sets the array of tab captions.
            Author		: Dale Lawless
            Create Date	: 11/27/2006
        ====================================================================================*/
        setTabCaptions: function(value)
        {	
            _tabCaptions = value;	
        },
        
        /*==================================================================================
            Property	: getDefaultTab
            Summary		: Returns the default tab id.
            Author		: Dale Lawless
            Create Date	: 11/29/2006
        ====================================================================================*/
        getDefaultTab: function() 
        {
            return _defaultTab;
        },

        /*==================================================================================
            Property	: setDefaultTab
            Summary		: Sets the default tab id.
            Author		: Dale Lawless
            Create Date	: 11/29/2006
        ====================================================================================*/
        setDefaultTab: function(value)
        {
            _defaultTab = value;
        },
        
        
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: init
            Summary		: Sets the tab caption array and the default tab id.
            Author		: Dale Lawless
            Create Date	: 11/29/2006
        ====================================================================================*/
        init: function () 
        { 
            var aTabs = [];
            
            try
            {
                // Tab Caption | DIV Tag to display | Tab Click Event | * (Default Selected Tab)
                aTabs = 
                [
                    'My&nbsp;Saved&nbsp;Searches|div_MySavedSearches_Tab|NRT.MySite.UI.tabClick(0)|*',
                    'My&nbsp;Saved&nbsp;Properties|div_MySavedProperties_Tab|NRT.MySite.UI.tabClick(1)',
                    'My&nbsp;Account|div_MyAccount_Tab|NRT.MySite.UI.tabClick(2)|*' 
                ];
                this.setTabCaptions(aTabs);
                this.setDefaultTab(0);
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.TabCaptions.init', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        }
    };
}();/* ##########################################################################################################################

    Namespace : NRT.MySite
    Classes   : UI
    Summary	  : Contains all the scripts to handle the entire client side functionality for the
                NRT MySite User-Interface functionality. 
    Copyright : (c) 2006 NRT Inc. All rights reserved.

    RevisionHistory: 
    -------------------------------------------------------------------------------------------------------------------------
    Date		Name		    Description
    -------------------------------------------------------------------------------------------------------------------------
    08/10/2006	Dale Lawless	Initial Creation

###########################################################################################################################*/

NRT.MySite.UI = function ()
{    
    return {
        /*******************************************************************************************************************
        *									P U B L I C   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: clear
            Summary		: Clear the Textbox to allow data entry
            Author		: Dale Lawless
            Create Date	: 08/10/2006
        ====================================================================================*/
        clear: function (element) 
        {
            try
            {
                element.style.display = 'inline';
                element.value = '';
                _oUtility.setFocus(element);
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.clear', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: clearAgentInfo
            Summary		: Clears out the agent information on the calling window.
            Author		: Dale Lawless
            Create Date	: 01/11/2007
        ====================================================================================*/
        clearAgentInfo: function ()
        {    
            var oAgentID = null;
            var oAgentName = null;
            var oDisplayAgent = null;
            var oClearAgent = null;
            var oDisplayAgentParent = null;
            var oDisplayAgentTeamParent = null;
            
            try
            {
                // Agent ID
                oAgentID = _oUtility.getElementByTagNameAndID('hdnAgentID','INPUT');
                if (oAgentID !== null) {
                    oAgentID.value = 0;
                } else {
                    oAgentID = window.opener._oUtility.getElementByTagNameAndID('hdnAgentID','INPUT');
                    if (oAgentID !== null) { oAgentID.value = 0; }
                }
                
                // Agent name
                oAgentName = _oUtility.getElementByTagNameAndID('hdnAgentName','INPUT');
                if (oAgentName !== null) {
                    oAgentName.value = '';
                } else {
                    oAgentName = window.opener._oUtility.getElementByTagNameAndID('hdnAgentName','INPUT');
                    if (oAgentName !== null) { oAgentName.value = ''; }
                }
                    
                // Display Agent
                oDisplayAgent = document.getElementById('spnDisplayAgent');
                if (oDisplayAgent !== null) {
                    oDisplayAgent.innerHTML = '';
                } else {
if (window.opener !== null && typeof window.opener !== 'undefined') {
                    oDisplayAgent = window.opener.document.getElementById('spnDisplayAgent','INPUT');
                    if (oDisplayAgent !== null) { oDisplayAgent.innerHTML = ''; }
}                    
                }
                
// AgentTeamText selector
oSelAgentText = document.getElementById('spnSelectAgentText');
if (oSelAgentText === null && window.opener !== null && typeof window.opener !== 'undefined') {
oSelAgentText = window.opener.document.getElementById('spnSelectAgentText');
}
// AgentTeamText selector
oSelAgentTeamText = document.getElementById('spnSelectAgentTeamText');
if (oSelAgentTeamText === null && window.opener !== null && typeof window.opener !== 'undefined') {
oSelAgentTeamText = window.opener.document.getElementById('spnSelectAgentTeamText');
}

                //Display the parentElement if it is a DIV, do nothing if the parentElement is a PANEL
                oDisplayAgentParent = oSelAgentText.parentElement;
                if (oDisplayAgentParent !== null && typeof oDisplayAgentParent !== 'undefined' )
                {
                    var parentId = oDisplayAgentParent.id;
                    if (parentId.indexOf("_divSelectAgent") > 0)
                    {
                        oDisplayAgentParent.style.display = 'inline';
                    }
                }
                    
                //Display the parentElement if it is a DIV, do nothing if the parentElement is a PANEL
                if (oSelAgentTeamText != null)
                {
                    oDisplayAgentTeamParent = oSelAgentTeamText.parentElement;
                    if (oDisplayAgentTeamParent !== null && typeof oDisplayAgentTeamParent !== 'undefined' )
                    {
                        var parentId = oDisplayAgentTeamParent.id;
                        if (parentId.indexOf("_divSelectAgentTeam") > 0)
                        {
                            oDisplayAgentTeamParent.style.display = 'inline';
                        }
                    }
                 }   
                // Clear Agent
                oClearAgent = document.getElementById('spnClearAgent');
                if (oClearAgent !== null) 
                {
                    oClearAgent.style.display = 'none';
oSelAgentText.style.display = '';
                } else {
if (window.opener !== null && typeof window.opener !== 'undefined') {
                    oClearAgent = window.opener.document.getElementById('spnClearAgent','INPUT');
                    if (oClearAgent !== null) { 
                        oClearAgent.style.display = 'none'; 
oSelAgentText.style.display = '';
                    }
}
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.clearAgentInfo', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: clearTeamInfo
            Summary		: Clears out the team information on the calling window.
            Author		: Dale Lawless
            Create Date	: 10/26/2007
        ====================================================================================*/
        clearTeamInfo: function ()
        {    
            var oTeamID = null;
            var oTeamName = null;
            var oDisplayTeam = null;
            var oClearTeam = null;
            
            try
            {
                // Team ID
                oTeamID = _oUtility.getElementByTagNameAndID('hdnTeamID','INPUT');
                if (oTeamID !== null) {
                    oTeamID.value = 0;
                } else {
                    oTeamID = window.opener._oUtility.getElementByTagNameAndID('hdnTeamID','INPUT');
                    if (oTeamID !== null) { oTeamID.value = 0; }
                }
                
                // Team name
                oTeamName = _oUtility.getElementByTagNameAndID('hdnTeamName','INPUT');
                if (oTeamName !== null) {
                    oTeamName.value = '';
                } else {
                    oTeamName = window.opener._oUtility.getElementByTagNameAndID('hdnTeamName','INPUT');
                    if (oTeamName !== null) { oTeamName.value = ''; }
                }
                    
                // Display Team
                oDisplayTeam = document.getElementById('spnDisplayTeam','INPUT');
                if (oDisplayTeam !== null) {
                    oDisplayTeam.innerHTML = '';
                } else {
if (window.opener !== null && typeof window.opener !== 'undefined') {
                    oDisplayTeam = window.opener.document.getElementById('spnDisplayTeam','INPUT');
                    if (oDisplayTeam !== null) { oDisplayTeam.innerHTML = ''; }
}
                }
                
// AgentTeamText selector
oSelAgentText = document.getElementById('spnSelectAgentText');
if (oSelAgentText === null && window.opener !== null && typeof window.opener !== 'undefined') {
oSelAgentText = window.opener.document.getElementById('spnSelectAgentText');
}

                // Clear Team
                oClearTeam = document.getElementById('spnClearTeam');
                if (oClearTeam !== null) 
                {
                    oClearTeam.style.display = 'none';
oSelAgentText.style.display = '';
                } else {
if (window.opener !== null && typeof window.opener !== 'undefined') {
                    oClearTeam = window.opener.document.getElementById('spnClearTeam','INPUT');
                    if (oClearTeam !== null) { 
                        oClearTeam.style.display = 'none'; 
oSelAgentText.style.display = '';
                    }
}
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.clearTeamInfo', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },        
    
        /*==================================================================================
            Method		: getSelectedCheckBoxes
            Summary		: Returns an array of all selected check boxes.
            Author		: Dale Lawless
            Create Date	: 01/05/2007
        ====================================================================================*/
        getSelectedCheckBoxes: function (checkboxName)
        {   
            var aSelectedCheckBoxes = [];
            var allInputs = null; 
            var x = 0;
            
            try
            {		
                allInputs = _oUtility.getElementsByTagNameAndID(checkboxName,'INPUT');
                
                // Set all check boxes to disabled
                for (x = 0; x < allInputs.length; x += 1)
                {
                    // Make sure it's a checkbox box
                    if (allInputs[x].type === 'checkbox')
                    {
                        // Make sure it was checked
                        if (allInputs[x].checked === true) 
                        {
                            // Add the checkbox to the array
                            aSelectedCheckBoxes.push(allInputs[x]);
                        }
                    }
                }
                return aSelectedCheckBoxes;
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.getSelectedCheckBoxes', _oErrorHandler.ERRORTYPE_JS, err);
            }			
        },

        /*==================================================================================
            Method		: initialize
            Summary		: Initialization script to set variables throughout MySite user-interface.
            Author		: Dale Lawless
            Create Date	: 02/06/2007
        ====================================================================================*/
        initialize: function (Settings)
        {    
            var sArray = null;
            
            try
            {
                // Set MySite Configuration Settings
                sArray = Settings.split("|");
                    
                if (sArray.length > 0)	   			
            {
                    // Sets the MySite javascript variables from Config settings 
                    _WebsiteID = sArray[0];
                    _MetroMySiteName = sArray[1];
                    _CookieExpireDays = sArray[2];	
                    _CookieLoginExpireMin = sArray[3];
                    _MaxSavedProperties = sArray[4];
                    _MaxSavedSearches = sArray[5];
                    _SavedSearchXSLTPath = sArray[6];
                    _SavedSearchDetailsXSLTPath = sArray[7];
                    _ShowGlobalAlerts = sArray[8];
                    _ShowEmailAlerts = sArray[9];
                    _ShowFreq = sArray[10];
                    _ShowAdditionalEmail = sArray[11];
                    _ShowSendToAgent = sArray[12];
                    _AllowDisableAccount = sArray[13];	
                    _EmailFrom = sArray[14];
                    _AltEmailTo = sArray[15];	
                    _AgentLinkURL = sArray[16];
                    _WebsiteHasTeams = sArray[17];
            }
                                
            // Prefill Email Address on Login Window
            if (NRT.MySite.UI.pageIsMySiteLogin())		
            {
                NRT.MySite.Login.prefillEmailAddress();
            }
                
            // Prefill Email Address on Authentication Panel
            if (NRT.MySite.UI.pageIsPropertySearch() || NRT.MySite.UI.pageIsPropertyResults() || NRT.MySite.UI.pageIsPropertyDetails() )
            {
                NRT.MySite.Authentication.prefillEmailAddress();
            }
                
            // Set Forms Authentication Cookie for pages that fetch the consumer id
            NRT.MySite.Authentication.setFormsAuthCookie();	  
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.initialize', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                
        /*==================================================================================
            Method		: initTab
            Summary		: Initializes the tab on my saved home page when it is first loaded.
            Author		: Dale Lawless
            Create Date	: 12/06/2006
        ====================================================================================*/
        initTab: function () 
        {   
            var aTabs = null;
            
            try
            {
                NRT.MySite.TabCaptions.init();
                aTabs = NRT.MySite.TabCaptions.getTabCaptions();
                if (aTabs !== null)
                {
                    _oTab.setTabs(aTabs);
                    _oTab.setTabAlign('LEFT');
                    _oTab.load();
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.initTab', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: pageIsMySiteHome
            Summary		: Determines if the current page is the login page.
            Author		: Dale Lawless
            Create Date	: 01/26/2007
        ====================================================================================*/
        pageIsMySiteHome: function () 
        {   
            var sSearchString  = ''; 
            var sPageName = '';
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/MYSITEHOME.ASPX/);
                if (sPageName > 0) 
                {
                    return true;  
                } else {
                    return false;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsMySiteHome', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: pageIsMySiteLogin
            Summary		: Determines if the current page is the login page.
            Author		: Dale Lawless
            Create Date	: 01/26/2007
        ====================================================================================*/
        pageIsMySiteLogin: function () 
        {   
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/MYSITELOGIN.ASPX/);
                if (sPageName > 0)
                {
                    return true; 
                } else {
                    return false;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsMySiteLogin', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: pageIsMySiteMain
            Summary		: Determines if the current page is the mysite main page.
            Author		: Dale Lawless
            Create Date	: 02/17/2007
        ====================================================================================*/
        pageIsMySiteMain: function () 
        {    
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/MYSITEMAIN.ASPX/);
                if (sPageName > 0)
                {
                    return true;   
                } else {
                    return false; 
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsMySiteMain', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: pageIsMySiteRegister
            Summary		: Determines if the current page is the register page.
            Author		: Dale Lawless
            Create Date	: 11/08/2007
        ====================================================================================*/
        pageIsMySiteRegister: function () 
        {   
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/MYSITEREGISTER.ASPX/);
                if (sPageName > 0)
                {
                    return true; 
                } else {
                    return false;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsMySiteRegister', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: pageIsPropertyDetails
            Summary		: Determines if the current page is the Property Details page.
            Author		: Dale Lawless
            Create Date	: 01/26/2007
        ====================================================================================*/
        pageIsPropertyDetails: function () 
        {   
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/PROPERTYDETAILS.ASPX/);
                if (sPageName > 0) 
                {
                    return true;  
                } else {
                    return false; 
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsPropertyDetails', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: pageIsPropertySearch
            Summary		: Determines if the current page is the Property Search page.
            Author		: Dale Lawless
            Create Date	: 01/26/2007
        ====================================================================================*/
        pageIsPropertySearch: function () 
        {  
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/PROPERTYSEARCH.ASPX/);
                if (sPageName > 0)
                {
                    return true;  
                } else {
                    return false; 
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsPropertySearch', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: pageHasAuthentication
            Summary		: Determines if the current page contains an authentication panel.
            Author		: Dale Lawless
            Create Date	: 10/30/2007
        ====================================================================================*/
        pageHasAuthentication: function () 
        {   
            var oDivAuthSavedSearchLogin = document.getElementById('divAuthSavedSearchLogin');

            try {
                if (oDivAuthSavedSearchLogin !== null && typeof oDivAuthSavedSearchLogin !== 'undefined') {
                    if (oDivAuthSavedSearchLogin.style.visibility !== "hidden" || oDivAuthSavedSearchLogin.style.display  !== "none" || oDivAuthSavedSearchLogin.disabled !== true) {
                        return true;
                    } else {
                        return false;  
                    }                        
                }
            } catch(err) {
                _oErrorHandler.Error('NRT.MySite.UI.pageHasAuthentication', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                
        /*==================================================================================
            Method		: pageIsHomePage
            Summary		: Determines if the current page is the Property Search page.
            Author		: Uma Chandrasekar
            Create Date	: 03/13/2007
        ====================================================================================*/
        pageIsHomePage: function () 
        {   
            var sSearchString  = ''; 
            var sPageName = '';    

            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                if (sSearchString.search(/.ASPX/)<=0)
                {
                    sPageName = 1
                } else {
                    sPageName = sSearchString.search(/DEFAULT.ASPX/);
                }
                    
                if (sPageName > 0)
                {
                    return true;
                } else {
                    return false;  
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsHomePage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: pageIsPropertyResults
            Summary		: Determines if the current page is the Property Results page.
            Author		: Dale Lawless
            Create Date	: 01/26/2007
        ====================================================================================*/
        pageIsPropertyResults: function () 
        {  
            var sSearchString  = ''; 
            var sPageName = '';    
            
            try
            {
                sSearchString = window.location.pathname.toUpperCase();
                sPageName = sSearchString.search(/PROPERTYRESULTS.ASPX/);
                if (sPageName > 0) 
                {
                    return true;
                } else {
                    return false;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.pageIsPropertyResults', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        

        /*==================================================================================
            Method		: redirectToHomePage
            Summary		: Redirect the user to the home page.
            Author		: Dale Lawless
            Create Date	: 01/17/2007
        ====================================================================================*/
        redirectToHomePage: function () 
        {
            try
            {
                window.location = _oUtility.getAppPath() + _HomePageURL;
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToHomePage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: redirectToLoginPage
            Summary		: Redirect the user to the login page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToLoginPage: function (tabID) 
        {
            try
            
            {
     //           var qs = window.location.search;  NO NO NO YOU ADD BRANDING 2 with this
                if (_LoginPageURL.lastIndexOf('?') > -1) {
         //            qs = qs.replace("?","&");                 
                 window.location = _oUtility.getAppPath() + _LoginPageURL;// + qs;
                } else {
                    window.location = _oUtility.getAppPath() + _LoginPageURL;// + qs;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToLoginPage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: redirectToMyAccount
            Summary		: Redirect the user to the My Account page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToMyAccount: function () 
        {
            try
            {
                if (NRT.MySite.UI.pageIsMySiteHome())
                {
                    NRT.MySite.UI.tabClick(2);
                } else {
                    var qs = window.location.search; 
                    qs = qs.toLowerCase();

                    if ( (_WebsiteID === '10') &&  (qs.lastIndexOf('ab=1&agentid=') > -1) )
                    {
                        var newURL = qs.replace("tab=0","");
                        if (_MyAccountURL.lastIndexOf('?') > -1)
                        {
                            newURL = newURL.replace("?","&");
                            newURL = newURL.replace("&&","&");                            
                        }
                        newURL = newURL.replace("?&","?");
                        var compareURL = _MyAccountURL.toLowerCase();
                        if (compareURL.lastIndexOf('&ab=1&agentid=') > -1)
                        {
                            window.location = _oUtility.getAppPath() + _MyAccountURL;
                        } else {
                            window.location = _oUtility.getAppPath() + _MyAccountURL + newURL;                        
                        }                        
                    } else {
                        window.location = _oUtility.getAppPath() + _MyAccountURL;
                    }                    
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToMyAccount', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                        
        /*==================================================================================
            Method		: redirectToMySavedProperties
            Summary		: Redirect the user to the My Saved Properties page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToMySavedProperties: function () 
        {
            try
            {
                if (NRT.MySite.UI.pageIsMySiteHome())
                {
                    NRT.MySite.UI.tabClick(1);
                } else {
                    if (!NRT.MySite.UI.pageIsHomePage())
                    {
                        Progress.fn.show('',true,'Loading Saved Properties');
                    }
                    
                    var qs = window.location.search; 
                    qs = qs.toLowerCase();

                    if ( (_WebsiteID === '10') &&  (qs.lastIndexOf('ab=1&agentid=') > -1) )
                    {
                        var newURL = qs.replace("tab=0","");
                        if (_MySavedPropertiesURL.lastIndexOf('?') > -1)
                        {
                            newURL = newURL.replace("?","&");
                            newURL = newURL.replace("&&","&");                            
                        }
                        newURL = newURL.replace("?&","?");           
                        var compareURL = _MySavedPropertiesURL.toLowerCase();
                        if (compareURL.lastIndexOf('&ab=1&agentid=') > -1)
                        {
                            window.location = _oUtility.getAppPath() + _MySavedPropertiesURL;
                        } else {
                            window.location = _oUtility.getAppPath() + _MySavedPropertiesURL + newURL;                        
                        }                                                             
                    } else {
                        window.location = _oUtility.getAppPath() + _MySavedPropertiesURL;
                    }                    
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToMySavedProperties', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
        
        /*==================================================================================
            Method		: redirectToMySavedSearches
            Summary		: Redirect the user to the My Saved Searches page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToMySavedSearches: function () 
        {
            try
            {
                if (NRT.MySite.UI.pageIsMySiteHome())
                {
                    NRT.MySite.UI.tabClick(0);
                } else {
                    if (!NRT.MySite.UI.pageIsHomePage())
                    {
                        Progress.fn.show('',true,'Loading Saved Searches');
                    }
                    
                    var qs = window.location.search; 
                    qs = qs.toLowerCase();

                    if ( (_WebsiteID === '10') &&  (qs.lastIndexOf('ab=1&agentid=') > -1) )
                    {
                        var newURL = qs.replace("tab=0","");
                        if (_MySavedSearchesURL.lastIndexOf('?') > -1)
                        {
                            newURL = newURL.replace("?","&");
                            newURL = newURL.replace("&&","&");                            
                        }
                        newURL = newURL.replace("?&","?");                        
                        var compareURL = _MySavedSearchesURL.toLowerCase();
                        if (compareURL.lastIndexOf('&ab=1&agentid=') > -1)
                        {
                            window.location = _oUtility.getAppPath() + _MySavedSearchesURL;
                        } else {
                            window.location = _oUtility.getAppPath() + _MySavedSearchesURL + newURL;                        
                        }                                                                            
                    } else {
                        window.location = _oUtility.getAppPath() + _MySavedSearchesURL;
                    }                    
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToMySavedSearches', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /*==================================================================================
            Method		: redirectToRegistrationPage
            Summary		: Redirect the user to the registration page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToRegistrationPage: function () 
        {
            try
            {
                // See if we required user to log in first to view property details
                if (NRT.Utility.getQueryStringParam('RedirectURL') !== null)
                {
                    window.location = _oUtility.getAppPath() + _RegisterPageURL + '?RedirectURL=' + _oUtility.decodeURL(NRT.Utility.getQueryStringParam('RedirectURL'));
                }
                else
                {
                    window.location = _oUtility.getAppPath() + _RegisterPageURL;// + window.location.search;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToRegistrationPage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
    
        /*==================================================================================
            Method		: redirectToPropertyResultsPage
            Summary		: Redirect the user to the property results page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToPropertyResultsPage: function (ConsumerSearchID,SearchOptionID) 
        {  
            var DTSince = null;
            var dtToday = null;
            var dtMonth = null;
            var dtDay = null;
            var dtYear = null;
            var iConsumerId = 0;
            var oLastLoginDate  = null; 
            var sURL = '';
            
            try
            {
                switch (SearchOptionID)
                {
                    case 0:
                        // All Matches
                        DTSince = null;
                        break;
                    case 1:
                        // Today's matches
                        dtToday = new Date();
                        dtMonth = dtToday.getMonth() + 1;
                        dtDay = dtToday.getDate();
                        dtYear = dtToday.getFullYear();
                        DTSince = dtMonth + '/' + dtDay + '/' + dtYear;
                        break;
                    case 2:
                        // Since Last Login
                        //Make AJAX call to get the last login date
                        iConsumerId = NRT.MySite.Authentication.getConsumerID();
                        oLastLoginDate = MySiteProvider.GetLastLoginDate(_WebsiteID, iConsumerId);
                        if (oLastLoginDate !== null && typeof oLastLoginDate !== 'undefined')
                        {
                            DTSince = oLastLoginDate.value;
                        }
                        break;
                }
                    
                sURL = _oUtility.getAppPath() + _PropertyResultsURL;
                
                if (sURL.indexOf('?') > -1)
                {
                    sURL += '&ConsumerSearchID=' + ConsumerSearchID + '&CallingPage=7' + '&SearchOption=' + SearchOptionID;
                } else {
                    sURL += '?ConsumerSearchID=' + ConsumerSearchID + '&CallingPage=7' + '&SearchOption=' + SearchOptionID;
                }
                    
                if (DTSince !== null && typeof DTSince !== 'undefined')
                {
                    sURL += '&DTSince=' + DTSince ;
                }
                
                window.location = sURL;
                
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToPropertyResultsPage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
            
        /*==================================================================================
            Method		: redirectToPropertySearchPage
            Summary		: Redirect the user to the login page.
            Author		: Dale Lawless
            Create Date	: 01/24/2007
        ====================================================================================*/
        redirectToPropertySearchPage: function () 
        {
            try
            {
                if (_WebsiteID === '10')
                {
                    var qs = window.location.search;
                    qs = qs.toLowerCase();
                    if (qs.lastIndexOf('ab=1&agentid=') > -1)
                    {
                        var newURL = qs.replace("?","&");      
                        newURL = newURL.replace(/propsearch=[0-9]+/,"");                                             
                        
                        var compareURL = _PropertySearchURL.toLowerCase();
                        if (compareURL.lastIndexOf('ab=1&agentid=') > -1)
                        {
                            window.location = _oUtility.getAppPath() + _PropertySearchURL;
                        } else {
                            window.location = _oUtility.getAppPath() + _PropertySearchURL + newURL;                        
                        }
                    } else {
                        window.location = _oUtility.getAppPath() + _PropertySearchURL;                                        
                    }
                } else {
                    window.location = _oUtility.getAppPath() + _PropertySearchURL;                    
                }                                
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.redirectToPropertySearchPage', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                
        /*==================================================================================
            Method		: setAgentInfo
            Summary		: Displays the agent information on the calling window
                          This is updated after the user elects to use the Agent Lookup 
                          functionality.
            Author		: Dale Lawless
            Create Date	: 01/11/2007
        ====================================================================================*/
        setAgentInfo: function (personnelID,agentName)
        {    
            var oAgentID = null; 
            var oAgentName = null;
            var oDisplayAgent = null;
            var oClearAgent = null;
            var oDisplayAgentParent = null;
            var oDisplayAgentTeamParent = null;
            try
            {
                // Clear out any previously selected Teams
                NRT.MySite.UI.clearTeamInfo();
            
                // Agent ID
                oAgentID = _oUtility.getElementByTagNameAndID('hdnAgentID','INPUT');
                if (oAgentID !== null)
                {
                    oAgentID.value = personnelID;
                } else {
                    oAgentID = window.opener._oUtility.getElementByTagNameAndID('hdnAgentID','INPUT');
                    if (oAgentID !== null)
                    {
                        oAgentID.value = personnelID;
                    }
                }
                
                // Agent name
                oAgentName = _oUtility.getElementByTagNameAndID('hdnAgentName','INPUT');
                if (oAgentName !== null)
                {
                    oAgentName.value = agentName;
                } else{
                    oAgentName = window.opener._oUtility.getElementByTagNameAndID('hdnAgentName','INPUT');
                    if (oAgentName !== null)
                    {
                        oAgentName.value = agentName;
                    }
                }
                
            // AgentTeamText selector
            oSelAgentText = document.getElementById('spnSelectAgentText');
            if (oSelAgentText === null && (window.opener !== null && typeof window.opener !='undefined')) {
            oSelAgentText = window.opener.document.getElementById('spnSelectAgentText');
            }
            // AgentTeamText selector
            oSelAgentTeamText = document.getElementById('spnSelectAgentTeamText');
            if (oSelAgentTeamText === null && (window.opener !== null && typeof window.opener !='undefined')) {
            oSelAgentTeamText = window.opener.document.getElementById('spnSelectAgentTeamText');
}

                    //Clear the parentElement if it is a DIV, do nothing if the parentElement is a PANEL
                    oDisplayAgentParent = oSelAgentText.parentElement;
                    if (oDisplayAgentParent !== null && typeof oDisplayAgentParent !== 'undefined' )
                    {
                        var parentId = oDisplayAgentParent.id;
                        if (parentId.indexOf("_divSelectAgent") > 0)
                        {
                            oDisplayAgentParent.style.display = 'none';
                        }
                    }
                    //Clear the parentElement if it is a DIV, do nothing if the parentElement is a PANEL
                    if (oSelAgentTeamText != null)
                    {
                        oDisplayAgentTeamParent = oSelAgentTeamText.parentElement;
                        if (oDisplayAgentTeamParent !== null && typeof oDisplayAgentTeamParent !== 'undefined' )
                        {
                            var parentId = oDisplayAgentTeamParent.id;
                            if (parentId.indexOf("_divSelectAgentTeam") > 0)
                            {
                                oDisplayAgentTeamParent.style.display = 'none';
                            }
                        }
                    }
                    
                // Display Agent
                oDisplayAgent = document.getElementById('spnDisplayAgent');
                if (oDisplayAgent !== null)
                {
                    oDisplayAgent.innerHTML = agentName;

                oSelAgentText.style.display = 'none';
                } else {
                    oDisplayAgent = window.opener.document.getElementById('spnDisplayAgent');
                    if (oDisplayAgent !== null) 
                    {
                        oDisplayAgent.innerHTML = agentName;

                oSelAgentText.style.display = 'none';
                    } else {
                oSelAgentText.style.display = '';                       
                    }
                    
                }
                
                // Clear Agent
                oClearAgent = document.getElementById('spnClearAgent');
                if (oClearAgent !== null)
                {
                    oClearAgent.style.display = 'inline';
                } else {
                    oClearAgent = window.opener.document.getElementById('spnClearAgent');
                    if (oClearAgent !== null) 
                    {
                        oClearAgent.style.display = 'inline';
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.setAgentInfo', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: setTeamInfo
            Summary		: Displays the team information on the calling window
                          This is updated after the user elects to use the Team Lookup 
                          functionality.
            Author		: Dale Lawless
            Create Date	: 10/26/2007
        ====================================================================================*/
        setTeamInfo: function (TeamID,TeamName)
        {    
            var oTeamID = null; 
            var oTeamName = null;
            var oDisplayTeam = null;
            var oClearTeam = null;
            try
            {
                // Clear out any previously selected Agents
                NRT.MySite.UI.clearAgentInfo();
            
                // Team ID
                oTeamID = _oUtility.getElementByTagNameAndID('hdnTeamID','INPUT');
                if (oTeamID !== null)
                {
                    oTeamID.value = TeamID;
                } else {
                    oTeamID = window.opener._oUtility.getElementByTagNameAndID('hdnTeamID','INPUT');
                    if (oTeamID !== null)
                    {
                        oTeamID.value = TeamID;
                    }
                }
                
                // Team name
                oTeamName = _oUtility.getElementByTagNameAndID('hdnTeamName','INPUT');
                if (oTeamName !== null)
                {
                    oTeamName.value = TeamName;
                } else{
                    oTeamName = window.opener._oUtility.getElementByTagNameAndID('hdnTeamName','INPUT');
                    if (oTeamName !== null)
                    {
                        oTeamName.value = TeamName;
                    }
                }
                
// AgentTeamText selector
oSelAgentText = document.getElementById('spnSelectAgentText');
if (oSelAgentText === null && window.opener !== null) {
oSelAgentText = window.opener.document.getElementById('spnSelectAgentText');
}
                
                // Display Team
                oDisplayTeam = document.getElementById('spnDisplayTeam');
                if (oDisplayTeam !== null)
                {
                    oDisplayTeam.innerHTML = TeamName;

oSelAgentText.style.display = 'none';
                } else {
                    oDisplayTeam = window.opener.document.getElementById('spnDisplayTeam');
                    if (oDisplayTeam !== null) 
                    {
                        oDisplayTeam.innerHTML = TeamName;

oSelAgentText.style.display = 'none';
                    } else {
oSelAgentText.style.display = '';
                    }
                    
                }
                
                // Clear Team
                oClearTeam = document.getElementById('spnClearTeam');
                if (oClearTeam !== null)
                {
                    oClearTeam.style.display = 'inline';
                } else {
                    oClearTeam = window.opener.document.getElementById('spnClearTeam');
                    if (oClearTeam !== null) 
                    {
                        oClearTeam.style.display = 'inline';
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.setTeamInfo', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
                
        /*==================================================================================
            Method		: setCheckBoxTextStyle
            Summary		: Called when a checkbox is clicked. Will bold or remove 
                          the bolding of the text.
            Author		: Dale Lawless
            Create Date	: 01/05/2007
        ====================================================================================*/
        setCheckBoxTextStyle: function (control)
        {
            var divTextControl = null;
            
            try
            {
                divTextControl = control.parentNode;
                                
                // Determine how do display the text
                if (control.checked)
                {
                    divTextControl.style.fontWeight='bold'; 
                } else {
                    divTextControl.style.fontWeight='';
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.setCheckBoxTextStyle', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                        
        /*==================================================================================
            Method		: showAgentLookupWindow 
            Summary		: Opens a new window for the Agent Lookup functionality.
            Author		: Dale Lawless
            Create Date	: 01/11/2007
        ====================================================================================*/
        showAgentLookupWindow: function ()
        {    
            var sURL = '';
            
            try
            {
                sURL = '/MySite/AgentSearch.aspx' + NRT.Utility.Branding.getBranding('?');
                _oUtility.showNewWindow(sURL,'',_WinW_AgentLookup,_WinH_AgentLookup);
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showAgentLookupWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: showAgentTeamSearchWindow
            Summary		: Opens a new window for the Search Agent or Team Lookup functionality.
            Author		: Dale Lawless
            Create Date	: 10/26/2007
        ====================================================================================*/
        showAgentTeamSearchWindow: function (searchtype)
        {    
            var sURL = '';
            
            try
            {
                if (searchtype === 'agent') {
                    sURL = '/MySite/AgentSearch.aspx?st=a' + NRT.Utility.getBranding('?');
                    _oUtility.showNewWindow(sURL,'',_WinW_AgentLookup,_WinW_AgentLookup);                
                } else if (searchtype === 'team') {
                    sURL = '/MySite/AgentSearch.aspx?st=t' + NRT.Utility.getBranding('?');
                    _oUtility.showNewWindow(sURL,'',_WinW_TeamLookup,_WinH_TeamLookup);                                
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showAgentTeamSearchWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: showConfirmationLayeredWindow
            Summary		: Displays a confirmation layered window.
            Author		: Dale Lawless
            Create Date	: 01/20/2007
        ====================================================================================*/
        showConfirmationLayeredWindow: function (ConfirmType,ConsumerID) 
        {        
            var sQueryString = null;
            
            try
            {
                switch (ConfirmType)
                {
                    case _ConfirmationType_SavedSearches:
                        sQueryString = 'controlType=SaveSearchConfirmation&ConsumerID=' + ConsumerID;
                        _oUtility.showLayeredPage(sQueryString, _WinW_Confirmation, _WinTitle_Confirmation_SS, _DefFocusItemID_Confirmation, _DefFocusItemType_Confirmation);
                        break;
                    case _ConfirmationType_SavedProperties:
                        sQueryString = 'controlType=SavePropertyConfirmation';
                        _oUtility.showLayeredPage(sQueryString, _WinW_Confirmation, _WinTitle_Confirmation_SP, _DefFocusItemID_Confirmation, _DefFocusItemType_Confirmation);
                        break;
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showConfirmationLayeredWindow', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },
                        
        /*==================================================================================
            Method		: showLayeredWindow
            Summary		: Displays the Window as a Layered Window
            Author		: Dale Lawless
            Create Date	: 08/10/2006
        ====================================================================================*/
        showLayeredWindow: function (control, title, width, defaultfocusitemid, defaultfocusitemtype)
        {
            var sQueryString = null;
            
            try
            {
                // Show the layered page              
                qs = location.search.length > 0 ? '&'+location.search.substr(1) : '';
                sQueryString = 'controlType='+control+qs;
                
                if (width === null) 
                {
                    _oUtility.showLayeredPage(sQueryString, _defWidth, title.toUpperCase(), defaultfocusitemid, defaultfocusitemtype);
                } else {
                    _oUtility.showLayeredPage(sQueryString, width, title.toUpperCase(), defaultfocusitemid, defaultfocusitemtype);
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showLayeredWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: showRememberMeAlertWindow
            Summary		: Displays the Remember Me as a Layered Alert Window
            Author		: TSA
            Create Date	: 2007.04.04
        ====================================================================================*/
        showRememberMeAlertWindow: function (title)
        {    
            var sHTML  = "";
            
            try
            {
                //contents
                sHTML += "<table style='border:0px; padding:0px; WIDTH:" + (_WinW_RememberMe - 10) + "px;'>";
                sHTML += "<tr>";
                sHTML += "<td class='text'>";
                sHTML += "By selecting the \"Remember Me\" checkbox,";
                sHTML += " <label class='textbold'>" + window.location.host + "</label>";
                sHTML += " will place a cookie on your computer that will";
                sHTML += " automatically log you in when you return to the Web site.";
                sHTML += "</td>";
                sHTML += "</tr>";
                sHTML += "<tr>";
                sHTML += "<td class='text'>";
                sHTML += "If you are using a shared or public computer,";
                sHTML += " we recommend that you do not use this feature."; 
                sHTML += "</td>";
                //sHTML += "</tr>";
                sHTML += "</tr>";
                sHTML += "<tr>";
                sHTML += "<td>";
                sHTML += "<TABLE style='padding:0px; border:0px; width:100%;'>";
                sHTML += "<TR>";
                sHTML += "<td style='height:9px;' class='separatorLineH'>";
                sHTML += "<img src='/NRTProducts/include/images/common_spacer.gif' border='0' width='100%' height='9'>";
                sHTML += "</td>";
                sHTML += "</TR>";
                sHTML += "</TABLE>";
                sHTML += "</td>";
                sHTML += "</tr>";
                sHTML += "<tr>";
                sHTML += "<td style='text-align:center;'>";
                sHTML += "<img id='" + _DefFocusItemID_RememberMe + "' border='0' class='pointer' src='/NRTProducts/include/images/btnOK.gif'";
                sHTML += " onmouseover=\"javascript:NRT.Utility.flipButton(this,1);\"  onmouseout=\"javascript:NRT.Utility.flipButton(this,0);\"";
                sHTML += " onclick=\"javascript:NRT.Utility.closeLayeredPage();this.onblur=null;\" onblur=\"javascript:this.focus();\">";
                sHTML += "</td>";
                sHTML += "</tr>";
                sHTML += "</table>";
                //end of content

                _oUtility.showInfo(sHTML, _WinW_RememberMe, title.toUpperCase(), _DefFocusItemID_RememberMe);
                return;
                
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showRememberMeAlertWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },

        /*==================================================================================
            Method		: showRememberMePopupWindow
            Summary		: Opens the Remember Me page in a new window from a layered window.
            Author		: Dale Lawless
            Create Date	: 01/11/2007
        ====================================================================================*/
        showRememberMePopupWindow: function ()
        {    
            var sQueryString = null; 
            
            try
            {
                sQueryString = 'controlType=RememberMe';
                _oUtility.showNewHostWindow(sQueryString,_WinW_RememberMe,_WinH_RememberMe,'');
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showRememberMePopupWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        
        /*==================================================================================
            Method		: showRegistrationPage
            Summary		: Opens Registration page either in a page or in a layered window.
            Author		: Dale Lawless
            Create Date	: 01/19/2007
        ====================================================================================*/
        showRegistrationPage: function ()
        {   
            var sQueryString = null; 
                        
            try
            {
                if (NRT.MySite.UI.pageIsMySiteLogin())
                {
                    // In-Page
                    NRT.MySite.UI.redirectToRegistrationPage();
                } else if (NRT.MySite.UI.pageIsMySiteHome())
                {
                    // New Window
                    sQueryString = 'controlType=Registration';
                    _oUtility.showNewHostWindow(sQueryString,_WinW_Registration,_WinH_Registration,_WinTitle_Registration);
                } else {
                    // Layered Window
                    NRT.MySite.UI.showLayeredWindow("Registration", _WinTitle_Registration, _WinW_Registration, _DefFocusItemID_Registration, _DefFocusItemType_Registration);
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.showRememberMePopupWindow', _oErrorHandler.ERRORTYPE_JS, err);
            }
        },
        

        /*==================================================================================
            Method		: tabClick
            Summary		: Tab click event for the My Save Home page.
            Author		: Dale Lawless
            Create Date	: 09/15/2006
        ====================================================================================*/
        tabClick: function (tabId)
        {
            var oLblMSS = null;
            var oLblMSP = null;
            var oLblMA = null; 
            var sBranding = '';
            var sAbrand = '';
            var sTbrand = '';
            var bLoggedIn = false;
            
            try {
                // Check if the user has been authenticated
                bLoggedIn = NRT.MySite.Authentication.isUserLoggedIn();
                if (bLoggedIn === false) {
                    NRT.MySite.UI.redirectToLoginPage(tabId);
                    return;
                }
            
                if (NRT.MySite.Authentication.checkCookieExpiration()) {
                    // Disables links
                    oLblMSS = _oUtility.getElementByTagNameAndID('lblMySavedSearches','LABEL');
                    oLblMSP = _oUtility.getElementByTagNameAndID('lblMySavedProperties','LABEL');
                    oLblMA  = _oUtility.getElementByTagNameAndID('lblMyAccount','LABEL');
                    _oUtility.disableAnchor(oLblMSS,true);
                    _oUtility.disableAnchor(oLblMSP,true);
                    _oUtility.disableAnchor(oLblMA,true);
                    
                    //Show the correct tab
                    _oTab.tabClick(tabId);
                    
                    switch (tabId)
                    {
                        case 0 :
                            //My Saved Searched Tab
                            _oUtility.disableAnchor(oLblMSP,false);	
                            _oUtility.disableAnchor(oLblMA,false);	
                            Progress.fn.show(null,true,'Loading Saved Searches');
                            
                            MySiteUIController.GetMySavedSearchesHTML(this._getMySavedSearchesHTML_Callback);
                            return;
                            
                        case 1 :
                            //My Saved Properties Tab
                            _oUtility.disableAnchor(oLblMSS,false);	
                            _oUtility.disableAnchor(oLblMA,false);
                            
                            //TSA - 2007.04.30 - Added to get branding
                            sAbrand = _oUtility.getQueryStringParam('abrand');
                            sTbrand = _oUtility.getQueryStringParam('tbrand');
                            
                            //TSA - 2007.04.30 - added to handle agent branding
                            if (sAbrand !== null && typeof sAbrand !== 'undefined')
                            {
                                sBranding = 'a' + sAbrand;
                            }
                            
                            //TSA - 2007.04.30 - added to handle team branding
                            if (sTbrand !== null && typeof sTbrand !== 'undefined')
                            {
                                sBranding = 't' + sTbrand;	
                            }
                            //setTimeout("Progress.fn.show('',true,'Loading Saved Properties');",50);
                            Progress.fn.show(null,true,'Loading Saved Properties');
                            MySiteUIController.GetMySavedPropertiesHTML(sBranding,this._getMySavedPropertiesHTML_Callback);
                            return;
                            
                        case 2 :
                            //My Account Tab
                            _oUtility.disableAnchor(oLblMSS,false);
                            _oUtility.disableAnchor(oLblMSP,false);
                            MySiteUIController.GetMyAccountHTML(this._getMyAccountHTML_Callback);
                            return;
                            
                        default :
                            // Should never happen
                            return;            
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.tabClick', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        },

        /******************************************************************************************************************
        *									A J A X   M E T H O D S
        *******************************************************************************************************************/
        /*==================================================================================
            Method		: _getMySavedSearchesHTML_Callback
            Summary		: Ajax callback method to display the My Saved Searches in the 
                          tab contents div control on the MySite home page.
            Author		: Dale Lawless
            Create Date	: 02/15/2007
        ====================================================================================*/
        _getMySavedSearchesHTML_Callback: function (response)
        {    
            var sMySavedSearchesHTML = null;
            var oDivTabContents = null;
            
            try
            {
                if (response.error !== null) 
                {
                    Progress.fn.hide();
                    _oErrorHandler.ResponseError('NRT.MySite.UI._getMySavedSearchesHTML_Callback',response);
                    return; 
                } else {
                    if (response !== null && response.value !== null)
                    {
                        sMySavedSearchesHTML = response.value;
                        if (sMySavedSearchesHTML !== null && typeof sMySavedSearchesHTML !== 'undefined')
                        {
                            // Fill the tab contents div
                            oDivTabContents = document.getElementById('div_MainControl_TabContents');
                            if (oDivTabContents !== null && typeof oDivTabContents !== 'undefined') 
                            {
                                oDivTabContents.innerHTML = sMySavedSearchesHTML;
                            }
                        }
                    }
                }
                Progress.fn.hide();
            }
            catch(err)
            {
                Progress.fn.hide();
                _oErrorHandler.Error('NRT.MySite.UI._getMySavedSearchesHTML_Callback', _oErrorHandler.ERRORTYPE_AJAX, err);
            }
        },
        
        /*==================================================================================
            Method		: _getMySavedPropertiesHTML_Callback
            Summary		: Ajax callback method to display the My Saved Properties in the 
                          tab contents div control on the MySite home page.
            Author		: Dale Lawless
            Create Date	: 02/15/2007
        ====================================================================================*/
        _getMySavedPropertiesHTML_Callback: function (response)
        {  
            var sMySavedPropertiesHTML = null;
            var oDivTabContents = null;
            
            try
            {
                if (response.error !== null) 
                {
                    Progress.fn.hide();
                    _oErrorHandler.ResponseError('NRT.MySite.UI._getMySavedPropertiesHTML_Callback',response);
                    return; 
                } else {
                    if (response !== null && response.value !== null)
                    {
                        sMySavedPropertiesHTML = response.value;
                        if (sMySavedPropertiesHTML !== null && typeof sMySavedPropertiesHTML !== 'undefined')
                        {
                            // Fill the tab contents div
                            oDivTabContents = document.getElementById('div_MainControl_TabContents');
                            if (oDivTabContents !== null && typeof oDivTabContents !== 'undefined') 
                            {
                                oDivTabContents.innerHTML = sMySavedPropertiesHTML;
                            }
                        }
                    }
                }
                Progress.fn.hide();
            }
            catch(err)
            {
                Progress.fn.hide();
                _oErrorHandler.Error('NRT.MySite.UI._getMySavedPropertiesHTML_Callback', _oErrorHandler.ERRORTYPE_AJAX, err);
            }
        },
        
        /*==================================================================================
            Method		: _getMyAccountHTML_Callback
            Summary		: Ajax callback method to display the My Account in the 
                          tab contents div control on the MySite home page.
            Author		: Dale Lawless
            Create Date	: 02/15/2007
        ====================================================================================*/
        _getMyAccountHTML_Callback: function (response)
        {   
            var sMyAccountHTML = null;
            var oDivTabContents = null;
            
            try
            {
                if (response.error !== null) 
                {
                    _oErrorHandler.ResponseError('NRT.MySite.UI._getMyAccountHTML_Callback',response);
                    return; 
                } else {
                    if (response !== null && response.value !== null)
                    {
                        sMyAccountHTML = response.value;
                        if (sMyAccountHTML !== null && typeof sMyAccountHTML !== 'undefined')
                        {
                            // Fill the tab contents div
                            oDivTabContents = document.getElementById('div_MainControl_TabContents');
                            if (oDivTabContents !== null && typeof oDivTabContents !== 'undefined') 
                            {
                                oDivTabContents.innerHTML = sMyAccountHTML;
                            }
                        }
                    }
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI._getMyAccountHTML_Callback', _oErrorHandler.ERRORTYPE_AJAX, err);
            }
        },
        
        setAlertTextStyle: function (control)
        {    
            var oParent = null;
            
           try
            {
                oParent = control.parentNode;
                
               if (control.checked)
               {
                   oParent.className = 'smallbold';
               } else {
                   oParent.className = 'small';
                }
            }
            catch(err)
            {
                _oErrorHandler.Error('NRT.MySite.UI.setAlertTextStyle', _oErrorHandler.ERRORTYPE_JS, err);
                return;
            }
        }
    };
}();
