(function (window, undefined) {
	
	var $ = window.jQuery;
	
	$.fn.callout = function() {
		
		var timer = null;
    
	    this.mouseenter(function (e) {
	    	
	    	var $callout  = $('div.callout', this);
	    	
	    	timer = window.setTimeout(function () {
	    	
	    		$callout.show();
	    		
	    	}, 300);
	    	
	    	return false;
	    	
	    }).mouseleave(function (e) {
	    
	    	$('div.callout', this).hide();
	    
	    	window.clearTimeout(timer);
	    
	    	return false;
	    });
	    
	    return this;
	}
	
	$.fn.contact = function () {
	
		var url = this.attr('href');
		
		this.overlay({
		
			closeOnClick: true,
			
			fixed: false,
			
			mask: {
				
				loadSpeed: 200
			},
			
			target: '#overlay',
			
			top: '5%',
			
			onBeforeLoad: function () {
			
				var $content = this.getOverlay().find('div:first');
				
				if ($content.is(':empty')) {
					
					$content.load(url);
				}
			},
			
			onLoad: function () {
			
				var $overlay = this.getOverlay();
			
				$overlay.find('form').live('submit', function () {
					
					$form = $(this);
			
					$overlay.find('div:first').load(url, $form.serializeArray());
			
					return false;
				});
			}
		});
		
		return this;
	}
	
})(this);

jQuery(function ($, undefined) {
	
	$('.section div.album').callout();
	$('.header a.tear, .vcard a.url').contact();
});
