// for older browsers, which dont have undefined.
var undefined;
var baseUrl = "http://www.lehigh.edu/computing/hpc/";
var numHeads = 8;
var heads = new Array();

// **************************************************************************
//
// Change headings and subheadings in the list on the left menu here
//
// **************************************************************************
//
// first input all data.
// following inputs define what headings and subheadings should appear in the
// left menu of the hpc pages.
// For instance, if you need the first heading and subheadings to be:
// WELCOME
//    HOW TO CODE
//    HOW TO MAKE PIE
//    HELP ME
// then the data will be entered as:
// heads[0] = new Head("WELCOME","index.html",3)
// heads[0].subHeads[0] = new subHead("HOW TO CODE","home/code.html");
// heads[0].subHeads[1] = new subHead("HOW TO MAKE PIE","home/pie.html");
// heads[0].subHeads[2] = new subHead("HELP ME","home/help_me_page.html");
//

heads[0] = new Head("HPC Home","index.html",0);

heads[1] = new Head("Accessing Services","services/index.html",6);
heads[1].subHeads[0] = new subHead("Available Hardware","services/hardware.html");
heads[1].subHeads[1] = new subHead("Available Software","services/software.html");
heads[1].subHeads[2] = new subHead("Usage Policies","help/policies.html");
heads[1].subHeads[3] = new subHead("Storage","services/storage.html");
heads[1].subHeads[4] = new subHead("Using ssh to login","services/ssh.html");
heads[1].subHeads[5] = new subHead("Usage Statistics","services/usage.html");

heads[2] = new Head("Running Jobs","running/index.html",5);
heads[2].subHeads[0] = new subHead("Compiling programs","running/compile.html");
heads[2].subHeads[1] = new subHead("Simple jobs","running/simple.html");
heads[2].subHeads[2] = new subHead("MPI jobs","running/parallel.html");
heads[2].subHeads[3] = new subHead("Using Condor","running/condor.html");
heads[2].subHeads[4] = new subHead("Application Software","running/software_howto.html");

heads[3] = new Head("Troubleshooting","troubleshooting/index.html",2);
heads[3].subHeads[0] = new subHead("Basic Linux","troubleshooting/linux.html");
heads[3].subHeads[1] = new subHead("FAQs","troubleshooting/faqs.html");

heads[4] = new Head("Information/Help","help/index.html",6);
heads[4].subHeads[0] = new subHead("Tutorials/Presentations","help/tutorials.html");
heads[4].subHeads[1] = new subHead("Request Forms","help/forms.html");
heads[4].subHeads[2] = new subHead("HPC Steer Commmitee","help/hpcsc.html");
heads[4].subHeads[3] = new subHead("HPC E-Mail List","home/mailing_list.html");
heads[4].subHeads[4] = new subHead("Access TeraGrid","help/teragrid.html");
heads[4].subHeads[5] = new subHead("Internet2","i2.html");

heads[5] = new Head("HPC Day at Lehigh","hpcday/2009/index.html",1);
heads[5].subHeads[0] = new subHead("HPC Day Archives","hpcday/archives.html");
heads[6] = new Head("Contact us","contact_us/index.html",0);

heads[7] = new Head("Search HPC","search/index.html",0);

//
// **************************************************************************
// End of list data, in the next section it, along with the top and the bottom
// information is written to the html page
// **************************************************************************
//

//
// Write the top horizontal bar
//
//
document.write("",
"<div class=\"top_box\">",
"<div class=\"left_box_background\"></div>",
"<a href=\"http://www.lehigh.edu/\">Lehigh Home</a> |",
"<a href=\"http://www.lehigh.edu/lts/\">LTS</a> |",
"<a href=\"http://www.lehigh.edu/computing/\">Computing & Media</a> |",
"<a href=\"http://www.lehigh.edu/library/library.html\">Libraries</a> |",
"<a href=\"http://www.lehigh.edu/phones/phones.html\">Telephones</a> |",
"<a href=\"http://www.lehigh.edu/lts/courses.html\">Course Materials</a>|",
"<a href=\"http://www.lehigh.edu/helpdesk/helpdesk.html\">Helpdesk</a>",
"</div>",
"<div class=\"left_box\">",
"<div align=\"center\">",
"<a href=\"http://www.lehigh.edu/~inlts/mainlts.html\"><img src=\"http://www.lehigh.edu/lts/ltslogo-m.gif\"  alt=\"LTS: Library and Technology Services\" border=\"0\"></a><BR>",
"High Performance<br>Computing at Lehigh<br>",
"<img src=\"http://www.lehigh.edu/lts/hr.gif\" width = \"95%\"alt=\"Line\"><BR><BR>",
"</div>"
);

for (var i=0;i<numHeads;i++) {
   if (i==headNum) {
      heads[i].collapsed=false;
   }
}

//
// Write all the heads and subheads of the left menu
//
document.write("<div id=\"headsAndSubheads\" class=\"headsAndSubheads\">");
document.write(getHeadsAndSubheads());
document.write("</div>");

//
// Write bottom of the left menu, image etc.
//
document.write("",
"<div align=\"center\">",
"<BR>",
"<img src=\"http://www.lehigh.edu/lts/hr.gif\" width=\"95%\" alt=\"\">",
"<BR><BR>",
"<span align=\"center\"><center><a href=\"http://www.lehigh.edu\"><img src=\"http://www.lehigh.edu/lts/lulogo.gif\" alt=\"Lehigh University\" border=\"0\"></a></center></span>",
"<br><br>",
"</div>",
"</div>"
);


// **************************************************************************
// YOU SHOULD NOT MESS WITH THE FOLLOWING IF YOU ARE ONLY CHANGING DATA
// **************************************************************************

// Constructor for the class Head, subHead
function Head(title, url, numSubHeads)
{
  this.title = title;
  this.url = baseUrl+url;
  this.numSubHeads = numSubHeads;
  this.subHeads = new Array();
  this.collapsed = true;
}
function subHead(title,url)
{
  this.title = title;
  this.url = baseUrl+url;
}

//
// This is the guts of the whole script it combines everything into the
// variable 'd', which is then written to the html page.
//
function getHeadsAndSubheads() {
   var d = "";
   for (var i=0;i<numHeads;i++) {
      d=d+"<ul class=\"left_menu\">";
      if (heads[i].numSubHeads==0) {
	 sign = "";
      } else if (heads[i].collapsed==false) {
	 sign="&nbsp;(-)";
      } else {
	 sign="&nbsp;(+)";
      }
      if (i==headNum && subHeadNum==-1) {
	 d=d+"<div class=\"highlight\">";
      }
      d=d+"<li>";
      d=d+"<a href=\""+heads[i].url+"\">"+heads[i].title+"</a>";
      d=d+"<font class=\"plus_sign\" onclick=toggle_subhead("+i+")>"+sign+"</font>";
      if (i==headNum && subHeadNum==-1) {
	 d=d+"</div>";
      }
      if (heads[i].collapsed==false) {
         d=d+"<ul class=\"left_sub_menu\">";
	 for (var j=0;j<heads[i].numSubHeads;j++) {
	    d=d+"<li>";
	    if (i==headNum && j==subHeadNum) {
	       d=d+"<div class=\"highlight\">";
	    }
	    d=d+"<a href=\""+heads[i].subHeads[j].url+"\">"+heads[i].subHeads[j].title+"</a>";
	    if (i==headNum && j==subHeadNum) {
	       d=d+"</div>";
	    }
	    d=d+"</li>";
	 }
	 d=d+"</ul>";
      }
      d=d+"</ul>";
   }
   return(d);
}


function toggle_subhead(i)
{
   // we should be here only for the unhighlighted heads
   //
   if (heads[i].collapsed==true) {
      heads[i].collapsed=false;
   } else {
      heads[i].collapsed=true;
   }
   d=getHeadsAndSubheads();
   //alert(d);
   document.getElementById("headsAndSubheads").innerHTML=d;
}

