///////////////////////////////////////
// openWin.js                        //
// --------------------------------- //////////////////////////////////////
// Window utility functions.                                             //
//                                                                       //
// Copyright 2001 (c) - Patrick Wolff - All rights reserved.             //
///////////////////////////////////////////////////////////////////////////

// Opens a secondary browser window.
//
// url = page to be displayed in new window
// win = name of new browser window
// w = width of new window
// h = height of new window
// settings = property settings for new window
//
function openWin(url,win,w,h,settings)
{
  if (!(win))
  {
    win = '_blank';
  }  
  if (!(w))
  {
    w = 400;
  }  
  if (!(h))
  {
    h = 220;
  }  
  if (!(settings))
  {
    settings = "title=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0";	
  }  
  else if (settings == 'scrollbars')
  {
    settings = "title=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars,resizable=0,copyhistory=0";	
  }  
  popup = window.open (url, win, "width="+w+",height="+h+","+settings);	
  popup.focus();
}

// Opens a new browser window after a warning.
//
// url = page to be displayed in new browser
// always returns false
//
function warnWin(url)
{
  if (confirm("This operation will log you out."))
  {
    document.location = url;
//    popup = window.open(url,"main");	
//    popup.focus();
  }
  return false;
}

// Changes to the specified exercise sub page.
//
// page = name of new page (path and file extension omitted)
// session = curent session id
//
function changeSubpage(page,session)
{
  document.location = 'http://www.wolffchess.com/exercises/'+page+'.php3?session='+session;
}

// Opens a secondary reader window.
//
// exer = exercise id
// session = curent session id
//
function showReader(exer,session)
{
//  openWin('http://www.wolffchess.com/exercises/reader.php3?session='+session+'&page='+exer,'_blank',650,550);
//  openWin('http://www.wolffchess.com/exercises/reader.php3?session='+session+'&page='+exer,'_blank',740,640);
//  openWin('http://www.wolffchess.com/exercises/reader.php3?session='+session+'&page='+exer,'_blank',710,550);
  openWin('http://www.wolffchess.com/exercises/reader.php3?session='+session+'&page='+exer,'_blank',730,580,'scrollbars');
}

// Opens the privacy policy page in a pop-up window.
//
function showPolicy()
{
  openWin('http://www.wolffchess.com/privacy.html','policy',500,300,'scrollbars');
}
