$(document).ready(function() {
						   
	// Index page
						   
	// hide the video and show the image
	//$('#the-video').hide();
	// listen out for a click on the image and show video
	$('#video-image').click(function() {
		$('#video-image').fadeOut(function() {
			$('#the-video').toggle('fade');
		});		
	});		
	
	
	// Subscribe form
	$('.newsSignUp#name-signup').click(function() {
		if($(this).val() == 'Name') {
			$(this).val('');
		} 
	}); 
	$('.newsSignUp#name-signup').blur(function() {		
		if($(this).val() == '') {
			$(this).val('Name');
		}
	}); 
	$('.newsSignUp#email-signup').click(function() {
		if($(this).val() == 'Email') {
			$(this).val('');
		} 
	}); 
	$('.newsSignUp#email-signup').blur(function() {		
		if($(this).val() == '') {
			$(this).val('Email');
		}
	}); 
	
	// Gallery page
	$('.thumbnail-gallery').click(function() {
		var clicked = $(this);
		$('#main-gallery-image').fadeOut(function() {
			$(this).attr('src', clicked.attr('rel'));
			$(this).fadeIn();
		})
	});
	
	// Video page
	$('.thumbnail-video').click(function () {
		var id = $(this).attr('rel');
		$('ul.video-page li').each(function() {
			$(this).hide();
		});
		$('ul.video-page li#'+id+'').show();
		
	});
	
	// Blog page	
	$.fn.getBlog = function () {
		var returner = $(this);
		// set date
		var month = $('select[name="month"]').val();
		var year = $('select[name="year"]').val();
		$.ajax({
			url: 'handler.php',
			data: 'action=getBlog&year='+year+'&month='+month+'',
			type: 'post',
			success: function(msg) {
				returner.hide();
				returner.html(msg);
				return returner.fadeIn();
			}
		
		});
		
	}
	$('select[name="month"]').change(function () {		
		$('#main-blog').getBlog();
	});
	$('select[name="year"]').change(function () {	
		$('#main-blog').getBlog();
	});
	
	
	// Tour page
	$('.datesList').quickPager({pageSize: 25});
	
	
	// Any page
	
	// Show slider at the bottom
	$("#homePageGallery").slideView();
	
	// Turn off the audio
	$('.toggle-audio').click(function() {
		$('.cas1').toggle('slide');
		$('.cas2').toggle('slide');		
		// do an ajax request to set session var
		$.ajax({
			type: "post",
			url: "handler.php",
			data: "action=toggleAudio",
			success: function(msg) {
				if(msg == 'true') {
					$('.toggle-audio').html('Turn audio on');
				} else {
					swfobject.embedSWF("/player/flashmo_212_mp3_player_mini.swf", "player", "420", "250", "9.0.0",flashvars, params, attributes);
					$('.toggle-audio').html('Turn audio off');
				}
			}
		});
	});
	
	// Show tooltips	
	$('.thumbnails a').tooltip({ 
		track: true, 
		delay: 0, 
		showURL: false, 
		showBody: " - ", 
		fade: 250 
	});
	
	
});