// wb0.js
// Winfried Beer, http://www.w-beer.de
//

fontsizenames=new Array("6pt", "8pt", "10pt", "12pt", "14pt", "18pt", "24pt");

basedir=".";
cssfile="";
transimg="images/t.gif";
triimg="images/tri.gif";

// ---------------------------------------
function getfontsize () { // get saved fontsize
  str=parent.name;
  parts=str.split("_");
  if (parts.length<2) { // not found
    if (navigator.userAgent.search(/Win/)>-1) return -1;  // smaller default font for MSWindows
    return 0;
  }
  str=parts[1].replace(/m/,"-"); // "-" not allowed in window names, using "m" instead
  return parseInt(str);
}

// ---------------------------------------
function setfontsize (fontsize) { // set larger/smaller font size and reload
  //if (document.all) { // Microsoft CSS
  //  document.all.h1.style.setAttribute("fontSize","18pt","false"); // ZZ first try
  //  return;
  //}
  //if (document.tags) { // Netscape JSSS
  //   document.tags.p.color="black"; // sorry, doesnt work after page loading
  //}
  str="windowname_"+(fontsize<0?"m":"")+Math.abs(fontsize);  // "-" not allowed in window names, using "m" instead
  parent.name=str;
  parent.location.href=parent.location.href; // reload page
  return;
}

// ---------------------------------------
function addfontsize (fontsize) { // set larger/smaller font size and reload
  setfontsize(fontsize+getfontsize());
}

// ---------------------------------------
function writefontsizelinks() {  // show +/- for changing default font size
  fontsize=getfontsize();
  if (fontsize<3) {
    document.write ('<a href="javascript:addfontsize(1)"');
    document.write (' onmouseover="status=\'Schrift größer (von '+fontsizenames[fontsize+3]);
    document.write (' auf '+fontsizenames[fontsize+3+1]+')\';return true;"');
    document.write (' onmouseout="status=\'\';return true;"><img src="'+basedir+'/images/lens-plus.gif" width=18 height=18 border=0 alt="Schrift größer"></a> ');
    //document.write (' onmouseout="status=\'\';return true;">+</a> / ');
  }else{
    //document.write ("+ / ");
  }
  if (fontsize>-3) {
    document.write ('<a href="javascript:addfontsize(-1)"');
    document.write (' onmouseover="status=\'Schrift kleiner (von '+fontsizenames[fontsize+3]);
    document.write (' auf '+fontsizenames[fontsize+3-1]+')\';return true;"');
    document.write (' onmouseout="status=\'\';return true;"><img src="'+basedir+'/images/lens-minus.gif" width=18 height=18 border=0 alt="Schrift kleiner"></a>');
    //document.write (' onmouseout="status=\'\';return true;">-</a>');
  }else{
    //document.write ("-");
  }
}

// ---------------------------------------
function sb(name) { // show button mark
  name.src=basedir+"/"+triimg;
}

// ---------------------------------------
function hb(name) {  // hide button mark
  name.src=basedir+"/"+transimg;
}

// ---------------------------------------
function loadCSS() { // Check for larger default font size.  Load another stylesheet to change font size.
  if (cssfile=="") return; // Check: Netscape hangs up on non available CSS.
  cssbase=cssfile.replace(/.css/,"");
  fontsize=getfontsize();
  if (fontsize!=0) {
    str="";
    switch(fontsize) {
      case 0: str=""; break;
      case 1: str="+1"; break;
      case 2: str="+2"; break
      case 3: str="+3"; break
      case -1: str="-1"; break;
      case -2: str="-2"; break;
      case -3: str="-3"; break;
    }
    document.write ('<link rel=stylesheet type="text/css" href="'+basedir+"/"+cssbase+str+'.css">');
    //alert(basedir+"/"+cssbase+str+".css");
  }
}   

// ---------------------------------------
function initJS(xbasedir, xcssfile, xtransimg, xtriimg) { // Set some filenames and parameters.
  basedir=xbasedir;
  cssfile=xcssfile;
  if (basedir=="") basedir=".";
  transimg=xtransimg;
  triimg=xtriimg;
}

var winSP; /* Eigentlich sollte man mehrere winSP verwalten, da mehrere Fenster mit showPicture()
  geöffnet werden können. */
// ---------------------------------------
function showPicture(url,wname,width,height) { 
  // popup (new) window "wname" with image "url" inside
 var tmp, xoff, yoff;

  if (!/Netscape/.test(navigator.appName)) {
    width=width+35;
    height=height+35;
  }
  if (!/Mozilla/.test(navigator.appName)) {
    width=width+35;
    height=height+35;
  }
  if (winSP) {
    if (!winSP.closed) {
      //winSP.close();  
    }
    // netscape is more stable when closing before opening window
    //   won't work with multiple windows very well
  }
  dummyurl=basedir+"/dummy.html";
  if (/Netscape/.test(navigator.appName)) {
    dummyurl="";  // Netscape needs no URL - it's faster and more stable
  }
  // double open: else no resize of already open windows!
  winSP=window.open(dummyurl,wname,"scrollbars=yes,resizable=yes,menubar=no,width="+width+",height="+height);
  winSP=window.open(dummyurl,wname,"scrollbars=yes,resizable=yes,menubar=no,width="+width+",height="+height);
  if (!winSP) {return false;}
  winSP.resizeTo(width,height); // focus and resize for IE
  if (winSP.focus) {
    winSP.focus();  // Netscape is more stable with using focus() before writing...
  }
  //alert(1);
  //winSP.location.href=url;
  str=""+url;
  tmp=str.split("/");
  filename=tmp[tmp.length-1];
  winSP.document.open ("text/html");
  winSP.document.writeln ('<html><head>');
  winSP.document.writeln ('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
  winSP.document.writeln ('<title>Picture ('+filename+')</title>');
  //winSP.document.writeln ('<link rel=stylesheet type="text/css" href="'+$basedir+'"/wb0.css">');
  //winSP.document.writeln ('<script language="JavaScript" src="'+$basedir+'/wb0.js" type="text/javascript"></script>');
  winSP.document.writeln ('</head>');
  winSP.document.writeln ('<body bgcolor="#ffffff" text="#000000" link="#000099" vlink="#333399" alink="#cc0000">');
  //winSP.document.writeln (' style="padding:0px;margin:-8px;">');
  winSP.document.writeln ('<div id="image" style="position:absolute;left:0px;top:0px;padding:0px;z-index:2">');
  winSP.document.writeln ('<center><img src="'+url+'" border=0 hspace=0 vspace=0></center>');
  winSP.document.writeln ('</div>');
  winSP.document.writeln ('</body></html>');
  winSP.document.close();
}
 
