/* Author: Office/Bureau

*/

function scale(){
	if($(window).height() < 860){
		height = 860;
	}else{
		height = $(window).height();
	}
	$('#container').css('height',height);
}

$('document').ready(function(){
	
	$(window).resize(function(){
		scale();
	});

	$.backstretch('img/bg_blank.jpg');
	$('form').fadeOut(1);
	$('#more').click(function(){
		$('#more, article, #tag').fadeOut('slow',function(){
			$('form').fadeIn('slow');
		});
	});
	
	$("label").inFieldLabels();
	
	$('#submit').click(function(ev){
		ev.preventDefault();
		var fail = 0;
		var req = [ "FNAME", "LNAME", "EMAIL", "PCODE" ];
		$.each(req, function(){
			if($("#" + this).val() == ''){
				$("#" + this).css('background','#FDD9D9');
				fail = 1;
			}
		})
		
		if(fail == 1){
			return;
		}else{
			$('form *').fadeOut('fast',function(){
				$('form').css('background','url(img/loader.gif) center center no-repeat');
			})
			$.post('api/subscribe.php', {
				FNAME: $('#FNAME').val(),
				LNAME: $('#LNAME').val(),
				PCODE: $('#PCODE').val(),
				PHONE: $('#PHONE').val(),
				EMAIL: $('#EMAIL').val(),
				AGENT: $('#AGENT').val(),
				BEDROOMS: $('#BEDROOMS').val(),
				FOOTAGE: $('#FOOTAGE').val(),
				PRICE: $('#PRICE').val()
			}, function() {
			  	$('form').append('<p class=success>Thank you for your interest in The Perry. A representative will contact you shortly with additional details about this exciting new residence.</p>');
			  	$('form').css('background','none');
			});
		}
				
	})
	
});



$(window).load(function(){
	scale();
	$('#man').animate({ 'opacity' : 1.0 },'fast');
});












