// JavaScript Document

// initialise topmenu
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
});

// initialise slider
$(function(){
	$('#slides').slides({
		generateNextPrev: false,
		generatePagination: false,
		effect: 'fade',
		crossfade: true,
		fadeSpeed: 1350,
		play: 15000,
		pause: 2500,
		hoverPause: true				
	});
	$('#slides_two').slides({
		generateNextPrev: true,
		paginationClass: 'pagination',
		play: false
	});
	$('#slides_three').slides({
		generateNextPrev: true,
		play: 6500,
		autoHeight: true
	});
});	

$(document).ready(function(){
	$(".exptext").hide();
	$(".expheader").click(function(){
		$(this).toggleClass("open").next().slideToggle("focused");
	});
});


$("article.country:even").addClass('colored');
 
// show employee info 
 $(document).ready(function(){
  $('.employee .additional').hide();
  $(".show").click( function() {
       var index = $('.show').index(this);
       $('.employee .additional').eq(index).show();
       $(this).hide();
       $('.additional .hide').show();
       $(this).parent().parent().addClass('shadow');

  });

  $(".hide").click(function(){
       var index = $('.hide').index(this);
       $('.employee .additional').eq(index).hide();
       $(this).hide();
       $('article .show').show();
	   $(this).parent().parent().parent().removeClass('shadow');
  });
  
  
    });
 

// tabbed navigation
/*$(function () {
	var tabContainers = $('div.tabs > div');
	tabContainers.hide().filter(':first').show();
	
	$('div.tabs .tabnavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('div.tabs .tabnavigation a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();
});

// stepped navigation
$(function () {
	var tabContainers = $('div.tabs > div');
	tabContainers.hide().filter(':first').show();
	
	$('div.tabs .steppednavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$('div.tabs .steppednavigation a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();
});*/

$(document).ready(function() {
	$(".lightbox").fancybox({
		'titlePosition'		: 'inside',
		'padding'			: '20',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'autoScale'			: 'false',
		'width'				: 600,
		'autoDimensions'	: 'false',
		'type'				: 'inline'
	});
});


$(document).ready(function() {
	$(".lightboxvideo").fancybox({
		'width'	: '50%',
		'height': '50%',
        'autoScale' 	: true,
        'transitionIn'	: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
});

// various IE quirks
$(document).ready(function(){
	$(".slider").parent().addClass('iepush');
	$(".teamoverview").parent().addClass('teampage');
	$(".incontent").parent().parent().addClass('fixborder');
	$("#worldmap").parent().addClass('arrangemap');
	$(".withtag").next().addClass('frontpage');
});

$(document).ready(function() {
	$(".paging").quickPager();
});

$(function(){
  // The "tab widgets" to handle.
  var tabs = $('.tabs'),
    
    // This selector will be reused when selecting actual tab widget A elements.
    tab_a_selector = 'ul.ui-tabs-nav a';
    tabs.tabs({ event: 'change' });
  
  // Define our own click handler for the tabs, overriding the default.
  tabs.find( tab_a_selector ).click(function(){
    var state = {},
      
      // Get the id of this tab widget.
      id = $(this).closest( '.tabs' ).attr( 'id' ),
      
      // Get the index of this tab.
      idx = $(this).parent().prevAll().length;
    
    // Set the state!
    state[ id ] = idx;
    $.bbq.pushState( state );
  });

  $(window).bind( 'hashchange', function(e) {
    
    // Iterate over all tab widgets.
    tabs.each(function(){
      var idx = $.bbq.getState( this.id, true ) || 0;
      $(this).find( tab_a_selector ).eq( idx ).triggerHandler( 'change' );
    });
  })
  
  $(window).trigger( 'hashchange' );
  
});


