//
// Miscellaneous code for Knight Science Journal Fellowships site
// -bio popup window
// -slideshow popup window
//


//
// open popup window
// call like this:
//  <a href="popup.html" onclick="return openpopup('popup.html')" target="_blank">Open Popup</a>
//
function openpopup(url) {
  var newwindow = window.open(url, 'knightpopup', 'width=564,height=450,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,status=no');
  if (newwindow) {
    if (window.focus)
      newwindow.focus();
    return false;
  }
  return true; // unsuccessful
}



//
// open slideshow in a new window
// call like this:
//  <a href="../slideshows/xyz_all.html" onclick="return openslideshow('../slideshows/xyz.html')" target="_blank">Open Slideshow</a>
//
function openslideshow (ssurl) {
	var windowname = "window"+Math.floor(Math.random()*1000000); // random window name so that slideshows have almost no chance of using same window
  var newwindow = window.open(ssurl, windowname, 'width=600,height=395,left=0,top=0,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,status=no');
  if (newwindow) {
    if (window.focus)
      newwindow.focus();
    return false;
  }
  return true; // unsuccessful
}



// open calendar window
// call like this:
//  <a href="calendar.html" onclick="return opencalendar('calendar.html')" target="_blank">Open Calendar</a>
//
function opencalendar(url) {
  var newwindow = window.open(url, 'knightcalendar', 'width=800,height=680,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,status=no');
  if (newwindow) {
    if (window.focus)
      newwindow.focus();
    return false;
  }
  return true; // unsuccessful
}


// open video window
// call like this:
//  <a href="xxx.html" onclick="return openvideo('xxx.html')" target="_blank">Open Video</a>
//
function openvideo(url) {
  var newwindow = window.open(url, 'knightvideo', 'width=328,height=304,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes,status=no');
  if (newwindow) {
    if (window.focus)
      newwindow.focus();
    return false;
  }
  return true; // unsuccessful
}