﻿$(document).ready(function() { 

	var $audioPlayer, audioPlayerId;
			
	$(document).pngFix(); 

	$('ul#slideshow').innerfade({
		speed: 'slow',
		timeout: 10000,
		type: 'sequence',
		containerheight: '212px'
	});

	$('div.fitted').fitted();

		
	$('#drive').click(function () {
		$('.drive').fadeIn('slow');
	});

	$('#ride').focus(function () {
		$('.drive').fadeOut('fast');
	});

	$('#yes').click(function () {
		$('.group_name').fadeIn('slow');
	});

	$('#no').focus(function () {
		$('#group_name').val('');
		$('.group_name').fadeOut('fast');
	});

	$('#friends').click(function () {
		$('.friends_list').fadeIn('slow');
	});

	$('#your_age, #your_ability, #the_height_of_your_horse, #your_riding_club_pony_club_livery_yard, #dont_mind').focus(function () {
		$('#friends_list').val('');
		$('.friends_list').fadeOut('fast');
	});

	$('div.message').fadeIn('slow');

	$('.dob').datePicker(
		{
			clickInput:true,
			startDate: '01/01/1900',
			endDate: (new Date()).asString()
		}
	);

	$('#faqs dt').click(function () {
		$(this).next('#faqs dd').toggle();
	});

	$('#rider-form').validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			driving_style: {
				required: "#drive:checked",
				minlength: 1
			},
			group_name: {
				required: "#yes:checked",
				minlength: 1
			},
			friends_list: {
				required: "#friends:checked",
				minlength: 1
			},
			terms_accepted: {
				required: true
			},
			vaccine: {
				required: true
			},
			cancelled: {
				required: true
			},
			gender: {
				required: true
			},
			stabling: {
				required: true
			},

			agree: "required"
		},
		messages: {
			event: "Please select what you would like to do",
			group: "Please select whether you’re a member of a Riding Club, Hunt, Pony Club or other association",
			group: "Please enter your friends names seprated with a comma",
			vaccine: "Your must be fully vaccinatied to continue",
			terms_accepted: "Your must accept our terms and conditions to proceed"
			},
		success: function(label) {
			label.addClass('valid');
		}
	});


	$('#sponsor-form').validate({
		rules: {
			email: {
				required: true,
				email: true
			},
			amount: {
				required: true,
				number: true,
				min: 1
			},
			cancelled: {
				required: true
			}
		},
		messages: {
			event: "Please select what you would like to do",
			group: "Please select whether you’re a member of a Riding Club, Hunt, Pony Club or other association",
			terms_accepted: "Your must accept our terms and conditions to proceed"
			},
		success: function(label) {
			label.addClass('valid');
		}
	});
	

	
	$('#countdown').flash({
		src: '/_swf/191209.swf',
		width: 212,
		height: 150
	});


	$('#movie').flash({
		src: '/_swf/martin_clunes.swf',
		width: 480,
		height: 270
	});

		// setup the audio player
		AudioPlayer.setup('/_swf/player.swf', {
			width:				'300',
			initialvolume:		'60',
			transparentpagebg:	"yes",
			width:				'100%',
			autostart: 			'no',
			loop:				'no',
			animation:			'no',
			bg: 				'2861AB',
			leftbg: 			'6DA3D7',
			rightbg: 			'6DA3D7',
			lefticon:			'B82336',
			righticon:			'B82336',
			rightbghover:		'B82336',
			voltrack:			'B82336',
			volslider:			'FFFFFF',
			tracker:			'6DA3D7',
			track: 				'2861AB',
			border: 			'2861AB',
			text: 				'FFFFFF',
			loader:				'C8D9E4'
		});

		// initialise the first audio entry
// 		audioPlayerId 	= $.audioPlayerId();


		AudioPlayer.embed('interview', {  
			soundFile:	'http://www.horses4heroes.co.uk/_swf/toni_terry.mp3',
			titles:		'Interview with Toni Terry',
			artists:	'Toni Terry'
		});


		$("#dialog").dialog({
			bgiframe: true,
			modal: true,
			autoOpen: false,
			width: 600
		});
		
		
		
		$('#clickertyclick').click(function() {
			$('#dialog').dialog('open');
		});

				
}); 
