
function animateImg(employee) {
  clearTimeout(timeout);
  for (x=1;x<=3;x=x+1) {
    timeout = setTimeout('swapPeopleImg(\'' + employee + '\', '+ x +')', initTime * x);
  }
  timeout = setTimeout('swapPeopleImg(\'' + employee + '\', 1)', initTime * x);
}

function swapPeopleImg(img, num) {
  $("#"+img + 'Photo').attr("src",'images/people/photo_' + img + num.toString() + '.jpg');
}

//function getPos(obj) {
//  posX = find_pos_x(getObj(obj));
//  posY = find_pos_y(getObj(obj));
//}

function swapPeople(who) {

    $("#"+who + 'Nav').css("color",'e3a82b');
//    getObj(currPeople + 'Nav').style.textDecoration = 'hover';


//    getObj(currPeople).style.visibility = 'hidden';
//    getObj(who).style.left = posX;
//    getObj(who).style.top = posY;
//    getObj(who).style.visibility = 'visible';

	$("#"+who + 'Nav').css("color",'e3a82b');
    $("#"+who + 'Nav').css("textDecoration",'none');
    $("#mainContent").html($("#"+who).html());
    $("#pullQuote").attr("src",'images/people/pullquote_' + who + '.gif');
	location.hash=who+"Nav";
    animateImg(who);

  currPeople = who;

}
  function pageload()
  {// build the images and set the first one to selected
  		$(".empnav").css("color","000000");
        if(location.hash != "" )
		{
			currPeople = location.hash;
		}
	    currPeople = currPeople.replace(/\#/,"");
		swapPeople(currPeople.replace(/Nav/,""));
		$(".empnav").css("text-decoration","none").css("color","#000000")
		$("#"+currPeople+"Nav").css("text-decoration","none").css("color","#e6b33c")
  }
  
 $(function() {

    // set the initial state from the url hash
    $.historyInit(pageload);
	$(".empnav").css("color","000000");

    $(".empnav").click(function () {

	  if ( currPeople+"Nav" == $(this).attr("id")) { return; }
      currPeople = $(this).attr("id"); 
	  location.hash = currPeople;
	  $(".empnav").css("color","000000");

      var hash = location.hash;
      hash = hash.replace(/^.*#/, '');
      // moves to a new page.
      // pageload is called at once.
      $.historyLoad(hash);
	  return false;
    });

 
 $(".empnav").hover(
    function()
    {
      if ($(this).attr("id") != currPeople+"Nav")
      {
        $(this).css("text-decoration","underline").css("color","#e6b33c").css("cursor","pointer")
      }
    },
    function()
    {
      if ($(this).attr("id") != currPeople+"Nav")
      {
        $(this).css("text-decoration","none").css("color","black").css("cursor","default")
      }
    });
 });