﻿var backGround = 'backgroundPopup';
var funcionPosterior = null;
var popupStatus = 0;

function cargarPopup(capaMostrar) {
    if(popupStatus==0){  
        $("#" + backGround).css({"opacity": "0.7"});  
        $("#" + backGround).fadeIn("slow");
        $("#" + capaMostrar).toggle();
        $("#" + capaMostrar).fadeIn("slow");
              
        centerPopup(capaMostrar);
        
        popupStatus = 1;  
    }  
}  

function centerPopup(capaMostrar){  
    var windowWidth = document.documentElement.clientWidth;  
    var windowHeight = document.documentElement.clientHeight;  
    var popupHeight = $("#" + capaMostrar).height();  
    var popupWidth = $("#" + capaMostrar).width(); 
    
    //alert(windowWidth + ' - ' + windowHeight);
    //alert(popupWidth + ' - ' + popupHeight);
    
    $("#" + capaMostrar).css(   {"position": "absolute",  
                                 "top": windowHeight/2-popupHeight/2,  
                                 "left": Math.round(windowWidth/2)-Math.round(popupWidth/2)
                                });
                                                             
    $("#" + backGround).css({"height": windowHeight}); 
}  

function ocultarPopup(){  
    if(popupStatus==1){  
        $("#" + backGround).fadeOut("slow");  
        $(".popup").fadeOut("slow");  
        popupStatus = 0;  
        
        if (funcionPosterior != null) 
        {          
            if (this[funcionPosterior] && typeof(this[funcionPosterior]) == "function") 
                this[funcionPosterior]();
        }
    }  
}

function recargarVentanaActual()
{
    document.location.reload();
}