﻿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();
    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();
    
    _popupId = popupId;
        
 }
 
 
 function repositionPopup() {
 
    if(_popupId != '') {
        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);  
    }
    
 }
 
 
 function closePopup() {

    jQuery(_popupId).hide();
    jQuery('#pageMask').hide();
 
 }
 
 
 jQuery(document).ready(function() {
 
    jQuery(window).resize(function(){
        repositionPopup();    
    });

 }); 