/*
// En el HTML:
<div id="div_message" class="divPopup" style="display:none;">
	bla bla bla aca va el html del mensaje
</div>

<!-- este div va justo antes del cierre del tag body: -->
<div id="overlay" style="display:none"></div>
</body>
*/

function hide_div(div)
{
	div = parent.$('#'+div);
	div.hide();  
	$('#overlay').hide();
}

function show_div(div){
	$('#overlay').css('top',0);
    $('#overlay').css('height',document.body.scrollHeight+"px");
	$('#overlay').show();
    center_div(div);
}

function center_div(element)
{	
	element = $('#'+element);

	var my_width  = get_window_width();
	var my_height = get_window_height();
	
	element.css('position','absolute');
	element.css('z-index',999999999); //999999999
	
	var scrollY = 0;
	if ( document.documentElement && document.documentElement.scrollTop ) {
		scrollY = document.documentElement.scrollTop;
	} else if ( document.body && document.body.scrollTop ) {
		scrollY = document.body.scrollTop;
	} else if ( window.pageYOffset ) {
		scrollY = window.pageYOffset;
	} else if ( window.scrollY ) {
		scrollY = window.scrollY;
	}
	var setX = ( my_width  - element.width()  ) / 2;
	var setY = ( my_height - element.height() ) / 2 + scrollY;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	
	element.css('left', setX);
	element.css('top', setY);
	element.css('display','block');
}

// Alto de la Pagina
function get_window_height() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

// Ancho de la Pagina
function get_window_width()
{
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}