function validateForm(){
	valid = true;
	if (document.contact.name.value == "") { valid = false; }
	if (document.contact.email.value == "") { valid = false; }
	if (document.contact.message.value == "") { valid = false; }
	if (document.contact.type.value == ""){ valid = false; }
	
	
	if (valid == false){
		alert("Error :: Please fill in all of the required fields.");
		return false;
	}
	
}

function validateForm_cpcp(){
	valid = true;
	if (document.cpcpRegister.zooName.value == "") { valid = false; }
	if (document.cpcpRegister.zooEmail.value == "") { valid = false; }
	if (document.cpcpRegister.zooPhone.value == "") { valid = false; }
	if (document.cpcpRegister.yourName.value == ""){ valid = false; }
	if (document.cpcpRegister.yourPosition.value == ""){ valid = false; }
	if (document.cpcpRegister.zooWebsite.value == ""){ valid = false; }
	
	
	if (valid == false){
		alert("Error :: Please fill in all of the required fields.");
		return false;
	}
	
}

function removeSpaces(string) {
	return string.split(' ').join('');
}

function jsSearch(type){
	searchField = $("#query");
	searchValue = searchField.val();
	
	if (type == 'blur'){
		if (removeSpaces(searchValue) == ""){
			searchField.css("color","#999999");
			searchField.val("Search...");
		}
	}else if(type == 'focus'){
		if (searchValue == 'Search...'){
			searchField.val("");
			searchField.css("color","#000000");
		}
	}
	
}

$("a.zoomZT").fancybox({
					  'frameWidth': 950,
					  'frameHeight': 470,
					  'padding': 0,
					  'enableEscapeButton':true,
					 });

$("a.zoom").fancybox();

function compEnter(){
	/* Check the Fields */
	var cont = true;
	if (removeSpaces($("#compName").val()) == "") { cont = false; }
	if (removeSpaces($("#compEmail").val()) == "") { cont = false; }
	if (removeSpaces($("#compEntry").val()) == "") { cont = false; }

	if (cont == false){
		alert("Error :: You are required to fill in all of the fields");
	}else{
		var confirmBox = confirm("Please check the information below: \n\n Name: "+$("#compName").val()+" \n Email: "+$("#compEmail").val()+"\n\n Caption: "+$("#compEntry").val()+"");
		if (confirmBox){
			enter = $.ajax({
				   type: "POST",
				   url: "/ajax/competitionEnter.php",
				   data: "compID=" + $("#compID").val() + "&compName=" + $("#compName").val() + "&compEmail=" + $("#compEmail").val() + "&compEntry=" + $("#compEntry").val(),
				   success: function(result){
					   $("#compEnterForm").slideUp();
					   $("#compEnterResult").html(result);
					   $("#compEnterResult").delay(300).fadeIn();
				   }
				   });
		}
	}
}

function resetCompForm(){
	$("#compEnterResult").fadeOut();
	$("#compEnterForm").delay(300).slideDown();
}

function showForgottenPassword(){
	alert("Due to the nature of this system we are unable to reset/create accounts online. \n\n Please contact Craig in order to reset your password.");
}

function disabledBooking(timestamp){
	var silly = confirm("This booking time has been disabled for a reason. \n\n Are you sure you want to unlock it?");
	
	if (silly){
		alert ("The booking time has been unlocked");
		$("#" + timestamp).removeAttr("disabled");
		$("#" + timestamp + "-div").removeAttr("onclick");
		$("#" + timestamp + "-div").removeAttr("style");
	}
}

function donate(){
	$("#paypalDonate").submit();
}