function popupHeight(inDesired) {
  var desired = 600;
  if( inDesired != "" ) {
    desired = inDesired;
  }
  var spacing = 20;
  var available = screen.availHeight;
  var total = screen.height;
  var extra = available - desired - spacing;
  if(extra < 0)
    return available - spacing;
  else
    return desired;
}

function popupWidth(inDesired) {
  var desired = 750;
  if( inDesired != "" ) {
    desired = inDesired;
  }
  var spacing = 20;
  var available = screen.availWidth;
  var total = screen.width;
  var extra = available - desired - spacing;
  if(extra < 0)
    return available - spacing;
  else
    return desired;
}

function openPortPopup(port,section) {
  var popupWin = window.open('/destinations/ports/default.asp?port=' + port + '&section=' + section, 'popupWin', 'toolbar=no,status=yes,scrollbars=yes,resizable=yes,location=no,directories=no,menubar=no,width=' + popupWidth(750) + ',height=' + popupHeight(600) );
  popupWin.focus();
}

function openFleetPopup(ship,section) {
  var popupWin = window.open('/fleet/popups/default.asp?ship=' + ship + '&section=' + section, 'popupWin', 'toolbar=no,status=yes,scrollbars=yes,resizable=yes,location=no,directories=no,menubar=no,width=' + popupWidth(750) + ',height=' + popupHeight(600) );
  popupWin.focus();
}

function openDestinationPopup(destination,section) {
  var popupWin = window.open('/destinations/popups/default.asp?destination=' + destination + '&section=' + section, 'popupWin', 'toolbar=no,status=yes,scrollbars=yes,resizable=yes,location=no,directories=no,menubar=no,width=' + popupWidth(750) + ',height=' + popupHeight(600) );
  popupWin.focus();
}

function openPlanner() {
  var popupWin = window.open('/reservations/planner.asp', 'popupWin', 'toolbar=no,status=yes,scrollbars=yes,resizable=yes,location=no,directories=no,menubar=no,width=' + popupWidth(592) + ',height=' + popupHeight(449) );
  popupWin.focus();
}

function showLanguageSelect() {
  bnav_language.offsetY = document.body.scrollTop - 120;
  bnav_language.showAtMouse(event);
}

function setImage(imageName, newImage) {
  if (document.images) {
    document[imageName].src = newImage;
  }
}
