﻿var map;
var standart, broschuere, logo, intro;
var geschaeft, news, bignews, pdf;
var smallnews, galerie, panorama;

function detectScreenSize() 
{
    try {
        if(screen.width < 600) 
        { window.location.href = "mobile/default.aspx?aid="+auswahlid; }
    }catch(e){}
}

detectScreenSize();

function Left(str, n) {
	if (n <= 0) return "";
	else if (n > String(str).length) return str;
	else return String(str).substring(0,n);
}

function Right(str, n) {
    if (n <= 0) return "";
    else if (n > String(str).length) return str;
    else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); }
}

function setBroschuere(resolution, first)
{
    if(broschuere || first)
    {
        if(resolution == "1024") { setImg(245, 150); }
        if(resolution == "1280") { setImg(290, 175); }
        if(resolution == "1680") { setImg(325, 200); }
        
        broschuere = true;
    }
}

function setStandart(resolution, first)
{
    if(standart || first)
    {
        if(resolution == "1024") { setImg(197, 264); }
        if(resolution == "1280") { setImg(231, 310); }
        if(resolution == "1680") { setImg(280, 375); }
        
        standart = true;
    }
}

function setGeschaeft(resolution, first)
{
    if(geschaeft || first)
    {
        if(resolution == "1024") { setImg(245, 328); }
        if(resolution == "1280") { setImg(300, 400); }
        if(resolution == "1680") { setImg(340, 455); }
        
        /*if(resolution == "1024") { setImg(197, 263); }
        if(resolution == "1280") { setImg(230, 306); }
        if(resolution == "1680") { setImg(279, 372); }*/
        geschaeft = true;
    }        
}

function setSmallFlash(resolution)
{
    var bfImage = document.getElementById('bfImage');
    var flvImage = document.getElementById('flvImage');
    var flvFrame = document.getElementById('flvFrame');
    

    var topImg = 0; var leftImg = 0;    
    var top = 0; var left = 0;
    var width = 0; var height = 0;

    if(resolution == "1024") { topImg = 264; leftImg = 371; top = 18; left = 10; width = 408; height = 292; }
    if(resolution == "1280") { topImg = 286; leftImg = 386; top = 40; left = 25; width = 455; height = 326; }
    if(resolution == "1680") { topImg = 306; leftImg = 411; top = 60; left = 50; width = 500; height = 383; }  
    
    if(flvFrame && flvImage && bfImage)
    {
        if(navigator.appName == "Netscape")
        {
            topImg += 9;
            leftImg += 8;
        }
    
        bfImage.style.top = topImg + "px";
        bfImage.style.left = leftImg + "px";        
    
        flvImage.style.top = topImg + "px";
        flvImage.style.left = leftImg + "px";
    
        flvFrame.style.paddingTop = top + "px";
        flvFrame.style.paddingLeft = left + "px";
        
        flvFrame.style.height = (height-top) + "px";
        flvFrame.style.width = (width-left) + "px";
    }
    
    document.getElementById('box_left_white').style.width = width + "px";
    document.getElementById('box_left_white').style.height = height + "px";
}

function setFlash(resolution)
{
    var flashlink = document.getElementById('flashLink');
    var flashlink2 = document.getElementById('flashLink2');
    var flash = document.getElementById('flash');
    
    var width = 0; var height = 0;

    if(resolution == "1024") { width = 140; height = 120; }
    if(resolution == "1280") { width = 190; height = 150; }
    if(resolution == "1680") { width = 205; height = 165; }
   
    if(flash && flashlink && flashlink2)
    {
        flash.style.height = height + "px";
        flash.style.width = width + "px";
        
        flashlink.style.height = height + "px";
        flashlink.style.width = width + "px";
        
        flashlink2.style.height = height + "px";
        flashlink2.style.width = width + "px";                
    }
}

function setPanorama(resolution, first)
{
    if(panorama || first)
    {
        if(resolution == "1024") { setImg(null, 500); }
        if(resolution == "1280") { setImg(null, 600); }
        if(resolution == "1680") { setImg(null, 700); }
        panorama = true;
    }        
}

function setKartenLogos(resolution)
{
    var width;
    if(resolution == "1024") { width = 170; }
    if(resolution == "1280") { width = 200; }
    if(resolution == "1680") { width = 240; }   
    
    if(typeof(optikerDaten) != "undefined")
    {
        for(var i=0; i < optikerDaten.length; i++)
        {
            if(optikerDaten[i])
            {
                var startIndex = optikerDaten[i].indexOf("&w=") + "&w=".length;
                
                if(optikerDaten[i].substr(startIndex, 3).indexOf(" ") > -1) 
                { optikerDaten[i] = optikerDaten[i].replace("&w=","&w="+width);}
                else 
                { 
                    var oldsize = optikerDaten[i].substr(startIndex, 3);
                    optikerDaten[i] = optikerDaten[i].replace("&w="+oldsize,"&w="+width);
                }
            }
        }
        
        $('punkt').style.display = "none";
        $('divOptiker').innerHTML = optikerDaten[0];
    }
}

function setGalerie(resolution, textheight, first)
{
    if(galerie || first)
    {
        var height, oldheight;
        var width, oldwidth;

        if(resolution == "1024") { width=598; oldwidth=714; height=382; oldheight=499; }
        if(resolution == "1280") { width=714; height=499; if(gWidth > resolution) { oldwidth=802; oldheight=498; } else { oldwidth=598; oldheight=382; } }
        if(resolution == "1680") { width=802; oldwidth=714; height=498; oldheight=499; }
        
        height = parseInt(height) - parseInt(textheight);
        
        setImg(height, width);
        
        for(var i=0; i < bilder.length; i++)
        {
            var startIndex = bilder[i].indexOf("&h=") + "&h=".length;
            var length = bilder[i].length - startIndex;

            if(length == 0) 
            {
                bilder[i] = bilder[i].replace("&w=","&w="+width)
                                     .replace("&h=","&h="+height);
            }
            else 
            { 
                var oldsize = bilder[i].substring(startIndex, (startIndex+length)) 
                bilder[i] = bilder[i].replace("&w="+oldwidth,"&w="+width)
                                     .replace("&h="+oldheight,"&h="+height);
            }
        }
        galerie = true;
    }        
}

function setNews(resolution, first)
{
    if(news || first)
    {
        if(resolution == "1024") { setImg(123, 148); }
        if(resolution == "1280") { setImg(150, 186); }
        if(resolution == "1680") { setImg(170, 211); }
        
        news = true;
    }        
}

function setBigBigNews(pWidth, pHeight)
{
    setImg(pHeight, pWidth);
    
    for(var i=0; i < bilder.length; i++)
    {
        var startIndex = bilder[i].indexOf("&h=") + "&h=".length;
        var length = bilder[i].length - startIndex;

        if(length == 0) 
        {
            bilder[i] = bilder[i].replace("&w=","&w="+pWidth)
                                 .replace("&h=","&h="+pHeight);
        }
    }       
}

function setBigNews(resolution, first)
{
    if(bignews || first)
    {    
        var height, oldheight;
        var width, oldwidth;
    
        if(resolution == "1024") { width=408; oldwidth=455; height=307; oldheight=344; }
        if(resolution == "1280") { width=455; height=344; if(gWidth > resolution) { oldwidth=500; oldheight=390; } else { oldwidth=408; oldheight=307; } }
        if(resolution == "1680") { width=500; oldwidth=455; height=390; oldheight=344; }    
    
        setImg(height, width);
        
        for(var i=0; i < bilder.length; i++)
        {
            var startIndex = bilder[i].indexOf("&h=") + "&h=".length;
            var length = bilder[i].length - startIndex;

            if(length == 0) 
            {
                bilder[i] = bilder[i].replace("&w=","&w="+width)
                                     .replace("&h=","&h="+height);
            }
            else 
            { 
                var oldsize = bilder[i].substring(startIndex, (startIndex+length)) 
                bilder[i] = bilder[i].replace("&w="+oldwidth,"&w="+width)
                                     .replace("&h="+oldheight,"&h="+height);
            }
        }       
        bignews = true;
    }        
}

function setSmallNews(resolution, first)
{
    if(smallnews || first)
    {   
        var width, height;
        
        if(resolution == "1024") { height=67; width=94; }
        if(resolution == "1280") { height=78; width=109; }
        if(resolution == "1680") { height=84; width=118; }   
        
        for(var i=0; i<newscount; i++)
        {
            var bild = document.getElementById('newsimg'+i);
            if(bild)
            {
                replaceImgSize(bild, width, "w");
                replaceImgSize(bild, height, "h");
            }
        }                 
                
        smallnews = true;
    }        

}

function setLogo(resolution, first)
{
    if(logo || first)
    {
        var width;
        var bild = document.getElementById('logo');

        if(resolution == "1024") { width = 170; }
        if(resolution == "1280") { width = 200; }
        if(resolution == "1680") { width = 240; }

        if(bild) { if(width) { replaceImgSize(bild, width, "w"); } }        
        logo = true;
    }
}

function setKarte(resolution)
{    
    var bild = document.getElementById('karte');
    if(bild) { bild.src = "grafik/"+resolution+"/sonstiges/Karte_Miniatur.png"; }    
}

function setWMTipp(resolution)
{
    var bild = document.getElementById('wmimg');
    
    if(bild) { bild.src = bild.src.replace("1024", resolution).replace("1280", resolution).replace("1680", resolution); }
}

function setShop(resolution)
{
    var bild = document.getElementById('shopimg');
    
    if(bild) { bild.src = bild.src.replace("1024", resolution).replace("1280", resolution).replace("1680", resolution); }
}

function setPDF(resolution)
{
    var bild = document.getElementById('file');
    if(bild) { bild.src = "grafik/"+resolution+"/buttons/pdf.png"; }
   
}

function setAuswahl(resolution, bildcount)
{
    var width;
    
    if(resolution == "1024") { width = 170; }
    if(resolution == "1280") { width = 200; }
    if(resolution == "1680") { width = 240; }
    
    for(j=0;j<bildcount;j++)
    {
        var bild = document.getElementById('bild'+(j+1));
        if(bild)
        {
            replaceImgSize(bild, width, "w");
        }
    }
}

function setAuswahl2(resolution, bildcount)
{
    var width;
    
    if(resolution == "1024") { width = 224; }
    if(resolution == "1280") { width = 267; }
    if(resolution == "1680") { width = 267; }
    
    for(j=0;j<bildcount;j++)
    {
        var bild = document.getElementById('bild'+(j+1));
        if(bild)
        {
            replaceImgSize(bild, width, "w");
        }
    }
}

function setAuswahl3(resolution, bildcount)
{
    var height;
    
    if(resolution == "1024") { height = 75; }
    if(resolution == "1280") { height = 90; }
    if(resolution == "1680") { height = 75; }
    
    for(j=0;j<bildcount;j++)
    {
        var bild = document.getElementById('bild'+(j+1));
        if(bild)
        {
            replaceImgSize(bild, height, "h");
        }
    }
}

// --------------------------------------------------------
// Bild RESIZE funktionen
// --------------------------------------------------------
function setImg(height, width)
{
    var bild = document.getElementById('bild');
    if(bild)
    {        
        if(height)  { replaceImgSize(bild, height, "h"); }
        if(width)   { replaceImgSize(bild, width, "w"); }
    }
}

function replaceImgSize(bild, newsize, size)
{
    size = "&"+size+"=";
    
    if(size == "&w=")
    {
        bild.src = bild.src.replace("&w=0","&w=");
    }
    
    var iStartIndex = bild.src.indexOf(size) + size.length;
    var iLength = bild.src.indexOf("&", iStartIndex) - iStartIndex;
    
    if(iLength < 0)
    {
        iLength = bild.src.length - iStartIndex;
    }
    
    var oldsize = bild.src.substr(iStartIndex, iLength);
           
    if(isNaN(oldsize) || oldsize.length == 0) 
         { bild.src = bild.src.replace(size,size+newsize); }
    else { bild.src = bild.src.replace(size+oldsize,size+newsize); }
}

function setImgPosition()
{
    var bild  = document.getElementById('bild');
    var box =  document.getElementById('box_image');
    
    if(bild && box) { bild.style.marginTop = ((box.offsetHeight - bild.offsetHeight) / 2)+"px"; }
    if(bild.offsetTop == "1") { bild.style.marginTop = "0px"; }
}

/*
function setBG()
{
    var rnd = GetRandom(1,29);
    for(i=1;i<=3;i++)
    {        
        document.getElementById('rndbg'+i).style.backgroundImage = 
            'url(./grafik/1024/Backgrounds_neu/'+rnd+'_'+i+'.jpg)';
    }   
}
*/

/* ----------------------------------------------------------------------------------- */
/* Box-Schliessen Button */
/* ----------------------------------------------------------------------------------- */
function setClose() 
{ 
    var color;
    var close = document.getElementById('close');
    
    if(document.getElementById('box')) { color = "Braun"; }
    if(document.getElementById('box_braun')) { color = "Weiss"; }
    if(close) { close.src = "grafik/"+iWidth+"/buttons/Schliessen_"+color+"_off.png"; }
}

function closeOn() 
{
    var close = document.getElementById('close');
    var color;
    
    if(close.src.indexOf("Weiss") > -1) { color = "Weiss"; } else { color = "Braun"; }
    close.src = 'grafik/'+iWidth+'/buttons/Schliessen_'+color+'_on.png';  
}

function closeOff()
{
    var close = document.getElementById('close');
    var color;
    
    if(close.src.indexOf("Weiss") > -1) { color = "Weiss"; } else { color = "Braun"; }
    close.src = 'grafik/'+iWidth+'/buttons/Schliessen_'+color+'_off.png';   
}

function closeBox() { document.getElementById('boxposition').style.display="none"; }

/* ----------------------------------------------------------------------------------- */


/* ----------------------------------------------------------------------------------- */
/* Box-Minimieren Button */
/* ----------------------------------------------------------------------------------- */
function setMinimize()
{
    var minimize = document.getElementById('minimize');
    var minimize1 = document.getElementById('minimize1');
    var color, state;
     
    if(document.getElementById('box')) { color = "Braun"; }
    if(document.getElementById('box_braun')) { color = "Weiss"; }

    if(minimize1) { minimize1.src = "grafik/"+iWidth+"/buttons/Maximieren_Braun_off.png"; }
    if(minimize) 
    { 
        if(minimize.src.indexOf("Minimieren_") > -1) { state = "Minimieren_"; } else { state = "Maximieren_"; }
        minimize.src = "grafik/"+iWidth+"/buttons/"+state+color+"_off.png"; 
    }
}
function minimizeBox(boxmargin, boxwidth, boxheight, menumargin, fromanimatebox)
{  
    var box = document.getElementById('box');
    var boxrand = document.getElementById('boxrand');

    var menu = document.getElementById('boxmenu');
    var image = document.getElementById('boximage');
    var content = document.getElementById('boxcontent');
    var minimize = document.getElementById('minimize'); 
    var documents = document.getElementById('documents');
    
    if(documents == null) 
    {
        for(var i=0; (t=document.getElementsByTagName('DIV')[i]); i++) 
        {
            if(t.id.indexOf("_documents") > -1) { documents = t; } 
        }
    }
    
    var position = document.getElementById('boxposition');
    
    document.getElementById('box_container').style.overflow = "auto";
    document.getElementById('box_container').style.height = "";
    document.getElementById('box_container').style.position = "static";

    window.clearTimeout(boxtimer);
    
    if(content.style.display == "none")
    {
        resetMinimizeImg(minimize,1, true);

        position.style.marginTop = boxmargin + "px";
        
        box.style.height = boxheight + "px";
        box.style.width = boxwidth + "px";

        boxrand.style.height = (boxheight-2) + "px";    
        boxrand.style.width = (boxwidth-2) + "px";
        
        if(menu) { menu.style.marginLeft = menumargin + "px"; }
        
        if(image) { image.style.display = "block"; }
        if(documents && documents.innerHTML.indexOf("pluginContent/dokumente") > -1) { documents.style.display = "block"; }
    
        content.style.display = "block";
        if(document.getElementById('scrollbox')&&document.getElementById('scrollbox').childNodes.lengh>0){
            document.getElementById('scrollbox').childNodes[0].style.height = document.getElementById('scrollbox').style.height;
        }
        
        boxtimer = window.setTimeout("setBoxHeight("+boxheight+",1);",300);
    }
    else
    {
        var change = !fromanimatebox;
        resetMinimizeImg(minimize,1, change);
        
        if(iWidth == "1280")
        {
            if(gWidth == "1680") {position.style.marginTop = "622px";}
            else                 {position.style.marginTop = "532px";}
            
            box.style.height = "44px";
            boxrand.style.height = "42px";
            
            if(menu) { menu.style.marginLeft = "33px"; }
        }
        else if(iWidth == "1680")
        {        
            position.style.marginTop = "616px";
            box.style.height = "50px";
            boxrand.style.height = "48px";
            
            if(menu) { menu.style.marginLeft = "40px"; }
        }
        else
        {
            if(gWidth == "1280")
            {position.style.marginTop = "542px";}        
            else
            {position.style.marginTop = "446px";}
            
            box.style.height = "34px";
            boxrand.style.height = "32px";
            
            if(menu) { menu.style.marginLeft = "30px"; }
        }
        
        box.style.width = boxwidth + "px";
        boxrand.style.width = (boxwidth-2) + "px";
         
        if(image) { image.style.display = "none"; }        
        if(documents && documents.innerHTML.indexOf("pluginContent/dokumente") > -1) { documents.style.display = "none"; }     
        
        content.style.display = "none";
        
    }
}

var boxtimer;

var boxcounter = 0;

function setBoxHeight(boxheight,val) 
{
    if(document.getElementById('boxcontent').style.display != "none") {
        document.getElementById('box').style.height = (boxheight-1)+"px";
        document.getElementById('boxrand').style.height = (boxheight-3)+"px";
        document.getElementById('box').style.height = (boxheight)+"px";
        document.getElementById('boxrand').style.height = (boxheight-2)+"px";
        boxcounter++;
        if(boxcounter < 20)
            boxtimer = window.setTimeout("setBoxHeight("+boxheight+","+(val+1)+");",300);
        else if(document.getElementById('scrollbox')){
            document.getElementById('scrollbox').childNodes[0].style.height = document.getElementById('scrollbox').style.height;
        }
    }
}

function resetMinimizeImg(obj,val,changestate)
{
    var color, highlight, state;
    
    if(obj.src.indexOf("Weiss") > -1)       { color = "Weiss"; } else { color = "Braun"; }
    if(obj.src.indexOf("Minimieren_") > -1) { state = "Minimieren_"; } else { state = "Maximieren_"; }
    if(obj.src.indexOf("_off") > -1)        { highlight = "_on"; } else { highlight = "_off"; }

    if(changestate) { if(obj.src.indexOf("Minimieren_") > -1) { state = "Maximieren_"; } else { state = "Minimieren_"; } }

    if(val == 1) 
    { obj.src = 'grafik/'+iWidth+'/buttons/'+state+color+'_off.png'; }
    else
    { obj.src = 'grafik/'+iWidth+'/buttons/'+state+color+'_on.png'; }
}
/* ----------------------------------------------------------------------------------- */

var sprungval = 40;

function animateBox(boxmargin, boxwidth, boxheight, menumargin, first) 
{
    var box = document.getElementById('box');
    var boxrand = document.getElementById('boxrand');

    var menu = document.getElementById('boxmenu');
    var image = document.getElementById('boximage');
    var content = document.getElementById('boxcontent');  
    var documents = document.getElementById('documents');
    var position = document.getElementById('boxposition');
    
    if(first) 
    {
        minimizeBox(boxmargin, boxwidth, boxheight, menumargin, true);
        window.setTimeout("blendIn("+boxmargin+","+boxwidth+","+boxheight+","+menumargin+",19)",700);
    }
}

function showNews()
{
    var news = document.getElementById('neuheiten');
    var title = document.getElementById('intro');
    
    title.style.display = "none";
    news.style.display = "block";
    
    var box_news =          document.getElementById('box_news');
    var boxrand_news =      document.getElementById('boxrand_news');
    
    resetBox(box_news, boxrand_news);
    
    document.getElementById('bild').style.marginTop = (document.getElementById('box_image').offsetHeight - document.getElementById('bild').offsetHeight) / 2;    
    
    setNews(iWidth, true);
}

function blendIn(boxmargin, boxwidth, boxheight, menumargin, time) 
{
    if(document.getElementById("boxcontent").style.display == "none" || time < 19) {
        if(time >= 19) {
            minimizeBox(boxmargin, boxwidth, boxheight, menumargin);
            return;
        //    document.getElementById("boxcontent").style.display = "none";
            window.setTimeout("blendIn("+boxmargin+","+boxwidth+","+boxheight+","+menumargin+","+(time-1)+")",50);
            return;
        } 
        else {
       //     document.getElementById("boxcontent").style.display = "block";
        }
        
        var texts = null;
        for(var i=0; (t=document.getElementsByTagName('DIV')[i]); i++) {
            if(t.className.indexOf("box_text") > -1) {
                texts = t;
            } 
        }
        
        if(time <= 0) {
            texts.className = "box_text";
        } else {
            texts.className = "box_text header"+time;
            window.setTimeout("blendIn("+boxmargin+","+boxwidth+","+boxheight+","+menumargin+","+(time-2)+")",15);
        }
    }
}

function GetRandom( min, max ) 
{        
    if( min > max ) 
    {
        return( -1 );
    }
    if( min == max ) 
    {
        return( min );
    }

    return( min + parseInt( Math.random() * ( max-min+1 ) ) );
} 

var region = "";
var oldid = "-1";
var oldoptiker = "--";
var donothing = false;

function showRegion(select, right, mouseout, optiker,id)
{
    var selected = document.getElementById("region"+select);
    if(!mouseout) 
    {
        document.getElementById("optikervorschau").innerHTML = optiker;
        selected.style.fontWeight = "bold";
        
    } else { selected.style.fontWeight = "normal"; }
}

function changeNothing() { donothing = false; }

function changeImg(over)
{
    var members = document.getElementById('members');
    
    var path = 'grafik/1024/Transparente_Felder/';
    var image;
    
    if(over == 1)
    {
        image = path + 'background_1_Memberliste_roll_over.jpg';
    }
    else
    {
       image = path + 'background_1_Memberliste.jpg';
    }
    members.src = image;
}

var showmap;
var showpopup;
var showbigbox;

function showPopup()
{
    var venergy = document.getElementById('venergy');
    venergy.style.display = "none";

    var popup = document.getElementById('popup');
    var box = document.getElementById('box');
    
    if(showpopup)
    {
        box.style.display  = "block";
        popup.style.display  = "none";
        showpopup = false;
    }
    else
    {
        box.style.display  = "none";
        popup.style.display  = "block";
        showpopup = true;
    }
}

function showMap()
{
    var venergy = document.getElementById('venergy');
    venergy.style.display = "none";

    var map = document.getElementById('map');
       
    if(showmap)
    {
        map.style.display  = "none";
        showmap = false;
    }
    else
    {
        map.style.display  = "block";
        showmap = true;
    }
    
}

function showBigbox()
{
    var box = document.getElementById('box');
    var bigbox = document.getElementById('bigbox');
    
    if(showbigbox)
    {
        box.style.display = "block";
        bigbox.style.display  = "none";
        showbigbox = false;
    }
    else
    {
        box.style.display  = "none";
        bigbox.style.display  = "block";
        showbigbox = true;
    }
}

var oldobj = null;
var oldval = null;

function checkText(obj,value) { 
    if(obj.value == value) {
        if(oldobj != null && oldobj.value == "") {
            oldobj.value = oldval;
        }
        oldobj = obj;
        oldval = obj.value;
        obj.value = "";
    }
}

var animationcnt = 0;

function startTitelAnimation(val) {
//    if(parseInt(titelbildgr.width) == 0) {
//        window.setTimeout("startTitelAnimation()",100);
//    } else {
//        animationcnt++;
//        if(animation_visualenergy.style.left == "")
//            animation_visualenergy.style.left = "-500";
//        animation_visualenergy.style.left = (parseInt(animation_visualenergy.style.left)+3);
//        
//        if(animationcnt > 4 && parseInt(animation_visualenergy.style.left) > -350) {
//            if(parseInt(titelbildgr.width) > 99){
//                titelbildgr.width = (parseInt(titelbildgr.width)-2);
//                if(parseInt(titelbildgr.width) < 106)
//                    titelbildgr.style.padding = "1px";
//            } 
//            animationcnt = 0;
//        }
//        
//        if(parseInt(animation_visualenergy.style.left) < 520) {
//            if(navigator.appName.indexOf("MSIE") > -1)
//                window.setTimeout("startTitelAnimation()",5);
//            else window.setTimeout("startTitelAnimation()",15);
//        } else {    
//        }
//    }
    var logoanimation = document.getElementById('logoanimation')
    if(val == 19)
        logoanimation.style.display = "block";
    if(val == 0)
        logoanimation.className = "";
    else {
        logoanimation.className = "header"+val;
        window.setTimeout("startTitelAnimation("+(val-1)+")",80);
    }
        
}

function showVisuskl() {
    document.getElementById('logoanimation').style.display = "none";
}

function showSuche() {
    if(window.location.href.toLowerCase().indexOf("neuheiten.aspx") > -1 || window.location.href.toLowerCase().indexOf("galerie.aspx") > -1 || window.location.href.toLowerCase().indexOf("offenestellen.aspx") > -1)
        closeBox();
    document.getElementById('suchcontainer').style.display = 'block';
    document.getElementById(suchclient+'_txtSuche').select();
    document.getElementById(suchclient+'_txtSuche').focus();
}

function closeSuchBox() {
    document.getElementById('suchcontainer').style.display = 'none';
    document.getElementById(suchclient+'_txtSuche').value = "";
}



/**
	 * Get XY position of an element in the document
	 * This function is browser independent!
	 */
	function getXY(contentElem)
	{
      var parent = null;
      var pos = [];
      var box;

	  // IE
      if (contentElem.getClientRect) 
      {
         box = contentElem.getClientRects();
                  
         var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
         var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
         
//        alert(contentElem.id);
//        alert(box.left +' : ' + scrollLeft + ' : ' + box.top + ' : ' + scrollTop);
         return [box.left + scrollLeft, box.top + scrollTop];
      }
      
    // gecko
    /*
    * doesn't work in firefox 
    * [Exception... "Node cannot be used in a document other than the one in
    * which it was created" code: "4" nsresult: "0x80530004
    * (NS_ERROR_DOM_WRONG_DOCUMENT_ERR)" location:
    * "file:///H:/@New/Projects/GmgBuch/XMLEditor/JavaScript/Editor/XMLDocument.js
    * Line: 720"]
    *
    * 
      else if (document.getBoxObjectFor) {
         box = document.getBoxObjectFor(contentElem);
         pos = [box.x, box.y];
      }
    */
      
      // safari/opera
      else { return [contentElem.offsetLeft, contentElem.offsetTop]; }

      if (contentElem.parentNode) { parent = contentElem.parentNode; }
      else { parent = null; }

      while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') {
         pos[0] -= parent.scrollLeft;
         pos[1] -= parent.scrollTop;

         if (parent.parentNode) { parent = parent.parentNode; }
         else { parent = null; }
      }
      return pos;
   }


var hidecontent = false;

function showSubContext() 
{
    var submenu = $('unteressubmenu');
    var button = $('pullupbutton');

    submenu.style.display = "block";
    
    /*var aktscrolldiv;
    if(document.getElementById("scrollbox") != null) 
    { aktscrolldiv = document.getElementById("scrollbox"); }
    else 
    {
        for(var i=0; (k=document.getElementsByTagName("DIV")[i]); i++) 
        {
            if(k.id.indexOf("_scrollbox") > -1) 
            {
                aktscrolldiv = k;
                break;
            }
        }
    }*/

    if(typeof(relvalue) != 'undefined')
    {
        if(navigator.appVersion.indexOf("MSIE") > -1)
        {
            submenu.style.marginTop = relvalue - (submenu.offsetHeight + button.offsetHeight) - 32 + "px";
            submenu.style.marginLeft = button.offsetLeft + 14 + "px";        
        }
        else
        {
            submenu.style.marginTop = relvalue - (submenu.offsetHeight + button.offsetHeight) - 22 + "px";
            submenu.style.marginLeft = button.offsetLeft + 52 + "px";        
        }
    }
    else
    {
        submenu.style.marginTop = button.offsetTop - submenu.offsetHeight + 14 + "px";
        submenu.style.marginLeft = button.offsetLeft + (submenu.offsetWidth - button.offsetWidth) - 8 + "px";
    }
    
    
//    try{
//        //document.getElementById("unteressubmenu").style.marginTop = (parseInt(aktscrolldiv.style.height)-((-1)*(document.getElementById("unteressubmenu").childNodes.length*20))-102)+"px";
//    }catch(e) { document.getElementById("boxcontent").style.marginTop = (parseInt(document.getElementById("boxcontent").style.height)-((-1)*(document.getElementById("unteressubmenu").childNodes.length*20))-11)+"px"; }

    /*var titel = document.getElementById('titel');
    
    var margintop, marginleft;

    if(iWidth == "1024") { margintop=260; marginleft=472;
    
        if(gWidth == "1024") { marginleft=442; }
    
        if(titel) 
        {
            if(iWidth!=gWidth) {margintop=428; marginleft=470;}
            else               {margintop=428; marginleft=434;}
        }
    }
    if(iWidth == "1280") { margintop=304; marginleft=560; 
        if(titel)
        { 
            if(iWidth!=gWidth){margintop=514; marginleft=570;}
            else              {margintop=514; marginleft=556;}
        }
    }
    
    //alert(margintop+', '+marginleft);
    
    if(iWidth == "1680") { if(titel) {margintop=594; marginleft=598;} else {margintop=354; marginleft=622;} }
    
    document.getElementById("unteressubmenu").style.marginTop = (margintop - (document.getElementById("unteressubmenu").childNodes.length*23))+ "px";
    document.getElementById("unteressubmenu").style.marginLeft = marginleft + "px";*/
    
    hidecontent = false;
}

function hideSubContext() { hidecontent = true; window.setTimeout("hideSub()",300); }
function hideSub() { if(hidecontent) document.getElementById("unteressubmenu").style.display = "none"; }

function showOverlay(src, nid, bid, auswahl, reiter)
{
    if(navigator.appName == "Netscape")
    {
        document.getElementById("divOverlay2").style.display = "block";
        document.getElementById("flashFrame2").src = "http://www.visus.ch/video/federer/showFLV.aspx?src="+src+"&res="+gWidth+"&nid="+nid+"&bid="+bid+"&auswahl="+auswahl+"&reiter="+reiter;                    
    }
    else
    {
        document.getElementById("divOverlay").style.display = "block";
        document.getElementById("flashFrame").src = "http://www.visus.ch/video/federer/showFLV.aspx?src="+src+"&res="+gWidth+"&nid="+nid+"&bid="+bid+"&auswahl="+auswahl+"&reiter="+reiter;        
    }
}