function centerPop(url,name,width,height,scroll){
	var x = (screen.availWidth - width)/2;
	var y = (screen.availHeight - height)/2;
	scroll = (scroll)?'yes':'no';
	var popper = window.open(url,name,'toolbar=no,location=no,status=yes,menubar=no,scrollbars='+scroll+',resizable=no,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	//setTimeout('popper.focus()', 250);
	//setTimeout('self.close()', 5000);

	return popper;
}


// the oLink can be about any object (such as links, inputs, whatever)
function findPosition( oLink ) {
  if( oLink.offsetParent ) {
	for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
	  posX += oLink.offsetLeft;
	  posY += oLink.offsetTop;

	  if(oLink.offsetParent.tagName == 'TABLE')
	  {
		if(oLink.offsetParent.border > 0)
		{
			posY += 1;
			posX += 1;
		}
	  }
	}
	return [ posX, posY ];
  } else {
	return [ oLink.x, oLink.y ];
  }
}

function showLinks( )
{
	showLink('tblMain');
}

function showLink( field )
{
	var obj = document.getElementById('divEditLink');
	
	var f = document.getElementById(field);
	if(! f  )
	{
		return;
	}
	
	//offsetParent.tagName
	if(f.tagName == 'TABLE2')
	{
		// push down the text with the link
		
	}
	else
	{
		// create a div and put it on top
		var pos = findPosition( f );

		obj.style.top = pos[1] + 1;
		obj.style.left = pos[0] + 1;

		obj.style.visibility = (obj.style.visibility == "hidden" ? "visible" : "hidden");

	}	
}

function showEdit( )
{
	showLink('tblMain');
}

function hideEdit( )
{
	showLink('tblMain');
}

function editSection( )
{
	var obj = document.getElementById('tblMain');
	
	if( !obj )
	{
		return;
	}
	
	var val = obj.value;
	
	if(val == null)
	{
		//alert('Unable to find edit value for this page!');
		//return;
	}

	centerPop('editpage.php?page=' + escape(val), 'EditPage', 700, 600, 1);
}
