function modal(modal,mask,maskClose) {
	this.modal = modal;
	maskClose = typeof(maskClose) != 'undefined' ? maskClose : 1;
	this.showModal = function showModal() {
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		mask.css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		mask.fadeIn(1000);	
		mask.fadeTo("slow",0.8,function () {
										
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		modal.css('top',  winH/2-modal.height()/2);
		modal.css('left', winW/2-modal.width()/2);
	
		//transition effect
		modal.fadeIn(1000); 
	});
	this.close = function close() {
		$('.close').trigger('click');
	}
	
	}
		$('.close').click(function (e) {
										
		//Cancel the link behavior
		e.preventDefault();
		modal.hide();
		mask.fadeOut(1000);
	});		
	
	// if set to 1 close by clicking mask
	if (maskClose==1) {
	mask.click(function () {
		$(this).fadeOut(1000,function() {modal.hide();});
		modal.hide();
	});			
	}
}
