<!-- Begin
// Copyright Realize IT GmbH, www.realize.ch
// Latest Changes
// 2004_06_00   GH new

  // minimum border around the window (difference window sizes to screen sizes); 
  // uses by image dimensions >= screen dimensions
  var borderLeft   = 25;
  var borderRight  = 25;
  var borderTop    = 40;
  var borderBottom = 60;
     
  // space for i.e. close button 
  var spaceLeft    = 0;
  var spaceRight   = 0;
  var spaceTop     = 50;
  var spaceBottom  = 59 + 61; // first number is determined by viewer, second number might be title bar height (different on all browsers)
  
  spaceBottom = spaceBottom + browserHeightCorrections(); // IE6 SP2 does not allow removal of status bar, IE 7 adds address bar

  //  check for safari-type browsers 
  //var detect = navigator.userAgent.toLowerCase();
  //var place = detect.indexOf('safari');    
  //if (place > 0) {
  //  spaceBottom = spaceBottom + 30 // Safari
  //}

  // alert('maxWindowWidth = ' + maxWindowWidth + '; screen.availWidth = ' + screen.availWidth + '; maxWindowHeight = ' + maxWindowHeight + '; screen.availHeight = ' + screen.availHeight);
  // alert('windowWidth = ' + windowWidth + '; windowHeight = ' + windowHeight + '; centerX = ' + centerX + '; centerY = ' + centerY + '; imgWidth = ' + imgWidth + '; imgHeight = ' + imgHeight);
  // alert('imageWidth=' + imgWidth + '; imageHeight=' + imgHeight);
      
  var newWindow = '';
      
  function albumViewerWindow(url, openStr, imgWidth, imgHeight, size){
    // openStr = '': program uses own window open-string
    // imgWidth, imgHeight: preferred picture sizes
     
    var windowWidth = getWindowWidth(imgWidth);
    var windowHeight = getWindowHeight(imgHeight);
    
    // find values to open window centered on screen
    var centerX = screen.availWidth/2 - windowWidth/2; 
    var centerY = screen.availHeight/2 - windowHeight/2; 
    
    if (openStr.length == 0) openStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes';
    
    openStr = openStr + ',width=' + windowWidth + ',height=' + windowHeight + ',left=' + centerX + ',top=' + centerY;
    
    // now calculate actual picture size
    imgWidth = getFinalImageWidth(windowWidth);
    imgHeight = getFinalImageHeight(windowHeight);
    
  	var fullUrl = url + '&maxImageWidth=' + imgWidth + '&maxImageHeight=' + imgHeight + '&size=' + size + '&newSize=-1' ;
    
  	newWindow = window.open(fullUrl, 'AlbumViewer', openStr);
  	
    // resize an already openend window with different sizes!
    newWindow.resizeTo(windowWidth+10, windowHeight+10);
    newWindow.moveTo(centerX, centerY);  
  }
  
  
  function getWindowWidth(imgWidth) {
    var windowWidth = imgWidth + spaceLeft + spaceRight; 
    
    var maxWindowWidth = screen.availWidth - borderLeft - borderRight;
    
    // don't allow window dimensions greater as screen
    if (windowWidth > maxWindowWidth) {
      windowWidth = maxWindowWidth;
    }
    
    return windowWidth;
  }
  
  function getWindowHeight(imgHeight) {
    var windowHeight = imgHeight + spaceTop + spaceBottom;  
    var maxWindowHeight = screen.availHeight - borderTop - borderBottom;

    // don't allow window dimensions greater as screen
    if (windowHeight > maxWindowHeight) {
      windowHeight = maxWindowHeight;
    } 
    
    return windowHeight;
  } 
  
  
  function getFinalImageHeight(windowHeight) {
    return (windowHeight - spaceTop - spaceBottom);
  } 
  
  
  function getFinalImageWidth(windowWidth) {
    return (windowWidth - spaceLeft - spaceRight);
  } 
    
    
  function openAlbumViewer(url, picSizeX, picSizeY, size) {  
    var picSize = picSizeX;
    if (picSizeY > picSize) picSize = picSizeY;

    albumViewerWindow(url, '', picSize, picSize, size);
    
    newWindow.focus();
  }
  

  
  function browserHeightCorrections()
  {
    if (window.navigator.userAgent.indexOf("SV1") != -1)
    {
     //This browser is Internet Explorer in SP2. 
     return 30;
    }
    else if (window.navigator.userAgent.indexOf("MSIE 7") != -1)
    {
     //This browser is Internet Explorer 7.
     
     return 36;
    }
    else
    {
      return 30;
    }
  }
  


//  End -->

