$(document).ready(function(){

  var myFile = document.location.toString();
  if (myFile.match('#')) { // the URL contains an anchor
    var target = '#' + myFile.split('#')[1];
    $('.client_behind_the_scenes:first .see_less').hide();
    $('.client_behind_the_scenes:first .see_more').show();
    $('.client_behind_the_scenes:first .down').removeClass('down').hide();

    $(target).prev().find('.see_more').hide();
    $(target).prev().find('.see_less').show();
    $(target).removeClass('hide');
    $(target).show();
    $(target).addClass('down');

  }


  $("a.creative").fancybox({
	  'frameWidth': 640,
		'frameHeight': 640
	});

	$("a.fancybox").fancybox();

  $('html').addClass('js');

  // Hide all the specified elements
  $('.hidden').hide();

  // Show all the specified elements
  $('.visible').show();

  $.fn.cycle.defaults.speed = 900;
  $.fn.cycle.defaults.timeout = 10000;

  $('.image_cycle').cycle({
    fx: 'fade'
  });

  $('#image_list a').lightBox();
  $('a[rel=lightbox]').lightBox();

  $('.toggle').click(function(){
    var container = $(this).attr("toggle");
    if ($(this).hasClass("toggle-up")) {
      $(this).removeClass("toggle-up");
    }
    else {
      $(this).addClass("toggle-up");
    }
    $(container).toggle('blind',{direction:'vertical'},500);
    return false
  });

  $('.blogs .blog:last').css('border-bottom', 'none');
  $('.blogs .blog .body img:first').addClass('first_img');

  $('.live_news').hover(function(){
    $('.live_news .menu').slideDown('fast');
  }, function(){
    $('.live_news .menu').slideUp();
  });

//  $('.toggle_target').click(function(){
//    target = $(this).attr('href');
//    $(target).toggle('blind',{direction:'vertical'},500);
//    $(this).toggle('blind',{direction:'vertical'},500);
//    return false
//  });

  $('.show_target').click(function(){
    target = $(this).attr('href');
    $(target).slideDown();
    $(this).parent().hide();
    $(this).parent().next().show();
    $(target).addClass('down');
  });

  $('.hide_target').click(function(){
    target = $(this).attr('href');
    $(target).slideUp();
    $(this).parent().hide();
    $(this).parent().prev().show();
    $(target).removeClass('down');
  });

  $('.show_container').click(function(){
    target = $(this).attr('href');
    if ($(target).hasClass('down'))
    {
      $(target).prev().find('.see_more').show();
      $(target).prev().find('.see_less').hide();
      $(target).slideUp();
      $(target).removeClass('down');
    }
    else
    {
      $(target).prev().find('.see_more').hide();
      $(target).prev().find('.see_less').show();
      $(target).slideDown();
      $(target).addClass('down');
    }
    return false;
  });

  $('.tweet').twitterSearch({
    term: 'from:theagencyuk',
    avatar: false
  });

  $('.who_we_are_people .about').css({'opacity' : 0.7});

  $('.who_we_are_people .person').hover(function(){
      $(this).find('.about').fadeIn();
  }, function(){
      $(this).find('.about').fadeOut();
  });

});

function set_banner_image(url, link) {
  $('#banner_image img').attr('src', url);
  $('ul.employees .employee').css('background-position', '0 0');
  $(link).css('background-position', '0 100px');
}




