popWin = null; // On page load, initializes window reference variable

var resizable, scrollbars, menubar, statusbar, locationbar, toolbar;

constants:{
  resizable = 1;
  scrollbars = 2;
  menubar = 4;
  statusbar = 8;
  locationbar = 16;
  toolbar = 32;
}
function winPop(imgURL,width,height,options) {
    // Check for window state
	//alert(popWin);
	//if(popWin!=null) alert(popWin.closed);
  if(!(popWin==null || popWin.closed)){
    popWin.close();
  }
  var windowname = "popWin";
  var attr  = "width="+width+",";
      attr += "height="+height;
  if(options>=32){
      attr += ",toolbar=yes";
      options -= 32;
  }
  if(options>=16){
      attr += ",locationbar=yes";
      options -= 16;
  }
  if(options>=8){
      attr += ",statusbar=yes";
      options -= 8;
  }
  if(options>=4){
      attr += ",menubar=yes";
      options -= 4;
  }
  if(options>=2){
      attr += ",scrollbars=yes";
      options -= 2;
  }
  if(options>=1){
      attr += ",resizable=yes";
      options -= 1;
  }
  popWin = open(imgURL,windowname,attr);
}
function closePopWin(){
  if(!(popWin==null || popWin.closed)) 
    popWin.close();
}
window.onunload = closePopWin;

function popPhoto(intPhoto, intWidth, intHeight, boolCaption)
{
	winPop
	(
		pathToRoot+"/photoPop.cfm?id="+intPhoto+"&caption="+boolCaption,
		parseInt(intWidth)+30,
		(boolCaption)?parseInt(intHeight)+37:parseInt(intHeight)+17,
		statusbar+menubar+resizable
	);
}

function popPDF(strFileName)
{
	window.open
	(
		strFileName,
		"",
		"width=650,height=500,statusbar=yes,menubar=yes,resizable=yes"
	);
}
function popImage(strFileName,width,height)
{
	winPop
	(
		strFileName,
		width,
		height,
		statusbar+menubar+resizable+scrollbars
	);
}
