function validEmailAddress(eA){var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return pattern.test(eA);}

$(document).ready(function(){
						   
        $(document).pngFix(); 
		
		$('#random_posts').cycle({ 
			fx:    'fade', 
			speed:  2500,
			delay:  4000
		});
		
		$('.image a').fancybox({
			'titleShow' : false
		});
		
		$('.fancyPop').fancybox({
			'titleShow' : false,
			'autoDimensions'	: true,
			'width'				: 470,
			'height'			: 400,
			'onCleanup'			: function(){ $("p#error").hide(); }

		});
		
		Cufon.replace('.cfnize');
		
		$("#contact-form form").bind("submit", function() {
			if ($("input#name",this).val().length < 3 || $("input#email",this).val().length < 3 || $("textarea#message",this).val().length < 3 || !(validEmailAddress($("input#email",this).val())) ) 
			{
				$("p#error",$(this).parents()).show();
				$.fancybox.resize();
				return false;
			}

			$.fancybox.showActivity();

			$.ajax({
				type		: "POST",
				cache		: false,
				url			: "http://www.imoveisltda.com.br/ajax/",
				data		: $(this).serializeArray(),
				success		: function(data) {
								$.fancybox(data);
							  }
			});
			
			this.reset();

			return false;
		});

});
