
function new_textwindow(url) {
link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes,width=745,height=345,left=180,top=60");
}


//browser code

  var menuItems = [
  ["Role", [
      ["Seminary Student", [
          ["Distance and Continuing Education", [
              ["Semlink", "semlink/index.php"],
              ["Writers' Workshop", "shoemaker/writers.php"],
              ["Pastors' Forums", "shoemaker/pastorsforums.php"],
              ["Summer Conference", "shoemaker/summerconference/index.php"]
            ]
          ],
          ["Personal Enrichment", [
              ["Faith Builders Audio Series", "store/index.php?cPath=20_13"],
              ["Pastor Builders Audio Series", "store/index.php?cPath=20_1"]
            ]
          ],
         /* ["Marriage and Family", [
              ["True Love Waits", "shoemaker/family.php"],
              ["Engagement Matters", "shoemaker/engagement.php"],
              ["Recapturing Eden", "shoemaker/marriage.php"]
            ]
          ], */
          ["Ministry in New England", [
              ["NERP Report", "churchrenewal/"]
            ]
          ],
          ["Missions", [
              ["World Christian Database", "globalchristianity/"],
              ["Urban Plunge", ""]
            ]
          ],		  
          ["Preaching", [
              ["PulpitTalk", "cfp/pulpittalk/index.php"],
              ["Sermon Doctor", "cfp/sermon_doc/index.php"],
              ["ThM in Preaching", "cfp/th_m.php"],
              ["Preaching Conference", "cfp/2006/index.php"]
            ]
          ],
          ["Renewal", [
              ["Brown Bag Sabbatical", "ockenga/shoemaker/brownbag.php"],
              ["Pastors' Forums", "shoemaker/pastorsforums.php"],
              ["Women's Sabbatical", "ockenga/shoemaker/womenssabbatical.php"],
              ["Spurgeon Sabbatical", "shoemaker/spurgeon.php"]
            ]
          ],
          ["Workplace", [
              ["Mockler Student Discussion Series", "mockler/index.php"],
              ["DMin in LBE", "mockler/workplace.php"],
              ["Faith in the Workplace Resources", "mockler/links.php"]
            ]
          ]
        ]
      ],

      ["All Believers", [
          ["Workplace", [
              ["Faith in the Workplace Resources", "mockler/links.php"],
              ["DMin in LBE", "mockler/churches.php"]
            ]
          ],
          ["Distance and Continuing Education", [
              ["Semlink", "semlink/"],
              ["Diploma Program", "diploma.php"],
              ["Dimensions of the Faith", "dimensions/"],
              ["Writers' Workshop", "shoemaker/writers.php"],
              ["Summer Conference", "shoemaker/summerconference/index.php"]
            ]
          ],
/*          ["Marriage and Family", [
              ["True Love Waits", "shoemaker/family.php"],
              ["Engagement Matters", "shoemaker/engagement.php"],
              ["Recapturing Eden", "shoemaker/marriage.php"]
            ]
          ], */
          ["Ministry in New England", [	
			        ["NERP Report", "churchrenewal/"],
            ]
          ],
          ["Missions", [
              ["World Christian Database", "ockenga/globalchristianity/"]
			      ]
          ],
          ["Personal Enrichment", [
              ["Faith Builders Audio Series", "store/index.php?cPath=20_13"],
              ["Pastor Builders Audio Series", "store/index.php?cPath=20_1"]
            ]
          ],
          ["Preaching", [
              ["PulpitTalk", "cfp/pulpittalk/index.php"],
              ["Preachers' College", "cfp/college/index.php"],
              ["Preaching Conference", "cfp/2004/index.php"]
            ]
          ],
          ["Programs for Youth",[
              ["Compass", "mccy/"]
			      ]
          ],
          ["Renewal", [
              ["Pastors' Forums", "shoemaker/pastorsforums.php"],
              ["Women's Sabbatical", "ockenga/shoemaker/sabbticalforwomen.php"],
              ["Summer Conference", "shoemaker/summerconference/index.php"]
            ]
          ]
        ]
      ],

      ["Pastor", [
          ["Preaching", [
              ["Sermon Doctor", "cfp/sermon_doc/index.php"],
              ["PulpitTalk", "cfp/pulpittalk/index.php"],
              ["Th.M. in Preaching", "cfp/th_m.php"],
              ["Preachers' College", "cfp/college/index.php"],
              ["Preaching Conferences", "cfp/2006/index.php"]
            ]
          ],
          ["Distance and Continuing Education", [
              ["Semlink", "semlink/"],
              ["Diploma Program", "diploma.php"],
              ["Dimensions of the Faith", "dimensions/index.php"],
              ["Writers' Workshop", "shoemaker/writers.php"],
              ["Pastors' Forums", "shoemaker/pastorsforums.php"],
              ["Summer Conference", "shoemaker/summerconference/index.php"]
            ]
          ],
          ["Programs for Youth", [
              ["Compass", "mccy/"]
			      ]
          ],
/*          ["Marriage and Family", [
              ["True Love Waits", "shoemaker/family.php"],
              ["Engagement Matters", "shoemaker/engagement.php"],
              ["Recapturing Eden", "shoemaker/marriage.php"]
			      ]
          ], */
          ["Ministry in New England", [
             ["NERP Report", "churchrenewal/"]
            ]
          ],
          ["Missions", [
              ["World Christian Database", "ockenga/globalchristianity/"]
			      ]
          ],
          ["Personal Enrichment", [
              ["Faith Builders Audio Series", "store/index.php?cPath=20_13"],
              ["Pastor Builders Audio Series", "store/index.php?cPath=20_1"]
            ]
          ],
          ["Renewal", [
              ["Brown Bag Sabbatical", "shoemaker/brownbag.php"],
              ["Pastors' Forum", "shoemaker/pastorsforums.php"],
              ["Spurgeon Sabbatical", "shoemaker/spurgeon.php"],
              ["Timothy Project", "shoemaker/timothy.php"],
              ["Women's Sabbatical", "ockenga/shoemaker/sabbaticalforwomen.php"],
              ["Summer Conference", "shoemaker/summerconference/index.php"],
                  ]
          ],
          ["Workplace", [
              ["DMin in LBE", "mockler/workplace.php"],
              ["Faith in the Workplace Resources", "mockler/links.php"]
            ]
          ]
        ]
      ],

      ["Missionary", [
          ["Distance and Continuing Education", [
              ["Semlink", "semlink/"],
              ["Diploma Program", "diploma.php"],
              ["Dimensions of the Faith", "dimensions/index.php"]
            ]
          ],
/*          ["Marriage and Family",[
              ["True Love Waits", "shoemaker/family.php"],
              ["Engagement Matters", "shoemaker/engagement.php"],
              ["Recapturing Eden", "shoemaker/marriage.php"]
			      ]
          ], */
		      ["Missions Resources", [
              ["World Christian Database", "globalchristianity/"],
              ["Web Resources", "missionscenter/resources.php"]
            ]
          ],
          ["Personal Enrichment", [
              ["Faith Builders Audio Series", "store/index.php?cPath=20_13"],
              ["Pastor Builders Audio Series", "store/index.php?cPath=20_1"]
            ]
          ],
          ["Preaching", [
              ["Sermon Doctor", "cfp/sermon_doc/index.php"],
              ["PulpitTalk", "cfp/pulpittalk/index.php"],
              ["Th.M. in Preaching", "cfp/th_m.php"],
              ["Preachers' College", "cfp/college/index.php"],
              ["Preaching Conferences", "cfp/2006/index.php"]
            ]
          ],
          ["Renewal", [
              ["Brown Bag Sabbatical", "shoemaker/brownbag.php"],
              ["Pastors' Forum", "shoemaker/pastorsforums.php"],
              ["Spurgeon Sabbatical", "shoemaker/spurgeon.php"],
              ["Timothy Project", "shoemaker/timothy.php"],
              ["Women's Sabbatical", ""],
              ["Summer Conference", "shoemaker/summerconference/index.php"],
                   ]
          ],
          ["Urban Plunges", [
              ["Mexico", "ockenga/missionscenter/programs.php"]
            ]
          ]
        ]
      ]
    ]
  ],

  ["Resource", [
      ["Events", [
          ["Conferences", [
              ["Summer Conference", "shoemaker/summerconference/index.php"],
              //["True Love Waits", "shoemaker/family.php"],
              ["Preaching Conference", "cfp/2006/index.php"],
              ["Pastors' Forum", "shoemaker/pastorsforums.php"],
              //["Marriage Builders", "shoemaker/marriage.php"]
            ]
          ],
		      ["Immersion", [
		          ["Urban Plunge", "ockenga/missionscenter/programs.php"],
			        ["Real Ministry Immersion", "mccy/rmi/index.php"]
			      ]
		      ],
		      ["Retreats", [
		          ["Brown Bag Sabbatical", "shoemaker/brownbag.php"],
			        ["Spurgeon Sabbatical", "shoemaker/spurgeon.php"],
			        ["Women's Sabbatical", "ockenga/shoemaker/sabbaticalforwomen.php"],
			     			      ]
		      ],
		      ["Discussion", [
		          ["Mockler Student Discussion Series", "mockler/"],
						      ]
		      ],
		      ["Workshop", [
              ["Writers' Workshop", "shoemaker/writers.php"],
			        ["Preachers' College", "cfp/college/index.php"],
			      //  ["Engagement Matters", "shoemaker/engagement.php"]
			      ]
		      ]
		    ]
	    ],
      
	    ["Products", [
          ["Audio", [
              ["Pastor Builders", "store/index.php?cPath=20_1"],
              ["Faith Builders", "store/index.php?cPath=20_13"],
              ["PulpitTalk", "cfp/pulpittalk/index.php"]
            ]
          ],
          ["Research and Reference", [
              ["World Christian Database", "globalchristianity/"],
              ["Missions Resources", "missionscenter/resources.php"],
              ["Faith in the Workplace Resources", "mockler/links.php"],
              ["NERP Report", "churchrenewal/"]
            ]
          ],
          ["Study Materials", [
              ["Dimensions of the Faith", "dimensions/index.php"]
            ]
          ],
		      ["Sermon Help", [
		          ["Sermon Doctor", "cfp/sermon_doc/index.php"]
			      ]
		      ]
        ]
      ],

      ["Programs", [
          ["Distance Learning", [
              ["Semlink", "semlink/index.php"],
			        ["Dimensions of the Faith", "dimensions/index.php"],
              ["Diploma", "diploma.php"]
            ]
          ],
          ["Continuing Education", [
			        ["Dimensions of the Faith", "dimensions/index.php"],
              ["Diploma", "diploma.php"]
            ]
          ]
        ]
      ]
    ]
  ],
  
  ["Center", [
      ["Center for Preaching", [
          ["Products", [
              ["Center Home", "cfp/"],
			        ["Sermon Doctor", "cfp/sermon_doc/index.php"],
			        ["PulpitTalk", "cfp/pulpittalk/index.php"]
            ]
          ],
		      ["Events", [
              ["Center Home", "cfp/"],
		          ["Preaching Conference", "cfp/2006/index.php"],
			        ["Preachers' College", "cfp/college/index.php"]
			      ]
		      ]
 		    ]
	    ],
	    ["Center for the Study of Global Christianity", [
	        ["Online Resources", [
              ["Center Home", "globalchristianity/"],
			        ["World Christian Database", "globalchristianity/"],
	            ["Status of World Christianity", "globalchristianity/resources.php"]
			      ]
		      ]
	      ]
	    ],
	    ["Ministry Center for Christian Youth", [
	        ["Youth Programs", [
			        ["Center Home", "mccy/index.php"],		      
			        ["Compass", "mccy/about/"],
			        ["Real Ministry Immersion", "mccy/rmi/index.php"]
			      ]
		      ]
		    ]
	    ],
	    ["J Christy Wilson Center, Jr. for World Missions", [
	        ["Events", [
			        ["Center Home", "missionscenter/index.php"],		      
			        ["Urban Plunges", "missionscenter/programs.php"]
			      ]
		      ],
		      ["Resources", [
			        ["Center Home", "missionscenter/index.php"],		      
			        ["Online Resources", "missionscenter/resources.php"],
			        ["About J Christy Wilson. Jr.", "missionscenter/biography.php"]
			      ]
	 	      ]
		    ]
	    ],
	    ["Mockler Center", [
	        ["Events", [
			        ["Center Home", "mockler/index.php"],		      
			        ["Sudent Discussion Groups", "mockler/"],
			        ["Speaking Events", "mockler/speaking_messenger.php"],
			        ["Christianity in the Workplace D.Min", "mockler/workplace.php"]
			      ]
		      ],
		      ["Resources", [
			        ["Center Home", "mockler/index.php"],		      
			        ["Sudent Discussion Groups", "mockler/index.php"],
			        ]
		      ]
		    ]
	    ],
	    ["Semlink", [
	        ["About the Semlink Program", [
			        ["Center Home", "semlink/"],		      
			        ["Program Information", "semlink/prospectivestudents/program/"],
			        ["Faculty and Staff", "semlink/prospectivestudents/facstaff/"],
			        ["Course Offerings",  "semlink/prospectivestudents/courses/allcourses.php"],
			        ["Register for a Class", "prospectivestudents/register/registerabout.php"]
			      ]
		      ],
		      ["Current Students", [
			        ["Center Home", "semlink/"],		      
			        ["Log into Your Course", "semlink/currentstudents/index.php"],
			        ["Go to the Interactivity Forums", "semlink/currentstudents/communitycenter/required/integration.php"],
			        ["Course Offerings", "semlink/prospectivestudents/courses/allcourses.php"],
			        ["Register for Class", "semlink/prospectivestudents/register/registerabout.php"]
			      ]
		      ]
		    ]
	    ],
	    ["Shoemaker Center for Church Renewal", [
	        ["Pastors and Students", [
			        ["Center Home", "shoemaker/"],		  
		          ["Brown Bag Sabbatical", "shoemaker/brownbag.php"],
			        ["Pastors' Forums", "shoemaker/pastorsforums.php"],
			        ["Surgeon Sabbatical", "shoemaker/spurgeon.php"],
			        ["Timothy Project", "shoemaker/timothy.php"],
			       ]
		      ],
		      ["All Believers", [
			        ["Center Home", "shoemaker/"],		     
			       // ["Engagement Matters", "shoemaker/engagement.php"],
			      //  ["Marriage Builders", "shoemaker/marriage.php"],
			        ["Summer Conference", "shoemaker/summerconference/index.php"],
			     //   ["True Love Waits", "shoemaker/family.php"],
			        ["Writers Workshop", "shoemaker/writers.php"]
			      ]
		      ],
		      ["Additional Resources", [
			        ["Center Home", "shoemaker/"],		      
			        ["Builders Series", "store/index.php?cPath=20"],
			        ["Dimensions of the Faith", "dimensions/index.php"],
			        ["Diploma Program", "diploma.php"]
			      ]
		      ]
		    ]
	    ]
	  ]
  ]
];


function deleteList(listNum)
{
  // Only delete the list if it exists
  if (document.getElementById("list" + listNum) != null)
  {
    var list = document.getElementById("list" + listNum);
    var column = document.getElementById("column" + listNum);

    column.removeChild(list);
  }
}


// If listNum is 1 then neither index1 or index2 are used.
// If listNum is 2 then index1 must be given.
// If listNum is 3 then both index1 and index2 must be given.

function populateList(listNum, index1, index2)
{

  
  // First get the browse by value
  var index0 = getBrowseBy();

  // Delete the old list
  deleteList(listNum);
 
  // If we are populating list 1 make sure lists 2 and 3 are empty
  if (listNum == 1)
  {
    deleteList(2);
    deleteList(3);
  }

  // Next, create a new list
  var list = document.createElement("ul");
  list.id = "list" + listNum;
  list.className = "list";
    
  // Determine which set of menuItems to use
  var temp = new Array();
  switch (listNum)
  {
   case 3:
    temp = menuItems[index0][1][index1][1][index2][1];
	document.getElementById('column1').style.display='none';
  	document.getElementById('column2').style.display='none';
	document.getElementById('column3').style.display='block';
    break;
   case 2:
    temp = menuItems[index0][1][index1][1];
	document.getElementById('column1').style.display='none';
	document.getElementById('column2').style.display='block';
  	document.getElementById('column3').style.display='none';
    break;
   case 1:
   default:
    temp = menuItems[index0][1];
	document.getElementById('column1').style.display='block';
	document.getElementById('column2').style.display='none';
  	document.getElementById('column3').style.display='none';
    break;
  }

  // Add the items to the list
  for(var i = 0; i < temp.length; i++)
  {
    var newNode = document.createElement("li");
    var newText = document.createTextNode(temp[i][0]);
    var newAnchor = document.createElement("a");
    newAnchor.appendChild(newText);

    // Attach the events now, or if this is list number 3 create the anchor href now.
    var href = "";
    switch (listNum)
    {
     case 3:
      href = "https://www.gordonconwell.edu/ockenga/" + temp[i][1];
      break;
     case 2:
      href = "javascript:populateList(3," + index1 + "," + i + ");";
      break;
     case 1:
     default:
      href = "javascript:deleteList(3);populateList(2," + i + ");";
      break;
    }

    newAnchor.href = href;
    newNode.appendChild(newAnchor);

    list.appendChild(newNode);
  }

  // Attach this list to the correct column
  var column = document.getElementById("column" + listNum);
  column.appendChild(list);

  // Finally, highlight the caller
  switch (listNum)
  {
   case 3:
    unHighlightAll(2);
    highlightLink(2, index2);
    break;
   case 2:
    unHighlightAll(1);
    highlightLink(1, index1);
    break;
  }
}


// TODO: Make this more dynamic.

function getBrowseBy()
{
  if (document.getElementById("role").checked)
    return(document.getElementById("role").value);
  else if (document.getElementById("resource").checked)
    return(document.getElementById("resource").value);
  else if (document.getElementById("center").checked)
    return(document.getElementById("center").value);
}


function appendClass(obj, className)
{
  // Only add this className if it doesn't already exist.
  myExp = new RegExp('\s*' + className + '\s*');
  if (!myExp.test(obj.className))
  {
    // Only add space if the current className is non-empty
    obj.className += (obj.className ? ' ' : '') + className;
  }
}


function removeClass(obj, className)
{
  // Replace className (and surrounding spaces if present) with a single space.
  obj.className = obj.className.replace(new RegExp('\s*' + className + '\s*'), ' ');
}


function highlightLink(listNum, index)
{
  var list = document.getElementById("list" + listNum);

  // All we need to do now is just find the index'th li element in this list.
  var j = 0;
  for (var i = 0; i < list.childNodes.length; i++)
  {
    if (list.childNodes[i].nodeName != "LI")
      continue;

    if (j == index)
      appendClass(list.childNodes[i], "GCTS_highlight");

    j++;
  }
}


function goback()
{
	if (document.getElementById('column3').style.display=='block'){
		document.getElementById('column1').style.display='none';
		document.getElementById('column2').style.display='block';
  		document.getElementById('column3').style.display='none';
	} else {
  		document.getElementById('column1').style.display='block';
		document.getElementById('column2').style.display='none';
  		document.getElementById('column3').style.display='none';
	}
}

function unHighlightAll(listNum)
{
  var list = document.getElementById("list" + listNum);

  // All we need to do now is just remove all hightlighting from the li elements
  for (var i = 0; i < list.childNodes.length; i++)
  {
    if (list.childNodes[i].nodeName != "LI")
      continue;

    removeClass(list.childNodes[i], "GCTS_highlight");
  }
}


