var globalPopupId = 0;
function showPopup(id) {
    globalPopupId = id;
    objScreen = $('screen');
    objPopup = $(id);
    objPopup.style.display = 'block';
    if(objScreen.style.display != 'block') {
    	objScreen.style.display = 'block';
    	scrl = getScrollSize();
    	var scrollY;
		var str, obj;    	
    	objScreen.style.width = scrl[0] + 'px';
    	if (scrl[1] > $('layout').offsetHeight) {
    		objScreen.style.height = scrl[1] + 'px';
    	} else {
			objScreen.style.height = $('layout').offsetHeight + 'px';
		}
    }
    objPopup.style.display = 'block';
    return false;
}

function getTopForPopup(obj, fromTop) {
	if (!fromTop) fromTop = 20;
	if (window.scrollY) {
		$(obj).style.top = (parseInt(window.scrollY) + parseInt(fromTop)) + 'px';
	} else if (document.body.scrollTop) {
		$(obj).style.top = (parseInt(document.body.scrollTop) + parseInt(fromTop)) + 'px';
	} else if (window.pageYOffset) {
		$(obj).style.top = (parseInt(window.pageYOffset) + parseInt(fromTop)) + 'px';
	} else if (document.body.parentNode.scrollTop) {
		$(obj).style.top = (parseInt(document.body.parentNode.scrollTop) + parseInt(fromTop)) + 'px'				
	} else {
		$(obj).style.top = fromTop + "px";
	}
}

function hidePopup(id) {
    objScreen = $('screen');
    if(!id) {
    	id = globalPopupId;
    }
    objPopup = $(id);
    objScreen.style.display = 'none';
    objScreen.style.width = 0;
    objScreen.style.height = 0;
    objPopup.style.display = 'none';
    return false;
}

function getScrollSize()
{
    yScroll = 0;
    if (window.innerHeight && (window.scrollMaxY || window.scrollMaxY == 0) || window.innerWidth && (window.scrollMaxX || window.scrollMaxX == 0))
    {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;

        var deff = document.documentElement;
        var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
        var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

        xScroll -= (window.innerWidth - wff);
        yScroll -= (window.innerHeight - hff);
    } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth) {
        yScroll = document.body.scrollHeight;
        xScroll = document.body.scrollWidth;
    } else {
        yScroll = document.body.offsetHeight;
        xScroll = document.body.offsetWidth;
    }
    ret = new Array(xScroll, yScroll);
    return ret;
}
