function getyScroll(bReturnX)
 {
  yScroll = 0;
  xScroll = 0;
  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX)
   {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;

    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)
   { // all but Explorer Mac
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
    
   } 
  else 
   { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
    
   }

  if(bReturnX) return xScroll; 
  else return yScroll;
 }


 var sLastAct = '';
 
// final funcs

function showPopupForm(sItemId, sDivPopup, sAct, sTitle)
{
    if (!sItemId) return false;
     
    var oObjItem   = document.getElementById(sItemId);
    var oObjPopup  = document.getElementById(sDivPopup);
    var oObjScreen = document.getElementById('screen');

    var iXSpace = 0;
    var iYSpace = 0;
    
    if (oObjItem && oObjPopup && oObjScreen)
    {
        var ar = findPos(oObjItem);
        
        if (sDivPopup == 'send_message')
        {
            iXSpace = -30;
            iYSpace = -15;

            if (document.getElementById('act') && sAct)
            {
                document.getElementById('act').value = sAct;
            }
            
            if (document.getElementById('jsErr'))
            {
                document.getElementById('jsErr').innerHTML = '';
            }
            
            if (document.getElementById('send_message_title') && sTitle)
            {
                document.getElementById('send_message_title').innerHTML = sTitle;
            }
            
            if (document.getElementById('mess_body') && sLastAct != sAct)
            {
                document.getElementById('mess_body').value = '';
            }
            
            sLastAct = sAct;
        }
         
        var x = ar[0] + iXSpace;
        var y = ar[1] + iYSpace;
       
        oObjPopup.style.left = x + 'px';
        oObjPopup.style.top  = y + 'px';
         
        oObjPopup.style.display = 'block';
        oObjScreen.style.display = 'block';
        oObjScreen.style.height = getyScroll() + 'px'; //window.innerHeight + window.scrollMaxY;
        oObjScreen.style.width = getyScroll(1) + 'px'; //window.innerHeight + window.scrollMaxY;
         
    }
}

function hidePopup()
{
    document.getElementById('send_message').style.display = 'none';
    document.getElementById('screen').style.display = 'none';
} 
 
function findPos(obj) 
{
    var curleft = curtop = 0;
    if (obj.offsetParent) 
    {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}


function popopUserLink(iDivId, bShow)
{
    var oDivDisplay = document.getElementById('div_user_avatar');
    var oDivData    = document.getElementById('div_user_data_' + iDivId);
    var oLink       = document.getElementById('link_user_data_' + iDivId);
    
    if (oDivDisplay)
    {
        if (bShow && oDivData && oLink)
        {
            iXSpace = 1;
            iYSpace = 20;
            
            var ar = findPos(oLink);
            
            var x = ar[0] + iXSpace;
            var y = ar[1] + iYSpace;
           
            oDivDisplay.style.left = x + 'px';
            oDivDisplay.style.top  = y + 'px';
                   
            oDivDisplay.style.display = '';
            oDivDisplay.innerHTML = oDivData.innerHTML;
        }
        else
        {
            oDivDisplay.style.display = 'none';
            oDivDisplay.innerHTML = '';
        }
    }
    
    return true;
}