

var popup_layer = {
    getClientHeight: function()
    {
    	return this.filter(
    		window.innerHeight ? window.innerHeight : 0,
    		document.documentElement ? document.documentElement.clientHeight : 0,
    		document.body ? document.body.clientHeight : 0
    	);
    },
    getClientWidth: function()
    {
    	return this.filter (
    		window.innerWidth ? window.innerWidth : 0,
    		document.documentElement ? document.documentElement.clientWidth : 0,
    		document.body ? document.body.clientWidth : 0
    	);
    },
    getScrollHeight: function()
    {
    	return this.filter (
    		window.scrollHeight ? window.scrollHeight : 0,
    		document.documentElement ? document.documentElement.scrollHeight : 0,
    		document.body ? ( document.body.parentNode.scrollHeight ? document.body.parentNode.scrollHeight:( document.body.scrollHeight ? document.body.scrollHeight : 0 ) ):0
    	);
    },
    getScrollWidth: function()
    {
    	return this.filter (
    		window.scrollWidth ? window.scrollWidth : 0,
    		document.documentElement ? document.documentElement.scrollWidth : 0,
    		document.body ? ( document.body.parentNode.scrollWidth ? document.body.parentNode.scrollWidth:( document.body.scrollWidth ? document.body.scrollWidth : 0 ) ):0
    	);
    },
    getScrollTop: function()
    {
    	return this.filter (
    		window.pageYOffset ? window.pageYOffset : 0,
    		document.documentElement ? document.documentElement.scrollTop : 0,
    		document.body ? document.body.scrollTop : 0
    	);
    },
    filter: function(n_win, n_docel, n_body)
    {
    	var n_result = n_win ? n_win : 0;
    	if (n_docel && (!n_result || (n_result > n_docel)))
    		n_result = n_docel;
    	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
    }
};

function showBackground(bg_id) {

var bg_name       = bg_id ? bg_id:'bg_trans';
var _windowheight = popup_layer.getClientHeight();
var _scrollheight = popup_layer.getScrollHeight();
var _finalHeight  = (_scrollheight<_windowheight) ? _windowheight:_scrollheight;
var _windowwidth  = popup_layer.getClientWidth(); 
var _scrollwidth  = popup_layer.getScrollWidth();
var _finalWidth   = (_scrollwidth<_windowwidth) ? _windowwidth:_scrollwidth;
document.getElementById(bg_name).style.height  = _finalHeight+'px';
document.getElementById(bg_name).style.width   = '100%'; //_finalWidth+'px';
document.getElementById(bg_name).style.display = 'block';
}

function hideBackground(bg_id) {

var bg_name       = bg_id ? bg_id:'bg_trans';
document.getElementById(bg_name).style.display = 'none';
}


function check_keycode(e) {

var keycode;
if (e==null) {
    //ie
    keycode = event.keyCode;
    }
else {
    //mozilla
    keycode = e.which;
    }

if(keycode == 27) {
	if (typeof(document.OnKeyUp_ESC)=="function") {
    	document.OnKeyUp_ESC();
    	}
    document.onkeyup = null;
    }
}
