// CMMR JavaScript

function initialize() {
	window.focus();
}

/*********************** QUICKLINKS DROPDOWN MENU ************************/

// Research & Support Group Constants corresponding to Quicklinks dropdown
TCP = 1
MICE = 2
CMMR = 3
CMHD = 4
ResearchFacility = 5
Transgenic = 6

function goSite() {
index = document.fQuicklinks.sQuicklinks.selectedIndex;
  if (index == TCP) {
    window.location = "http://www.phenogenomics.ca" 
  } 
  else if (index == CMHD) {
    window.location = "http://www.cmhd.ca" 
  } 
  else if (index == CMMR) {
    window.location = "http://www.cmmr.ca" 
  } 
  else if (index == MICE) {
    window.location = "http://www.mouseimaging.ca" 
  } 
  else if (index == ResearchFacility) {
    window.location = "http://www.phenogenomics.ca/rs/research_facility.html" 
  } 
  else if (index == Transgenic) {
    window.location = "http://www.phenogenomics.ca/transgenics/index.html" 
  }
}

/*********************** DYNAMIC LEFT NAVIGATION MENU ************************/

/*
// The following is for Reference: each numerical ID corresponds to the html tag IDs and menu IDs assigned to each page

0_0_0 = Home

1_0_0 = About CMHD
1_1_0 = About CMHD -> Organization & Objectives
1_2_0 = About CMHD -> Partners & Collaborators
1_3_0 = About CMHD -> PI's Message
1_4_0 = About CMHD -> Publications
1_5_0 = About CMHD -> Contact Us
1_6_0 = About CMHD -> Maps & Directions

2_0_0 = ENU Mutagenesis
2_1_0 = ENU Mutagenesis -> Physiology Statistics
2_2_0 = ENU Mutagenesis -> Search Mutants by Phenotype
2_3_0 = ENU Mutagenesis -> Search Mutants by Heritability
2_4_0 = ENU Mutagenesis -> Mutagenesis & Physiology Overview
2_5_0 = ENU Mutagenesis -> Physiology Assays & Protocols
2_6_0 = ENU Mutagenesis -> Mutagenesis Throughput
2_7_0 = ENU Mutagenesis -> Current Research Projects
2_8_0 = ENU Mutagenesis -> Pathology
2_9_0 = ENU Mutagenesis -> ENU Pathology Screens

3_0_0 = Gene Trap
3_1_0 = Gene Trap -> About Us
3_1_1 = Gene Trap -> About Us -> Personnel
3_1_2 = Gene Trap -> About Us -> Funding
3_1_3 = Gene Trap -> About Us -> Collaborators
3_2_0 = Gene Trap -> Search by Sequence
3_3_0 = Gene Trap -> Search by Expression
3_4_0 = Gene Trap -> Statistics
3_5_0 = Gene Trap -> Clone Requests
3_6_0 = Gene Trap -> Custom Email Alert
3_7_0 = Gene Trap -> NAISTrap
3_8_0 = Gene Trap -> IGTC
3_9_0 = Gene Trap -> Information
3_9_1 = Gene Trap -> Information -> Gene Trap Primer
3_9_2 = Gene Trap -> Information -> PolyA Trapping & NMD
3_9_3 = Gene Trap -> Information -> Cell Lines
3_9_4 = Gene Trap -> Information -> Vectors
3_9_5 = Gene Trap -> Information -> Vector Maps
3_9_6 = Gene Trap -> Information -> Protocols
3_9_7 = Gene Trap -> Information -> Publications
3_9_8 = Gene Trap -> Information -> Gene Trap How-To
3_9_9 = Gene Trap -> Information -> Gene Trap FAQs

4_0_0 = CMHD Services

5_0_0 = CMHD Databases
------------------------------------------------ 
5_0_0 = Mutants Database -> Mouse Line List
5_0_0 = Mutants Database -> Tailclips Collection
5_0_0 = Mutants Database -> Histopathology
5_0_0 = Mutants Database -> Archiving
5_0_0 = Mutants Database -> Database Download
------------------------------------------------

6_0_0 = Help & Reference
6_1_0 = Help & Reference -> Glossary
6_2_0 = Help & Reference -> FAQs
6_3_0 = Help & Reference -> Links

7_0_0 = TCP News & Events

*/

// Each page will keep a line of Javascript that looks like the following for its menu ID
// var menuID = new String("#_#_#");

// Array to keep track of the number of submenu items
menu = new Array(7);		// main menu
menu[0] = new Array(6);		// About Us section
menu[1] = new Array(9);		// ENU Mutagenesis section
menu[2] = new Array(9);		// Gene Trap section
menu[2][0] = new Array(3);		// Gene Trap -> About Us section
menu[2][8] = new Array(9);		// Gene Trap -> Information section
menu[5] = new Array(3);		// Help & Reference section

// for keeping track of swap image
var prev_img;

function displayLeftMenu() {
	var strLevel = menuID.split("_");
	var level = new Array(3);
	for (i=0; i<3; i++) {
		level[i] = Number(strLevel[i]);
	}
/*
	// Get the menu level indices for the current page based on this page's menu id that has been assigned at that page
	var item1 = Number(menuID.substr(0,1)); 
	var item2 = Number(menuID.substr(2,1)); 
	var item3 = Number(menuID.substr(4,1)); 
*/
	
	// Get the number of submenu items required for this page
	var length1 = menu.length; //number of menu items at the lowest level
	var length2=0, length3=0;
	if ((level[0] != 0) && (menu[level[0]-1] != null)) {
		length2 = menu[level[0]-1].length;
		if ((level[1] != 0) && (menu[level[0]-1][level[1]-1] != null)) {
			length3 = menu[level[0]-1][level[1]-1].length;
		}
	}
	
	// Go through the menu, displaying the relevant items for the current page
	for (i=1; i<=length1; i++) {
		// if this menu item corresponds to the current page, display it selected and display its submenu if applicable
		// otherwise, display it unselected
		if (i==level[0]) {
			displaySelected (level[0]+"_0_0");
			if (length2 > 0) displaySectionBody (level[0]);
			for (j=1; j<=length2; j++) {
				// if this menu item corresponds to the current page, display it selected and display its submenu if applicable
				// otherwise, display it unselected
				if (j==level[1]) {
					displaySelected (String(i)+"_"+String(j)+"_0");
					if (length3 > 0) displaySectionBody (level[0]+"_"+level[1]);
					for (k=1; k<=length3; k++) {
						if (k==level[2]) {
							displaySelected (String(i)+"_"+String(j)+"_"+String(k));
						}
						else {
							displayUnselected (String(i)+"_"+String(j)+"_"+String(k));
						}
					}
				}
				else {
					displayUnselected (String(i)+"_"+String(j)+"_0");
				}
			}
		}
		else {
			displayUnselected (String(i)+"_0_0");
		}
	}
	//display end of left menu
    var end_obj = document.getElementById("lhn_end");
	end_obj.style.display = "block";
	
	var end_tcp_obj = document.getElementById("lhn_tcp_end");
	end_tcp_obj.style.display = "block";

}

function displaySelected(menu_id) {
    var menu_obj = document.getElementById(menu_id);
	menu_obj.style.listStyleImage ="url(/assets/CMHD_arrow_sel.gif)";
	menu_obj.style.display = "list-item";
}

function displayUnselected(menu_id) {
    var menu_obj = document.getElementById(menu_id);
	menu_obj.style.display = "list-item";
}

function displaySectionBody(section_id) {
    var section_obj = document.getElementById(section_id);
	section_obj.style.display = "block";
}

function swapBullet (menu_id) {
    var menu_obj = document.getElementById(menu_id);
	prev_img = menu_obj.style.listStyleImage;
	menu_obj.style.listStyleImage = "url(/assets/CMHD_arrow.gif)";
	menu_obj.style.display = "list-item";
}

function swapBullet_TCP (menu_id) {
    var menu_obj = document.getElementById(menu_id);
	prev_img = menu_obj.style.listStyleImage;
	menu_obj.style.listStyleImage = "url(/assets/CMHD_arrow_TCP.gif)";
	menu_obj.style.display = "list-item";
}

function swapRestore(menu_id) {
    var menu_obj = document.getElementById(menu_id);
	menu_obj.style.listStyleImage = prev_img;
}

/************************ DREAMWEAVER PREDEFINED FUNCTIONS ***********************/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out") {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}