if (typeof (RE) == 'undefined')
    Ext.namespace('RE');

if (typeof (RE.data) == 'undefined')
    Ext.namespace('RE.data');


if (typeof (RE.Forms) == 'undefined')
    RE.Forms = {};



function intersticial_show(version, height, width) {
    if (!this.cookieProvider)
        this.cookieProvider = new Ext.state.CookieProvider({ domain: ".realestate.com" });

    if (!height)
        height = 400;
    if (!width)
        width = 700;

    var intersticialShown = this.cookieProvider.get('intersticialShown');

    if (intersticialShown)
        return;
    var loadUrl = '/common/includes/intersticial/version_' + version + '.htm';
    if (version > 4)
        loadUrl = '/common/includes/intersticial/version_' + version + '.aspx';

    this.racwin = new Ext.Window({
        width: width,
        height: height,
        baseCls: 're-nowindow',
        cls: 're-intersticial',
        closeAction: 'close',
        shadow: false,
        modal: true,
        autoLoad: { url: loadUrl, callback: rac_init, scripts: true },
        border: false,
        draggable: false,
        resizable: false,
        plain: true
    });
    this.racwin.show();
    this.racwin.setActive(true);

    function rac_init() {
        if (Ext.get('rac_close'))
            Ext.get('rac_close').on('click', function() { this.racwin.close() }, this);
        if (Ext.get('rac_close_link'))
            Ext.get('rac_close_link').on('click', function() { this.racwin.close() }, this);

        var racintersticial = new RE.Forms.RequestCall({ applyTo: 'rac_intersticial', icode: 3910 })
        racintersticial.on('submit', function() { this.racwin.close(); }, this);
    }

    this.cookieProvider.set('intersticialShown', true)
}

Ext.onReady(function() {



});


RE.EventManager.onLoggedIn(function(options) {
    toolboxDh = {
        tag: 'div',
        cls: 'block toolbox',
        children: [
            {
                tag: 'div',
                cls: 'title',
                children: { tag: 'div', cls: 'squeeze', html: 'MyRealEstate Toolbox' }
            },
            {
                tag: 'div',
                cls: 'body',
                children: [
                    { tag: 'div', id: 'savedsearch-grid' },
                    { tag: 'div', id: 'savedlisting-grid' }
                ]
            }
        ]
    };

    var sidebarEl = Ext.getBody().child('.sidebar-panel');
    var firstEl = sidebarEl.first();

    firstEl.insertSibling(toolboxDh, 'before');

    initSavedSearch();
    initSavedListings();
});




