var capable = 0;
var browserName = navigator.appName;
var browserVersion = parseInt(navigator.appVersion); 
var ver = '';
if (browserName == "Netscape" && browserVersion >= 3) ver = "n3";
else if (browserName == "Netscape" && browserVersion == 2) ver = "n2";
else if (browserName == "Microsoft Internet Explorer" && (browserVersion == 2 || browserVersion == 3 )) ver = "e3";
else if (browserName == "Microsoft Internet Explorer" && browserVersion >= 4) ver = "e4";
if (ver == "n3" || ver == "e4" ) 
{ 
  capable = 1; 
}

function timeClose()
{
  window.remotePopWindow.close();
}

function showGemeinde(url, popH)
{
  // alert("function showGemeinde(" + url + ")");
  if (capable)
  {
    // alert("> window.remoteWindow = " + window.remoteWindow);
    if (window.remoteWindow && (! window.remoteWindow.closed))
    {
      // alert("> window.remoteWindow.closed = " + window.remoteWindow.closed);
      window.remoteWindow.location = url;  // Neuer URL im Fenster laden
      window.remoteWindow.focus();
    }
    else
    {
      window.remoteWindow =  window.open(url,'gemeindeDetail','dependent=yes,locationbar=no,menubar=no,status=no,width=490,height='+popH+',scrollbars=yes,resizable=yes');
    }
  }
  else // (! capable)
  {
    location.href = url;
  }
}

function showWindow(url, imageName, imageWidth, imageHeight, scroll)
{
  // var scroll;
  // alert("function imageOpen(" + url + "," + imageName + "," + imageWidth + "," + imageHeight + "," + scroll + ")\nwindow.name = " + window.name) + ")";
  if (((scroll==null) && (imageWidth < 901) && (imageHeight < 701)) || (scroll == "no")) 
  {
    // alert('smaller');
    imageWidth = imageWidth + 16;
    imageHeight = imageHeight + 16;
    if ((browserName == "Microsoft Internet Explorer") || (browserVersion >= 5))
    {
      imageHeight = imageHeight + 5;
    }
    scroll = "scrollbars=no";
  }
  else
  {
    // alert('greater');
    if (imageWidth >= 801) 
    {
      imageWidth = 817;
      imageHeight = imageHeight + 18;  // for scroll bar
      if ((browserName == "Microsoft Internet Explorer") || (browserVersion >= 5))
      {
        imageHeight = imageHeight + 5;
      }
    }
    else 
    {
      imageWidth = imageWidth + 16;
    }
    if (imageHeight >= 601) 
    {
      imageHeight = 606;
      imageWidth = imageWidth + 18;  // for scroll bar
      if ((browserName == "Microsoft Internet Explorer") || (browserVersion >= 5))
      {
        imageWidth = imageWidth + 5;
      }
    }
    else 
    {
      imageHeight = imageHeight + 16;
      if ((browserName == "Microsoft Internet Explorer") || (browserVersion >= 5))
      {
        imageHeight = imageHeight + 5;
      }
    }
    scroll = "scrollbars=yes";
  }
  // alert("> capable = " + capable);
  if (capable)
  {
    // alert("> window.remoteWindow = " + window.remoteWindow);
    if (window.remoteWindow && (! window.remoteWindow.closed) && (window.remoteWindow.name == imageName))
    {
      // alert("> window.remoteWindow.closed = " + window.remoteWindow.closed + "\n> window.remoteWindow.name = " + window.remoteWindow.name);
      if ((browserName == "Microsoft Internet Explorer") || (browserVersion >= 5))
      {
        imageWidth = imageWidth + 12;
        imageHeight = imageHeight + 30;
      }
      // alert("... resize " + window.remoteWindow.name);
      window.remoteWindow.resizeTo(imageWidth, imageHeight); 
      window.remoteWindow.location = url;  // Neuer URL im Fenster laden
      window.remoteWindow.focus();
    }
    else
    {
      // alert("... open " + imageName);
      if ((browserName == "Netscape") && (browserVersion >= 5))
      {
        imageWidth = imageWidth + 3;
        imageHeight = imageHeight + 3;
      }
      window.remoteWindow = window.open(url,imageName,'dependent=yes,locationbar=no,menubar=no,status=no,width=' + imageWidth + ',height=' + imageHeight + ',' + scroll + ',resizable=yes');
    }
  }
  else // (! capable)
  {
    // alert("... location.href = " + url);
    location.href = url;
  }
}

function popWindow(url,imageWidth, imageHeight, time)
{
//  showWindow(url, 'pop', imageWidth, imageHeight);
  window.remotePopWindow = window.open(url,'pop','dependent=yes,locationbar=no,menubar=no,status=no,width=' + imageWidth + ',height=' + imageHeight + ', scrollbars=no, resizable=yes');
  window.setTimeout("timeClose()", time);
}



// **************** to be deleted **************************

function windowOpen(url)
{
  if (window.remoteWindow && window.remoteWindow.document)
  {
  }
  else
  {
    remoteWindow = window.open(url,'gemeindeDetail','dependent=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=540,height=320,resizable=yes');
  }
  window.remoteWindow.location = url;  // Neuer URL im Fenster laden
  if (capable)
  {
    window.remoteWindow.focus();
  }
}

function imageOpen(url, imageName, imageWidth, imageHeight)
{
  if ((imageWidth < 601) && (imageHeight < 421)) 
  {
    imageWidth = imageWidth + 16;
    imageHeight = imageHeight + 16;
    scroll = "scrollbars=no";
  }
  else
  {
    if (imageWidth >= 601) imageWidth = 617;
      else imageWidth = imageWidth + 16;
    if (imageHeight >= 421) imageHeight = 477;
      else imageHeight = imageHeight + 16;
    scroll = "scrollbars=yes";
  }
  if (capable && window.remoteWindow && (! window.remoteWindow.closed) && (window.remoteWindow.name == imageName))
  {
    window.remoteWindow.resizeTo(imageWidth,imageHeight);
  }
  else
  {
    remoteWindow = window.open(url,imageName,'dependent=yes,toolbar=no,location=no,status=no,menubar=no,' + scroll + ',width=' + imageWidth + ',height=' + imageHeight + ',resizable=yes');
  }
  window.remoteWindow.location = url;  // Neuer URL im Fenster laden
  if (capable)
  {
    window.remoteWindow.focus();
  }
}
