/*For Mac with layout manager issues where css is loaded AFTER javascript load, this should resolve the
js css style change event*/

/*
 *	This is the function for adjusting the right and left navigation bar so the color will extend to the bottom
 *  of the page.
 *
 *	Author: Huming Tang
 */
function adjustNavigation()
{
	var staticHeight = document.getElementById("biosk-center-container").clientHeight;
	
	if (staticHeight<300)
		staticHeight=300;
	try{
		document.getElementById("biosk-left-left-container").style.height = (staticHeight+25) + "px";
		document.getElementById("biosk-right-container").style.height = (staticHeight+25) + "px";
	}
	catch(e)
	{
		//do nothing case for pages with no left nav
		
		
	}
	
	
}

/*this is the script for setting the left nav coloring scene*/
//javascript for getting the correct highlight, please be aware that this is a temp solution
function setHighlight()
{
	// Get current URL
	var path = window.location.pathname;
	// get the parameters
	var fullPath = window.location.href;
	var params = "?"+fullPath.split("?")[1];
	params = params.split("#")[0];
	
	// Ignore to the right of a "#" sign in the URL
	var pathArray = path.split("#");
	path = pathArray[0];

	if (path.indexOf("people")!=-1)
		document.getElementById("people").style.backgroundColor="white";
	else if (path.indexOf("clinicians")!=-1)
		document.getElementById("clinical").style.backgroundColor="white";
	else if (path.indexOf("research")!=-1)
		document.getElementById("research").style.backgroundColor="white";
	else if (path.indexOf("pubs")!=-1)
		document.getElementById("publications").style.backgroundColor="white";
	else if (path.indexOf("contact")!=-1)
		document.getElementById("contact").style.backgroundColor="white";
}




/*
 *	This is the function for loading the table css to have a uniformed look and feel for the tables
 *
 *	Author: Huming Tang
 */

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(adjustNavigation);
addLoadEvent(setHighlight);
addLoadEvent(function() {
  /* more code to run on page load */ 
});

