$(document).ready(function(){
	
	/*	Form - Contacts	*/	
	$("#contact-form").validate(
	{
		submitHandler: function()
		{
			$.post("_php/_go/go.php?f=form-contact", $("#contact-form").serialize(),
			function()
			{
				//	Placing message
					$("#getMessage").fadeIn("slow").load("_php/_go/go.php?f=getMessage&place=1");	
					
				//	GA analytics
					_gaq.push(['_trackPageview', '/thank-you-enquire']);
					
				//	Clean form
					$(":input, #contact-form").not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
			});
		}
	});
		
	/*	Scroll to the top	*/
			
		$("#page-top-button").click(function(e)
			{
				e.preventDefault();
	
				$('html, body').animate({ scrollTop: 0 }, 'slow');
			})	
			
	
	/*	Testimonials Pagination Button	*/
	
		//When you click on an individual button			
		$("#testimonials-pagination .right .pagi-button").click(function()
			{			
				testimonialID = $(this).attr("rel");
				
				$(".testimonial-id").hide();				
				$("."+testimonialID).show();
				$(".pagi-button").removeClass("active");
				$(this).addClass("active");
				
				if($(".testimonial1").is(":visible"))
				{
					$("#pagi-left").addClass("deactivated");
				}
				else
				{
					$("#pagi-left").removeClass("deactivated");
				}
					
				if($(".testimonial4").is(":visible"))
				{
					$("#pagi-right").addClass("deactivated");
				}
				else
				{
					$("#pagi-right").removeClass("deactivated");
				}
			})
			
		
		//When you click on left arrow
		$("#testimonials-pagination .right #pagi-left").click(function()
			{
				
				//working out which one is active
				activeid = $(".active").attr("rel");
				
				//if 2nd is active, must hide left button as extra		
				if($(".testimonial2").is(":visible"))
				{	
						$(".testimonial-id").hide();				
						$(".testimonial1").show();
						$(".pagi-button").removeClass("active");
						$(".pagi-button").first().addClass("active");
						$("#pagi-left").addClass("deactivated");			
				}	
				
				//If first is active, do nothing
				if($(".testimonial1").is(":visible"))
				{	
				}		
				
				//normal			
				else
				{
					$("."+activeid).hide();	
					$("."+activeid).prev().show();
					$(".active").prev().addClass("active");
					$(".active").last().removeClass("active");
				}
				
				//if anything but 4 is showing, show right button
				if($(".testimonial4").is(":hidden"))
				{	
					$("#pagi-right").removeClass("deactivated");	
				}
	
			})
			
			//When you click on right arrow
		$("#testimonials-pagination .right #pagi-right").click(function()
			{
				
				//working out which one is active
				activeid = $(".active").attr("rel");
				
				//if 2nd is active, must hide left button as extra		
				if($(".testimonial3").is(":visible"))
				{	
						$(".testimonial-id").hide();				
						$(".testimonial4").show();
						$(".pagi-button").removeClass("active");
						$(".pagi-button").last().addClass("active");
						$("#pagi-right").addClass("deactivated");			
				}	
				
				//If first is active, do nothing
				if($(".testimonial4").is(":visible"))
				{	
				}		
				
				//normal			
				else
				{
					$("."+activeid).hide();	
					$("."+activeid).next().show();
					$(".active").next().addClass("active");
					$(".active").first().removeClass("active");
				}
				
				//if anything but 4 is showing, show right button
				if($(".testimonial1").is(":hidden"))
				{	
					$("#pagi-left").removeClass("deactivated");	
				}
	
			})
			
		/*	Scroll to the top	*/
		

				
				//test random
				
				var divs = $("#cast-studies-right .block").get().sort(function(){ 
							return Math.round(Math.random())-0.5; //so we get the right +/- combo
						   }).slice(0,1);
				$(divs).show();


});






