//
// JavaScript Utility Library
// (C) 1996-2006 by Bernhard Lukas.
//
// Note:
// If you want to use these scripts for your own site,
// please leave this copyright notice unchanged.
//
// - www.bernhardlukas.com -
//

// shortcuts:
var wn = window.name;

// persistent:
//   0: window.name
//   1: counter
//   2: showGfx
var defaultStr = "1000ideen_0_0_0_";
if (wn.substr(0,9) != defaultStr.substr(0,9) || wn == "") window.name = defaultStr;

function setGlobal(value, pos) {
    wn = window.name;
    var j = 0;
    for (var i = 0; i < pos; ++i) j = wn.indexOf("_", j+1);
    window.name = wn.substring(0, j+1) + value + wn.substr(wn.indexOf("_", j+1));
}

function getGlobal(pos) {
    wn = window.name;
    var j = 0;
    for (var i = 0; i < pos; ++i) j = wn.indexOf("_", j+1);
    return wn.substring(j+1, wn.indexOf("_", j+1));
}

// sequence:
var counter = getGlobal(1);
setGlobal(counter++,1);

var dispPic;
var winObject = null;
var dispTitle = "Taten statt Worte (PopUp)";
//TODO:scrolling should be a parameter in the function call
var scrollbarsize = 0;
var dispProps;
if (scrollbarsize > 0)
     dispProps = "toolbar=no,location=no,directories=no,scrollbars=yes,status=no,border=0";
else
    dispProps = "toolbar=no,location=no,directories=no,scrollbars=no,status=no,border=0";

function showGfx(argTarget, argTimeout) {
    var argName = "showGfx_" + getGlobal(2);
    if (arguments.length < 2) {
        dispPic = new Image();
        dispPic.src = argTarget;
    }
    if (dispPic.complete == true || dispPic.height > 0) {
        winObject = new Object();
        argHeight = dispPic.height + scrollbarsize;
        argWidth = dispPic.width + scrollbarsize;
        winObject = window.open("", argName, "" + dispProps + ",width=" + argWidth + ",height=" + argHeight);
        with (winObject) {
            document.open();
            document.write("<html><head><title>" + dispTitle + "</title></head>");
            document.write("<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">");
            document.write("<a href=\"javascript:void(0);\" onmouseover=\"window.status=''; return true;\"");
            document.write(" onclick=\"self.close();\"><img src=\"" + argTarget + "\" border=\"0\" alt=\"");
            document.write("Image " + argTarget + "\" title=\"Klicken Sie hier um dieses Fenster zu schlie&szlig;en\"></a>");
            document.write("</body></html>");
            document.close();
            focus();
        }
        setGlobal((getGlobal(2)*1)+1,2);
    } else {
        window.setTimeout("showGfx(\"" + argTarget + "\")", 300);
    }
    return winObject;
}