<!-- Paste this code into an external JavaScript file named: expandingMenu.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com
version date: 06/02/03 :: If want to use this code, feel free to do so,
but please leave this message intact. (Travis Beckham) */

// Node Functions

if(!window.Node){
  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}

function checkNode(node, filter){
  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
  var result = new Array();
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    if(checkNode(children[i], filter)) result[result.length] = children[i];
  }
  return result;
}

function getChildrenByElement(node){
  return getChildren(node, "ELEMENT_NODE");
}

function getFirstChild(node, filter){
  var child;
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    child = children[i];
    if(checkNode(child, filter)) return child;
  }
  return null;
}

function getFirstChildByText(node){
  return getFirstChild(node, "TEXT_NODE");
}

function getNextSibling(node, filter){
  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
    if(checkNode(sibling, filter)) return sibling;
  }
  return null;
}
function getNextSiblingByElement(node){
        return getNextSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;
var episodes = new Array();
var initarray = new Array();
var xshowhide = "X";
var abc;
var xyz;

var clickctr = 0;
var ctr = 0;
var initctr = 0;
var printHref;
var nolax;
var currval="";
var cflag="N";
var menus, menu, text, a, i;
var xshort="";

function newWindow1() {
    printHref = printHref.replace("&"," ");
    mywindow1=open("print_series?nola="+printHref,"mynamex","resizable=yes,toolbar=1,location=yes,scrollbars=yes,width=350,height=400");
    mywindow1.location.href = "print_series?nola="+printHref;
    if (mywindow1.opener == null) mywindow1.opener = self;
}

function restart1() {
    mywindow1.close();
}


function showMenu() {
  if(this == activeMenu){
    currval = getFirstChildByText(activeMenu).nodeValue;
  } else {
    currval = getFirstChildByText(this).nodeValue;   
  } 

  ctr = 0;
  cflag = "Y";
  for(j=0; j < clickctr; j++){
    if(currval == initarray[j]) {
     ctr = ctr + 1;
   }
  }
  if(ctr%2 == 0) {
   cflag = "N";
  }
     
  if(this == activeMenu){
    clickctr = clickctr + 1;
    activeMenu.className = "";
    getNextSiblingByElement(activeMenu).style.display = "none";
    episodes[clickctr] = getFirstChildByText(activeMenu).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    initctr = initctr + 1;
    initarray[initctr] = getFirstChildByText(activeMenu).nodeValue;
    printHref=printHref + "|" + nolax + "|" + xshort;
  }

  if((this != activeMenu) && (cflag == "N") && (xshowhide == "S")){
    clickctr = clickctr + 1;
    this.className = "";
    getNextSiblingByElement(this).style.display = "none";
    episodes[clickctr] = getFirstChildByText(this).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    initctr = initctr + 1;
    initarray[initctr] = getFirstChildByText(this).nodeValue;
    printHref=printHref + "|" + nolax + "|" + xshort;
  }

  if((this != activeMenu) && (cflag == "N") && (xshowhide == "H")){
    clickctr = clickctr + 1;
    this.className = "active";
    getNextSiblingByElement(this).style.display = "block";
    episodes[clickctr] = getFirstChildByText(this).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    initctr = initctr + 1;
    initarray[initctr] = getFirstChildByText(this).nodeValue;
    printHref=printHref + "|" + nolax + "|" + xshort;
  }

  if((this != activeMenu) && (cflag == "Y") && (xshowhide == "H")){
    clickctr = clickctr + 1;
    this.className = "";
    getNextSiblingByElement(this).style.display = "none";
    episodes[clickctr] = getFirstChildByText(this).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    initctr = initctr + 1;
    initarray[initctr] = getFirstChildByText(this).nodeValue;
    printHref=printHref + "|" + nolax + "|" + xshort;
    activeMenu = this;
  }

  if((this != activeMenu) && (cflag == "Y") && (xshowhide == "S")){
    clickctr = clickctr + 1;
    this.className = "active";
    getNextSiblingByElement(this).style.display = "block";
    episodes[clickctr] = getFirstChildByText(this).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    initctr = initctr + 1;
    initarray[initctr] = getFirstChildByText(this).nodeValue;
    printHref=printHref + "|" + nolax + "|" + xshort;
    activeMenu = this;
  }

  activeMenu = null;
  return false;
}

function whichMenu(){
  printHref = document.getElementsByName("xnola")[0].value;
  xshowhide = document.getElementsByName("xshowhide")[0].value;
  xnola = document.getElementsByName("xnola")[0].value;
  if(xshowhide == "X"){
    xshowhide = "S";
  }
  if(xshowhide == "H"){
    hideMenu();
  }
  if(xshowhide == "S"){
    initMenu();
  }
}


function initMenu(){
  menus = getChildrenByElement(document.getElementById("menu"));
  xyz = document.getElementsByName("xshowhide")[0].value;
  abc = document.getElementsByName("xnola")[0].value;
  printHref = abc;
  nolax = abc;
  xshowhide = xyz;
  episodes[0] = abc;
  for(i = 0; i < menus.length; i++){
    menu = menus[i];
    text = getFirstChildByText(menu);
    clickctr = clickctr + 1;
    a = document.createElement("a");
    menu.replaceChild(a,text);
    a.appendChild(text);
    a.style.display="block";
    a.href = "#";
    a.onclick = showMenu;
    a.onfocus = function(){this.blur()};

    a.className = "active";
    getNextSiblingByElement(a).style.display = "block";

    episodes[clickctr] = getFirstChildByText(a).nodeValue;
    xshort=episodes[clickctr].substring(0,6);
    printHref=printHref + "|" + nolax + "|" + xshort;    
  }
}

function hideMenu(){
  menus = getChildrenByElement(document.getElementById("menu"));
  for(i = 0; i < menus.length; i++){
    menu = menus[i];
    text = getFirstChildByText(menu);
    clickctr = clickctr + 1;
    a = document.createElement("a");
    menu.replaceChild(a,text);
    a.appendChild(text);
    a.href = "#";
    a.onclick = showMenu;
    a.onfocus = function(){this.blur()};
  }
}

if(document.createElement) window.onload = whichMenu;
