// JScript source code 
//Xin Jin 
//June 30 2005
//display left menu

//below is not being used.
//object used as a menu item

//contribute seems to have problems for the link\
//created by javascript, so php is now used for
//menu display
/*
function LMenu(name, action)
{
	this.name = name;
	this.items = new Array();
	this.addMenuItem = addLMenuItem;
	this.action = action;
}

function addLMenuItem(son)
{
	//document.writeln('addmenuitem '+ son.name + ' to ' + this.name + '<p>');
	this.items[this.items.length] = son;	
}
function getActive(i, name)
{
	//document.writeln('beggining of getActive for ' + i.name +'<p>');		
	var j;
	for (j=0; j<i.items.length;j++) {
			//document.writeln('son of i is' + i.items[j].name+'<p>');
		if (i.items[j].name == name) {
			return '+' + name + '+';
		}
	}
	var k =0;
	var activedir = '';
	for (k=0; k<i.items.length;k++) {
		activedir = getActive(i.items[k], name);
		if	(activedir != "")
			return '+' + i.items[k].name + "+" + activedir;
	}	
	return "";
}
function RenderMenu(name)
{
	var r = ConstructMenu();
	
	active = getActive(r, name);
	
	DrawLeftMenu(r,-1,active);
}
//DrawLeftMenu will draw the menu on the left according to the id of menu
//layer: 0,1 or 2
//active is the list of names on the branch
function DrawLeftMenu(menu, layer, active)
{
	//document.writeln('beggining of DrawLeftMenu name is '+menu.name+' layer is '+layer+'active is '+active+'<p>');	
	if (layer == -1) {
		//document.writeln('layer is -1');
		var k = 0;
		//document.writeln('k is' + k);
		//document.writeln('lenght is' +menu.items.length);
		for (k=0; k<menu.items.length;k++) {
			//document.writeln('k is' + k);
			DrawLeftMenu(menu.items[k], 0, active);
		}
		
		return;
	}
			
	var cls = "";
	if (active.indexOf('+'+menu.name+'+') != -1)
		cls = 'act';
	else
		cls = 'no';

	//document.writeln('cls is '+cls+'<p>');	
	var c = "";
	switch (layer) {
	case 0:
		c = ' <tr><td colspan="1" class="left_nav_level_0-' + cls + '"> </td>';
		c += '<td class="left_nav_level_0-' + cls + '" colspan="3"> &raquo; &nbsp;<A HREF="'+ menu.action +'" onFocus="blurLink(this);">'+menu.name+'</A></td></tr>';
		break;
	case 1:
		c += '<tr><td class="left_nav_level_0-act" colspan="1"> </td>'; //parents must be active
		c += '<td class="left_nav_level_1-' + cls + '" colspan="1"> </td>';
		c += '<td class="left_nav_level_1-' + cls + '" colspan="2"> &raquo; &nbsp;<A HREF="'+ menu.action +'" onFocus="blurLink(this);">'+menu.name+'</A></td></tr>';
		break;
	case 2:
		c += '<tr><td class="left_nav_level_0-act" colspan="1"> </td>';
		c += '<td class="left_nav_level_1-no" colspan="1"> </td>';
		c += '<td class="left_nav_level_2-' + cls + '" colspan="1"> </td>';
		c += '<td class="left_nav_level_2-' + cls + '" colspan="1"> &raquo; &nbsp;<A HREF="'+ menu.action +'" onFocus="blurLink(this);">'+menu.name+'</A></td></tr>';
		break;
	}
	document.writeln(c);
	//only active menuitem draw their sons
	if (cls == 'act') {
		var i;
		for (i=0; i<menu.items.length;i++)
			DrawLeftMenu(menu.items[i], layer+1, active);		
	}
	//document.writeln('ending of DrawLeftMenu name is '+menu.name+' layer is '+layer+'active is '+active+'<p>');	
}

//draw navigator information on top of content
function RenderNavigator(name)
{
	var r = ConstructMenu();
	
	active = getActive(r, name);
	DrawNavigator(r, -1, active, name);
}

function DrawNavigator(menu, layer, active, name)
{
	if (layer == -1) {
		if (menu.name != name)
			document.write('<A HREF="'+menu.action+'">'+menu.name+'</A>');
		else {
			document.write(name);
			return;
		}
		var k = 0;
		for (k=0; k<menu.items.length;k++) {
			DrawNavigator(menu.items[k], 0, active, name);
		}		
		return;
	}

	var cls = "";
	if (active.indexOf('+'+menu.name+'+') != -1)
		cls = 'act';
	else
		cls = 'no';

	if (cls == 'act') {
	    document.write(' << ');
		if (menu.name == name)
			document.write(menu.name);		
		else
			document.write('<A HREF="'+menu.action+'">'+menu.name+'</A>');		
	
		var i;
		for (i=0; i<menu.items.length;i++)
			DrawNavigator(menu.items[i], layer+1, active, name);		
	}	
}


function ConstructMenu()
{
	//document.writeln('beggining of constructmenu<p>');
	root = new LMenu("home","../index.php");	
	
	//Homepage
	hp = new LMenu('HomePage', '../index.php');
	
	
	//about
	about = new LMenu("About Us","../aboutus/index.php");
	contact = new LMenu("Contact Us","../aboutus/contact.php");
	employment = new LMenu("Employment","../aboutus/employment.php");
	fulltime = new LMenu("Full-time Staff","../aboutus/fulltime.php");
	posdocEmp = new LMenu("Postdoctoral Fellowships","../aboutus/posdocemp.php");
	gradAssist = new LMenu("Graduate Assistantships","../aboutus/gradassist.php");
	loc = new LMenu("Location","../aboutus/location.php");
	mailList = new LMenu("Mailing List","../aboutus/mailList.php");
	news = new LMenu("News","../aboutus/news.php");
	
	about.addMenuItem(contact);
	about.addMenuItem(employment);
	about.addMenuItem(loc);
	about.addMenuItem(mailList);
	about.addMenuItem(news);
	employment.addMenuItem(fulltime);
	employment.addMenuItem(posdocEmp);
	employment.addMenuItem(gradAssist);	

	//people
	people = new LMenu("People","../people/index.php");
	Faculty = new LMenu("Faculty", "../people/faculty.php");
	Staff = new LMenu("Staff", "../people/staff.php");
	PostdoctoralFellows = new LMenu("Postdoctoral Fellows", "../people/postfellow.php");
	GraduateStudents = new LMenu("Graduate Students","../people/graduatestu.php");
	Undergraduates = new LMenu("Undergraduates", "../people/undergraduates.php");
		//faculty
		MAon = new LMenu('Miguel Aon', '../people/mAon.php');
		sCortassa = new LMenu('Sonia Cortassa', '../people/sCortassa.php');
		dGeman = new LMenu('Donald Geman', '../people/dGeman.php');
		jGreenstein= new LMenu('Joseph Greenstein', '../people/jGreenstein.php');
		eMarbán = new LMenu('Eduardo Marbán', '../people/eMarbán.php');
		aMcCulloch = new LMenu('Andrew McCulloch', '../people/aMcCulloch.php');
		dNaiman = new LMenu('Daniel Naiman', '../people/dNaiman.php');
		sSubramaniam = new LMenu('Shankar Subramaniam', '../people/sSubramaniam.php');
		gTomaselli = new LMenu('Gordon Tomaselli', '../people/gTomaselli.php');
		jEyk = new LMenu('Jennifer Van Eyk', '../people/jEyk.php');
		rWinslow = new LMenu('Raimond Winslow', '../people/rWinslow.php');										
		
		Faculty.addMenuItem(MAon);
		Faculty.addMenuItem(sCortassa);Faculty.addMenuItem(dGeman);
		Faculty.addMenuItem(jGreenstein);Faculty.addMenuItem(eMarbán);Faculty.addMenuItem(aMcCulloch);
		Faculty.addMenuItem(dNaiman);Faculty.addMenuItem(sSubramaniam);Faculty.addMenuItem(gTomaselli);Faculty.addMenuItem(jEyk);Faculty.addMenuItem(rWinslow);
		
		//staff
  	    aAlbinak = new LMenu('Anne Albinak', '../people/aAlbinak.php');
		sGranite = new LMenu('Stephen Granite', '../people/sGranite.php');
		kStevens = new LMenu('Keith Stevens', '../people/kStevens.php');
		jTrentowski = new LMenu('Jennifer Trentowski', '../people/jTrentowski.php');
		jXiang = new LMenu('Joseph Xiang', '../people/jXiang.php');
		gYang = new LMenu('Gem Yang', '../people/gYang.php');
		jYang = new LMenu('Jason Yang', '../people/jYang.php');
		
		Staff.addMenuItem(aAlbinak);
		Staff.addMenuItem(sGranite);Staff.addMenuItem(kStevens);
		Staff.addMenuItem(jTrentowski);	Staff.addMenuItem(jXiang);Staff.addMenuItem(gYang);	Staff.addMenuItem(jYang);
		
		//post doc
		
		yCao = new LMenu('Yan Cao', '../people/yCao.php');
		zGao = new LMenu('Zhong Gao', '../people/zGao.php');
		//pHelm = new LMenu('Patrick Helm', '../people/pHelm.php');
		aTan = new LMenu('Aik Choon Tan', '../people/aTan.php');
		aTanskanen = new LMenu('Antti Tanskanen', '../people/aTanskanen.php');
		

		PostdoctoralFellows.addMenuItem(yCao);
		PostdoctoralFellows.addMenuItem(zGao);
		//PostdoctoralFellows.addMenuItem(pHelm);
		PostdoctoralFellows.addMenuItem(aTan);
		PostdoctoralFellows.addMenuItem(aTanskanen);		
		
		//graduate students
        tAlmas = new LMenu('Tabish Almas', '../people/tAlmas.php');
		tAnderson = new LMenu( 'Troy Anderson', '../people/tAnderson.php');
		rKazmierskis = new LMenu('Robert Kazmierskis', '../people/rKazmierskis.php');
		pShah = new LMenu('Preyash Shah', '../people/pShah.php');		
		kYeung = new LMenu('Katherine Yeung', '../people/kYeung.php');
		cYung = new LMenu('Christina Yung', '../people/cYung.php');
		lXu = new LMenu('Lei Xu', '../people/lXu.php');
		
		GraduateStudents.addMenuItem(tAlmas);GraduateStudents.addMenuItem(tAnderson);GraduateStudents.addMenuItem(rKazmierskis);
		GraduateStudents.addMenuItem(kYeung);GraduateStudents.addMenuItem(cYung);GraduateStudents.addMenuItem(lXu);
		
		//undergraduates
		wBishop = new LMenu('Will Bishop', '../people/wBishop.php');
		lDoyle = new LMenu('Laura Doyle', '../people/lDoyle.php');
		//rJacques = new LMenu('Robert Jacques', '../people/rJacques.php');
		//vLee = new LMenu('Victor Lee', '../people/vLee.php');
				
		Undergraduates.addMenuItem(wBishop); Undergraduates.addMenuItem(lDoyle);
		//Undergraduates.addMenuItem(rJacques); Undergraduates.addMenuItem(vLee);
		

				
	people.addMenuItem(Faculty);
	people.addMenuItem(Staff);
	people.addMenuItem(PostdoctoralFellows);
	people.addMenuItem(GraduateStudents);
	people.addMenuItem(Undergraduates);
	
	
	
	//Research 
	rs = new LMenu('Research', '../research/index.php');
	
	rProjects = new LMenu('Research Projects', '../research/rProjects.php');
	Collaborations =  new LMenu('Collaborations', '../research/Collaborations.php');
	dSets = new LMenu('Data Sets', '../research/dSets.php');
	im = new LMenu('Images & Movies', '../research/im.php');

	
	
	rs.addMenuItem(rProjects);	rs.addMenuItem(Collaborations); 	rs.addMenuItem(dSets);	rs.addMenuItem(im);
	
	
	//Databases
	db = new LMenu('Databases', 'http://localhost/databases/research/index.php');
	
	
	cage = new LMenu(' CAGE (Cardiac Gene Expression) Knowledgebase', 'http://localhost/databases/databases/cage.php');
	mage = new LMenu('MAGE-DB2', 'http://localhost/databases/databases/mage.php');
	protein = new LMenu('Protein-DB2',  'http://localhost/databases/databases/protein.php');
	
	db.addMenuItem(cage); db.addMenuItem(mage); db.addMenuItem(protein);

	
	//Software
	sw = new LMenu('Software', 'http://localhost/software/index.php');
	app = new LMenu('Applications', '../software/applications.php');
	models = new LMenu('Models', '../software/models.php');

	card = new LMenu('Cardiac Anatomic Database', '../software/card.php');
	pdb2 = new LMenu('Protein-DB2', '../software/proteindb2.php');
   	app.addMenuItem(card); app.addMenuItem(pdb2);
	
	huvmm = new LMenu('Human Ventricular Myocyte Models', '../software/hvmm.php');
	cvcm = new LMenu('Canine Ventricular Cell Models', '../software/cvcm.php');
	scvm = new LMenu('Stochastic Canine Ventricular Model', '../software/scvm.php');
	eccd = new LMenu('Endothelial Cell Calcium Dynamics', '../software/eccd.php');
	//fru = new LMenu('Functional Release Unit', '../software/fru.php');
	gpvcm = new LMenu('Guinea Pig Ventricular Cell Model', '../software/gpvcm.php');
	kcm = new LMenu('hKv4.3 Channel Model', '../software/kcm.php');
	//kkmpc = new LMenu('KvLQT1 and KvLQT1/minK Potassium Channels', '../software/kkmpc.php');
	mimo = new LMenu('Mitochondrial Model', '../software/mimo.php');
	nacm = new LMenu('Na Channel Model (SCN5A)', '../software/nacm.php');
	whm = new LMenu('Whole Heart Model', '../software/whm.php');
	models.addMenuItem(huvmm); models.addMenuItem(cvcm); models.addMenuItem(scvm); models.addMenuItem(eccd);
	//models.addMenuItem(fru);
	models.addMenuItem(gpvcm); models.addMenuItem(kcm); 
	//models.addMenuItem(kkmpc);
	models.addMenuItem(mimo); models.addMenuItem(nacm);
	models.addMenuItem(whm);

	sw.addMenuItem(app); sw.addMenuItem(models);
	
	
	//Publications
	pb = new LMenu('Publications', 'http://localhost/publications/index.php');
	spb = new LMenu('Publications', 'http://localhost/publications/publications.php');
	presentation = new LMenu('Presentations', 'http://localhost/publications/presentation.php');
	theses = new LMenu('Theses', 'http://localhost/publications/theses.php');
	
	ppb = new LMenu('Peer Reviewed Publications', '../publications/ppb.php');
	spb.addMenuItem(ppb);
	
	pb.addMenuItem(spb); pb.addMenuItem(presentation); pb.addMenuItem(theses);
	//Education
	ed = new LMenu('Education',  'http://localhost/education/index.php');
	grtrain = new LMenu('Graduate Training', '../education/gratrain.php');
	cws = new LMenu('Course Web Sites', '../education/cws.php');
	ccse = new LMenu('CCBM Seminars', '../education/ccse.php');

	bme421 = new LMenu('BME 580.421', '../education/bme421.php');
	bme483 = new LMenu('BME 580.483', '../education/bme483.php');
	bme681 = new LMenu('BME 580.681', '../education/bme681.php');
	bme682 = new LMenu('BME 580.682', '../education/bme682.php');
	cws.addMenuItem(bme421); cws.addMenuItem(bme483);cws.addMenuItem(bme681);cws.addMenuItem(bme682);
	
	se1 = new LMenu('9/23/2004 -Michael Beer', '../education/se9232004.php');
	se2 = new LMenu('9/21/2004 -Myong-Hee Sung', '../education/se9212004.php');
	se3 = new LMenu('8/18/2004 - Jason Papin', '../education/se8182004.php');
	se4 = new LMenu('4/20/2004 - Tanveer Syeda-Mahmood', '../education/se4202004.php');
	se5 = new LMenu('4/13/2004 - Laurent Younes ', '../education/se4132004.php');
	se6 = new LMenu('3/30/2004 - Michael Miller', '../education/se3302004.php');
	se7 = new LMenu('3/23/2004 - Donald Geman', '../education/se3232004.php');
	se8 = new LMenu('3/9/2004 - Joel Bader', '../education/se3092004.php');
	se9 = new LMenu('2/18/2004 - Albert Montillo', '../education/se2182004.php');
	se10 = new LMenu('2/10/2004 - Aik Choon Tan', '../education/se2102004.php');
	se11 = new LMenu('12/11/2003 - Jennifer Van Eyk', '../education/se12112004.php');
	se12 = new LMenu('11/06/2003 - Eduardo Marbán', '../education/se11062003.php');
	se13 = new LMenu('10/23/2003 - Brian O\'Rourke', '../education/se10232003.php');
	se14 = new LMenu('9/12/2003 - Shankar Subramaniam', '../education/se9122003.php');
	ccse.addMenuItem(se1);	ccse.addMenuItem(se2);	ccse.addMenuItem(se3);	ccse.addMenuItem(se4);	
	ccse.addMenuItem(se5);	ccse.addMenuItem(se6);	ccse.addMenuItem(se7);	ccse.addMenuItem(se8);	
	ccse.addMenuItem(se9);	ccse.addMenuItem(se10);	ccse.addMenuItem(se11);	ccse.addMenuItem(se12);	
	ccse.addMenuItem(se13);	ccse.addMenuItem(se14);	

	ed.addMenuItem(grtrain); ed.addMenuItem(cws); ed.addMenuItem(ccse);
	
	//Resources
	//rscs = new LMenu('Resources',  'http://localhost/resources/index.php');
	//conferencing = new LMenu('Conferencing', '../resources/conferencing.php');
	//facility = new LMenu('Facilities', '../resources/facilities.php');
	//rscs.addMenuItem(conferencing); rscs.addMenuItem(facility);

	
	//Links
	lk = new LMenu('Links',  'http://localhost/links.php');
	//Site Map
	sm = new LMenu('Site Map',  'http://localhost/sitemap.php');
	//Search
	srch = new LMenu('Search',  'http://localhost/search.php');
	//User Login
	ul = new LMenu('User Login',  'http://localhost/user/login.php');
	
	
	
	
	//root
	
	
	root.addMenuItem(hp);
	root.addMenuItem(about);
	root.addMenuItem(people);
	root.addMenuItem(rs);
	root.addMenuItem(db);
	root.addMenuItem(sw);
	root.addMenuItem(pb);
	root.addMenuItem(ed);
	root.addMenuItem(rscs);
	root.addMenuItem(lk);	
	root.addMenuItem(sm);
	root.addMenuItem(srch);
	root.addMenuItem(ul);
	
	

	
	
	//document.writeln('ending of constructmenu<p>');					   
	return root;
}
*/