$(document).ready(function(){
						   $("#eventSelect").change(function(){
												  	$.ajax({
														   type: "POST",
														   url: '/ajax/tickets-1.php',
														   data: "eventID=" + $("#eventSelect").val(),
														   success: function(data){
															   $("#theForm").html(data);
														   }
														   });
														   });
						   
						   });

function updateTickets(){	
	var adultPrice = $("#adultPrice").val();
	var childPrice = $("#childPrice").val();
	
	var noAdultTickets = $("#noAdultTickets").val();
	var noChildTickets = $("#noChildTickets").val();
	
	var total = (adultPrice * noAdultTickets) + (childPrice * noChildTickets);
	
	var total = total.toFixed(2);
	
	$("#totalCost").html(total);
	
	var item_name = 'Adult Tickets ' + noAdultTickets + ' | Child Tickets ' + noChildTickets;
	$("#item_name").val(item_name);
	$("#amount").val(total);
}

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");
		}
	}
	
}

$(".zoomZT").fancybox({
					  'width': 950,
					  'height': 470,
					  'padding':0,
					  'enableEscapeButton':true,
					  'type':'iframe'
					 });

$(".zoomNL").fancybox({
					  'width': 650,
					  'height': 600,
					  'padding':0,
					  'enableEscapeButton':true,
					  'type':'iframe'
					 });

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

$.featureList(
				$("#tabs li a"),
				$("#output li"), {
					start_item	:	0
				}
			);

function showComments(){
	$("#comments").slideToggle('slow');
	
	if ($("#commentToggle").html() == "Show Comments"){
		$("#commentToggle").html("Hide Comments");
	}else{
		$("#commentToggle").html("Show Comments");
	}
}
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 + "-comment").removeAttr("disabled");
		$("#" + timestamp + "-div").removeAttr("onclick");
		$("#" + timestamp + "-div").removeAttr("style");
	}
}

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

function loadFile(url){
	ajax = $.ajax({
				  url: url,
				  success: function(data){
					  $.fancybox(data,
								 {
									 'autoDimensions': false,
									 'width': 650,
									 'height': 'auto'
								 });
				  }
				  });
}

function popupMap(){
	window.open('/visit-us/map/map.html','Interactive Map - The Parrot Zoo','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=590, height=410');
}

function linkClick(url){
	var goLink = true;
	var enter = $.ajax({
					   type: "POST",
					   data: "url=" + url,
					   url: '/ajax/linkClick.php',
					   });
}