/*
    *****************************************************************************************************
    Author : Daniel Degasperi
    Last modified: R3 GIS (20/09/2005)
    Date : 20/09/2005
    Version: 1.0
    *****************************************************************************************************
*/

function OpenWindow(url, target, width, height) {

  scrollbars = "yes";
  l = ((screen.availWidth - width - 10) * .5);
  t = ((screen.availHeight - height - 10) * .5);

  if (width > screen.availWidth - 10) {
    width = screen.availWidth - 10;
    scrollbars = "yes";
  }
  if (height > screen.availHeight - 10) {
    height = screen.availHeight - 10;
    scrollbars = "yes";
  }

  param = 'scrollbars=' + scrollbars + ', ' +
          'toolbar=no, ' +
          'location=no, ' +
          'status=no, ' +
          'menubar=no, ' +
          'resizable=no, ' +
          'width=' + width + ', ' +
          'height=' + height + ', ' +
          'left=' + l + ', ' +
          'top=' + t;

  Win = window.open('',
                    target,
                    param);
  Win.resizeTo(width, height);
  Win.location.href = url;
  Win.focus();
}

function OpenWindowWithToolbar(url, target, width, height) {

  scrollbars = "yes";
  l = ((screen.availWidth - width - 10) * .5);
  t = ((screen.availHeight - height - 10) * .5);

  if (width > screen.availWidth - 10) {
    width = screen.availWidth - 10;
    scrollbars = "yes";
  }
  if (height > screen.availHeight - 10) {
    height = screen.availHeight - 10;
    scrollbars = "yes";
  }

  param = 'scrollbars=' + scrollbars + ', ' +
          'toolbar=no, ' +
          'location=no, ' +
          'status=no, ' +
          'menubar=yes, ' +
          'resizable=no, ' +
          'width=' + width + ', ' +
          'height=' + height + ', ' +
          'left=' + l + ', ' +
          'top=' + t;

  Win = window.open('',
                    target,
                    param);
  Win.resizeTo(width, height);
  Win.location.href = url;
  Win.focus();
}

function OpenWindowResizable(url, target, width, height) {

  scrollbars = "yes";
  l = ((screen.availWidth - width - 10) * .5);
  t = ((screen.availHeight - height - 10) * .5);

  if (width > screen.availWidth - 10) {
    width = screen.availWidth - 10;
    scrollbars = "yes";
  }
  if (height > screen.availHeight - 10) {
    height = screen.availHeight - 10;
    scrollbars = "yes";
  }

  param = 'scrollbars=' + scrollbars + ', ' +
          'toolbar=no, ' +
          'location=no, ' +
          'status=no, ' +
          'menubar=no, ' +
          'resizable=yes, ' +
          'width=' + width + ', ' +
          'height=' + height + ', ' +
          'left=' + l + ', ' +
          'top=' + t;

  Win = window.open('',
                    target,
                    param);
  Win.resizeTo(width, height);
  Win.location.href = url;
  Win.focus();
}

function OpenPDF(url, width, height) {

  target = "TREES_PDF";
  scrollbars = "yes";
  l = ((screen.availWidth - width - 10) * .5);
  t = ((screen.availHeight - height - 10) * .5);

  if (width > screen.availWidth - 10) {
//    width = screen.availWidth - 10;
    scrollbars = "yes";
  }
  if (height > screen.availHeight - 10) {
//    height = screen.availHeight - 10;
    scrollbars = "yes";
  }

  param = 'scrollbars=' + scrollbars + ', ' +
          'toolbar=no, ' +
          'location=no, ' +
          'status=no, ' +
          'menubar=no, ' +
          'resizable=yes, ' +
          'width=' + width + ', ' +
          'height=' + height + ', ' +
          'left=' + l + ', ' +
          'top=' + t;

  Win = window.open('',
                    target,
                    param);
  Win.resizeTo(width, height);
  Win.location.href = url;
  Win.focus();
}

function ShowImage(url, width, height) {

  target = 'TREES_IMAGE';

  height = height + 100;
  width = width + 50;
  scrollbars = "no";
  if (width > screen.availWidth - 10) {
    width = screen.availWidth - 10;
    scrollbars = "yes";
  }
  if (height > screen.availHeight - 10) {
    height = screen.availHeight - 10;
    scrollbars = "yes";
  }
  l = ((screen.availWidth - width - 10) * .5);
  t = ((screen.availHeight - height - 10) * .5);

  param = 'scrollbars=' + scrollbars + ', ' +
          'toolbar=no, ' +
          'location=no, ' +
          'status=no, ' +
          'menubar=no, ' +
          'resizable=no, ' +
          'width=' + width + ', ' +
          'height=' + height + ', ' +
          'left=' + l + ', ' +
          'top=' + t;

  Win = window.open('',
                    target,
                    param);
  Win.resizeTo(width, height);
  Win.location.href = url;
  Win.focus();
}

function ShowDoc(url) { 
  target = 'doc';
  width = 800; 
  height = 600; 
  l = ((screen.availWidth - width - 10) * .5); 
  t = ((screen.availHeight - height - 10) * .5); 

  param = 'scrollbars=no, ' + 
          'toolbar=no, ' + 
          'location=no, ' + 
          'status=yes, ' + 
          'menubar=no, ' + 
          'resizable=yes, ' + 
          'width=' + width + ', ' + 
          'height=' + height + ', ' + 
          'left=' + l + ', ' + 
          'top=' + t; 

  Win = window.open(url, 
                    target, 
                    param); 
  Win.resizeTo(width, height); 
  Win.location.href = url; 
  Win.focus(); 
}