$(document).ready(function() {	
	$('a[name=modal]').hover(function(e) {
		$('.window').fadeOut(500);
		e.preventDefault();
		var id = $(this).attr('href');
		$(id).fadeIn(500); 
});
	
	$('.window').bind('mouseleave', function(event){
										   $(this).fadeOut(50); 
										   });
	
	$('.window').bind('mouseenter', function(event){
										   $(this).show(); 
										   });
	
	$('a[name=modalbox]').click(function(e) {
		e.preventDefault();
		var ido = $(this).attr('href');
		$(ido).fadeIn(500);
	});
	
	$('a[name=hidebox]').hover(function(e) {
		$('.window').fadeOut(50);
	});
	
	
	//if close button is clicked
	$('.windows .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.windows').hide();
	});	
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});		
});