/////////////
// Actions //
/////////////

// Set Global Variables
var contactWidth = 940;
var contactMargin = -(contactWidth/2);


// Document Ready
$(document).ready( 
	function() {
		
		// init
		
		
	}
);


/*
 * launchContactBox()
 */
function launchContactBox() {
	
	$('<div id="modal-overlay" onClick="hideContact()"></div>')
		.prependTo('body')
		.css('position','absolute')
		.css('z-index','10000')
		.css('opacity','0')
		.css('background','black')
		.css('height',$(document).height())
		.css('width','100%')
		.css('min-width','100%')
		.animate( { opacity: 0.65 }, 300,
				
			// Build Content Div
			function() {
				$('<div id="modal-content"></div>')
					.appendTo('body')
					.animate( { opacity: 0 }, 0)
					.css('position','absolute')
					.css('left','0')
					.css('z-index','20000')
					.css('border','0px solid yellow')
					.css('width','100%')
					.load("/contact/contact-html.php",
						
						// Build Modal Box Div
						function() {
							$('<div id="modal-box"></div>')
								.appendTo('body')
								.css('position','absolute')
								.css('left','50%')
								.css('border','0px solid red')
								.css('z-index','30000')
								.css('width',contactWidth)
								.css('margin-left',contactMargin)
								.css('height',$('#modal-content').height())
								.append('<div id="modal-middle"></div>')
								.animate( {top:$(window).scrollTop()+37+"px"}, 
									
									function() {
										// Set Modal Component Sizes
										$('#modal-middle').css('height',$('#modal-content').height() + 2);
										$('#modal-content').css('width',$('#modal-middle').width());

										// Append Content Div To Correct Location
										$('#modal-content').appendTo('#modal-middle');
										
										// Slide down modal
										$('#modal-box').slideDown("fast", 
												
											function() {
											
												// Show Content After slideDown
													
													// Set Height Var
													var contentHeight = $('#modal-content').height();

													// Set Height To Zero
													$('#modal-content').css('height','0px');
													
													// Show
													$('#modal-content').animate( { opacity: 1.0 }, 0);
													$('#modal-content').animate( { height: contentHeight }, 600);
												
											});
									});
						}); // End Build Modal
		}); // End Build Content
}


/**
 * hideContact
 */
function hideContact() {
	$('#modal-content')
		.css('background','#013763')
		.css('height',$('#modal-content').height())
		.empty()
		.animate( { height: 0+"px" }, 600,
			function() {
				$('#modal-box').hide();
				$('#modal-overlay').animate( { opacity: 0 }, 400, 
					function() {
						$('#modal-content').remove();
						$('#modal-box').remove();	
						$('#modal-overlay').remove();
					});
		});
}
