	//	JQuery/JS functions
	
$(document).ready(function() {
	//	Animate index page
	$('.indexText').hide(0);
	$('.indexImage').hide(0);
	$('.indexText').fadeIn(1000);
	$('.indexImage').show('clip', '', 1000);
	//	Animate about page
	$('#aboutPara1').hide(0);
	$('#aboutPara2').hide(0);
	$('#aboutPara3').hide(0);
	$('#aboutPara4').hide(0);
	$('#aboutPara5').hide(0);
	$('#aboutPara6').hide(0);
	$('#aboutPara1').show('blind', '', 500, function() {
		$('#aboutPara2').show('blind', '', 500, function() {
			$('#aboutPara3').show('blind', '', 500, function() {
				$('#aboutPara4').show('blind', '', 500, function() {
					$('#aboutPara5').show('blind', '', 500, function() {
						$('#aboutPara6').show('blind', '', 500);
					});	
				});	
			});	
		});	
	});
	//	Animate contact page
	$('#contact').hide(0);
	$('#contact').show('slide', '', 1200);
	//	Animate join page
	$('#join').hide(0);
	$('#join').show('slide', '', 1200);
	//	Animate directory page
	$('#directoryextras').hide(0);
	$('#directoryextras').show('clip', '', 2000);
	
	
	$('.top-sf-menu ul').superfish();	//	Superfish menu
	
	$('#slideshow').cycle();	//	Slideshow
	
	$('#joinButton').click(function() {
		var formValid = true;
		var reason = "";
		if ($("#groupname").val().length == 0)
		{	
			formValid = false;
			$("#groupname")	.css("background-color", "red");
		}
		else
			$("#groupname")	.css("background-color", "white");
			
		if ($("#email").val().length == 0)
		{	
			formValid = false;
			$("#email")	.css("background-color", "red");
		}
		else
			$("#email")	.css("background-color", "white");
			
		str = $("#email").val();
		if (echeck(str))
			$("#email")	.css("background-color", "white");
		else
		{	
			formValid = false;
			$("#email")	.css("background-color", "red");
		}
		
		if ($("#postcode").val().length == 0)
		{	
			formValid = false;
			$("#postcode")	.css("background-color", "red");
		}
		else
			$("#postcode")	.css("background-color", "white");
		if ($("#description").val().length == 0)
		{	
			formValid = false;
			$("#description")	.css("background-color", "red");
		}
		else
			$("#description")	.css("background-color", "white");
		
		
		if (formValid == false)
			alert ("The form contains invalid fields, please amend the form and re-submit it.");
		return formValid;
		
		
	}); 
	

function echeck(str)
{
	/**
	* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
	*/
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1)
	   return false
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	   return false
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		return false
	if (str.indexOf(at,(lat+1))!=-1)
		return false
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		return false
	if (str.indexOf(dot,(lat+2))==-1)
		return false
	if (str.indexOf(" ")!=-1)
		return false

	return true					
}

	
});
