// JavaScript Document

var playerWidth = 370;
var playerHeight = 230;


var vid_rocknroll = '-NoS5kZKKjY';
var vid_heigh_ho = 'XkXD8mdm4gc';
var vid_jiggety_jig = 'oxgVdxCCYZA';
var vid_ding_dong = 'Kws1sfGxkew';

$(document).ready(function(){
	
	$('#find-class-home')
	.mouseenter(function(){
			$(this).addClass('hover');
		})
	.mouseleave(function(){
			$(this).removeClass('hover');
		});
	
});


$(window).ready(function () {
	
	
	$('#enter-postcode-btn').click(function(e){
		e.preventDefault();
		$('#postcodesubmit').submit();
		
	});
	
	$('#mon-rock-n-roll a').each(function(){ vid_rocknroll = $(this).attr('rel');});
	$('#mon-high-ho a').each(function(){ vid_heigh_ho = $(this).attr('rel');});
	$('#mon-jiggety-jig a').each(function(){ vid_jiggety_jig = $(this).attr('rel');});
	$('#mon-ding-dong a').each(function(){ vid_ding_dong = $(this).attr('rel');});
	
	//remove iframe youtube videos
	 $("#videoContainer").html('');
	 $("#find-a-class-non-js-btn").css("display","none");
	 $("#enter-postcode-btn").css("display","inline-block");
	 
	
	initializeYoutube();
	initializeLinks();
	
	
});


function initializeLinks(){
	$('#mon-rock-n-roll a').click(function(e){
		e.preventDefault();
		//yellow
	 	$('#home-video-cont').css('background-position','-1243px -278px');
		jQuery("#videoContainer").tubeplayer("play", vid_rocknroll);
	});
	
	$('#mon-high-ho a').click(function(e){
		e.preventDefault();
		//blue
		
		$('#home-video-cont').css('background-position','-832px -278px');
		$("#videoContainer").tubeplayer("play", vid_heigh_ho);
		
	});
	
	$('#mon-jiggety-jig a').click(function(e){
		e.preventDefault();
		//green
		$('#home-video-cont').css('background-position','-421px -278px');
		jQuery("#videoContainer").tubeplayer("play", vid_jiggety_jig);
	});
	
	$('#mon-ding-dong a').click(function(e){
		e.preventDefault();
		//purple
		$('#home-video-cont').css('background-position','-10px -278px');
		jQuery("#videoContainer").tubeplayer("play", vid_ding_dong);
	});
}


function initializeYoutube(){
	
	
	jQuery("#videoContainer").tubeplayer({
		width: playerWidth, // the width of the player
		height: playerHeight, // the height of the player
		allowFullScreen: "true", // true by default, allow user to go full screen
		initialVideo: vid_rocknroll, // the video that is loaded into the player
		playerID: "youtube-player", // the ID of the embedded youtube player
		preferredQuality: "default",// preferred quality: default, small, medium, large, hd720
		iframed: false,
		onPlay: function(id){}, // after the play method is called
		onPause: function(){}, // after the pause method is called
		onStop: function(){}, // after the player is stopped
		onSeek: function(time){}, // after the video has been seeked to a defined point
		onMute: function(){}, // after the player is muted
		onUnMute: function(){}, // after the player is unmuted
		onPlayerEnded: function(){
			jQuery("#videoContainer").tubeplayer("seek", 0);
		}
	});
	
	
		
}
