$(document).ready(function() {

	// Activate fancybox for photo galleries
	$(".shop-gallery a").fancybox({ 
		'zoomSpeedIn': 700, 
		'zoomSpeedOut': 500, 
		'overlayShow': true,
		'overlayOpacity': 0.8 
	});

	// Activate fancybox for email contact form
	$(".email-link a").fancybox({ 
		'zoomSpeedIn': 700, 
		'zoomSpeedOut': 500, 
		'overlayShow': true,
		'overlayOpacity': 0.8,
		'hideOnContentClick': false,
		'frameWidth': 350,
		'frameHeight': 430,
		'padding': 0
	});

	// Calculate price for display
	// This logic mirrors the actual price
	// calculation function
	function calculateTotal() {
		var numLocations = parseInt($("#numLocations").val());
		var numBrands1 = parseInt($("#makes1 input:checked").length);
		var numBrands2 = parseInt($("#makes2 input:checked").length);
		var amount1 = (numLocations * numBrands1 * 35) + 22;
		if (amount1 < 57) {
			amount1 = 57
		}
		var amount2 = (numLocations * numBrands2 * 12);
		var total = amount1 + amount2;

		$('#dispAmount').text(total);
	};

	// Refresh the price on pageload and after
	// relevant form elements are clicked.
	calculateTotal();
	$(".shopform input:checkbox").click(calculateTotal);
	$(".shopform #numLocations").click(calculateTotal);
	
	
	// Lead form
	$('.leadcheckout.passform').css("display","none"); 
	$('.leadcheckout #saveCard').click(function() { 
		$('.leadcheckout .passform').slideToggle('slow');
	});
	
	// For the appoint scheduler datepicker
	$('#scheduler #date').datepicker();
	
	// Home page "Show More Cities" link
	$('.cities_toggle').click(function() {
		$('#fewcities').slideToggle('normal');
		$('#morecities').slideToggle('normal');
		$('#show_more_cities').toggle();
		$('#hide_more_cities').toggle();

		return false;
	});


});