eventMapLoadedAlready = false;
	
function showSection(id, button) {
	$('.eventMenu li.current').each( function(index) {
		$(this).removeClass('current');
	});

	$('.detailBlock.current').each( function(index) {
		$(this).removeClass('current');
		$(this).css({ display: 'none' });
	});
	
	$('#event_' + String(id)).css({ display: 'block' });
	$('#event_' + String(id)).addClass('current');
	$(button).addClass('current');
	
	if ($('#eventMap') != undefined)
		if ($('#eventMap').is(":visible") && !eventMapLoadedAlready)
			loadEventMap();
	
	triggerSeatingMaps();
	drawStadiumMaps();
}

//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 ($('#questionName').val() == '') {
		goodToGo = false;
		$('#questionName').addClass('errorHere');
	} else
		$('#questionName').removeClass('errorHere');
		
	if ($('#questionEmail').val() == '') {
		goodToGo = false;
		$('#questionEmail').addClass('errorHere');
	} else
		$('#questionEmail').removeClass('errorHere');
		
	if ($('#questionQuestion').val() == '') {
		goodToGo = false;
		$('#questionQuestion').addClass('errorHere');
	} else
		$('#questionQuestion').removeClass('errorHere');
	
	if (goodToGo) {
		$('#questionFormContainer').fadeOut('fast', function() {
				$('#questionMessageDiv').html('');
				$('#questionFormLoader').css({ display: 'block' });
				$.ajax({
					url: '/tickets/engine/actions/askQuestionAction.php',
					type: 'post',
					data: $('#askQuestionForm').serializeArray(),
					success: function(transport) {
						if (parseInt(transport) > 0) {
							$('#questionFormBox').html('<div class="message">Your question has been sent, and we will respond as soon as possible.<br />Thank you!</div>');	
							$('#questionFormLoader').css({ display: 'none' });
							$('#questionFormContainer').css({ display: 'block' });
						} else {
							$('#questionMessageDiv').html(transport);
							$('#questionMessageDiv').css({ display: 'block' });
							$('#questionFormLoader').css({ display: 'none' });
							$('#questionFormContainer').css({ display: 'block' });
						}
					}
				});
			}
		);
	}
}

function sendContact() {
	var goodToGo = true;
	
	if ($('#contactName').val() == '') {
		goodToGo = false;
		$('#contactName').addClass('errorHere');
	} else
		$('#contactName').removeClass('errorHere');
		
	if ($('#contactEmail').val() == '') {
		goodToGo = false;
		$('#contactEmail').addClass('errorHere');
	} else
		$('#contactEmail').removeClass('errorHere');
		
	if ($('#contactQuestion').val() == '') {
		goodToGo = false;
		$('#contactQuestion').addClass('errorHere');
	} else
		$('#contactQuestion').removeClass('errorHere');
	
	if (goodToGo) {
		$('#contactFormContainer').fadeOut('fast', function() {
				$('#contactMessageDiv').html('');
				$('#contactFormLoader').css({ display: 'block' });
				$.ajax({
					url: '/tickets/engine/actions/sendContactAction.php',
					type: 'post',
					data: $('#sendContactForm').serializeArray(),
					success: function(transport) {
						if (parseInt(transport) > 0) {
							$('#contactFormBox').html('<div class="message">Your contact has been sent, and we will respond as soon as possible.<br />Thank you!</div>');	
							$('#contactFormLoader').css({ display: 'none' });
							$('#contactFormContainer').css({ display: 'block' });
						} else {
							$('#contactMessageDiv').html(transport);
							$('#contactMessageDiv').css({ display: 'block' });
							$('#contactFormLoader').css({ display: 'none' });
							$('#contactFormContainer').css({ display: 'block' });
						}
					}
				});
			}
		);
	}
}
