// fixme: rename the functions?!


// This must run `after' parsing whole HTML !!
function winOnLoad()
{
        // mmc: This does not work!
  alert("winOnLoad!");
  setup();
}


// mmc: So, we rely on the "active" elements being named:   triggerN N from an interval
function setup()
{
        var ele, i = 0;
        do {
                // alert("searching for trigger!");
                ele = xGetElementById('trigger' + i);
                // alert("the trigger-element " + i + " has imgurl " + ele.imgurl + "!");
                if (ele) {
                        // mmc:  So here we add a slot: panelID !
                        ele.panelId = i++;
                        ele.onmouseover = tOnMouseover;
                        ele.onmouseout = tOnMouseout;
                }
        } while(ele);
}


// And we need an element called `panel' which has `img' inside it.
//    and we assign 

// Note, that it is irrelevant where the `panel' element is! we move it!! 
function tOnMouseover()
{
        var panel = xGetElementById('panel');

        var img = panel.getElementsByTagName("img").item(0);
        // fixme: This fails for  /t/2 thumbnails! 
        // How to cut off the "/t" ?
        var thurl = this.src; // That is the thumbnail   /t   -2  /t/2  -4
        img.src = thurl.slice(0, thurl.length - 4);


        // "/f/3721/" + this.panelId;
        img.width = "600";

        if (panel) {
                var x = xScrollLeft() + (xClientWidth() - xWidth(panel)) / 2;
                var y = xScrollTop() + (xClientHeight() - xHeight(panel)) / 2;
                xMoveTo(panel, x, y);
                xShow(panel);
        }
}



function tOnMouseout()
{
        var panel = xGetElementById('panel');
        // resize to 1x1 ?
        var img = panel.getElementsByTagName("img").item(0);
        img.src = "/dot.jpg";
        img.width = "0";
        xHide('panel');
}
