
// Instantiate Global JS
document.observe('dom:loaded', function () {
    $(document.body).addClassName('js-enabled'); 		// Add a class name to the body as a global flag that the user has javascript enabled...
    document.fire('js:enabled'); 						// ... and broadcast custom 'js:enabled' event for widgets that need the body class
    var flyoutNav = new FlyoutNav('div#mainnav ul > li', 'div.flyoutnav');
    //GoogleSearchLabelInput = new LabelInputText($$('fieldset#global_searchbox label')[0], $$('fieldset#global_searchbox input[type=text]')[0]);
    //FooterPrintLink = new PrintPage($('footer_print_link'));
    BucketH2HeightAdjust = new HeightAdjust($$('div.bucket h2'), { repeatPattern: 2 });
    BucketHeightAdjust = new HeightAdjust($$('div.bucket'), { repeatPattern: 2 });

    if ($('spu-stories')) {
        var stories = new Stories('spu-stories', { shuffle: true, animationDelay: 0.1, animationDuration: 0.5, animateInGroups: true, animateInGroupsOf: 4, contentContainer: 'spu-stories', createToggles: false, rowspan: 4 });
    }

    VideoCalloutPopover = new CustomModalVideoPlayer(
		$('modalflashvideocontent'),
		$$('a.lnk-video-popover'),
		{ topOffset: -100, minTopSpacing: 20 },
		{ stageWidth: '640', stageHeight: '360', videoWidth: '640', videoHeight: '360', bgcolor: '#eeede9', swfPath: rootVirtual + '_ui/swf/videoPlayer_home.swf' }
	);
    // Instantiate IE CSS3 shims
    if (isIE6) {
        FixIE.addClasses({
            'table.content-grid th:first-child': 'first-child',
            'table.content-grid td:first-child': 'first-child',
            'div.timeline-tabnav ul li:first-child': 'first-child',
            'ul.featured-items li:first-child': 'first-child',
            'ul.featured-items li:last-child': 'last-child'
        });
        FixIE.addHoverClasses({
            'div.home-follow-links ul li': 'hover',
            'div.home-magazine-callouts ul li': 'hover',
            'ul.connect-checkboxes li': 'hover'
        });
    }

    if (isIE) {
        FixIE.addClasses({
            'table.content-grid tbody tr:nth-child(odd)': 'nth-child-odd',
            'table.content-grid tbody tr:nth-child(even)': 'nth-child-even',
            'table.data-list tbody tr:nth-child(odd)': 'nth-child-odd',
            'table.data-list tbody tr:nth-child(even)': 'nth-child-even',
            'div.paginav-carousel ul.paginav-carousel-inner li:last-child': 'last-child'
        });

        // work around to make select dropdowns not cut off content in IE7/8, or be too short
        var ddl = $$('select.styled');
        for (var i = 0; i < ddl.length; i++) {
            ddl[i].observe('mouseenter', function (e) {
                var el = e.findElement('select');
                var oldWidth = el.getWidth(); // get default width
                el.addClassName('ieddl'); // assign ddl class (with CSS width set to auto)
                var newWidth = el.getWidth(); // get new width
                // if new width is shorter than original revert back by removing class
                if (newWidth < oldWidth) {
                    el.removeClassName('ieddl');
                }
            });
        }
    }
    // End IE CSS3 shims
});
// End Global JS

