// Widen the center column if the app has ads  [Jon Aquino 2006-09-13]
dojo.addOnLoad(function() {
    if (dojo.byId('xn_app_ads') == null && ! window.location.href.match(/test_ad_layout/)) { return; }
    dojo.byId('xn_app_body').style.width = dojo.byId('xn_app').style.width = dojo.byId('userHeader').style.width = '970px';
    dojo.byId('holder').style.width = '790px';
    document.body.style.backgroundImage = dojo.style.getComputedStyle(document.body, 'background-image').replace(/shadow_bg/, 'shadow_bg_wide');
    dojo.lang.forEach(dojo.byId('nav2').getElementsByTagName('li'), function(li) {
        // Change the background preemptively to avoid shifting in IE (VID-616)  [Jon Aquino 2006-09-18]
        li.style.background = '#123123';
        li.style.background = 'none';
    });
});


(function() {
    if (typeof sIFR == "function" && dojo.byId('header-font-sifr').value == 'Y'){
        // If title has more than one line, start it on its own line; otherwise sIFR font
        // is too big in IE (VID-573)  [Jon Aquino 2006-09-12]
        var title = dojo.byId('header-text');
        var image = dojo.byId('header-image');
        if (title != null && image != null) {
            var a = dojo.dom.firstElement(dojo.byId('header-text'));
            var originalText = a.innerHTML;
            a.innerHTML = 'M';
            var mHeight = dojo.style.getInnerHeight(title);
            a.innerHTML = originalText;
            // This criterion works in Safari  [Jon Aquino 2006-09-13]
            if (dojo.style.getInnerHeight(title) > 2*mHeight) {
                title.style.position = 'static';
                title.style.display = 'block';
            }
        }
    };
}());

// VID-647 [ David Sklar 2006-09-24 ]
ning.Bar.whenLoaded(function() {
    if (window.location.search.match(/xn_panel=clone/)) {
        ning.Bar.open('clone');
    }
});

ning.loader.require("ning.system", function() {
    var ensureClonePanelKeptOpenThroughSignIn = function(invocation) {
        if (ning.Bar.getOpenPanelName() == 'clone' && ! window.location.search.match(/xn_panel=clone/)) {
            var target = document.location.href;
            target += (dojo.string.endsWithAny(target, '?', '&') ? '' : (target.indexOf('?') > -1 ? '&' : '?')) + 'xn_panel=clone';
            invocation.args[0].target = invocation.args[0].errorTarget = encodeURIComponent(target);
        }
        return invocation.proceed();
    }
    dojo.event.connect('around', ning.system, 'signIn', dojo.lang.nameAnonFunc(ensureClonePanelKeptOpenThroughSignIn, dj_global));
    dojo.event.connect('around', ning.system, 'signUp', dojo.lang.nameAnonFunc(ensureClonePanelKeptOpenThroughSignIn, dj_global));
});