var target;
var child;
var oldcolor;
var oldcolor2;

function copy(el)
{
  try
  {
    var x=document.getElementById(el);
    x.select();
    c = document.selection.createRange();
    c.execCommand("Copy")
  }
  catch(err)
  {
    alert("This browser does not allow text to be copied to the clipboard!");
  }
}

function addTextToTarget(textToAdd)
{
  if(target == null) return;
  
  e = document.getElementById(target);
  
  e.value=textToAdd;
}

function setTarget(targetID)
{
  if(target != null) 
  {
    document.getElementById(target).style.borderColor = oldcolor;
    document.getElementById(target).style.backgroundColor = oldcolor2;
  }
  target = targetID;
  oldcolor = document.getElementById(target).style.borderColor;
  oldcolor2 = document.getElementById(target).style.backgroundColor;
  
  document.getElementById(target).style.borderColor = 'green';
  document.getElementById(target).style.backgroundColor = '#ada';
}

function clearTarget()
{
  document.getElementById(target).style.borderColor = oldcolor;
  document.getElementById(target).style.backgroundColor = oldcolor2;
  target = "";
}

x = 400;
y = 100;
function setPopupVisible(element)
{
  element = document.getElementById(element);
  element.style.visibility = (element.style.visibility == 'visible') ? 'hidden' : 'visible';
}
function hidePopup(element)
{
  element = document.getElementById(element);
  element.style.visibility = 'hidden';
}
function placePopup(element)
{
	e = document.getElementById(element);
	if (document.documentElement)
	{
		left = document.documentElement.scrollLeft;
		top = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		left = document.body.scrollLeft;
		top = document.body.scrollTop;
	}
	left += x;
	top += y;
        try
        {
          e.style.left = left + 'px' ;
          e.style.top = top + 'px' ;
        }
        catch(e){}
    
	setTimeout("placePopup('pagebox')",10);
}
window.onscroll = setTimeout("placePopup('pagebox')",10);


