var g_divClassSectionContainer = null;
var g_ProfID = null;

function cat_section_prof( id, name )
{
   // *******************************
   // shows the single child article
   // *******************************
   
   // copy left nav name in the header in right body
   var obj = window.document.getElementById( 'divSelectedSection' );
   obj.innerHTML = name;

   // divSectionContainerXXX are the items under the parent node
   // divClassSectionContainerXXX contains the content of a single child items in the right body
   // divClassSectionContainerYYY contains the child items of a category in the left nav

   SetObjectDisplayPropertyBlock( 'divClassSectionContainer' + id );

   // show classes of the newly selected course on the right
   SetObjectDisplayPropertyBlock( 'Wrapper' );

   // Expand the parent category in the left nav
   SetObjectDisplayPropertyBlock( 'divSectionContainer' + g_ProfID );

   // mark the child item in the left nav as selected
   obj = window.document.getElementById( 'aNav' + id );

   if( obj != null )
   {
      obj.style.color = '#990000';
   }
}

function cat_section_review( id, name )
{
   // shows the list of child articles under a parent node

   var obj = window.document.getElementById( 'divSelectedSection' );
   obj.innerHTML = name;

   SwapObjectDisplayProperty( 'divSectionContainer' + id );

   if( g_divClassSectionContainer != null )
   {
      SetObjectDisplayPropertyNone( 'Wrapper' );
      SetObjectDisplayPropertyNone( g_divClassSectionContainer );
   }

   // show classes of the newly selected course on the right
   g_divClassSectionContainer = 'divClassSectionContainer' + id;

   SetObjectDisplayPropertyBlock( g_divClassSectionContainer );
}

function cat_section_expandTo(id,name)
{
   var obj = window.document.getElementById( 'divSelectedSection' );
   obj.innerHTML = name;

   var obj = window.document.getElementById( 'aPrintLink' );
   //obj.href = 'htcc-audiokb-print.aspx?id=' + id;

   var obj = window.document.getElementById( 'divSectionContainer' + id );

   SwapObjectDisplayProperty( 'divSectionContainer' + id );

   if( g_divClassSectionContainer != null )
   {
      SetObjectDisplayPropertyNone( 'Wrapper' );
      SetObjectDisplayPropertyNone( 'divClassSectionContainer' + id );
   }

   // show classes of the newly selected course on the right
   g_divClassSectionContainer = 'divClassSectionContainer' + id;

   SetObjectDisplayPropertyBlock( g_divClassSectionContainer );
}

function cat_section_new(id,name)
{
   var obj = window.document.getElementById( 'divSelectedSection' );
   var obj = window.document.getElementById( 'divSectionContainer' + id );
   var img = window.document.getElementById( 'image' + id);
   var obj = window.document.getElementById(id);

   obj.style.color = "#990000";

   if( obj!= null )
   {
      var cssDisplay = obj.style.display;
      switch( cssDisplay )
      {
         case 'block' :
            obj.style.display = 'none';
            break;

         case '' :
         case 'none' :
         default :
            obj.style.color = "#990000";
            obj.style.display = 'block';
            break;
      }
  }

   if( g_divClassSectionContainer != null )
   {
      obj = window.document.getElementById('Wrapper');
      if( obj != null )
      {
         obj.style.display = 'none';   
      }
      obj = document.getElementById( 'divClassSectionContainer' + id );
      if( obj != null )
      {
         obj.style.display = 'none';
      }
   }

   // show classes of the newly selected course on the right

   g_divClassSectionContainer = 'divClassSectionContainer' + id;

   obj = window.document.getElementById( g_divClassSectionContainer );

   if( obj!= null )
   {
      obj.style.display = 'block';
   }
}

function cat_section_click( id, name )
{
   // set the text in the header on the right
   var obj = window.document.getElementById( 'divSelectedSection' );
   obj.innerHTML = name;

   // set the printer friendly hyperlink in that header
   var obj = window.document.getElementById( 'aPrintLink' );
   obj.href = 'htcc-catalog-print.aspx?id=' + id;

   // collapse or expand the course catalog hierarchy on the left
   obj = window.document.getElementById( 'divSectionContainer' + id );

   var cssDisplay = obj.style.display;

   switch( cssDisplay )
   {
      case 'block' :
         obj.style.display = 'none';
         break;
      case '' :
      case 'none' :
      default :
         obj.style.display = 'block';
         break;
   }

   // hide any existing classes of the old selected course on the right
   if( g_divClassSectionContainer != null )
   {
      obj = window.document.getElementById( g_divClassSectionContainer );
      obj.style.display = 'none';
   }

   // show classes of the newly selected course on the right
   g_divClassSectionContainer = 'divClassSectionContainer' + id;

   obj = window.document.getElementById( g_divClassSectionContainer );
   obj.style.display = 'block';
}

function SetObjectDisplayPropertyBlock( elementName )
{
   SetObjectDisplayProperty( elementName, 'block' );
}

function SetObjectDisplayPropertyNone( elementName )
{
   SetObjectDisplayProperty( elementName, 'none' );
}

function SetObjectDisplayProperty( elementName, displayValue )
{
   var obj = window.document.getElementById( elementName );

   if( obj != null )
   {
      obj.style.display = displayValue;
   }
}

function SwapObjectDisplayProperty( elementName )
{
   var obj = window.document.getElementById( elementName );

   if( obj != null )
   {
      var cssDisplay = obj.style.display;

      switch( cssDisplay )
      {
         case 'block' :
            obj.style.display = 'none';
            break;

         case '' :
         case 'none' :
         default :
            obj.style.display = 'block';
            break;
      }
   }
}

function test( id )
{
   var obj = window.document.getElementById( id );
   if( obj!= null )
   {
      obj.style.color = "#990000";
   }
}