window.onresize = function() { DrawPopupContent(true); } 
window.onscroll = function() { DrawPopupContent(true); }

var PopupContentHeight = "700";
var PopupContentWidth = "950";
function StartPopupcContent(HtmlToUse,NewWidth,newHeight)
{
	PopupContentHeight = newHeight+15;
	PopupContentWidth = NewWidth;
 body = document.getElementsByTagName("body")[0];
 
    if(!document.getElementById("usereditor") && !document.getElementById("shadetree"))
    {
     shadetag = document.createElement("div");
     shadetag.className="transparent";
     shadetag.id = "shadetree";
     shadetag.onclick = function() { CloseContent(); }; 
     userinfo =  document.createElement("div");
     userinfo.id = "usereditor";
     userinfo.style.width=PopupContentWidth + "px";
     userinfo.style.height=PopupContentHeight + "px";
	 userinfo.onclick = function() { CloseContent(); }; 
     /*extra = document.createElement("div");
     extra.id="extralayout";
     body.appendChild(extra);*/
     body.appendChild(userinfo);
      body.appendChild(shadetag);
    } 
    
    document.getElementById("usereditor").innerHTML="<div onclick='CloseContent();' id='closearea'> Click here to close X</div>" + HtmlToUse;
    DrawPopupContent(false);
}

function DrawPopupContent(CheckHTML)
{
 var myWidth = 0, myHeight = 0, scrOfX = 0, scrOfY = 0;
  
  if( typeof( window.innerWidth ) == 'number' )
  {	//Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  {	//IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {	    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  if( typeof( window.pageYOffset ) == 'number' )
  {	//Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
  {	//DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
  {	//IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
 
  myWidth = (myWidth);
  myHeight = (myHeight);
	
	if(document.getElementById("usereditor"))
	{
		usereditorHeight  = (myHeight-PopupContentHeight)/2 + scrOfY;
		//alert(usereditorHeight);
		if(usereditorHeight<0)
		{
			usereditorHeight= 0+(PopupContentHeight)/2 + scrOfY;
		}
		
		if((CheckHTML && getE("usereditor").innerHTML!="") || !CheckHTML)
		{
		   
			getE("usereditor").style.position="absolute";
			getE("usereditor").style.float="left";
			getE("usereditor").style.left=(myWidth-PopupContentWidth)/2+scrOfX + "px";
			getE("usereditor").style.top=usereditorHeight + "px";
			getE("usereditor").style.zIndex = "9";
			getE("shadetree").style.position="absolute";
			getE("shadetree").style.top="0px";
			getE("shadetree").style.left="0px";
			getE("shadetree").style.width=myWidth+scrOfX + "px";
			getE("shadetree").style.height=myHeight+scrOfY + "px";
		}
	}
}

function getE(elmid)
{
    return document.getElementById(elmid);
}

function CloseContent()
{
    body = document.getElementsByTagName("body")[0];
    
    body.removeChild(document.getElementById("shadetree"));
    body.removeChild(document.getElementById("usereditor"));
}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=296,height=194,scrollbars=no');
return false;
}