// JavaScript Document

// Opens new window
var WindowObjectReference = null; // global variable
var PDFWindowObjectReference = null; // global variable
var previousUrl; /* global variable which will store the
                    url currently in the secondary window */
var previousPDF;					
var strWindowFeatures = "width=650,height=500,left=250,top=30,menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";					

function openRequestedSinglePopup(strUrl)
{
  if(WindowObjectReference == null || WindowObjectReference.closed)
  {
   WindowObjectReference = window.open(strUrl, "SingleSecondaryWindow", strWindowFeatures);
  }
  else if(previousUrl != strUrl)
  {
   WindowObjectReference = window.open(strUrl, "SingleSecondaryWindow", strWindowFeatures);
    /* if the resource to load is different,
       then we load it in the already opened secondary window and then
       we bring such window back on top/in front of its parent window. */
   WindowObjectReference.focus();
  }
  else
  {
    WindowObjectReference.focus();
  };
  previousUrl = strUrl;
  /* explanation: we store the current url in order to compare url
     in the event of another call of this function. */
}

//  Separate funciton to handle PDFs
function openRequestedPopup(strUrl, strWindowName)
 {
  if(PDFWindowObjectReference == null || PDFWindowObjectReference.closed)
  {
    PDFWindowObjectReference = window.open(strUrl, strWindowName, strWindowFeatures);
  }
  else
  {
    PDFWindowObjectReference.focus();
  };
 }
