/* Author: 

*/

$(document).ready(function() {
     $('.thumb1').animate({'left':'5px'}, 200);
	 $('.thumb1').animate({'left':'0px'}, 200);
	 $('.thumb2').delay(100).animate({'left':'5px'}, 200);
	 $('.thumb2').animate({'left':'0px'}, 200);
	 $('.thumb3').delay(200).animate({'left':'5px'}, 200);
	 $('.thumb3').animate({'left':'0px'}, 200);
	 $('.thumb4').delay(300).animate({'left':'5px'}, 200);
	 $('.thumb4').animate({'left':'0px'}, 200);
	 $('.thumb5').delay(400).animate({'left':'5px'}, 200);
	 $('.thumb5').animate({'left':'0px'}, 200);
	 $('.thumb6').delay(500).animate({'left':'5px'}, 200);
	 $('.thumb6').animate({'left':'0px'}, 200);
	 $('.thumb7').delay(600).animate({'left':'5px'}, 200);
	 $('.thumb7').animate({'left':'0px'}, 200);
	 $('.thumb8').delay(700).animate({'left':'5px'}, 200);
	 $('.thumb8').animate({'left':'0px'}, 200);
});

 function initialize() {
    var latlng = new google.maps.LatLng(51.519005,-0.135035);
    var Centlatlng = new google.maps.LatLng(51.519051,-0.15678); 
	var myOptions = {
      zoom: 14,
	  center: Centlatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("google-map"),
        myOptions);

	var image = new google.maps.MarkerImage('img/map-icon.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(40, 57),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(20, 56));
      
	var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image
    });

    $('#full-screen-image').css('position','absolute');
  }

  jQuery(function($){
  	if ($('#contact').size()>0) {
  		initialize();
  	};
	
	var originalSize = $('#content-container').height();
	
	function checkWindow() {
		if(originalSize < $(window).height()){
			$('#content-container, #nav-container, #container, #content, #thumbnails-holder, #thumbnails-over').height($(window).height());
		}
	}
	checkWindow();
	$(window).bind('resize', checkWindow);
  })
  
$('#hide-content').click(function(){
	$('#content-container').animate({'left':'0px'}, 500);
	$('#hide-content').fadeOut();
	$('#show-content').delay(500).fadeIn();
});

$('#show-content').click(function(){
	$('#content-container').animate({'left':'321px'}, 500);
	$('#show-content').fadeOut();
	$('#hide-content').delay(500).fadeIn();
});

$('.thumb-switch').click(function(){
	clearInterval(transition);
	transition = setInterval(imageTransition, 5000);
	var imageswap = $(this).attr('id').replace('thumb', 'main');
	$('#full-screen-image').fadeOut(350, function(){
		$('#MainImage').attr("src", "img/gallery/"+imageswap+".jpg");
		$('#full-screen-image').delay(150).fadeIn(700);											  
	});
	
});

$(".fancypop").fancybox({
	'width'				: '560px',
	'height'			: '340px',
	'autoScale'			: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'overlayOpacity'	: '0.75',
	'overlayColor'		: '#000'
});

$(".fancyjoin").fancybox({
	'width'				: '580px',
	'height'			: '450px',
	'autoScale'			: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'overlayOpacity'	: '0.75',
	'overlayColor'		: '#000'
});

$("#full-screen-image").fullSizeImage({ 
     overlayLine: true,
     repositionImage : true,
     offset : "320,0",
     position : "fixed"
});

//var swapnumber = 2;

var transition = setInterval(imageTransition, 5000);

function imageTransition() {
	var swapsetup1 = $('#MainImage').attr('src').replace('img/gallery/main-'+pageName, '');
	var swapsetup2 = swapsetup1.replace('.jpg', '');
	var swapnumber = parseInt(swapsetup2) + 1;
	if (swapnumber > 8) {
		swapnumber = 1;
	}
	$('#full-screen-image').fadeOut(350, function(){
		$('#MainImage').attr("src", "img/gallery/main-"+pageName+swapnumber+".jpg");
		$('#full-screen-image').delay(150).fadeIn(700);	
	});
}
