// JavaScript Document
$(document).ready(function()	{
	$("form").submit(submitForm);						   
});

function submitForm()	{
	formData = $("form").serialize();
	
	// Record visit with Google Analytics
	pageTracker._trackPageview('/formsubmission');
	
	$.ajax({
		type : "POST",
		url : "procForm.php?action=send",
		data : formData,
		success : function(content, msg)	{
			$("#contact .content .text").css("position", "relative");
			$("#results")
				.html(content)
				.prependTo("#contact .content .text")
				.css({
					 "position" : "absolute",
					 "top" : "50px",
					 "left" : "358px"
					 })
				.show();
			
			if($("#results").html() == 'Thank you for your interest in Forty Two Eighty Nine. We will follow up as soon as possible.')	{							
				$("form input.txtInput").attr("value", "");
				$("form textarea").val("");
				setTimeout(function()	{
					$("#results").fadeOut();
					
					}, 5000);
				}
								
		}
	   });
	
	return false;
}

/*
scrollLeft = $(document).scrollLeft();
			scrollTop = $(document).scrollTop();
			windowHeight = $(window).height();
			windowWidth = $(window).width();
			resultWidth = $("#results").width();
			resultHeight = $("#results").height();
			
			//$("#results").appendTo("#cover");
			
			posLeft = (windowWidth - resultWidth) / 2;
			posTop = (windowHeight - resultHeight) / 2;
			
			//posLeft = posLeft + scrollLeft;
			//posTop = posTop + scrollTop;
			
			$("#cover")
				.height(windowHeight)
				.width(windowWidth)
				.css({
					"top" : scrollTop,
					"left" : scrollLeft,
					"opacity" : 0.5
					})
				.fadeIn("slow");
			
			$("#results")
				.css({
					"top" : posTop,
					"left" : posLeft
					})
				.fadeIn();							
				
			$("#results").blur(function()	{
										$("#cover").fadeOut();
										});	
			
			setTimeout(function()	{
								$("#results").blur();
								}, 5000);	
*/