// JavaScript Document

var $window, $document, $popup, width, height, popup_width, popup_left;

$(function(){
	
	$window = $(window);
	$document = $(document);
	$popup1 = $('#popup1');
	$popup2 =$('#popup2');
	width = $document.width();
	height = $document.height();

	
	$('.overlay').width(width).height(height);
	
	$window.resize(function(e){
	
		width = $document.width();
		height = $document.height();
		
		$('.overlay').width(width).height(height);
		
		popup_left = (($window.width() - popup_width) / 2) + 'px';
		$popup1.css('left',popup_left);
		$popup2.css('left',popup_left);
	
	});
	
	$('a.btn_close').click(function(e){
						 
		e.preventDefault();
		
		$('.modal').fadeOut(100,function(e){
			
			$('.overlay').fadeOut(500);
			
		});			 
						 
	});
	
	$('#featured_project').click(function(e){
		
		e.preventDefault();
		
		$('.overlay').fadeIn(100,function(e){
			
			$popup1.fadeIn(500);	
			popup_width = $popup1.width();
			popup_left = (($window.width() - popup_width) / 2) + 'px';
			
			$popup1.css('top','20px').css('left',popup_left);
			
		});
		
	});
	
	$('#current_events').click(function(e){
		
		e.preventDefault();
		
		$('.overlay').fadeIn(100,function(e){
			
			$popup2.fadeIn(500);	
			popup_width = $popup1.width();
			popup_height = '400';
			popup_left = (($window.width() - popup_width) / 2) + 'px';
			
			$popup2.css('top','20px').css('left',popup_left);
			
		});
		
	});
	
});
