	jQuery(document).ready(function(){
        jQuery('.activate_modal').click(function(){
		  //get the id of the modal window stored in the name of the activating element       
              var modal_id = jQuery(this).attr('name');
              //use the function to show it
              showModal(modal_id);
        });
        jQuery('.close_modal').click(function(){
            //use the function to close it
            closeModal();
        });
    });/**/

//THE FUNCTIONS
    function closeModal(){        
        //hide the mask
        jQuery('#mask').fadeOut(200);
        //hide modal window(s)
        jQuery('.modal_window').fadeOut(200);
    }
    function showModal(modal_id){
		var offsetTop = jQuery(document).scrollTop();
		var offsetLeft = jQuery(document).scrollLeft();
    //vertical and horizontal centering of modal window(s)
        
		//get the height and width of the page
		var window_width = jQuery(window).width();
		var window_height = jQuery(window).height();
		
        //get the height and width of the modal
        var modal_height = jQuery('#'+modal_id).outerHeight();
        var modal_width = jQuery('#'+modal_id).outerWidth();
        
        //calculate top and left offset needed for centering
        var top = offsetTop + (window_height-modal_height)/4;
        var left = offsetLeft + (window_width-modal_width)/4;
        
        //apply new top and left css values 
        jQuery('#'+modal_id).css({'top' : top , 'left' : left});

        //set display to block and opacity to 0 so we can use fadeTo
        jQuery('#mask').css({ 'display' : 'block', opacity : 0});
        
        //fade in the mask to opacity 0.8 
        jQuery('#mask').fadeTo(200,0.8);
         
         //show the modal window
        jQuery('#'+modal_id).fadeIn(200);
        
    }

function printModal(path) {
	var printDoc = '/' + path;
	var pp = window.open(printDoc,'popup','scrollbars,resizable,viewSource,width=500,height=400,left=20,top=20');
	setTimeout(function(){pp.print();},1000);
	setTimeout(function(){pp.close();},2000);
}
