$(document).ready(function() {

	// Photo Gallery
	$('#gallery').cycle({
		fx: 'fade'
	});

	// Dealer drop downs for crappy browsers
	$('.no-csstransitions #dealers>li').hover(function() {
			$(this).find('ul').show().stop().animate({'top':98,'opacity':1},300);
		}, function() {
			$(this).find('ul').stop().animate({'top':49,'opacity':0},300,function(){$(this).hide()});
	});

	// Contact Form
	if ($('#contactForm').length) {
		$('#contactForm').submit(function(e){
			e.preventDefault();
			var form = this;
			var action = $(form).attr('action');
			$('#submit')
				.after('<img src="wp-content/uploads/home/loader.gif" class="loader">')
				.attr('disabled','disabled');

			$.post(action, {
					name: $('#name').val(),
					email: $('#email').val(),
					phone: $('#phone').val(),
					message: $('#message').val()
				},
				function(data){
					$('#contactForm #submit').removeAttr("disabled");
					$('#response').remove();
					$('#contactForm').before('<div id="response" class="response">'+data+'</div>');
					$('#response').hide().slideDown();
					$('#contactForm img.loader').fadeOut(500,function(){$(this).remove()});
					if(data=='Your message has been sent.') $('#contactForm').slideUp();
				}
			);
		});
	}

});
