/*
===============================
DotControl copyright 2011
===============================
*/

function QuickFixes() {
    
    // Hide menu while custom font is rendered. Then show with fade effect;
    $('.MenuPane .rtsUL').hide().delay(3000).fadeIn('slow');

    // Fade in book content, fixing font blinking problem as well
    $('.BookPaneMiddle').children().each(function () {
        $(this).hide().delay(1000).fadeIn(1000);
    });

    InitFonts();

    // Enumerate Menu Items
    if ($('.MenuPane').length) {
        var Index = 1;
        $('.MenuPane .rtsLI').each(function () {
            $(this).addClass('Item' + Index);
            $(this).find('.rtsTxt').css('visibility', 'hidden');
            Index++;
        });
    }

    // Fix content height for non-flash website
    if ($('.AlternateContent').length) {
        $('.AlternateContent').height($('.AlternateContent').parent().parent().height());
    }

    InitRotator($('.RotatorWrapper'));
}

$(function () {
    // Logo fix
    setTimeout(function () {
        if ($('.AlternateContent').length) {
            $('.LogoH1').fadeIn('slow');
        }
    }, 3000);
});


// Apply Cufon
function InitFonts() {
    Cufon.replace('.MenuPane .rtsLink', {
        textShadow: '#000000 1px 1px 1px',
        hover: {
            textShadow: '#000000 1px 1px 1px',
            color: '#febc0b'
        }
    });
    Cufon.replace('.DefaultContainer h2');
    Cufon.replace('.NarrowContainer h3');
    Cufon.replace('.NewsDetail .NewsHeader h2');
    Cufon.replace('.PageHeader h2');
    Cufon.replace('.BigLinkTitle');
    Cufon.replace('.DarkBgTitle h3');
    Cufon.replace('.FullWidthContainer h3');
}

// Init Rotators
function InitRotator(rotator) {
    rotator.jshowoff({ changeSpeed: 1000, controlText: { play: 'Play', pause: 'Pause', previous: '', next: '' }, speed: 5000, controls: false, linksControls: false, links: false });
}
