// ---------------------------------------------------------------------------------------
// GLOBAL VARIABLES
// ---------------------------------------------------------------------------------------
var childPopup; // used in checkChildPopupStatus, popup

// ---------------------------------------------------------------------------------------
// Function:  popup
// ---------------------------------------------------------------------------------------
// Synopsis:  Opens specified URL in a child popup browser window (piece of code copied from ABC News)
//
// Input:     url - what to open, width - in pixels, height - in pixels, windowsname - title of window
//
// Modifications
//    No.   Date        Initial   Desc
//    ----  ----------- -------   ------------------------------
//    [0]   07/05/2008  JM        Intial creation
// ---------------------------------------------------------------------------------------
function popup (url, width, height, windowname) 
{
	if (!width) var width = 600;
	if (!height) var height = 500;
	if (!windowname) var windowname = 'abctriplejpopup'+new Date().getTime();
	if (url.indexOf('?') != -1) url += '&layout=popup';	else url += '?layout=popup';
	var left = screen.width/2 - width/2;
	var top = screen.height/2 - height/2;
	childPopup = window.open(url, windowname, 'width='+width+',height='+height+',toolbar=0,resizable=1,scrollbars=1,left='+left+',top='+top);
	checkChildPopupStatus(); // call function to check popup window status
	return false;
}

// ---------------------------------------------------------------------------------------
// Function:  checkChildPopupStatus
// ---------------------------------------------------------------------------------------
// Synopsis:  Because of cross site scripting we cannot simply close the comments popup and
//            refresh the comments page (popup comes up on www2b, comments pages are usually
//            on www) using commands like location.refresh so we must check if the popup
//            is closed and then refresh else check again in XXX ms.
//
// Modifications
//    No.   Date        Initial   Desc
//    ----  ----------- -------   ------------------------------
//    [0]   07/05/2008  JM        Intial creation
// ---------------------------------------------------------------------------------------
function checkChildPopupStatus() 
{
  if (childPopup.closed) 
  {
    location.reload(true); // child popup closed so refresh yourself
  }
  else 
  {
    setTimeout("checkChildPopupStatus()", 400); // child popup still open wait XXX ms
  }
}
