/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	*/
/*	File: 				main.js
/*	Description:		Contains all master javascript code.
/*	Target browsers:	IE6+, Mozilla/Firefox, Safari, Opera
/*	Author(s):			J. Jackson | jjackson@jplcreative.com
/*	Created: 			04.07.2010
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	*/

/* +++++ custom scripts +++++ */
/* +++++ require jquery 1.4.2 +++++++++++++++++++++++++++++++++++++++++ */
$(function(){
	// bind event for contact form
	$('#contact-btn').click( function() { createOverlay() });		   
});

function createOverlay(){
	// create elements, assign classes/styles, append to body
	var overlay = document.createElement("div");
	var scroll_position = $(window).scrollTop();
	var contact_left = ($(window).width() / 2) - 265;
	if ( $('.overlay').length == 0 ) {
		$(overlay).addClass('overlay').width($(window).width() + 'px').height($(document).height() + 'px').css('top', '0px').appendTo('body');
	}
	// fade in overlay
	$(".overlay").fadeIn('fast', function(){							  
		// bind overlay removal events
		$('a#close').click(function(){ removeOverlay() });
		// fade in open house window
		$('#contact-form').css('left', contact_left + 'px').fadeIn('slow');
	});
}
function removeOverlay() {
	// fade contact form
	$('#contact-form').fadeOut('fast', function(){
		// fade overlay
		$('.overlay').fadeOut('fast', function(){
			// remove overlay from DOM
			$('.overlay').remove();
		});
	});
}
