// DHTML micro-api from http://www.quirksmode.org/js/dhtmloptions.html
function getObj(name)
{
    if (document.getElementById)
        return document.getElementById(name);
    else if (document.all)
        return document.all[name];
    else if (document.layers)
        return getObjNN4(document,name);
    else
        return null;
}
function getStyle(name)
{
    if (document.getElementById)
        return document.getElementById(name).style;
    else if (document.all)
        return document.all[name].style;
    else if (document.layers)
        return getObjNN4(document,name);
    else
        return null;
}      
function getObjNN4(obj,name)
{
    var x = obj.layers;
    var foundLayer;
    for (var i=0;i<x.length;i++)
    {
        if (x[i].id == name)
            foundLayer = x[i];
        else if (x[i].layers.length)
            var tmp = getObjNN4(x[i],name);
        if (tmp) foundLayer = tmp;
    }
    return foundLayer;
}
function setHTML(obj, text)
{
    if (!obj) return;
    if (document.getElementById || document.all) 
    { 
        obj.innerHTML = text; 
    }
    else if (document.layers)
    {
        obj.document.write(text); 
        obj.document.close(); 
    }
}
function setVisible(name, state)
{
    var s = getStyle(name);
    if (s) s.visibility = state;
}

// Call this function when the small viewer is ready to be shown
function initSmall(small)
{
    setVisible(small, "visible");
}
// Call this function when the large viewer is ready to be shown
function initLarge(small, large)
{
    // wait a while before hiding the small model
    setTimeout("hideSmall('"+small+"','"+large+"');", 5000);
}

function hideSmall(small, large)
{
    setVisible(small, "hidden");
    // wait a bit before showing the large model and closing small one
    setTimeout("showLarge('"+small+"', '"+large+"');",50);
}
function showLarge(small, large)
{
    setVisible(large, "visible");
    setHTML(getObj(small), "dummy");      // remove loading applet
}
