$(function() {

  $("a.fancybox").fancybox({
    'transitionIn'  :  'elastic',
    'transitionOut'  :  'elastic',
    'speedIn'    :  400, 
    'speedOut'    :  200, 
    'overlayShow'  :  true,
    'overlayOpacity':  0.7
  });
  
  $('.video-embed').hide();
  
  $("a.video").fancybox({
    onStart : function() {
      var URL = $(this).attr('href');
      var video_id = '#' + URL.split('#')[1];
      $(video_id).show();
    },
    onClosed : function() {
      var URL = $(this).attr('href');
      var video_id = '#' + URL.split('#')[1];
            $(video_id).hide();
            $('#fancybox-title .addthis_button').appendTo(video_id);
    },
    onComplete : function () {
      var URL = $(this).attr('href');
      var video_id = '#' + URL.split('#')[1];
      $(video_id + ' .addthis_button').appendTo('#fancybox-title');
    },
    onCleanup : function () {
      var URL = $(this).attr('href');
      var video_id = '#' + URL.split('#')[1];
            $('#fancybox-title .addthis_button').appendTo(video_id);
    },
    'transitionIn'  :  'elastic',
    'transitionOut'  :  'elastic',
    'speedIn'    :  400, 
    'speedOut'    :  200, 
    'overlayShow'  :  true,
    'overlayOpacity':  0.7,
    'titlePosition' : 'inside'
  });
  
  
  $('#home #banner .window a').hide();
  $('#home #banner .window a:first').show();

  var slide_count;
  var slide_interval;
  var old_slide = 0;
  var current_slide = 0;
   
  slide_count = $("#home #banner .window a").size();
  
  slide_interval = setInterval(slide_rotate,5000);
  
  function slide_rotate() {
    current_slide = (old_slide + 1) % slide_count; 
    showWindow(current_slide);
    old_slide = current_slide;
  }

  function showWindow(current_slide){
    $('#home #banner .window a').not(this).fadeOut(1000);
    $("#home #banner .window a:eq(" + current_slide + ")").fadeIn(1000);
  };

      // interactive map rollovers for contact page
      
      $("a#sydney-hover").mouseenter(function () {
      
        $('#locations-map').css('background-position', '0 0')
    
             });
          
       $("a#sydney-hover").mouseleave(function () {
        
        $('#locations-map').css('background-position', '-650px 0')
        
       
        
        });
    
    $("a[href*='.pdf'], a[href*='.doc'], a[href*='.docx'], a[href*='.xls'], a[href*='.xlsx'], a[href*='.ppt'], a[href*='.pptx'], a[href*='.gif'], a[href*='.jpg']").addClass('document-link');
	
	


});

