// JavaScript Document

$(document).ready(function(){



//enable prettyPhoto

$('#gallerygrid li a, .box-photos ul li a, .box-videos ul li a, a.gallery').prettyPhoto({theme:'dark_square'});


//-----------Sub-navigation accordion menu-----------------------//

//Set default open/close settings
$('.acc_container').hide(); //Hide/close all containers
/*$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container*/

$('.acc_trigger.opennav').addClass('active').next().show();


//On Click
$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
		$(this).next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
	}
	return false; //Prevent the browser jump to the link anchor
});



      // append scrollbar to all DOM nodes with class="css-scrollbar" or whatever class is listed here
     $(function(){
		$('.simple2').scrollbar();
		$('.css-scrollbar').scrollbar();
      })
	 
	 

//-----------------JQuery fix for IE for fixed sub-navigation-----------------//

    function staticNav() {
        var sidenavHeight = $("#inside-lcol").height(); //Get height of sidenav
        var winHeight = $(window).height(); //Get height of viewport
        var browserIE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false; //Check for IE6

        if (browserIE6) { //if IE6...
            $("#inside-lcol").css({'position' : 'absolute'});  //reset the sidenav to be absolute
        } else { //if not IE6...
            $("inside-lcol").css({'position' : 'fixed'}); //reset the sidenav to be fixed
        }

        if (sidenavHeight > winHeight) { //If sidenav is taller than viewport...
            $("#inside-lcol").css({'position' : 'static'}); //switch the fixed positioning to static. Say good bye to sticky nav!
        }
    }

    staticNav(); //Execute function on load

    $(window).resize(function () { //Each time the viewport is adjusted/resized, execute the function
        staticNav();
    });
	


//----------- individual profile/bio gallery -----------------------//


	
$('.biothumb1').hover(function() {
var currentclass = $('#gallery1 img').attr("class");
var personname = currentclass;
$('#gallery1 img').attr('src', "../images/profiles/" + personname + "/" + currentclass + "1.jpg");	
			});
		

$('.biothumb2').hover(function() {	
var currentclass = $('#gallery1 img').attr("class");
var personname = currentclass;
$('#gallery1 img').attr('src', "../images/profiles/" + personname + "/" + currentclass + "2.jpg");					
			});

$('.biothumb3').hover(function() {	
var currentclass = $('#gallery1 img').attr("class");
var personname = currentclass;
$('#gallery1 img').attr('src', "../images/profiles/" + personname + "/" + currentclass + "3.jpg");
			});
	
	



	
	
///-------------------Fathom People landing page ------------------------//

$('ul#teamgrid li').hover(function(){  
    $(".cover", this).stop().animate({top:'125px'},{queue:false,duration:200});  
     }, function() {  
    $(".cover", this).stop().animate({top:'220px'},{queue:false,duration:250});  
   });	

//----- hover effect for each person -----//
$('ul#teamgrid li').bind({   
  mouseenter: function() {
  $(this).find(".p1").fadeOut(200);
  },
  mouseleave: function() {
  $(this).find(".p1").fadeIn(250);
  }
});

				
///----------------------------------------------------------------------------//



//----------------------------------------------------------------------------//


$('#dropbar.dropfeatures a').click(function() {	 
				$('#featuresdiv').slideToggle(200);
      			$("#dropbar").slideUp("fast");
				return false;
			});	

$('a.closefeatures').click(function() {	 
			$("#featuresdiv").slideUp(200);
      		$("#dropbar").slideDown("fast");
				return false;							 
			});	



//---------------------------------Floating side nav-------------------------------------------//

//config
$float_speed=300; //milliseconds
$float_easing="easeOutQuint";

//cache vars
$fl_menu=$("#inside-lcol");
var subnavHeight = 0;

$(function() {
/*	menuPosition=$('#inside-lcol').position().top;*/
	subnavHeight = ($('#subnav h2.acc_trigger').size()*36) + 76 + (getMaxItemCountWithinNode()*24);	//approximate value
	FloatMenu();
});

$(window).scroll(function () { 
	FloatMenu();
});

function FloatMenu(){
	var scrollAmount=$(document).scrollTop();
	var newPosition=scrollAmount;
	var position = $('#footer').position();
	
	if (scrollAmount + subnavHeight + 150 < position.top)	//adjust for more or less if needed
		$fl_menu.stop().animate({top: newPosition}, $float_speed, $float_easing);
}


function getMaxItemCountWithinNode()
{
	maxItemCount = 0;
	
	$('#subnav .acc_container').each(function(){
		itemCount = $(this).find('li').size();
		if (itemCount > maxItemCount)
			maxItemCount = itemCount;
	});
	
	return maxItemCount;
}



// Fathom logo color change //

jQuery(function($) {
var timer = setTimeout(spectrum, 0);
});

var myColors = new Array('yellow', 'green', 'aqua', 'blue' , 'magenta', 'red');
var logoColors = new Array();
var colorsNo = myColors.length;

for(i=0; i<colorsNo; ++i){
	if(i == 0){
		var ind = Math.floor(Math.random() * myColors.length);
	}
	else{
		++ind;
		if(ind >= colorsNo){
			ind = 0;
		}
	}
	logoColors[i] = myColors[ind];
}			

$('#logo').css('background-color', logoColors[0]);
spectrum();

function spectrum(){
var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
				$('#logo').animate( { backgroundColor: logoColors[0] }, 11000)
				.animate( { backgroundColor: logoColors[1] }, 11000)
				.animate( { backgroundColor: logoColors[2] }, 11000)
				.animate( { backgroundColor: logoColors[3] }, 11000)
				.animate( { backgroundColor: logoColors[4] }, 11000)
				.animate( { backgroundColor: logoColors[5] }, 11000, function() {
				 timer = setTimeout(spectrum, 0);
			
});
}
});



