eventMapLoadedAlready = false;
	
function showSection(id, button) {
	var currentButton = $('.eventMenu li.current');
	var currentSection = $('.detailBlock.current');
	if (currentButton.length > 0)
		currentButton[0].removeClass('current');
	
	if (currentSection.length > 0) {
		currentSection[0].removeClass('current');
		currentSection[0].style.display = 'none';
	}
	
	$('#event_' + id).style.display = 'block';
	$('#event_' + id).addClass('current');
	$(button).addClass('current');
	
	if ($('#eventMap') != undefined)
		if ($('#eventMap').visible() && !eventMapLoadedAlready)
			loadEventMap();
}

//this is a single point version of this.  it will center and zoom on the last point added.
function codeAddress(address, targetMap) {
	var geocoder;
	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { address: address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK && results.length) {
			if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
				var marker = new google.maps.Marker({
					position: results[0].geometry.location,
					map: targetMap,
					icon: 'tickets/images/blueMarker.png'
				});
				
				targetMap.setCenter(results[0].geometry.location);
				targetMap.setZoom(11);
				
				var infowindow = new google.maps.InfoWindow({
					content: address
				});
				
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.open(targetMap, marker);
				});
			}
		} else {
			//alert("Geocode was unsuccessful due to: " + status);
		}
	});
}

var contactMap = false;
function loadEventMap() {
	var latlng = new google.maps.LatLng(42.34, -83.55);
	var mapOptions = {
		zoom: 1,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.TERRAIN
	};
	contactMap = new google.maps.Map(document.getElementById("eventMap"), mapOptions);
	codeAddress($F('mapAddress'), contactMap);
	eventMapLoadedAlready = true;
}

function createCaptcha() {
	try {
		Recaptcha.create("6LcR4wkAAAAAADNRLZnOECJkaLkZiDA5PMw-Na81", "recaptcha_div", {
			theme: "red",
			callback: Recaptcha.focus_response_field
		});
	} catch (caught) {}
}

function askQuestion() {
	var goodToGo = true;
	
	if ($F('questionName') == '') {
		goodToGo = false;
		$('#questionName').addClass('errorHere');
	} else
		$('#questionName').removeClass('errorHere');
		
	if ($F('questionEmail') == '') {
		goodToGo = false;
		$('#questionEmail').addClass('errorHere');
	} else
		$('#questionEmail').removeClass('errorHere');
		
	if ($F('questionQuestion') == '') {
		goodToGo = false;
		$('#questionQuestion').addClass('errorHere');
	} else
		$('#questionQuestion').removeClass('errorHere');
	
	if (goodToGo) {
		new Effect.Fade($('#questionFormContainer'), {
			duration: .3, 
			afterFinish: function() {
				$('#questionMessageDiv').update('');
				$('#questionFormLoader').style.display = 'block';
				new Ajax.Request('/tickets/actions/askQuestionAction.php', {
					method: 'post',
					parameters: $('#askQuestionForm').serialize(true),
					onSuccess: function(transport) {
						if (parseInt(transport.responseText) > 0) {
							$('#questionFormBox').update('<div class="message">Your question has been sent, and we will respond as soon as possible.<br />Thank you!</div>');	
							$('#questionFormLoader').style.display = 'none';
							$('#questionFormContainer').style.display = 'block';
						} else {
							$('#recaptcha_div').update('');
							createCaptcha();
							$('#questionMessageDiv').update(transport.responseText);
							$('#questionMessageDiv').style.display = 'block';
							$('#questionFormLoader').style.display = 'none';
							$('#questionFormContainer').style.display = 'block';
						}
					}
				});
			}
		});
	}
}

function tooltip(item, tooltipItem) {
	item.hover(
		function() {
			//$(tooltipItem).fadeIn('fast');
			document.getElementById(tooltipItem).style.display = 'block';
		},
		function() {
			//$(tooltipItem).fadeOut('fast');
			document.getElementById(tooltipItem).style.display = 'none';
		}
	);
}
