var longFmtWindow = 0;
var bbagWindow = 0;
var winavailwidth = screen.availWidth;
var winX = ( winavailwidth - 475 ); 
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var winparams = "";

function popupBBagWindow( URLstr, focusFlag )
{
  if (ie4)
  {
     winparams = 'scrollbars=yes,resizable=yes,width=450,height=400,left='+winX;

  }
  else
  {
	 winparams = 'scrollbars=yes,resizable=yes,width=450,height=400,screenX='+winX;

  }


    if ( bbagWindow && !bbagWindow.closed )
    {
        if ( focusFlag )
        {  bbagWindow.focus();   }
    }
    else
    {
	bbagWindow = window.open( '', "bibbookbag", winparams );
        if ( focusFlag )
        {      bbagWindow.focus( );      }
        else
        {       self.focus();    }
    }

    bbagWindow.document.write('<p>Retrieving record, please wait ...</p>');
    bbagWindow.document.location = URLstr;
}

function popupBBagWindowIds()
{
  if (ie4)
  {
     winparams = 'scrollbars=yes,resizable=yes,width=450,height=400,left='+winX;

  }
  else
  {
	 winparams = 'scrollbars=yes,resizable=yes,width=450,height=400,screenX='+winX;

  }


    if ( bbagWindow && !bbagWindow.closed )
    {
    	bbagWindow.focus();
    }
    else
    {
			bbagWindow = window.open( '', "bibbookbag", winparams );
      bbagWindow.focus( ); 
    }

    bbagWindow.document.write('<p>Retrieving record, please wait ...</p>');
    return true;
}

function popupLongFmtWindow( URLstr )
{
  if (ie4)
  {
          winparams = 'scrollbars=yes,resizable=yes,width=450,height=600,left='+winX;
  }
  else
  {
          winparams = 'scrollbars=yes,resizable=yes,width=450,height=600,screenX='+winX;
  }


  if ( longFmtWindow && !longFmtWindow.closed )
  {
          longFmtWindow.focus();
  }
  else
  {
          longFmtWindow = window.open( '', "longformat", winparams );
          longFmtWindow.focus( );
  }

  longFmtWindow.document.write('<p>Retrieving record in long format, please wait ...</p>');
  longFmtWindow.document.location = URLstr;
}



function open_window_sfx (loc)
{
	var w = window.open (loc,
	"winsfx",
	"height=600,width=600,location=no,menubar=no,status,scrollbars,resizable"
	);
	w.focus();
}

function open_window( url , name , width , height , resizable , scrollbars , menubar , status , directories , location, toolbar ) {

	var sSize = 'width='+width+', height='+height+', '+resizable+', SCROLLBARS='+scrollbars+', MENUBAR='+menubar+', STATUS='+status+', DIRECTORIES='+directories+', LOCATION='+location+', TOOLBAR='+toolbar;
	var sDate = new Date();
	var sTime = sDate.getSeconds() + "_" + sDate.getMinutes() + "_" + sDate.getHours();
	var newWindow = window.open(url,sTime,sSize);
}

function open_image( url ) {
	 open_window( url , 'image_window' , 600 , 500 , 'RESIZABLE=yes, RESIZEABLE=yes' , 'yes' , 'no' , 'no' , 'no' , 'no' , 'no' );
}

function open_parent( url ) {
  var p = window.opener;
  p.location = url;
  p.focus();
}
