function launchPopup( url, name, parentWin, size_x, size_y )
{
   if ( url == null ) return null;
   if ( name == null ) name= "";
   if ( size_x == null ) size_x = 640
   if ( size_y == null ) size_y = 480

   if ((typeof(parentWin.popup) != "undefined") && ( parentWin.popup != null ))
   {
      if(!parentWin.popup.closed)
      {
         parentWin.popup.focus();
         return parentWin.popup;
      }
      else
         parentWin.popup = null;
   }

   if (document.all) 
   {
     var xMax=screen.width, yMax=screen.height;
   } 
   else if (document.layers) 
   {
     var xMax=window.outerWidth, yMax=window.outerHeight;
   } 
   else {var xMax=1024, yMax=768}; 
    
   var xOffset = (xMax - size_x)/2, yOffset = (yMax - size_y)/2; 

   var features ;
   features = 'width=' + size_x +
                ',height=' + size_y +
                ',top=' + yOffset +
                ',left=' + xOffset;
   features += ",status=no,fullscreen=no,resizable=yes,menubar=yes,toolbar=no";

   var newWin=window.open(url, name, features);
   if ( newWin == null ) return null;
   parentWin.popup = newWin;
   newWin.focus();
   newWin.creator = parentWin;
   newWin.opener = parentWin; 
   return newWin;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// launchPopupEx
//
// Created by GKM to add functionality to launchPopup. It is set up to be backwards compatible to be used 
// in place of launchPopup. It adds the ability name the popup javascript object to a different name. It also 
// allows the user to set: Resize, scrollbars, and status
//
////////////////////////////////////////////////////////////////////////////////////////////////////////

function launchPopupEx( url, name, parentWin, size_x, size_y, pPopup, pResize, pScrollBars, pStatus, pDependent, pMenu, pToolbar, pLocation)
{
   if ( url == null ) return null;
   if ( name == null ) name= "";
   if ( size_x == null ) size_x = 640;
   if ( size_y == null ) size_y = 480;

   if(arguments.length <= 5)
   {
      if ( pPopup == null ) pPopup  = eval("parentWin.popup");
   }
   
   if ( pResize    == null ) pResize = true;
   if ( pScrollBars == null ) pScrollBars = false;
   
   if ( pStatus == null ) pStatus = false;
   if( pDependent == null) pDependent = false;
   if( pMenu == null) pMenu = false;

   // alert(pPopup);

   if ( (typeof(pPopup) != "undefined") && ( pPopup != null ) )
   {
      if(!pPopup.closed)
      {
         pPopup.focus();
         return pPopup;
      }
      else
         pPopup = null;
   }

   //if ( pPopup != null )
   //{
   // //parentWin.pPopup.focus();
   // //return parentWin.pPopup;
   //
   // pPopup.focus();
   // return pPopup;
   //}

   if (document.all) 
   {
      var xMax=screen.width, yMax=screen.height;
   } 
   else if (document.layers) 
   {
      var xMax=window.outerWidth, yMax=window.outerHeight;
   } 
   else {var xMax=1024, yMax=768}; 
    
   var xOffset = (xMax - size_x)/2, yOffset = (yMax - size_y)/2; 
   
   var features ;

   features = 'width=' + size_x +
   ',height=' + size_y +
   ',top=' + yOffset +
   ',left=' + xOffset;
   features += ",fullscreen=no";

   // toolbar[=yes|no]|[=1|0]   location[=yes|no]|[=1|0]   directories[=yes|no]|[=1|0]   status[=yes|no]|[=1|0]   menubar[=yes|no]|[=1|0]   scrollbars[=yes|no]|[=1|0]   resizable[=yes|no]|[=1|0]   width=pixels   height=pixels

   if( pResize )
      features += ",resizable=yes";
   else
      features += ",resizable=no";
      
   if( pScrollBars )             
      features += ",scrollbars=yes";
   else
      features += ",scrollbars=no";
   
   if( pMenu )             
      features += ",menubar=yes";
   else
      features += ",menubar=no";

   if( pStatus )
      features += ",status=yes";
   else
      features += ",status=no";

   if( pToolbar )
      features += ",toolbar=yes";
   else
      features += ",toolbar=no";
 
   if (pLocation)
      features += ",location=yes";
   else
      features += ",location=no";

   var newWin=window.open(url, name, features);

   if ( newWin == null ) return null;

   if ( ( pPopup != null ) && (typeof(pPopup) != "undefined") )
      pPopup = newWin;
   newWin.focus();
   newWin.creator = parentWin;
   newWin.opener = parentWin; 
   return newWin;
}

function launchSmallPopUp(url)
{
   //var newwin = launchPopupEx( url, // url
	launchPopupEx( url, // url
                               "SamllPopup",    // popup name
                               self,                 // parent window
                               450, 300,             // size_x and size_y
                               null,                 // pPopup ??
                               true,                 // resize
                               true,                 // scrollbars
                               false,                // status
                               false,                // dependent
                               true,                 // menu bar
                               false,                 // tool bar
                               false                  // location (address bar) 
                           );                    // ignore other flags

   //newwin.focus();
}

