	$(document).ready(function(){

		$("#seLocationZip").autocomplete("/event/submit/autocomplete_zip.cfm", {
			width: 300,
			selectFirst: false,
			minChars: 2
		});
				
		$("#seLocationZip").result(function(event, data, formatted) {
			if (data) {
				
				// Extract autocomplete data values          
				var zipzip = data[1];
				var zipcity = data[2];
				var zipstate = data[3];
				
				// Display autocomplete result
				$("#seLocationZip").val("" + zipzip + "");
				$("#seLocationCity").val("" + zipcity + "");
				$("#seLocationState").val("" + zipstate + "");
			}
		});

		$("#seLocationLocation").autocomplete("/event/submit/autocomplete_location.cfm", {
			width: 300,
			selectFirst: false,
			minChars: 3,
			extraParams: {
				state: function() { return $("#seLocationState").val(); },
				city: function() { return $("#seLocationCity").val(); }
			}			
		});
				
		$("#seLocationLocation").result(function(event, data, formatted) {
			if (data) {
				
				// Extract autocomplete data values          
				var location = data[0];
				var locationID = data[1];
				var address1 = data[2];
				var address2 = data[3];
				var city = data[4];
				var state = data[5];
				var zip = data[6];
				
				// Display autocomplete result
				$("#sePreserveLocationID").val("1"); 
				$("#seLocationID").val("" + locationID + ""); 
				$("#seLocationCity").val("" + city + "");
				$("#seLocationCityDisplayContainer").text("" + city + "").show();
				$("#seLocationCityInputContainer").hide();
				$("#seLocationState").val("" + state + "");
				$("#seLocationStateDisplayContainer").text("" + state + "").show();
				$("#seLocationStateInputContainer").hide();
				$("#seLocationLocationDisplayContainer").text("" + location + "").show();
				$("#seLocationLocationInputContainer").hide();				
				$("#seLocationAddress1").val("" + address1 + "");
				$("#seLocationAddress1DisplayContainer").text("" + address1 + "").show();
				$("#seLocationAddress1InputContainer").hide();	
				$("#seLocationAddress2").val("" + address2 + "");
				$("#seLocationAddress2DisplayContainer").text("" + address2 + "").show();
				$("#seLocationAddress2InputContainer").hide();	
				$("#seLocationZip").val("" + zip + "");
				$("#seLocationZipDisplayContainer").text("" + zip + "").show();
				$("#seLocationZipInputContainer").hide();	
				$("#locationResetContainer").show();
				$("#locationReset").show();
				$("#sePreviousLocation").hide();				
			}
		});
   		
		// reset location fields
		$("#locationReset").click( 
			function () 
			{ 
				$("#sePreserveLocationID").val("0");
				$("#seLocationID").val("");  
				$("#seLocationCity").val(""); 
				$("#seLocationCityInputContainer").show();
				$("#seLocationCityDisplayContainer").empty().hide();
				$("#seLocationState").val(""); 
				$("#seLocationStateInputContainer").show();
				$("#seLocationStateDisplayContainer").empty().hide();
				$("#seLocationLocation").val("");   
				$("#seLocationLocationInputContainer").show();
				$("#seLocationLocationDisplayContainer").empty().hide();    
				$("#seLocationAddress1").val(""); 
				$("#seLocationAddress1InputContainer").show();
				$("#seLocationAddress1DisplayContainer").empty().hide();   
				$("#seLocationAddress2").val(""); 
				$("#seLocationAddress2InputContainer").show();
				$("#seLocationAddress2DisplayContainer").empty().hide();
				$("#seLocationZip").val(""); 
				$("#seLocationZipInputContainer").show();
				$("#seLocationZipDisplayContainer").empty().hide();
				$("#sePreviousLocation").val("").show();
				$("#locationReset").hide();
				$("#locationResetContainer").hide();
			}
		);
		
		// reset contact results
		$("#contactReset").click( 
			function () 
			{ 
				$("#sePreserveContactID").val("0");
				$("#seContactID").val("");  
				$("#seContactFirstName").val("");
				$("#seContactFirstNameInputContainer").show();
				$("#seContactFirstNameDisplayContainer").empty().hide();
				$("#seContactLastName").val("");
				$("#seContactLastNameInputContainer").show();
				$("#seContactLastNameDisplayContainer").empty().hide();
				$("#seContactEmailAddress").val("");
				$("#seContactEmailAddressInputContainer").show();
				$("#seContactEmailAddressDisplayContainer").empty().hide();
				$("#seContactCompany").val("");
				$("#seContactCompanyInputContainer").show();
				$("#seContactCompanyDisplayContainer").empty().hide();
				$("#seContactWebsite").val("");
				$("#seContactWebsiteInputContainer").show();
				$("#seContactWebsiteDisplayContainer").empty().hide();
				$("#seContactAddress1").val("");
				$("#seContactAddress1InputContainer").show();
				$("#seContactAddress1DisplayContainer").empty().hide();
				$("#seContactAddress2").val("");
				$("#seContactAddress2InputContainer").show();
				$("#seContactAddress2DisplayContainer").empty().hide();
				$("#seContactCity").val("");
				$("#seContactCityInputContainer").show();
				$("#seContactCityDisplayContainer").empty().hide();
				$("#seContactState").val("");
				$("#seContactStateInputContainer").show();
				$("#seContactStateDisplayContainer").empty().hide();
				$("#seContactZip").val("");
				$("#seContactZipInputContainer").show();
				$("#seContactZipDisplayContainer").empty().hide();
				$("#seContactPhoneArea1").val("");
				$("#seContactPhone1InputContainer").show();
				$("#seContactPhone1DisplayContainer").empty().hide();
				$("#seContactPhoneExchange1").val("");
				$("#seContactPhoneNumber1").val("");
				$("#seContactFaxArea1").val("");
				$("#seContactFax1InputContainer").show();
				$("#seContactFax1DisplayContainer").empty().hide();
				$("#seContactFaxExchange1").val("");
				$("#seContactFaxNumber1").val("");
				$("#sePreviousContact").val("").show();
				$("#contactReset").hide();
				$("#contactResetContainer").hide();
			}
		);

		$('#seDatepicker1').datepicker({
			useThemeRoller: true,
			alignment: 'bottomRight', 
			beforeShow: readseSelected1,
			onSelect: updateseSelected1,
			showOn: 'both',
			showOtherMonths: true,
			nextText: '',
			showButtonPanel: true,
			buttonImageOnly: true,
			buttonImage: '/include/images/calendar.gif',
			buttonText: 'Select A Date'
		}); 
			 
		// Prepare to show a date picker linked to three select controls  
		function readseSelected1() {  
			$('#seDatepicker1').val($('#seEventMonth1').val() + '/' +  $('#seEventDay1').val() + '/' + $('#seEventYear1').val());  
			return {};  
		}  
		  
		// Update three select controls to match a date picker selection  
		function updateseSelected1(date) {  
			$('#seEventMonth1').val(date.substring(0, 2));  
			$('#seEventDay1').val(date.substring(3, 5));  
			$('#seEventYear1').val(date.substring(6, 10));  
		}
		
		$('#seDatepicker2').datepicker({
			useThemeRoller: true,
			alignment: 'bottomRight', 
			beforeShow: readseSelected2,
			onSelect: updateseSelected2,
			showOn: 'both',
			showOtherMonths: true,
			nextText: '',
			showButtonPanel: true,
			buttonImageOnly: true,
			buttonImage: '/include/images/calendar.gif',
			buttonText: 'Select A Date'
		}); 
			 
		// Prepare to show a date picker linked to three select controls  
		function readseSelected2() {  
			$('#seDatepicker2').val($('#seEventMonth2').val() + '/' +  $('#seEventDay2').val() + '/' + $('#seEventYear2').val());  
			return {};  
		}  
		  
		// Update three select controls to match a date picker selection  
		function updateseSelected2(date) {  
			$('#seEventMonth2').val(date.substring(0, 2));  
			$('#seEventDay2').val(date.substring(3, 5));  
			$('#seEventYear2').val(date.substring(6, 10));  
		}
		
		
		
		/*
		$("#searchBar_fieldGraphic").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=searchBar_fieldGraphic'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});		
		$("#seasonal_sfLocation").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=searchBar_fieldGraphic'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});		
		$("#sfRadius").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=sfRadius'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});					
		$("#sfTags").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=sfTags'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});		
		$("#sfExact").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=sfExact'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});		
		$("#sfNoSports").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=sfNoSports'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});		
		$("#sfFilter").qtip({
			content: {
				url: '/include/tooltip.cfm?tooltipText=sfFilter'
			},
			tip: 'topLeft',
			style: {
				width: 300,
				background: '#fcfef8',
				padding: 10,
				tip: 'topLeft',
				border: {
					width: 6,
					radius: 5,
					color: '#7bbb04'
				}
			}
		});
		*/
				
	});
