// convert sections in downloads page into collapsible regions
// 2011-10-11 Ben
// I put this at the head of the included JS file because the stuff below
// throws errors.

delayedDownloadPatch = function($) {
    if ($('.content-center h2:first-child').text() === 'Downloads') {
        $('.content-center h2').each(function() {
            if ($(this).text() !== 'Downloads') {
                var $heading = $(this),
                    $list = $heading.nextAll('ul:first');
                $heading
                    .data('original_text', $(this).text())
                    .html($(this).html() + ' &raquo;')
                    .css({color: '#4db4d9', cursor: 'default'})
                    .click(function() {
                        $list.stop().slideToggle(function() {
                            $heading.html($heading.data('original_text') + ($list.is(':visible') ? ' &darr;' : ' &raquo;'));
                        });
                    });
                $list.hide();

                $list.find('ul').each(function() {
                    var $list = $(this),
                        $heading = $(this).parent().find('h2,h3');

                    $heading
                        .data('original_text', $heading.text())
                        .html($heading.html() + ' &raquo;')
                        .css({color: '#4db4d9', cursor: 'default'})
                        .click(function() {
                            $list.stop().slideToggle(function() {
                                $heading.html($heading.data('original_text') + ($list.is(':visible') ? ' &darr;' : ' &raquo;'));
                            });
                        });
                    $list.hide();
                });
            }
        });
    }
};

jQuery(document).ready(function() {
    setTimeout('delayedDownloadPatch(jQuery)', 100);
});


// The following will run as soon as the page is loaded and the DOM is ready, but images might still be loading.
jQuery.noConflict();

// Use jQuery via jQuery(...)

jQuery(document).ready(function(){

    jQuery("ul#newNav")
    .superfish({
        animation : {height:"show"},
        delay : 1000,
        pathLevels:    2,
    })

    jQuery('.rmv-dft-val').click(
        function() {
            if (this.value == this.defaultValue) {
                this.value = '';
            }
        }
    );

    jQuery('.rmv-dft-val').blur(
        function() {
            if (this.value == '') {
                this.value = this.defaultValue;
            }
        }
    );

});


