/**
/**
*	Interactive Poster Background Processes 1.0
*
*	Mark Lindros, Oracle Corporation
*	Last Modification: 07/15/2012
*
*/

/*
 * Initialize all JS for the Background Processes Interactive
 */
function initBgProcesses() {
    init_bgcategories();
}


/**
 * This function initializes all the categories of bg processes rendered by the poster.
 */
function init_bgcategories() {
    // Does element exist?
    if (!$('ul.bgcategories').length) {
        //If not, exit.
        return;
    }

    // Listen for click on categories
    $('ul.bgcategories a').click(function() {
        writeBackgroundProcesses($(this).text());
        this.blur();
        return false;
    });

    //Initialize the window with the first category's processes
    writeBackgroundProcesses($('ul.bgcategories a:first').text());
}


function writeBackgroundProcesses(category) {
    //Write background processes information
    $('.bgwindow').scrollTop(0);
    $('.bgwindow').html(''); //Clear the window for new content

    $.ajax({
        type:"GET",
        url:"xml/poster.xml",
        dataType:"xml",
        success:function (xml) {
            interactive = $(xml).find('interactive[style="background_processes"]');

            //Set title bar
            $('.bgtitleleft').html('<p align="" style="font-size:14pt;"><strong>&nbsp;' + category + '</strong></p>');
            $('.bgtitleright').html('<p style="font-size:16pt;"><strong>' + $(interactive).attr("name") + ' Background Processes&nbsp;</strong></p>');

            $(interactive).find('process[category="' + category + '"]').each(function() {
                $('.bgwindow').append('  <tr>');
                $('.bgwindow').append('    <td class="bgacronym">' + $(this).attr("acronym") + '</td>');
                $('.bgwindow').append('    <td class="bgname">' + $(this).attr("name") + '</td>');
                $('.bgwindow').append('    <td class="bgdesc">' + $(this).attr("desc") + '</td>');
                $('.bgwindow').append('    <td class="bgrequired" align="center">' + $(this).attr("required") + '</td>');
                $('.bgwindow').append('    <td class="bgstart_by_default" align="center">' + $(this).attr("start_by_default") + '</td>');
                $('.bgwindow').append('    <td class="bgnew_this_release" align="center">' + $(this).attr("new_this_release") + '</td>');
                $('.bgwindow').append('  </tr>');
            });
        }
    });
}