/**
 * Common JS used in the theme
 *
 * Created by: Topsitemakers
 * http://www.topsitemakers.com/
 */
jQuery.noConflict();
jQuery(document).ready(function($){
  
  // Apply cufon for phone in top right, content heading and for bottom boxes
  Cufon.replace("#call-us, .tab-title, #content h1");
  
  // Setup Nivo
  if($("#featured-wrap>*").length>1){
    $('#featured-wrap').nivoSlider({
      effect: "fade",
      animSpeed: "300",
      pauseTime: "4000",
      directionNav: false
    });
  }
  
  // Tabs
  if($("#tabs").length){
    $(".tab-content").hide();
    $(".tab-title").click(function(){
      $(".tab-title.active").removeClass("active");
      $(this).addClass("active");
      $(".tab-content").hide();
      $("#"+$(this).attr("rel")).show();
      Cufon.replace(".tab-title");
    });
    $(".tab-title").eq(0).click();
  }
  
  // Accordions
  if($(".accordion-title").length){
    $(".accordion-content").hide();
    $(".accordion-title").click(function(){
      $(this).toggleClass("active").next(".accordion-content").toggle();
    });
  }
  
  // Attorneys dropdown
  $("#menu-item-31, #menu-item-539").mouseover(function(){
    $(this).addClass("current-menu-item");
    $("#attorneys-dropdown").show();
  });
  $("#nav-main li:not(#menu-item-31, #menu-item-539), #logo, #featured").hover(function(){
    $("#attorneys-dropdown").hide();
    $("#menu-item-31, #menu-item-539").removeClass("current-menu-item");
  });
  
  // Last post class
  if($(".post").length){
    $(".post").eq(-1).addClass("last");
  }
  
  // Class for last <li> item in sidebar
  if($("#right").length){
    $("#right .widget-box").each(function(){
      $(this).find("li").eq(-1).addClass("last");
    });
  }
  
});

