/* 

START jQUERY 

*/
$(document).ready(function(){	

	/*
	
	SHOW-HIDE TOGGLE
	 	 
	 */	 
	 
	var toggleSpeed = 300;
	$(".show-hide h3").click(function(){
			$(this).toggleClass("toggler-closed").next().slideToggle(toggleSpeed);
		})
	.end();

	
	/*
       
       TEAM BIOS, investment approach
       
       */
       
       $(".nav-team a, a.nav-team").click(function () {      
       
              
			// exception to swao h1 on investment approach
			if ($(this).attr("href") == "#criteria") {
				$("h1 img").attr("src","../common/images/h1-investment-criteria.png");
			}
			if ($(this).attr("href") == "#structure") {
				$("h1 img").attr("src","../common/images/h1-investment-structure.png");
			}  
			if ($(this).attr("href") == "#focus") {
				$("h1 img").attr("src","../common/images/h1-industries-focus.png");
			}      
       
       
               // turn off all nav-team links
               $(".nav-team a").removeClass("on");
       
               // turn on link just clicked        
               $(this).addClass("on");                
               
               // close all bios
               $(".bio").hide();
               
               // open relevant bio
               var theBio = $(this).attr("href")
               $(theBio).show();
               
               
               // if user clicks "criteria" link in the investment approach intro, highlight the left nav
              if ($(this).hasClass("nav-team")) {
                      // var teamLink = $(".nav-team a")[0];
                       //$(teamLink).addClass("on");
                       //$(theNavTeamAnchor).addClass("on");
                       var theNavTeamAnchor = "a-" + theBio.substring(1);
                       if (document.getElementById(theNavTeamAnchor)) {
	                       document.getElementById(theNavTeamAnchor).className="on";
	                  }
                       return false;
              }
               
               // don't skip down the page
               return false;
       
       });	
	/*
	
	INITIALIZE FIELD VALUE RESET (looks for presence of "alt" attribute in the input tag)
	
	*/
	$("input[alt!='']").focus(function(){
		setValue(this,"onfocus"); 
		return false;
	});
	$("input[alt!='']").blur(function(){
		setValue(this,"onblur"); 
		return false;
	});

 });
 
 /* setValue clear's a text input's value and resets it to the input's alt attribute if the user doesn't enter a value */
function setValue(pEl,pSwitch) {	
	if (pSwitch == "onfocus") {
		if (pEl.value == pEl.alt) {
			pEl.value = "";	
		}
	}
	if (pSwitch == "onblur") {
		if (pEl.value == "") {
			pEl.value = pEl.alt;
		}
	}
}
