//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
var popupTimer;
var popupObj;


function showPopup(obj, objDst)
{
	if(popupObj && !popupObj.getAttribute('rel'))
		popupObj.className = '';
	
	obj.className = '';
	popupObj = obj;

	clearTimeout(popupTimer);
	
	posWrapper = findPosX(document.getElementById('wrapper'));
	posObj = findPosX(obj);
	
	document.getElementById(objDst).style.left = (posObj - posWrapper) + 'px';
	document.getElementById(objDst).style.display = 'block';
	Effect.Fade(objDst, {duration: 0.4, from: 0, to: 1});
}

function stillPopup(objDst)
{
	document.getElementById(objDst).className = 'active';
	clearTimeout(popupTimer);
}


function hidePopup(objDst)
{
	
	if(popupObj.getAttribute('rel'))
		popupObj.className = popupObj.getAttribute('rel');

		
	popupTimer = setTimeout(function() {
		document.getElementById(objDst).style.display = 'none';
		if(popupObj.getAttribute('rel'))
			popupObj.className = popupObj.getAttribute('rel');
		else
			popupObj.className = '';
		clearTimeout(popupTimer);
	}, 700);
}



//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
