try{document.execCommand("BackgroundImageCache", false, true);}catch(err){};

$(function(){

	/* Cycle Init */
	
	$('.slideshow').cycle({
		fx:      'fade', 
	    timeout:  3500,
		speed: 2000
	});

	/* Form validation & ajax submit */
	
	$('.send').click(function(){
		var tForm = $('form').eq($('.send').index(this));
		var tReq = tForm.find('.required');
		tReq.removeClass('error');
		tReq.each(function(){ if ($(this).val()=='' || ($(this).attr('name')=='email' && !checkEmail($(this).val()))) $(this).addClass('error'); });
		if (tReq.hasClass('error')) {alert('Rellene los campos marcados en rojo'); return false;}
		$.post(tForm.attr('action'), tForm.serialize(), function(rdata) {
			if (rdata == '') {
				$('.send').hide();
				$(tForm).each (function(){
				  this.reset();
				});
				return !$('.success').fadeIn();
			}
			return !$('.error').fadeIn();
		});
		return false;
	});
	
	$('#photolist a').colorbox({maxWidth:960});
	
//	$('.uploaded_image').colorbox({maxHeight:570});
	
	function checkEmail(d){
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		return filter.test(d);
	}

	return false;
	
});
