var curvyCornersVerbose = false; 

$(document).ready(function(){  
  $('.scrollbar').jScrollPane({showArrows: true});
  
  $("#news-archive-list li a").hover(
    function(){
      $(this).parent("li").addClass("hover");
    },
    function(){
      $(this).parent("li").removeClass("hover");
    }
  );
  
  $(".imageinfo a").click(function(event) {
    var unexpandedHeight = 24;
    var expandedHeight = unexpandedHeight + $("#imageinfotextinner").height() + 5;
      if ($(".imageinfo").hasClass('expanded'))
      {
        $(".imageinfo").animate({
          height: unexpandedHeight}, 500 , function() {
            $(".imageinfo").removeClass("expanded");
        });
      } else {
        $(".imageinfo").animate({
          height: expandedHeight}, 500 , function() {
            $(".imageinfo").addClass("expanded");
        });
      }
    
    //prevent that annoying anchor link 
    //so the link won't follow through causing the page to jump about
    event.preventDefault();    
  });
  

  $('#slider li').hover(
  function () {
    $('#case-study-title').html('<h2>' + $('#case-study-title-hidden',this).html() + '</h2>');
    $('#case-study-content').html($('#case-study-content-hidden',this).html());
  });
  
  $('#slider li:first').hover();

  
    $('#slider').jcarousel();
 //   $('#slider li a[title]').tooltip({position: "bottom right", offset: [2, -53]});

    $("img.home-background-faded", this).stop().animate({"opacity": "0"}, 8000);    
  
  PageSlider();
  
  ShowTeamDetails();
  //not specifying whether it's a div or a li as the content may vary
  //however in most cases you'd probably expect the element to be a div
  //$(".team-member:first").click();
});

//Page Slider
var _pages = ".box-content-2-inner > .box-content-2-page";
var _pageCount = 0;
var _resetIndex = 0;
var _pageHeights;

function PageSlider()
{
  $("body").addClass("js");       
  if ($(_pages).length > 1)
  {
      _pageCount = $(_pages).length;
    
      _pageHeights = [_pageCount];
    
      $(_pages).each(function(index, item)
      {
          var offsetIndex = index + 1;
          $(this).attr("id", "p" + offsetIndex);
        
        _pageHeights[index] = $(this).height();
          //$("#page-navi").append("<img id=\""+ offsetIndex +"\" src=\"/images/blank.gif\" alt=\"\" />");
      });
      
      //$("#page-navi > img:first").addClass("active");
      //$("#page-navi > img:last").addClass("last");
      
      $(_pages + ":not(:first)").fadeTo(0,0).hide().css({"z-index": "-10"});

      $("#content-pagination a").click(function(e)
      {
          e.preventDefault();
          if($(_pages + ":visible") != $(_pages).eq($(this).attr("id") - 1) && $(_pages+":animated").length == 0)
          {
              _resetIndex = $(this).attr("id") - 1;
              MovePage();
          }
      });
      $("#content-pagination a").hover(function(){$(this).toggleClass("hover");},function(){$(this).toggleClass("hover");});
      $(".box-content-2-page .arrow").click(function(event){
        event.preventDefault();
          if($(_pages+":animated").length == 0)
          {
              var offset = $(this).hasClass("next") ? 1 : -1;
              _resetIndex += offset;
              MovePage();        
          }
      });            
  } 
}
function MovePage()
{
    var tempIndex = _resetIndex % _pageCount;
    /*if(_pageImages[tempIndex].src.length > 0)
    {
        $("#right-panel").append("<img src=\"" + _pageImages[tempIndex].src + "\" alt=\"" + _pageImages[tempIndex].alt + "\" title=\"" + _pageImages[tempIndex].alt + "\" class=\"new\" />");
        $("#right-panel > img:hidden").fadeIn("slow", function(){$("#right-panel > img:first").remove()});
    }*/
  
  $("#content-pagination a:eq("+ tempIndex +")").attr("class", "on").siblings().removeClass("on");
//  $("#content-pagination a").attr("class", "off");
//  $("#content-pagination a").eq(tempIndex).attr("class", "on");
  
  $(".box-content-2-inner").animate({"height": _pageHeights[tempIndex]}, "fast", function(){
    $(_pages + ":visible").css({"z-index": "-10"}).fadeTo("fast", 0, 
        function()
        {          
            $(_pages).eq(tempIndex).css({"z-index": "10"}).show().fadeTo("fast", 1);
        }).hide();
      });
}

//ShowTeamDetails
function ShowTeamDetails()
{
  $("#team-members-flowing .team-member, .team-board .team-member").click(function(event){
    event.preventDefault();
    var _this = $(this);
    
    //Clear contents of holding divs
    $("#team-member-details > div[class^='team-member-']").empty();
    
    //Empty the text node and append the new name
    var _nameSelector = _this.get(0).tagName.toLowerCase() == "div" ? ".person-name a" : "a .person-name";

    $("#team-member-details > .team-member-name").text('').append($(_nameSelector, _this).text());
    
    //Add the rest of the data
    $(".person-bio-hidden img.team-image", _this).clone().appendTo("#team-member-details > .team-member-image");
    $(".person-bio-hidden div.person-bio", _this).clone().appendTo("#team-member-details > .team-member-bio");
    $(".person-bio-hidden div.person-role", _this).clone().appendTo("#team-member-details > .team-member-role");
    //$(".person-bio-hidden img")
  });
  
  $("#team-members-flowing .team-member").hover(ToggleActive);
}
function ToggleActive()
{
  $(this).toggleClass("active");
}

