// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery(document).ready(function(){
  
  
  //***************************** Header **************************************
  // make pictureframe rotate through available images
  $('#storefront').cycle({
		fx:      'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed:    3500,
		timeout:  14000,
  });

  
  
  // ********* Employee Info ***********************************************************
  
  // show and hide employee extra info from sidebar
  $(".more>.info").hide(); // hide to start out
  $(".employee-profile").mouseover(function(){
    //$(".more>.info").hide(); // hide others
    $(this).find(".info").show();
  });
  $(".employee-profile").mouseout(function(){
    $(this).find(".info").hide();
  });


  // Used on CONTACT.HTML
  // highlight employees in clicked-on department
  $(".departments>ul>li>a").click(function(){
    var dept_id = $(this).attr('class');
    $(".team-members>ul>li").each(function(){
      if ( $(this).hasClass(dept_id) ){
        $(this).addClass('green');
        var id= $(this).attr('id');
        var a = $('<a/>').attr('href', "#"+id);
        $(this).children("a").css('color','#ACD038'); 
        $(this).fadeOut('slow').fadeIn('fast')
      } else {
        $(this).removeClass("green");
      }
    });
  });

  
  // ********** Page Content Show/Hide *************************************************
  
  // show/hide details when a detail-link is clicked
  // get #word in url window.location or default to first
  function show_detail(item){
    if (!item){
      item = window.location.href.split("#",2)[1];        // set the item to the #sub-action
    };
    if (!item){                                           // if there still isn't an item
      $("#details").children(':first').siblings().hide(); // hide all but the top one to start
    } else {
      $("#details").children().slideUp('slow'); // hide all
      $("."+item).slideDown('slow');             // then show the one with the ID that matches the class
    };
  };
  
  // run show_detail() on page load
  show_detail();
  // or when a detail-links anchor is clicked
  $("#detail-links > li > a").click(function(){
    $("#detail-links > li > a").css('color', '#fff'); // color other links white
    $(this).css('color', '#00A9E8');                  // color the clicked link blue
    var item = $(this).parent().attr('class');
    show_detail(item);
  });
    
  
});



