//--------------------------------------------------------------------------------
//
// Name: dhtml_funcs.js
//
// Makes a div layer active or inactive depending on the setTo value.
//
// Version: 1.0
// Library: dhtml
// Requires: none
// Author: Brian McWilliams
//
//--------------------------------------------------------------------------------

//---------------------------------------------------------------------
//
// set_layer
//
//---------------------------------------------------------------------
function set_layer(id, setTo) 
{
   //alert(id);
   var theElement;
   if (document.getElementById) 
   {
      //DOM
      theElement = document.getElementById( id );
   }
   else if (document.all)
   {
      //Proprietary DOM
      theElement = document.all[ id ];
   }
  
   if (!theElement)
   {
      /* The page has not loaded, or the browser claims to
      support document.getElementById or document.all but
      cannot actually use either */
      return;
  }

   //Reference the style ...
   if (theElement.style)
      theElement = theElement.style;
      
   if (typeof(theElement.display) == 'undefined') 
   {
      //The browser does not allow us to change the display style
      //Alert something sensible (not what I have here ...)
      window.alert( 'Your browser does not support this' );
      return;
   }
  
   //Change the display style
   theElement.display = setTo;
}

//-----------------------------------------------------------
// 
// show_banner - for homepage banner area
//
//-----------------------------------------------------------
function show_banner(banner_id)
{
   //alert(banner_id);

   if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
   }
   else
   {// code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange = function()
   {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {
         document.getElementById("banner").innerHTML = xmlhttp.responseText;
      }
   }

   xmlhttp.open("GET", "includes/banner_ajax.php?banner_id=" + banner_id, true);
   xmlhttp.send();
}

//---------------------------------------------------------------------
//
// set_thumb- for homepage banner area
//
//---------------------------------------------------------------------
function set_thumb(active_id) 
{
   //alert(active_id);

   // Clear all thumbs
   for (i = 1; i <= 6; i++)
   {
      normal_id = "thumb" + i;
      normal_class = "thumb" + i + "Normal";
      document.getElementById(normal_id).className = normal_class;
   }

   // Set current thumb to active state
   active_class = active_id + "Active";
   document.getElementById(active_id).className = active_class;
}

//---------------------------------------------------------------------
//
// clear_resource - for homepage footer
//
//---------------------------------------------------------------------
function clear_resource(header_id, layer_id) 
{
   // Set previous nav to normal state
   document.getElementById(header_id).className = 'resNormal';

   // Hide the 3 column information to the right of the navigation
   document.getElementById(layer_id).style.display = 'none';
}

//---------------------------------------------------------------------
//
// set_resource - for homepage footer
//
//---------------------------------------------------------------------
function set_resource(header_id, layer_id) 
{
   // If resource is already highlighted, no need to change it
   if (document.getElementById(header_id).className != 'resActive')
   {
      // Clear all nav
      clear_resource('parentH3', 'parentResources');
      clear_resource('studentH3', 'studentResources');
      clear_resource('staffH3', 'staffResources');

      // Set current nav to active state
      document.getElementById(header_id).className = 'resActive';

      // Show the 3 column information to the right of the navigation
      document.getElementById(layer_id).style.display = 'inline';
   }
}

