
var researchByTopicMenu = new Array( "organizational_culture", "organizational_learning", "trust", "disputeManagement", 
                                     "constructionContacting", "mediation", "negotiation" );

var numberOfProjects = new Array ( 1, 5, 5, 10, 9, 5, 8 );

var projectNames = new Array ( "organizational_culture_project", "organizational_learning_project", "trust_project", "dispute_management_project",
                               "construction_contacting_project", "mediation_project", "negotiation_project", "partnering_project");

function resetResearchByTopic()
{
   
    for( var i = 0; i < researchByTopicMenu.length; i++ )
    {
        document.getElementById( researchByTopicMenu[i] ).style.display= "none";
        document.getElementById( researchByTopicMenu[i] + "_backMenu" ).style.display = "none";
        
        for( var j = 1; j <= numberOfProjects[i]; j++ )
        {
            if( i == 2 && j >= 3 )
                document.getElementById( projectNames[researchByTopicMenu.length] + ( j - 2 ) ).style.display = "none";
            else
            {
                document.getElementById( projectNames[i] + j ).style.display = "none";
            }
        }
    }
    
    document.getElementById("researchByTopicContent").style.display = "none";
    document.getElementById("researchByTopicBackMenu").style.display = "none";
    
    $("#researchByTopicIndex").fadeIn();
}

function resetResearchByTopicIndex( topic )
{

    for( var i = 0; i < researchByTopicMenu.length; i++ )
    {
        if( topic == researchByTopicMenu[i] )
        {
            if( topic == "trust" )
            {                       
                for( var j = 1; j <= (numberOfProjects[i]-3); j ++ )
                {
                    document.getElementById( projectNames[i] + j ).style.display = "none";
                }
                
                for( var j = 1; j <= numberOfProjects[i]-2; j ++ )
                {
                    document.getElementById( projectNames[researchByTopicMenu.length] + j ).style.display = "none";
                }
            }
            else
            {
                for( var j = 1; j <= numberOfProjects[i]; j ++ )
                {
                    document.getElementById( projectNames[i] + j ).style.display = "none";
                }
            }
            
            document.getElementById( topic + "_backMenu" ).style.display = "none";
            showTopicMenu( i + 1 );
            break;
        
        }
    }
}


function showResearchByTopicProj( topic, projectIndex )
{
    for( var i = 0; i < researchByTopicMenu.length; i++ )
    {
        if( topic == researchByTopicMenu[i] )
        {
            if( topic == "trust" && projectIndex >= 3 ) //is partnering
            {
                $("#partnerSubBanner,#trustSubBanner, #researchByTopicBackMenu,#" + topic + "Index, #partneringIndex,#trustSubBanner").fadeOut( "slow", function()
                {
                    $("#partnerSubBanner, #" + researchByTopicMenu[i] + "_backMenu,#" + projectNames[researchByTopicMenu.length] + ( projectIndex-2 ) ).fadeIn();
                });
            }
            else if( topic == "trust" )
            {
                $("#partnerSubBanner, #researchByTopicBackMenu,#" + topic + "Index, #partneringIndex").fadeOut( "slow", function()
                {
                    $("#trustSubBanner, #" + researchByTopicMenu[i] + "_backMenu,#" + projectNames[i] + projectIndex).fadeIn();
                });            
            }
            else
            {
                $("#researchByTopicBackMenu,#" + topic + "Index").fadeOut( "slow", function()
                {
                    $("#" + researchByTopicMenu[i] + "_backMenu,#" + projectNames[i] + projectIndex).fadeIn();
                });
            }
            break;
        }
    }
}

function showTopicMenu( menuIndex )
{
    if( menuIndex == 3 )
    {
        $("#researchByTopicIndex").fadeOut( "slow", 
        function()
        {
            $("#researchByTopicContent, #researchByTopicBackMenu, #" + researchByTopicMenu[menuIndex-1] + ",#" + researchByTopicMenu[menuIndex-1] + "Index,#partneringIndex, #partnerSubBanner, #trustSubBanner").fadeIn();
        });    
    }
    else
    {
        $("#researchByTopicIndex").fadeOut( "slow", 
        function()
        {
            $("#researchByTopicContent, #researchByTopicBackMenu, #" + researchByTopicMenu[menuIndex-1] + ",#" + researchByTopicMenu[menuIndex-1] + "Index").fadeIn();
        });
    }
}
