/*  TechCentral 2010 Primary Functionality
 *
********************************************************************************
 */
 
/*  This starts all the important functions.
 */

function initTechCentral2010()
{
  initTopMenu();
  sidebarMostViewedSelect(0);
}
  
/*  Top Menu Pt 2
    Code adapted from http://www.alistapart.com/d/horizdropdowns/horizontal.htm
    Part 1 is the CSS!
--------------------------------------------------------------------------------
*/
function initTopMenu()
{
  if (document.all&&document.getElementById)
  {
    navRoot = document.getElementById("topmenu");
    try
    {
      if (navRoot != null)
      {
        for (i=0; i<navRoot.childNodes.length; i++)
        {
          node = navRoot.childNodes[i];
          if (node.nodeName=="LI")
          {
            node.onmouseover=function() { this.className+=" over"; }
            node.onmouseout=function() { this.className=this.className.replace(" over", ""); }
          }
        }
      }
    } catch (err) {}
  }
}
/*
--------------------------------------------------------------------------------
 */


/*  A typical display-this-element-and-hide-the-others script. Runs when the
    Most Viewed component in the sidebar's clicked.
 */
function sidebarMostViewedSelect(id)
{
  var i = 0;
  while (true)
  {
    var section = document.getElementById("sidebarMostViewed_sections_" + i);
    var story = document.getElementById("sidebarMostViewed_stories_" + i);
    if (section == null || story == null) { break; }
    if (i == id) { section.className = "show"; story.className = "show"; }
    else { section.className = "hide"; story.className = "hide"; }
    i++;
  }
}




/*  Utility Functions
--------------------------------------------------------------------------------
*/
/*  Well, since we don't have Server.HTMLEncode() in JS...
 */
function htmlSafe(str)
{
  var output = new String(str);
  output = output.replace(/&/g, "&amp;");
  output = output.replace(/\"/g, "&quot;");
  output = output.replace(/</g, "&lt;");
  output = output.replace(/>/g, "&gt;");
  return output;
}

/*  Bind function to an object.
*/
function bindFunction(obj, fnc)
{ return function() { return fnc.apply(obj, arguments); }; }
/*
--------------------------------------------------------------------------------
*/



/*  TechCentral2010, GO!
--------------------------------------------------------------------------------
 */
window.onload = initTechCentral2010;
/*
--------------------------------------------------------------------------------
 */