$(document).ready(function() { 

$.facebox.settings.opacity = 0.8;
$('a[rel*=facebox]').facebox();

//$('.to_top').click(function(){$('#top').ScrollTo(500); return false; });
$("#tour_stop_list li a").click(function() {
	var href = $(this).attr("href");
	$(href).ScrollTo(500);
	return false;
});

	/* resets the ticket form values */
	$.resetContactForm = function() {
		$("#name").val('');
		$("#email").val('');
		$("#phone").val('');
		$("#inquiry").val('');
		$("#quantity").val('Please select a quantity');
	};
	
	/* sponsor list */
	$('#sponsor_text a').tooltip({ track: true, delay: '0', showURL: false, top: -14, left: 7 });
	
	$("#bbq_extra").hide();
	
	$("#bbq_check").change(function() {
		if( $("#bbq_check:checked").val() != null) {
			$("#bbq_extra").slideDown("fast");
		} else {
			$("#bbq_extra").slideUp("fast");
		}
	});

	/* ajax ticket form */
	/*
	$("#ticket_form").submit(function() {
		$("#ticket_form_load").fadeIn("fast",function() {
			var quantity = $("#quantity :selected").text();
			var bbq		 = $("#bbq :selected").text();
			$.ajax({
				type:	"POST",
				url:	"http://thetasteofhistory.com/acs-themes/thetasteofhistory/ajax/contact.php",
				data:	"name="+escape($("#name").val())+
						"&email="+escape($("#email").val())+
						"&phone="+escape($("#phone").val())+
						"&bbq="+escape(bbq)+
						"&quantity="+escape(quantity)+
						"&inquiry="+escape($("#inquiry").val()),
				success:function(html) {
					$("#ticket_form_load").fadeOut("fast");
					$("#resp").text("Your ticket reservation has been sent. We will contact you shortly.");
					$("#resp").slideDown("fast");
					$.resetContactForm();
					setInterval('$("#resp").slideUp("fast");',10000);
				},
				error:function(xml,ts,et) {
					$("#resp").empty();
					$("#resp").text("There was an error in your request. Please try again later.");
					$("#resp").slideDown("fast");
					$.resetContactForm();
					setInterval('$("#resp").slideUp("fast");',10000);
				}
			});
		});
		return false;
	});
	*/
	
	$('#questionnaire_form').submit(function() {
		$('#questionnaire_form_load').fadeIn('fast',function() {
			var first, value, wine, food, history, music, art, comments;
			
			first = $("input[name=firsttime]:checked").val();
			value = $("input[name=value]:checked").val();
			wine = $("input[name=wine]:checked").val();
			food = $("input[name=food]:checked").val();
			history = $("input[name=history]:checked").val();
			music = $("input[name=music]:checked").val();
			art = $("input[name=art]:checked").val();
			/*
			$("input[name=like]:checked").each(function() {
				favorite += ' ' + $(this).val();
			});
			*/
			comments = $('#comments').val();
			
			$.ajax({
				type:	'POST',
				url:	'http://thetasteofhistory.com/acs-themes/thetasteofhistory/ajax/questionnaire.php',
				data:	'first='+first+
						'&value='+value+
						//'&favorite='+favorite+
						'&comments='+comments+
						'&wine='+wine+
						'&food='+food+
						'&history='+history+
						'&music='+music+
						'&art='+art+
						'&ajaxian=booyeah',
				success:function(html) {
					$('#resp').empty();
					$('#resp').text("Thank you for your input. We look forward to seeing you next year.");
					$('#resp').slideDown('fast');
					$('#questionnaire_form_load').fadeOut('fast');
					$('#comments').val('');
					$('input:checked').attr('checked', false);
				}
			});
			
		});
		return false;
	});
});
