// JavaScript Document

// change the header background image on mouseover

$(document).ready(function() {
	$(".button").hover(
      function () {
		$(this).addClass("hover");
        $(this).css({'background-image': "url(/images/lite-bg.gif)"});
      }, 
      function () {
		$(this).removeClass("hover");
        $(this).css({'background-image': "url(/images/dark-bg.gif)"});
      }
    );
});

//end







// show a close icon when a header is clicked

//$(document).ready(function() {
//	$(".button").toggle(
//			function (){$(this).find('span').show();},
//			function (){$(this).find('span').hide();}
//		);
//});

// end

// show the content when a header is clicked

//$(document).ready(function() {
//   	$("#hOne").css({marginTop: '0px'}); // sets the margin top of the first header to zero as all headers have 5px in the css but we don't want the first one to have that
//	$(".button").bind('click', function () {
//		$(this).next(".content").slideToggle();
//    });
//});

// end






// slide up and fade in the s1 logo PLUS fade in all the headers and the footer

$(document).ready(function() {
	$("#logoIMG").css({top: '223px', display: 'none'});
	
	$("#logoIMG").animate({ 
        "top": "0px",
		"opacity": "show",
		"width": "100px",
		"height": "100px"
      }, 1000 , function(){
		 $("#strap img").animate({
							 "top": "0px",
							 "opacity": "show"
							 }, 1000, 
							 
		    function(){$("#hOne").fadeIn('normal', 
			  function(){$("#hTwo").fadeIn('normal', 
				function(){$("#hThree").fadeIn('normal', 
					function(){$("#hFour").fadeIn('normal', 
						function(){$("#hFive").fadeIn('normal', 
							function(){$("#hSix").fadeIn('normal', 
								function(){$("#hSeven").fadeIn('normal', 
									function(){$("#hNews").fadeIn('normal',
										function(){$("#hEight").fadeIn('normal', 
											function(){$("#footer").fadeIn('normal')
										;});});});});});});});});});} 
			); // end first animate function
			
		  });
});

// end


$(document).ready(function() {
   	$("#hOne").css({marginTop: '0px'}); // sets the margin top of the first header to zero as all headers have 5px in the css but we don't want the first one to have that
	$(".button").bind('click', function () {
		
		if ( $(this).next(".content").hasClass("slideOpen") )
		{
			$(".content").removeClass("slideOpen");
			$(".content").slideUp();
			$(".button span").hide();
		}
		else
		{
			$(".content").removeClass("slideOpen");
			$(".content").slideUp();
			$(".button span").hide();
			$(this).next(".content").slideDown().addClass("slideOpen");
			$(this).find('span').show();
		}
		
    });
	
});



// terms of use & privacy policy pages

$(document).ready(function() {
	$("#logo2IMG").css({top: '223px'});
	$("#logo2IMG").animate({ 
        "top": "0px",
		"opacity": "show",
		"width": "100px",
		"height": "100px"
      }, 1000 , function(){
		 $("#strap img").animate({
							 "top": "0px",
							 "opacity": "show"
							 }, 1000,   
	  function(){
	
	$("#hSub").fadeIn('1500', function(){$(".content2").slideToggle('50000', function(){$("#footer").fadeIn('1000');});});
	  }); });
});

// end


// video ajax code

$(document).ready(function() {
	$("#video").empty();
	$("#video").load('/video/video.html');
	
	$(".s1jobs2009").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_danny.html');
		});
	$(".s1jobs1").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_doodles.html');
		});
	$(".s1jobs2").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_boardroom.html');
		});
	$(".s1jobs2a").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_eyes.html');
		});	
	$(".s1jobs3").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_nursery.html');
		});
	$(".s1jobs4").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_pizza.html');
		});
	$(".s1jobs5").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_ice_cream.html');
		});
	$(".s1jobs6").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1jobs_lavvyheid.html');
		});
	
	$(".s1homes1").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1homes_snails.html');
		});
	$(".s1homes2").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1homes_squatters.html');
		});
	$(".s1homes3").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1homes_leek.html');
		});
	$(".s1homes4").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1homes_weasel.html');
		});
	$(".s1homes5").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1homes_rubberman.html');
		});
	
	$(".s1play1").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1play_elastic.html');
		});
	$(".s1play2").click(function()
		{
			$("#video").empty();
			$("#video").load('/video/video_s1play_sellotape.html');
		});
		
		
		// news stories

	$("#news").empty();
	$("#news").load('/news/news-11.html');
	
	$(".news1").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-1.html');
		});
	$(".news2").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-2.html');
		});
	$(".news3").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-3.html');
		});
	$(".news4").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-4.html');
		});
	$(".news5").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-5.html');
		});
    $(".news6").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-6.html');
		});
	$(".news7").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-7.html');
		});
	$(".news8").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-8.html');
		});
	$(".news9").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-9.html');
		});
	$(".news10").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-10.html');
		});
	$(".news11").click(function()
		{
			$("#news").empty();
			$("#news").load('/news/news-11.html');
		});
		
});





$(document).ready(function() {
	$("#loading").ajaxStart(function()
		{
			$(this).show();
		})
	.ajaxStop(function()
		{
			$(this).hide();
		});
	$("#loading2").ajaxStart(function()
		{
			$(this).show();
		})
	.ajaxStop(function()
		{
			$(this).hide();
		});
});


// end


// contact form validation

function checkForm() {
	var myName = $("#name").val();
	var myEmail = $("#email").val();
	var myEnquiry = $("#enquiry").val();
	
	if ( (myName == '') || (myEmail == '') || (myEnquiry == '') )
	{
		$("#msg").slideDown();
		return false;
	}
}

// end




