﻿var _popupId = '';


jQuery.noConflict();  


function openPopup(popupId) {

    var pageHeight = jQuery(document).height();  
    var pageWidth = jQuery(window).width();  
       
    jQuery('#pageMask').css({'width':pageWidth,'height':pageHeight});  
           
    jQuery('#pageMask').show(0);
    jQuery('#pageMask').fadeTo(0,0.8);
       
    var windowHeight = jQuery(window).height();  
    var windowWidth = jQuery(window).width();               
         
    jQuery(popupId).css('top',  windowHeight / 2 - jQuery(popupId).height() / 2);  
    jQuery(popupId).css('left', windowWidth / 2 - jQuery(popupId).width() / 2);  
         
    jQuery(popupId).show(0);
    
    _popupId = popupId;
        
 }
 
 
 function closePopup() {

    jQuery(_popupId).hide(0);
    jQuery('#pageMask').hide(0);
 
 }
 
 
 jQuery(document).ready(function() {
 
    jQuery('a[name=modalPopup]').click(function(e) {  
        e.preventDefault();  
        openPopup(jQuery(this).attr('href'));
    }); 
    
    jQuery('a[name=closeModal]').click(function(e) {
        e.preventDefault(); 
        closePopup();
    });
    
    jQuery('#pageMask').click(function() {  
        closePopup();
    });               
 
 }); 