var to       = false;
var to_hide  = false;
var fixalpha = false;
var hoverCol = '#cccccc';
function openSub(_i,startfade)
{
    if(to) clearTimeout(to);
    var str = '';
    document.getElementById("td_betanav").innerHTML = str;
    
    if(_i==0) { if(_i != iMain) goTo(doc); }//home
    else if(beta[_i].length == 1) { if(_i != iMain) goTo(doc+'?c='+_i); }
    else if(beta[_i][0])
    {
        
        for(var i=1;i<beta[_i].length;i++) str += '<a href="#" onclick="goTo(\''+doc+'?c='+_i+','+i+'\');return false;" onmouseover="this.orgCol=this.style.color;this.style.color=hoverCol;window.status=\'führt zu: '+beta[_i][0]+' &raquo; '+beta[_i][i]+'\';return true;" onmouseout="this.style.color=this.orgCol;window.status=\'\';return true;">'+beta[_i][i]+'</a><img src="images/trans.gif" width="13" height="1" alt="" border="0">';
        document.getElementById("td_betanav").innerHTML = str;
        subFadeIn(_i,str,(startfade ? startfade : 1));
    }
    return false;
}
function startMenuInterval()
{
    to_hide = setTimeout('recoverMenu()',1000);
}
function stopMenuInterval()
{
    if(to_hide) clearTimeout(to_hide);
}
function recoverMenu()
{
    if(fixalpha == document.images['imgAlpha'+iMain]) return false;
    openSub(iMain);
    fixalpha.src = fixalpha.s;
    fixalpha     = document.images['imgAlpha'+iMain];
    fixalpha.src = fixalpha.s.replace(/\.gif/,'_ro.gif');
}
function subFadeIn(menue,_str,_i)
{
    if(_i > 10) return;
    var obj = document.getElementById("td_betanav");
    //B0B1B0 -> 176,177,176
    //Start (body): 7F837E -> 127,131,127
    var col = parseInt(((176-128) / 10) * _i) + 128;
    for(var i=j=0;i<obj.childNodes.length;i++) if(obj.childNodes[i].tagName.toUpperCase()=='A') obj.childNodes[i].orgCol = obj.childNodes[i].style.color = (iMain!=menue || iSub != ++j) ? "rgb("+col+","+col+","+col+")" : hoverCol;
    to = setTimeout("subFadeIn("+menue+",'"+(_str.replace(/\'/g,"\\\'").replace(/\"/g,'\\\"'))+"',"+(_i+1)+")",80);
    return false;
}

function goTo(_url)
{
    top.location.href = _url;
}

function createLayer(layId)
{
    var tempElem = document.body.appendChild(document.createElement("div"));
    tempElem.style.position = "absolute";
    tempElem.style.left = 10;
    tempElem.style.top  = 10;
    tempElem.layid = layId;
    tempElem.id    = layId;
    return tempElem;
}

var tempElemExtended = false;
function showextended(_title)
{
    if(tempElemExtended)
    {
        tempElemExtended.style.visibility = 'hidden';
        document.body.removeChild(tempElemExtended);
    }
    
    tempElemExtended = createLayer('extended');
    var layH = 335;
    var layW = 650;
    var posx = document.body.scrollLeft + ((document.body.clientWidth  - layW)/2);
    var posy = document.body.scrollTop  + ((document.body.clientHeight - layH)/2);

    var _url = 'view_extended.php?a='+escape(_title)+(location.search ? '&'+location.search.substring(1) : '');    
    
    var txt  = '<table id="t_extended" cellspacing=0 cellpadding=0 border=0 width='+layW+' height='+layH+'>'+
               ' <tr>'+
               '  <td height=35 id="td_extended_head">&nbsp;</td>'+
               ' </tr>'+
               ' <tr>'+
               '  <td><iframe frameborder=0 src="'+_url+'" width="'+(layW-2)+'" height="'+(layH-70)+'"></iframe></td>'+
               ' </tr>'+
               ' <tr>'+
               '  <td height=35><a href="#" onmousedown="parent.tempElemExtended.innerHTML=\'\';parent.tempElemExtended.style.visibility=\'hidden\';window.status=\'\';return false;" onmouseover="window.status=\'close\';return true;" onmouseout="window.status=\'\';return true;"><img onmouseover="t=this.src;this.src=\'images/extended/button_close_ro.gif\';" onmouseout="this.src=t;" src="images/extended/button_close.gif" width="59" height="23" alt="" border="0"></a></td>'+
               ' </tr>'+
               '</table>'+
               '';
    
    tempElemExtended.style.left = posx;
    tempElemExtended.style.top  = posy;
    tempElemExtended.innerHTML  = txt;
    tempElemExtended.style.visibility = 'visible';
}

function showimage(_src,_w,_h)
{
    var oversized = 0; 
    
    //generiere Größen und position
    var w = _w + 2;
    var h = _h + 31;
    var l = (screen.availWidth-w)/2;
    var t = (screen.availHeight-h)/2;
    
    //negativeer bereich -> 0
    if(l < 0) l = 0;
    if(t < 0) t = 0;
    
    //recht der Screen für das fenster?
    var needWidth  = (screen.availWidth-10-w);
    var needHeight = (screen.availHeight-h);
    var scrollbarwidth = 19; //wenn oversized nur in eine Richtung, kann Breite bzw. Höher ggf. größer und so zusätzlichen Scroller verhindern.
    
    if(needWidth  <= 0) { w = (screen.availWidth-10); if(needHeight >= scrollbarwidth) h += scrollbarwidth; oversized = 1; }
    if(needHeight <= 0) { h = (screen.availHeight);   if(needWidth  >= scrollbarwidth) w += scrollbarwidth; oversized = 1; }
    
    var win =  window.open('view_image.php?src='+_src+'&oversized='+oversized,'image','scrollbars=no,top='+t+',left='+l+',width='+w+',height='+h);
    if(win) win.focus();
}

function showlink(_url)
{
    // goTo(adir + _url);   
    goTo(_url);
}

function showextlink(_url)
{
    window.open(_url);
}

var tempElemTooltip = false;
function tooltip(_arg,txt)
{   
    switch(_arg)
    {
        case "start":
          tempElemTooltip = createLayer('tooltip');
          tempElemTooltip.innerHTML = txt;
          tempElemTooltip.style.left = (!document.all ? _arg.pageX : window.event.clientX + document.body.scrollLeft) + 7;
          tempElemTooltip.style.top  = (!document.all ? _arg.pageY : window.event.clientY + document.body.scrollTop)  + 11;
          document.onmousemove = tooltip;
          tempElemTooltip.style.visibility = 'visible';
        break;
        
        case "stop":
          document.onmousemove = null;
          tempElemTooltip.style.visibility = 'hidden';
          document.body.removeChild(tempElemTooltip);
        break;
        
        default: //move
          if(!tempElemTooltip) return false;
          tempElemTooltip.style.left = (!document.all ? _arg.pageX : window.event.clientX + document.body.scrollLeft) + 7;
          tempElemTooltip.style.top  = (!document.all ? _arg.pageY : window.event.clientY + document.body.scrollTop)  + 11;
        break;
    }
}
