// JavaScript Document


var galleries = {
	
	
};
	
	


$( function(){
			
	var banner_width = 720;		
			
	$('#banner .slide').each( function(i){
		$(this).attr('index', i);								   
	});
			
		
	var pics = {
		
		'jousting' : [
			['images/jousting/DSC_3084.jpg', ''],
			['images/jousting/DSC_3099.jpg', ''],
			['images/jousting/DSCF7945.jpg', ''],
			['images/jousting/DSCF7947.jpg', '']
		],
		'weddings' : [
			['images/weddings/1.jpg', ''],
			['images/weddings/2.jpg', ''],
			['images/weddings/3.jpg', ''],
			['images/weddings/DSC02111.jpg', ''],
			['images/weddings/IMG_0001_NEW.jpg', ''],
			['images/weddings/stormweddingimage.jpg', '']					
		],
		'modelling' : [
			['images/modelling/1.jpg', 'Photo by Alex Howe'],
			['images/modelling/2.jpg', 'Photo by Alex Howe'],
	     	['images/modelling/3.jpg', 'Photo by Alex Howe'],	
		  	['images/banners/little-boots.jpg', 'Little Boots Photoshoot'],
			['images/modelling/4.jpg', 'courtesy of The Evening Standard and Kristian Schuller'],
			['images/modelling/5.jpg', 'courtesy of The Evening Standard and Kristian Schuller ']
		 ],
		'reenactment' : [
			['images/reenactment/2.jpg', ''],
			['images/reenactment/3.jpg', ''],
			['images/reenactment/4.jpg', ''],
			['images/reenactment/5.jpg', '']
		],
		'events' : [
			['images/events/1.jpg', ''],
			['images/events/2.jpg', ''],	
			['images/events/3.jpg', ''],
		],
		'tv' : [
				
			['images/tv/1.jpg', 'Horrible Histories'],
			['images/tv/3.jpg', 'The Other Boleyn Girl'],
			['images/tv/4.jpg', 'The Other Boleyn Girl'],
			['images/banners/eastenders.jpg', 'Eastenders']
		]
	}
	
	
	if( window.location.href.indexOf('services') != -1 ){
		var hash = (window.location.hash == '') ? '#film_tv' : window.location.hash;
		$('#services-nav a[href*='+hash+']').addClass('current');	
		
		$('#services-nav ul a').click( function(e){
		e.preventDefault();
		var hash = this.hash;
		$('#services-nav a').removeClass('current');
		$(this).addClass('current');
		var i = parseInt( $(this.hash).attr('index') ) * banner_width;
		$('#banner').animate({'scrollLeft' : i}, {
			complete: function(){
				location.hash = hash;	
			}
		});
	});
		
	}
	
		if( $('#location-map').length > 0 ){
		
		var lat = $('#location-map').attr('lat');
		var lng = $('#location-map').attr('lng');
		
	 	var latlng = new google.maps.LatLng(lat, lng);
		var opts = {
		  zoom: 14,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
    	var map = new google.maps.Map(document.getElementById("location-map"), opts);
		
		var marker = new google.maps.Marker({
      		position: latlng, 
      		map: map 
  		}); 
		
  	}

	
	$('a.slimbox-link').show()
	.click( function(e){
		e.preventDefault();
		var cat = $(this).attr('rel');
		if( !pics[cat] ) return;
		jQuery.slimbox(pics[cat], 0);
	});
	
	$('#home-banner .img').each( function(i){
		$(this).attr('index', i);
		$( $('#home-banner-text .caption')[i] ).attr('index', i);
	});
	
	$(window).load( function(){
	
		$('#home-banner').css('background-image', 'none');
		var current = $('#home-banner .img:first');
		$('#home-banner-text .caption[index=0]').show();
		current.addClass('current').fadeIn(1000);
		$('#home-banner-text').animate({'right':0}, {duration:500});
		
		function next(){
			var old = $('#home-banner .img.current');
			var next = old.next('.img');
			if( next.length == 0 ) next = $('#home-banner .img:first');
			var i = next.attr('index');
			$('#home-banner-text').animate({'right':-200}, {duration:500});
			old.removeClass('current').fadeOut(1000);
			next.addClass('current').fadeIn(1000, function(){
				$('#home-banner-text .caption').hide();
				$('#home-banner-text .caption[index='+i+']').show();
				$('#home-banner-text').animate({'right':0}, {duration:500});
			});
		}
		
		window.setInterval(next, 5000);
	});
			
			
			
			
			
			
});


