function pop(type)
{
  var p_url = "../pops/";
  var p_name = "Impressum";
  var width = 400;
  var height = 420;
  type = type.toLowerCase();
  var skol = "no";
  switch(type.substr(0,3))
  {
    case "glo":
       p_url += "glossar.php";
       p_name = "Glossar";
       width = 500;
       height = 460;
       break;
    case "ind":
       p_url += "popindex.php";
       p_name = "Index";
       width = 500;
       height = 460;
       break;
    case "imp":
       p_url += "impressum.php";
       p_name = "Impressum";
       width = 360;
       height = 400;
       break;
    case "map":
       p_url += "sitemap.php";
       p_name = "Sitemap";
       skol = "yes";
       width = 540;
       height = 460;
       break;
    default:
       p_url += "impressum.php";
  }
  openWindow(p_url,p_name,height,width,'right','bottom',skol);

}

function popcms(type)
{
  var p_url = "../popcms/";
  var p_name = "Impressum";
  var width = 400;
  var height = 420;
  type = type.toLowerCase();
  var skol = "no";
  
  switch(type.substr(0,3))
  {
    case "glo":
       p_url += "red_glossar.php";
       p_name = "Glossar";
       width = 500;
       height = 460;
       break;
    case "ind":
       p_url += "cms_index.php";
       p_name = "Index";
       width = 500;
       height = 460;
       break;
    case "imp":
       p_url += "impressum.php";
       p_name = "Impressum";
       width = 360;
       height = 400;
       break;
    case "map":
       p_url += "sitemap.php";
       p_name = "Sitemap";
       skol = "yes";
       width = 540;
       height = 460;
       break;
    case "ort":
       bistumID = type.substring(3,type.length);
       p_url += "red_ortsliste.php?bistumID="+bistumID;
       p_name = "Ortsliste";
       skol = "yes";
       width = 360;
       height = 480;
       break;
    case "per":
       p_url += "persliste.php?bistumID="+type.substring(3,type.length);
       p_name = "Menschen";
       skol = "yes";
       width = 360;
       height = 400;
       break;
    default:
       p_url += "impressum.php";
  }
  openWindow(p_url,p_name,height,width,'right','bottom',skol);

}

function poport(type,bistid)
{
  var p_url = "../pops/";
  var p_name = "Ortsliste";
  var width = 400;
  var height = 400;
  type = type.toLowerCase();
  switch(type.substr(0,3))
  {
    case "ort":
       p_url += "ortsliste.php?bistumID="+bistid;
       p_name = "Ortsliste";
       width = 360;
       height = 480;
       break;
    case "per":
       p_url += "persliste.php?bistumID="+bistid;
       p_name = "Menschen";
       width = 360;
       height = 400;
       break;
    default:
       p_url += "ortsliste.php";
  }
  openWindow(p_url,p_name,height,width,'right','bottom','yes');
 return false;
}

function popPDF(pdf)
{
  var p_url = pdf+"#toolbar=0";
  var p_name = "pdf";
  var width = 780;
  var height = 580;
  var skol = "yes";
  openWindow(p_url,p_name,height,width,'left','top','yes');
 return false;
}

/**
 * Opens a window with given URL and name.
 * made by aec for mec 27.12.2001
 * p_url - uri of document; p_name - name of window,
 * p_height - height of window, p_width - width of window,
 * p_horiAlign - left, center or right; p_vertiAlign - top, center or bottom
 */
function openWindow(p_url, p_name, p_height, p_width, p_horiAlign, p_vertiAlign, skol) {
        var properties = "dependent=yes, location=no, menubar=no, resizable=yes";
        properties += ", status=no, toolbar=no";
        properties += ", scrollbars="+skol;
        properties += ", width="+p_width+", height="+p_height;

        var horiAl = 0;
        if (p_horiAlign == "center") {
                horiAl = 1;
        } else if (p_horiAlign == "right") {
                horiAl = 2;
        }
        var vertiAl = 0;
        if (p_vertiAlign == "center") {
                vertiAl = 1;
        } else if (p_vertiAlign == "bottom") {
                vertiAl = 2;
        }

        var xPos = alignW(p_width, screen.width, horiAl);
        var yPos = alignW(p_height, screen.height-35, vertiAl);
        properties += ", screenX="+xPos+", screenY="+yPos+", left="+xPos+", top="+yPos;

        var fenster = window.open(p_url, p_name, properties);
        fenster.focus();
}

/**
 * Align the left or top of a window.
 * made by aec for mec 27.12.2001
 * p_size         -        the size (width or height) of the window
 *                         (tip: if height, p_size should be screen.height-35)
 * p_available - the available size (width or height of the screen)
 * p_alignment - 0 for top or left, 1 for center, 2 for right or bottom
 */
function alignW(p_size, p_available, p_alignment) {
        if (p_alignment == 0) { // left, top
                return 0;
        } else if (p_alignment == 1) { // center
                return (p_available - p_size-24)/2;
        } else { // right, bottom
                return (p_available - p_size-30);
        }
}
