
$(function(){
	$('#homepage_slideshow').cycle({
		speed:  	2000,
		timeout:	5000,
		delay:		-2000, 
	});
	$('.errorlist').hide();
	$('.errorlist').fadeIn(1000);
	
	$('.photo_list').hide();
	$('.photo_list').fadeIn(600);
	
	$('.photo_list img').hover(
		function(){ $(this).animate({opacity: 0.8}, 200); },
		function(){ $(this).animate({opacity: 1}, 200); }
	);
	
	// $('#contact_form').validate({
	// 	rules: {
	// 		'name': { required: true, maxlength: 100 },
	// 		'email': { required: true, email: true, maxlength: 200 },
	// 		'message': { required: true }
	// 	},
	// 	messages: {
	// 		'name': 'Your name would be nice to know.',
	// 		'email': 'Need your email to write back to you.',
	// 		'message': 'I want to hear what you have to say too!'
	// 	},
	// 	submitHandler: function(form){
	// 		var url	= $(form).attr('action');
	// 		var data = $(form).serialize();
	// 		$('#contact_loader').show();
	// 		$.post(url, data, function(data){
	// 			$('#contact_loader').hide();
	// 			$('#contact_thanks').fadeIn();
	// 		});
	// 		return false;
	// 	},
	// 	validClass: 'valid',
	// 	debug: false
	// });
	
	$('#mailing_list_form').validate({
		rules: { 'email': { required: true, email: true, maxlength: 200 }, },
		messages: { 'email': 'Need your email for a mailing list!', },
		submitHandler: function(form){
			var url	= $(form).attr('action');
			var data = $(form).serialize();
			$('#mailing_list_loader').show();
			$.post(url, data, function(data){
				$('#mailing_list_loader').hide();
				$('#mailing_list_thanks').fadeIn();
			});
			return false;
		},
		validClass: 'valid',
		debug: false
	});
	
	//$('#gallery_thumbnails li').gallery('#gallery_photo');
});

(function($){
	$.fn.gallery = function(photo_div){
		$(this).each(function(index){
			var title	= $(this).find('a').attr('title');
			var photo	= $(this).find('a').attr('href');
			var html	= '<img src="' + photo + '" style="width: 100%;" /><h4>' + title + '</h4><p></p>';
			
			$(this).click(function(){
				$(photo_div).html(html);
			});
			if (index == 0){
				$(photo_div).html(html);
			}
			$(this).find('a').attr('href', '#');
		});
	}
})(jQuery);

