// JavaScript Document

$(document).ready(function() {
	$('.anchor').removeClass('anchor');
	if (accActive == 0) {
		doIndex();
	} else if (accActive == 4) {
		doContact();
	} else if (accActive == 2) {
		doAwards();
	} else if (accActive == 1) {
		doLeader();
	}

	$(window).resize(windowHandler);
	var thePadMod = 84 + 36 + $('#bodyContent  > div:last-child').height();
	// 84 for Header height, 36 for padding (.section) = 120 (for the scrollTo)
	var thePad;
	windowHandler();
	function windowHandler() {
		thePad = $(window).height() - thePadMod
		$('#bodyContent').css('paddingBottom', thePad);
	}
	
	
	function aboutHandler(argSec) {
		if (argSec == "") argSec = activeSection;
		if (activeSection != argSec) {
			if (activeSection != "notSetYet") {
				$(activeSection + " .section").animate({backgroundColor: "#D8D2C9"}, 'fast'); // off
				$(activeSection + "Link").animate({color: "#666666"}, 'fast');
			} else {
			}
			activeSection = argSec;
			$(activeSection + "Link").animate({color: "#000000"}, 'fast');
			$(activeSection + " .section").animate({backgroundColor: "#E7E3DD"}, 'fast'); // on
			$.scrollTo($(activeSection).offset().top - 120, 500, {axis:'y'}); //84
		}
	}
	var activeSection;
	
	
	function doIndex() {
		var activeSection = "notSetYet";
		$('#backgroundLink').click(function () {
			aboutHandler('#background');
         	return false;
         });
		$('#whatwedoLink').click(function () {
			aboutHandler('#whatwedo');
         	return false;
         });
		$('#howwedoitLink').click(function () {
			aboutHandler('#howwedoit');
         	return false;
         });
		$('#whatitmeansLink').click(function () {
			aboutHandler('#whatitmeans');
         	return false;
         });
		$('#philosophyLink').click(function () {
			aboutHandler('#philosophy');
         	return false;
         });
    	$.scrollTo('body',84);
		aboutHandler(location.hash);
	}
	
	function doAwards() {
		var activeSection = "notSetYet";
		$('#pressLink').click(function () {
			aboutHandler('#press');
         	return false;
         });
		$('#researchLink').click(function () {
			aboutHandler('#research');
         	return false;
         });
		$('#publicationsLink').click(function () {
			aboutHandler('#publications');
         	return false;
         });
		$('#awardsLink').click(function () {
			aboutHandler('#awards');
         	return false;
         });
    	$.scrollTo('body',84);
		aboutHandler(location.hash);
	}
	
	function doContact() {
		var activeSection = "notSetYet";
		$('#contactLink').click(function () {
			aboutHandler('#contact');
         	return false;
         });
		$('#employmentLink').click(function () {
			aboutHandler('#employment');
         	return false;
         });
    	$.scrollTo('body',84);
		aboutHandler(location.hash);
	}
	
	function doLeader() {
		var activeSection = "notSetYet";
		$('#personnelLink').click(function () {
			aboutHandler('#personnel');
         	return false;
         });
		$('#clientsLink').click(function () {
			aboutHandler('#clients');
         	return false;
         });
		$('#servicesLink').click(function () {
			aboutHandler('#services');
         	return false;
         });
		$('#publicserviceLink').click(function () {
			aboutHandler('#publicservice');
         	return false;
         });
		/*$('#testimonialsLink').click(function () {
			aboutHandler('#testimonials');
         	return false;
         });*/
    	$.scrollTo('body',84);
		aboutHandler(location.hash);
	}
	
});
