//Browser = Firefox?
var isFirefox = false;
var actAgentStr = navigator.userAgent;  
var nrSearch1 = actAgentStr.indexOf("Gecko");
var nrSearch2 = actAgentStr.indexOf("Firefox");
if (nrSearch1 >= 0 && nrSearch2 >= 0){
    isFirefox = true;
}
var newTerminId = 0;
var doNoTransform = false;

Function.prototype.bind = function(object) {
    var __method = this;
    return function() {
        return __method.apply(object, arguments);
    }
}

function initSingleBox(id, detail) {
    if (!this.oBoxes) {
        initBoxes()
    }
    
    if (document.getElementById('scrollTitle_' + id)) {
        var aktNode = document.getElementById('scrollTitle_' + id);
        this.oBoxes[id] = new Box(aktNode, detail, false, false, false, false, false, false, false, false);
    }
    if (document.getElementById('scrollTitleAfh_' + id)) {
        var aktNode = document.getElementById('scrollTitleAfh_' + id);
        this.oBoxesAfh[id] = new Box(aktNode, detail, false, true, false, false, false, false, false, false);
    }   
    if (document.getElementById('scrollTitleHbw_' + id)) {
        var aktNode = document.getElementById('scrollTitleHbw_' + id);
        this.oBoxesHbw[id] = new Box(aktNode, detail, true, false, false, false, false, false, false, false);
    }     
    if (document.getElementById('scrollTitleClip_' + id)) {
        var aktNode = document.getElementById('scrollTitleClip_' + id);
        this.oBoxesClip[id] = new Box(aktNode, detail, false, false, false, false, false, false, false, true);
    }     
    if (document.getElementById('scrollTitleFz_' + id)) {
        var aktNode = document.getElementById('scrollTitleFz_' + id);
        this.oBoxesFz[id] = new Box(aktNode, detail, false, false, true, false, false, false, false, false);
    }   
    if (document.getElementById('scrollTitleMf_' + id)) {
        var aktNode = document.getElementById('scrollTitleMf_' + id);
        this.oBoxesMf[id] = new Box(aktNode, detail, false, false, false, true, false, false, false, false);
    }    
    if (document.getElementById('scrollTitleSki_' + id)) {
        var aktNode = document.getElementById('scrollTitleSki_' + id);
        this.oBoxesSki[id] = new Box(aktNode, detail, false, false, false, false, true, false, false, false);
    } 
    if (document.getElementById('scrollTitleKli_' + id) && $('btnTableWeather_'+id) != null) {
        var aktNode = document.getElementById('scrollTitleKli_' + id);
        this.oBoxesKli[id] = new Box(aktNode, detail, false, false, false, false, false, true, false, false);
    }
    if (document.getElementById('scrollTitleThumb_' + id)) {
        var aktNode = document.getElementById('scrollTitleThumb_' + id);
        this.oBoxesThumb[id] = new Box(aktNode, detail, false, false, false, false, false, false, true, false);
    }      
}

//_________________________________________________________________________________________________
function initBoxes() { 

    if (!this.oBoxes) {
        this.oBoxes = new Object();
    }
    if (!this.oBoxesHbw) {
        this.oBoxesHbw = new Object();
    }
    if (!this.oBoxesClip) {
        this.oBoxesClip = new Object();
    }
    if (!this.oBoxesAfh) {
        this.oBoxesAfh = new Object();
    }     
    if (!this.oBoxesFz) {
        this.oBoxesFz = new Object();
    }  
    if (!this.oBoxesMf) {
        this.oBoxesMf = new Object();
    }      
    if (!this.oBoxesSki) {
        this.oBoxesSki = new Object();
    }
    if (!this.oBoxesKli) {
        this.oBoxesKli = new Object();
    }         
    if (!this.oBoxesThumb) {
        this.oBoxesThumb = new Object();
    }         
       
    var aktNode;
    var i = 0;
    var j = 0;
    
    if (detail == 'zielgebiet' && typeof(nrAllRegs)!='undefined') {
        nrAllRegs = parseInt(nrAllRegs); 
        while(i < nrAllRegs) {
             if (document.getElementById("scrollTitle_" + (i)) != null){
                aktNode = document.getElementById("scrollTitle_" + (i));                
                this.oBoxes[i] = new Box(aktNode, detail, false, false, false, false, false, false, false, false);
             } 
             if (document.getElementById("scrollTitleKli_" + (i)) != null && $('btnTableWeather_'+(i)) != null){
                aktNode = document.getElementById("scrollTitleKli_" + (i));                
                this.oBoxesKli[i] = new Box(aktNode, detail, false, false, false, false, false, true, false, false);
             }         
             i++;
        }
    }
    else{
        var titleName = 'scrollTitle_';
        
        if (nurflug == '1') {
            titleName = 'scrollTitleAfh_';
        } 
        
        while(aktNode = document.getElementById(titleName + (i))) {
             this.oBoxes[i] = new Box(aktNode, detail, false, false, false, false, false, false, false, false);   
             i++;
        }
    }
    
    if (detail == 'hotel') {
        for (j = 0; j <= i; j++) {
            if (document.getElementById("scrollTitleHbw_" + (j))) {
                aktNode = document.getElementById("scrollTitleHbw_" + (j));
                this.oBoxesHbw[j] = new Box(aktNode, detail, true, false, false, false, false, false, false, false);
            }
            if (document.getElementById("scrollTitleClip_" + (j))) {
                aktNode = document.getElementById("scrollTitleClip_" + (j));
                this.oBoxesClip[j] = new Box(aktNode, detail, false, false, false, false, false, false, false, true);
            }
            if (document.getElementById("scrollTitleThumb_" + (j))) {
                aktNode = document.getElementById("scrollTitleThumb_" + (j));
                this.oBoxesThumb[j] = new Box(aktNode, detail, false, false, false, false, false, false, true, false);
            }
        }
    }
    if (detail == 'termine') {
        //Abflughafeninfos
        for (j = 0; j <= i; j++) {
            if (document.getElementById("scrollTitleAfh_" + (j))) {
                aktNode = document.getElementById("scrollTitleAfh_" + (j));
                this.oBoxesAfh[j] = new Box(aktNode, detail, false, true, false, false, false, false, false, false);
            }
            if (document.getElementById("scrollTitleMf_" + (j))) {
                aktNode = document.getElementById("scrollTitleMf_" + (j));
                this.oBoxesMf[j] = new Box(aktNode, detail, false, false, false, true, false, false, false, false);
            }            
        }
        
        /* obere StartBox */
        initSingleBox('105', detail); 
               
    } 
    if (detail == 'buchung') {
        //Abflughafeninfos + Flugzeiten
        for (var bs = 0; bs < 2; bs++) {
            if (document.getElementById("scrollTitleAfh_" + (bs))) {
                aktNode = document.getElementById("scrollTitleAfh_" + (bs));
                this.oBoxesAfh[bs] = new Box(aktNode, detail, false, true, false, false, false, false, false, false);
            }
            //Flugzeiten
            if (document.getElementById("scrollTitleFz_" + (bs))) {
                aktNode = document.getElementById("scrollTitleFz_" + (bs));
                this.oBoxesFz[bs] = new Box(aktNode, detail, false, false, true, false, false, false, false, false);
            }
        }         
    }    
    
    /* Merkzettel? */
    if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {              
        for (j = 0; j < 5; j++) { 
            if (document.getElementById("scrollTitle_" + (j))) {
                aktNode = document.getElementById("scrollTitle_" + (j));
                this.oBoxes[j] = new Box(aktNode, detail, false, false);                
            }
            if (document.getElementById("scrollTitleHbw_" + (j))) {
                aktNode = document.getElementById("scrollTitleHbw_" + (j));
                this.oBoxesHbw[j] = new Box(aktNode, detail, true, false);                
            }
            if (document.getElementById("scrollTitleTH_" + (j))) {
                aktNode = document.getElementById("scrollTitleTH_" + (j));
                this.oBoxes[j] = new Box(aktNode, detail, false, false);                
            }
            if (document.getElementById("scrollTitleHbwTH_" + (j))) {
                aktNode = document.getElementById("scrollTitleHbwTH_" + (j));
                this.oBoxesHbw[j] = new Box(aktNode, detail, true, false);                
            }            
            if (document.getElementById("scrollTitleFO_" + (j))) {
                aktNode = document.getElementById("scrollTitleFO_" + (j));
                this.oBoxes[j] = new Box(aktNode, detail, false, false);    
                this.oBoxes[j].isFewoObject = 1;             
            }
        }          
    }      
    
}
var aktOpenBoxId  = -1;
var openedIsHbw   = false;
var openedIsClip  = false;
var openedIsAfh   = false;
var openedIsFz    = false;
var openedIsMf    = false;
var openedIsSki   = false;
var openedIsKli   = false;
var openedIsThumb = false;
//_________________________________________________________________________________________________
function closeOtherAndShow(Box) {  
    if(Box.stepper){
        window.clearInterval(Box.stepper);
        Box.stepper = null;
    }
    
    if (aktOpenBoxId >= 0) {        
        if (openedIsHbw) {
            this.oBoxesHbw[aktOpenBoxId].hide();
            this.oBoxesHbw[aktOpenBoxId].setOtherBoxTitleOnHide();
        } else if (openedIsClip) {
            this.oBoxesClip[aktOpenBoxId].hide(); 
            this.oBoxesClip[aktOpenBoxId].setOtherBoxTitleOnHide();
        } else if (openedIsAfh) {
            this.oBoxesAfh[aktOpenBoxId].hide(); 
            this.oBoxesAfh[aktOpenBoxId].setOtherBoxTitleOnHide(); 
        } else if (openedIsFz) {
            this.oBoxesFz[aktOpenBoxId].hide(); 
            this.oBoxesFz[aktOpenBoxId].setOtherBoxTitleOnHide();        
        } else if (openedIsMf) {
            this.oBoxesMf[aktOpenBoxId].hide(); 
            this.oBoxesMf[aktOpenBoxId].setOtherBoxTitleOnHide();      
        } else if (openedIsSki) {
            this.oBoxesSki[aktOpenBoxId].hide(); 
            this.oBoxesSki[aktOpenBoxId].setOtherBoxTitleOnHide();   
        } else if (openedIsKli) {
            this.oBoxesKli[aktOpenBoxId].hide(); 
            this.oBoxesKli[aktOpenBoxId].setOtherBoxTitleOnHide();
        } else if (openedIsThumb) {
            this.oBoxesThumb[aktOpenBoxId].hide(); 
            this.oBoxesThumb[aktOpenBoxId].setOtherBoxTitleOnHide();
        } else {
            this.oBoxes[aktOpenBoxId].hide();
            this.oBoxes[aktOpenBoxId].setOtherBoxTitleOnHide();
        }
    }
    //alert('closeOtherAndShow:\naktOpenBoxId='+aktOpenBoxId+'\nboxId='+Box.boxId+'\nopenedIsHbw='+openedIsHbw+'\nisHbw='+Box.isHbw+'\nopenedIsThumb='+openedIsThumb+'\nisThumb='+Box.isThumb+'\n'+detail); 
    if ((aktOpenBoxId != Box.boxId) || 
        (openedIsHbw != Box.isHbw && Box.isHbw==true && detail != 'termine') || 
        (openedIsHbw != Box.isHbw && detail == 'termine') || 
        (openedIsClip != Box.isClip && Box.isClip == true) || 
        (openedIsAfh != Box.isAfh) || 
        (openedIsFz != Box.isFz) || 
        (openedIsMf != Box.isMf) || 
        (openedIsSki != Box.isSki) || 
        (openedIsKli != Box.isKli && Box.isKli == true) || 
        (openedIsThumb != Box.isThumb && Box.isThumb == true)) {        
            //alert(openedIsHbw+'/'+Box.isHbw+'\n'+openedIsAfh+'/'+Box.isAfh+'\n'+openedIsFz+'/'+Box.isFz+'\n'+openedIsMf+'/'+Box.isMf+'\n'+openedIsSki+'/'+Box.isSki+'\n'+openedIsThumb+'/'+Box.isThumb);        
            openedIsAfh   = Box.isAfh;        
            openedIsFz    = Box.isFz;        
            openedIsMf    = Box.isMf;        
            openedIsSki   = Box.isSki; 
            if(detail == 'zielgebiet' && aktOpenBoxId == Box.boxId && aktOpenBoxId >= 0 && openedIsKli){
                aktOpenBoxId  = Box.boxId;
                openedIsKli = Box.isKli;    
            /*
            } else if(detail == 'hotel' && aktOpenBoxId == Box.boxId && aktOpenBoxId >= 0 && openedIsHbw) {
                aktOpenBoxId  = Box.boxId;
                openedIsHbw   = Box.isHbw; 
            } else if(detail == 'hotel' && aktOpenBoxId == Box.boxId && aktOpenBoxId >= 0 && openedIsClip) {
                aktOpenBoxId  = Box.boxId;
                openedIsClip  = Box.isClip;
            */
            } else if(detail == 'hotel' && aktOpenBoxId == Box.boxId && aktOpenBoxId >= 0 && openedIsThumb) {
                aktOpenBoxId  = Box.boxId;
                openedIsThumb = Box.isThumb;    
            } else {
                aktOpenBoxId  = Box.boxId;
                openedIsKli   = Box.isKli;
                openedIsHbw   = Box.isHbw;
                openedIsClip  = Box.isClip;
                openedIsThumb = Box.isThumb;
                window.setTimeout(function(){Box.show()}.bind(this),100);
                Box.setThisBoxTitleOnShow(Box.isAlt);    
            }
    } else{
        //Box.hide();
        //Box.setThisBoxTitleOnHide();
        aktOpenBoxId = -1;
    } 
          
}
//_________________________________________________________________________________________________
function Box(BoxTitle, detail, isHbw, isAfh, isFz, isMf, isSki, isKli, isThumb, isClip){
    this.title      = BoxTitle;  
    this.detail     = detail;
    this.showEffect = "1";
    this.hideEffect = "1";
    var aktNode     = this.title;    
    var tmpId       = aktNode.getAttribute("id").split('_');
    
    this.boxId = tmpId[1];
    if (this.boxId >= '90') { // Alle zusätzlichen Boxen auf der Termin-Seite
        this.hasScrollLine = "0";
    } else {
        this.hasScrollLine = "1";
    }
    
    this.isHbw   = isHbw;
    this.isClip  = isClip;
    this.isAfh   = isAfh;
    this.isFz    = isFz;
    this.isMf    = isMf;
    this.isSki   = isSki;
    this.isKli   = isKli;
    this.isThumb = isThumb;
    
    //alert(isThumb);
    
    /* Setzen der ursprünglichen Klassen-Eigenschaften der geklickten Zeile */
    if (this.hasScrollLine == "1") {
        this.setOldClassesOfBox();
    }
    
    if (isHbw) {
        this.box = document.getElementById('scrollContentHbw_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomHbw_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkHbw_' + this.boxId);
    } else if (isClip) {
        this.box = document.getElementById('scrollContentClip_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomClip_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkClip_' + this.boxId);
    } else if (isAfh) {
        this.box = document.getElementById('scrollContentAfh_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomAfh_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkAfh_' + this.boxId);
    } else if (isFz) {
        this.box = document.getElementById('scrollContentFz_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomFz_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkFz_' + this.boxId);      
    } else if (isMf) {
        this.box = document.getElementById('scrollContentMf_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomMf_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkMf_' + this.boxId);     
    } else if (isSki) {
        this.box = document.getElementById('scrollContentSki_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomSki_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkSki_' + this.boxId);                  
    } else if (isKli) {
        this.box = document.getElementById('scrollContentKli_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomKli_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkKli_' + this.boxId);
    } else if (isThumb) {
        this.box = document.getElementById('scrollContentThumb_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottomThumb_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLinkThumb_' + this.boxId);
    } else {
        this.box = document.getElementById('scrollContent_' + this.boxId);
        this.boxBottom = document.getElementById('scrollContentBottom_' + this.boxId);
        this.closeLink = document.getElementById('scrollCloseLink_' + this.boxId);
    }
    
    this.title.onclick=function(){   
            closeOtherAndShow(this);
        }.bind(this);

    if (this.closeLink) {
        this.closeLink.onclick=function(){
                closeOtherAndShow(this);
            }.bind(this);        
    }
}
//_________________________________________________________________________________________________
Box.prototype.hide = function(){
    //alert('hide');
    if(this.hideEffect!=""){
        this.transform(this.box.offsetHeight,0);
        //this.transform(Box.BoxDefaultHeight,0);
    }else{
        this.box.style.height="0px";
    }
    
    this.box.style.display = 'none';
    this.boxBottom.style.display = 'none';
    this.box.style.margin="0px";
    this.box.style.padding="0px";
         
    if (this.detail == 'zielgebiet'){
        isOpenScroll = '-1';        
        if (!this.isKli) {
            var elem = document.getElementById('scrollSpecBtn_'+this.boxId);
            elem.innerHTML = genSpecBtnTable(this.boxId, 0);
            //this.title.innerHTML = genSpecBtnTable(this.boxId, 0);
        }  
        if($('btnTableWeather_'+this.boxId) != null) {
            var tmpCacheScrollW = scrollCacheWeather[this.boxId].split("#");
            var elemW = document.getElementById('scrollKlimaBox_'+this.boxId);
            elemW.innerHTML = genWeatherBtnTable(this.boxId, tmpCacheScrollW[0], tmpCacheScrollW[1], 0);
            outBtnTableWeather(this.boxId);    
        }   
        outBtnTable(this.boxId); 
        $('scrollLine_'+this.boxId).className = 'tt_regTabAct';        
        imgInact(this.boxId);
    } else if (this.detail == 'hotel'){
        isOpenScroll = '-1';        
        if (!this.isHbw && !this.isThumb && !this.isClip) {
            var elem = document.getElementById('scrollSpecBtn_'+this.boxId);
            elem.innerHTML = genSpecBtnTable(this.boxId, 0);
            
            //this.title.innerHTML = genSpecBtnTable(this.boxId, 0);
        }
        outBtnTable(this.boxId);
    } else if (this.detail == 'buchung'){
        this.title.innerHTML = genSpecBtnTableBooking(0, this.title.id);
        var tmpTitle = this.title.id; 
        if (tmpTitle.indexOf('scrollTitleAfh_') >= 0) {            
            outBtnTable('airport_'+this.boxId);              
        } else if (tmpTitle.indexOf('scrollTitleFz_') >= 0) {            
            outBtnTable('flytime_'+this.boxId);              
        }                 
    }        
}
//_________________________________________________________________________________________________
/*
    Funktion ermittelt die Position eines Elements anhand seiner Elternelement
    Parameter: ein Element (z.B. ermittelt durch getElementById
    Rückgabewert: ein Positionselement
*/
function getPosition(element)
{
    
    
  var elem=element,tagname="",x=0,y=0;        
  
  if ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined"))  
  {
    y+=elem.offsetTop;
    x+=elem.offsetLeft;
    tagname=elem.tagName.toUpperCase();

    if (tagname=="BODY" || tagname == 'HTML')
      elem=0;

    if (typeof(elem)=="object")
      if (typeof(elem.offsetParent)=="object")
        elem=elem.offsetParent;
        
  }

  position=new Object();
  position.x=x;
  position.y=y;
  return position;
}
//_________________________________________________________________________________________________
Box.prototype.show = function(){    
    if(this.showEffect!=""){
        if(!doNoTransform) {
            this.transform(0,Box.BoxDefaultHeight);    
        }        
    }else{
       if (typeof(Box.BoxDefaultHeight) != 'undefined' && Box.BoxDefaultHeight > 0) {           
           this.box.style.height = Box.BoxDefaultHeight + "px";
       }
    }    
    this.box.style.display = 'block';
    this.boxBottom.style.display = 'block';
    if (this.detail == 'zielgebiet'){
        isOpenScroll = this.boxId;
    }
    else if (this.detail == 'hotel'){
        isOpenScroll = this.boxId;
    }
}
//_________________________________________________________________________________________________
Box.prototype.transform = function(from, to){
    this.posStart = from;
    this.posEnd = to;
    this.startTime = (new Date()).getTime();
    this.duration = 300;
    this.stepper = window.setInterval(this.step.bind(this),13);
}
//_________________________________________________________________________________________________
Box.prototype.step = function(){
    var time = (new Date()).getTime();
    if (time >= this.duration+this.startTime) {
        this.box.style.height =  this.posEnd+"px";  
        window.clearInterval(this.stepper);
        this.stepper=null;
    }else {
        var pos = (time - this.startTime) / (this.duration);
        this.box.style.height = String(this.effect(pos)*(this.posEnd-this.posStart)+this.posStart)+"px";        
    }
}
//_________________________________________________________________________________________________
Box.prototype.effect = function(pos){
    return ((-Math.cos(pos*Math.PI)/2) + 0.5);
}

//_________________________________________________________________________________________________
Box.prototype.setOtherBoxTitleOnHide = function(){
    var linkStr = '';
    doNoTransform = false;
    
    switch (this.detail) {
        case 'zielgebiet':
            if (this.isKli) {
                linkStr = 'Wetterinfo';
            } else {
                linkStr = 'Regionsinfo';
            }
            document.getElementById("scrollLine_" + this.boxId).className = this.oldClassName;            
            break;
        case 'hotel':
            if (this.isHbw) {
                linkStr = 'jetzt lesen';
            } else if (this.isClip) {
                linkStr = 'Impressionen';
                document.getElementById('ttHotelClip' + this.boxId).className = 'ttHotelClip';
            } else {
                if (engine == 'fewo') {
                    linkStr = 'Objektinfos';
                } else {
                    linkStr = 'Hotelinfos &amp; Bilder';
                }
            }
            document.getElementById("scrollLine_" + this.boxId).className = this.oldClassName;
            break;
        case 'termine':
            var elemSL = document.getElementById('scrollLine_' + this.boxId);
            elemSL.setAttribute('isActive', '0'); 
            if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
            }else{
                highlightBox(elemSL, false, this.boxId);    
            }
                    
            if (this.boxId == 99) {
                if (typeof(engine) != 'undefined' && engine == 'fewo') {
                    linkStr = 'Länderinfos';
                } else {
                    linkStr = 'Umgebungsinfos';
                }
            } else if(this.boxId == 98) {
                linkStr = 'Bewertung lesen';
            }
            else {
                if (this.isHbw) {
                    linkStr = 'Bewertung lesen';
                } else if (this.isAfh) {
                 //   linkStr = 'Flughafeninfos';
                } else {
                    if (typeof(engine) != 'undefined' && engine == 'fewo') {
                        linkStr = 'Objektinfos';
                    } else {
                        linkStr = 'Hotelinfos';
                    }
                }
            }            
            
            if (typeof(vak_data) != 'undefined') {
                document.getElementById("scrollLine_0").style.backgroundColor = '#FDE4B1';
                if (document.getElementById("scrollLine_0_div")) {
                    document.getElementById("scrollLine_0_div").style.backgroundColor = '#FFF4DD';
                }
                if (typeof(document.getElementById('scrollLineOstfriese_0')) != 'undefined') {
                    document.getElementById('scrollLineOstfriese_0').style.display = 'inline';
                }
                if (isFirefox == 0) {
                    if (this.isHbw) {
                        document.getElementById('scrollLine_0_hbwBottom').style.display = 'none';
                    }
                    else if (this.isAfh) {
                        document.getElementById('scrollLine_0_afhBottom').style.display = 'none';
                    }
                    else {
                        document.getElementById('scrollLine_0_hibBottom').style.display = 'none';
                    }
                }
            } else {
                if (this.hasScrollLine == "1") {
                    document.getElementById("scrollLine_" + this.boxId).className = this.oldClassName + this.boxColor;
                }
                if (isFirefox == 0){
                    if (this.isAfh && document.getElementById('scrollLine_' + this.boxId + '_afhBottom')) {
                        document.getElementById('scrollLine_' + this.boxId + '_afhBottom').style.display = 'none';
                     } else if(this.isHbw){
                         if (document.getElementById('scrollLine_' + this.boxId + '_hbwBottom')) {
                             document.getElementById('scrollLine_' + this.boxId + '_hbwBottom').style.display = 'none';
                         }
                     } else{
                        if (document.getElementById('scrollLine_' + this.boxId + '_hibBottom')) {
                            document.getElementById('scrollLine_' + this.boxId + '_hibBottom').style.display = 'none';
                        }                         
                     }
                }                
            }
            break;
        case 'buchung':            
            if (isFirefox == false) {
                //alert(openedIsAfh+'\n'+openedIsFz);
                document.getElementById('scrollLine_' + this.boxId + '_afhBottom').style.display = 'none'; 
                document.getElementById('scrollLine_' + this.boxId + '_fzBottom').style.display = 'none';
            }
            break;
    }
    
    /* Link wird nach dem Zuklappen gesetzt */
    switch (this.detail) {
        case 'termine':
            var elem = document.getElementById('idBtn_' + this.boxId + '_' + this.title.getAttribute('type'));
            if (elem) {
                elem.setAttribute('status', 'none');
                elem.onclick = onclickSetBtnActive;
                
                var elemPrev = elem.previousSibling;
                var elemNext = elem.nextSibling;
                elemPrev.onclick = onclickSetBtnActive;
                elemNext.onclick = onclickSetBtnActive;
                
                setBorderAroundBox(this.boxId, false);
                
            }
            else {
                /*
                var elemTextLink = document.getElementById('idTextLink_' + this.boxId + '_' + this.title.getAttribute('type'));
                
                if (elemTextLink) {
                    elemTextLink.onclick = onclickTextLinkRefresh;
                }
                */
            }
            
            if (this.isMf) {
                callbackMoreFlights(this.boxId, false);
                var elemPrice = document.getElementById('idTerRowPrice_' + this.boxId);
                if (elemPrice) {
                    elemPrice.style.display = 'block';
                } 
                doNoTransform = true;  
            }
            
            break;
            
        case 'hotel':
            if (this.isHbw) {
                var elem = document.getElementById('scrollHbwBox_'+this.boxId);
                elem.setAttribute('onclick', "refreshContent(\'" + this.boxId + "\', \'hbw\'); imgActScroll(\'" + this.boxId + "\')");
            } if (this.isClip) {
                var elem = document.getElementById('scrollClipBox_'+this.boxId);
                elem.setAttribute('onclick', "refreshContent(\'" + this.boxId + "\', \'4\'); imgActScroll(\'" + this.boxId + "\')");
            } else if (this.isThumb) {
                var elem = document.getElementById('scrollThumbBox_'+this.boxId);
                elem.setAttribute('onclick', "refreshContent(\'" + this.boxId + "\', \'2\'); imgActScroll(\'" + this.boxId + "\')");
            }
            if(engine == 'fewo') {
                if(!this.isThumb) {
                    var elemCont = '';
                    elemCont += '<div class="tt_HotResultInfoButton" onClick="refreshContent(' + this.boxId + ', \'hi\'); imgActScroll(\'' + this.boxId + '\');">';
                    elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId)+'</div>';
                    elemCont += '</div>';
                    this.title.innerHTML = elemCont;    
                }                    
            } else {
                var tmpCacheScroll = scrollCache[this.boxId].split("#");
                var elemCont = '';
                elemCont += '<div class="tt_HotResultInfoButton" onClick="navigate(\'idContent=' + this.boxId + '&prefix=0&time=' + tmpCacheScroll[0] + '&IFF=' + tmpCacheScroll[1] + '\',\'scrollContent_' + this.boxId + '\',\'\',\'reqAllHbs\'); imgActScroll(\'' + this.boxId + '\');">';
                elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId)+'</div>';
                elemCont += '</div>';
                
                if (this.isHbw || this.isThumb || this.isClip) {                
                    var leftScrollTitle = document.getElementById('scrollTitle_'+this.boxId);
                    leftScrollTitle.innerHTML = elemCont;
                } else {                
                    this.title.innerHTML = elemCont;    
                }    
            }
            break;
        case 'zielgebiet':                             
            var regStyleCol = 'tt_reg_colB';
            if(engine == 'fewo') {
                regStyleCol = 'tt_regFewo_colB';
            }
            if(engine == 'fewo') {
                var elemCont = '';
                elemCont += '<div class="'+regStyleCol+'" onClick="refreshContent(' + this.boxId + ', \'reg\'); imgActScroll(\'' + this.boxId + '\');">';
                elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId)+'</div>';
                elemCont += '</div>';
                this.title.innerHTML = elemCont;     
            } else {
                var tmpCacheScroll = scrollCache[this.boxId].split("#");            
                var elemCont = '';
                elemCont += '<div class="'+regStyleCol+'" onClick="navigate(\'idContent='+this.boxId+'&DLC='+tmpCacheScroll[0]+'&prefix=0&Laender_Ref_ID='+tmpCacheScroll[1]+'\',\'scrollContent_' + this.boxId + '\',\'\',\'reqRegInfo\'); imgActScroll(\'' + this.boxId + '\');">';
                elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId)+'</div>';
                elemCont += '</div>';
                if (this.isKli) {                
                    var leftScrollTitle = document.getElementById('scrollTitle_'+this.boxId);
                    leftScrollTitle.innerHTML = elemCont;
                } else {                
                    this.title.innerHTML = elemCont;    
                }                                   
            }             
            if($('btnTableWeather_'+this.boxId) != null) {
                var tmpCacheScrollW = scrollCacheWeather[this.boxId].split("#");            
                var elemContW = '';
                elemContW+= '<div class="tt_reg_colsCD" onClick="navigate(\'idContent='+this.boxId+'&prefix=6&DLC=' + tmpCacheScroll[0] + '&Laender_Ref_ID='+tmpCacheScroll[1]+'&startNavi=500100\',\'scrollContentKli_' + this.boxId + '\',\'\',\'reqRegInfo\'); imgActScroll(\''+this.boxId+'\');">';
                elemContW+= '<div id="scrollKlimaBox_' + this.boxId + '">'+genWeatherBtnTable(this.boxId, tmpCacheScrollW[0], tmpCacheScrollW[1])+'</div>';
                elemContW+= '</div>';                
                if (!this.isKli) {                    
                    var rightScrollTitle = document.getElementById('scrollTitleKli_'+this.boxId);
                    rightScrollTitle.innerHTML = elemContW; 
                } else {                
                    this.title.innerHTML = elemContW;    
                }        
            }                                               
            break;
            
        case 'buchung':             
            break;
                
        default:
            if (typeof(isMerkzettel) == 'undefined' || isMerkzettel != 1) {
                this.title.innerHTML = '<span onclick="refreshContent(' + this.boxId + ', \'hi\');" class="arrowDownLink" style="background-color:red;">' + linkStr + '</span>';
            }
    }
    
    if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
        //alert('setOtherBoxTitleOnHide');
        if (typeof(ttCloseButton) == 'undefined' || !ttCloseButton) {
            ttCloseButton = '';
        }                
        //alert(this.boxId + '-> ' + ttCloseStrecke[this.boxId]);
        //this.title.innerHTML = '<span onclick="ttCloseButton = ' + ttCloseButton + '; ttSetButtonActive(' + this.boxId + ', "' + ttCloseStrecke[this.boxId] +  '"); refreshContent(' + this.boxId + ', \'hi\');"><img id="buttonHotelinfo_' + this.boxId + '" style="padding:0px;margin:0px;" src="/kunden_parameter/weg_tt/ibe_v2/images/merkzettel/' + ttCloseButton + '" alt="" border="0"></span>';
    }
}

//_________________________________________________________________________________________________
Box.prototype.setThisBoxTitleOnShow = function(isAlt){
    var linkStr = '';
    doNoTransform = false;
    
    switch (this.detail) {
        case 'zielgebiet':                      
            document.getElementById("scrollLine_" + this.boxId).className = 'tt_regTabScroll';
            break;
        case 'hotel':
            document.getElementById("scrollLine_" + this.boxId).className = 'tt_HotResultScroll';
            break;
        case 'termine':
            var elemSL = document.getElementById('scrollLine_' + this.boxId);
            elemSL.setAttribute('isActive', '1'); 
            if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
            }else{
                highlightBox(elemSL, true, this.boxId);    
            }
               
            
            if (this.isMf) {
                callbackMoreFlights(this.boxId, true);
                var elemPrice = document.getElementById('idTerRowPrice_' + this.boxId);
                if (elemPrice && elemPrice.getAttribute('doNotHide') != '1') {
                    elemPrice.style.display = 'none';
                }
                doNoTransform = true;
            }            
            break;
        case 'buchung':
            if (isFirefox == false){
                if (openedIsAfh) {
                    document.getElementById('scrollLine_' + this.boxId + '_afhBottom').style.display = 'block';
                }
                if (openedIsFz) {
                    document.getElementById('scrollLine_' + this.boxId + '_fzBottom').style.display = 'block';
                }
            }
            if (openedIsAfh) {
                document.getElementById('scrollLine_' + this.boxId + '_afhBottom').style.backgroundColor = '#FFFACE';
            }
            if (openedIsFz) {
                document.getElementById('scrollLine_' + this.boxId + '_fzBottom').style.backgroundColor = '#FFFACE';
            }
            break;
    }
    if (this.isHbw) {
        linkStr = 'Bewertungen schließen';
    } else if (this.isClip) {
        linkStr = 'Impressionen schließen';
    } else if (this.isAfh) {
    } else {
        if (this.boxId == '98') {
            linkStr = 'Bewertung schließen';
        } else {
            if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
                if (typeof(ttCloseButton) == 'undefined' || !ttCloseButton) {
                    ttCloseButton = 'hotelinfos_close.gif';
                }
                
                linkStr = '<img src="/kunden_parameter/weg_tt/ibe_v2/images/merkzettel/' +  ttCloseButton + '" alt="" />';
            } else {
                linkStr = 'Info schließen';    
            }
        }
    }
   
    switch (this.detail) {
        case 'zielgebiet':             
            var regStyleCol = 'tt_reg_colB';
            if(engine == 'fewo') {
                regStyleCol = 'tt_regFewo_colB';
            }
            var elemCont = '';
            elemCont += '<div class="'+regStyleCol+'">';
            elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId, 1)+'</div>';
            elemCont += '</div>';
            if (this.isKli) {
                var leftScrollTitle = document.getElementById('scrollTitle_'+this.boxId);
                leftScrollTitle.innerHTML = elemCont;    
            } else {
                this.title.innerHTML = elemCont;    
            }            
            overBtnTableClose(this.boxId);                                    
            if($('btnTableWeather_'+this.boxId) != null) {
                var tmpCacheScrollW = scrollCacheWeather[this.boxId].split("#");
                var tmpCacheScroll  = scrollCache[this.boxId].split("#");
                var elemContW = '';
                elemContW += '<div class="tt_reg_colsCD">';
                elemContW += '<div id="scrollKlimaBox_' + this.boxId + '">'+genWeatherBtnTable(this.boxId, tmpCacheScrollW[0], tmpCacheScrollW[1], 1)+'</div>';
                elemContW += '</div>'; 
                
                var elemContW2 = '';
                elemContW2+= '<div class="tt_reg_colsCD" onClick="navigate(\'idContent='+this.boxId+'&prefix=6&DLC=' + tmpCacheScroll[0] + '&Laender_Ref_ID='+tmpCacheScroll[1]+'&startNavi=500100\',\'scrollContentKli_' + this.boxId + '\',\'\',\'reqRegInfo\'); imgActScroll(\''+this.boxId+'\');">';
                elemContW2+= '<div id="scrollKlimaBox_' + this.boxId + '">'+genWeatherBtnTable(this.boxId, tmpCacheScrollW[0], tmpCacheScrollW[1])+'</div>';
                elemContW2+= '</div>';                
                                              
                if (!this.isKli) {                     
                    var rightScrollTitle = document.getElementById('scrollTitleKli_'+this.boxId);
                    rightScrollTitle.innerHTML = elemContW2; 
                } else {                
                    this.title.innerHTML = elemContW;    
                }                
                overBtnTableCloseWeather(this.boxId);    
            }
            this.closeLink.innerHTML = 'Regionsinfos schließen';                  
            break;
        
        case 'hotel':
            if (this.isHbw) {
                var elemHbw = document.getElementById('scrollHbwBox_'+this.boxId);
                elemHbw.removeAttribute('onclick');                 
            } else if (this.isClip) {
                var elemClip = document.getElementById('scrollClipBox_'+this.boxId);
                elemClip.removeAttribute('onclick');                 
            } else if (this.isThumb) {
                var elemThumb = document.getElementById('scrollThumbBox_'+this.boxId);
                elemThumb.removeAttribute('onclick');   
            } 
            var elemCont = '';
            elemCont += '<div class="tt_HotResultInfoButton">';
            elemCont += '<div id="scrollSpecBtn_' + this.boxId + '">'+genSpecBtnTable(this.boxId, 1)+'</div>';
            elemCont += '</div>';
            
            if (this.isHbw || this.isThumb || this.isClip) {
                var leftScrollTitle = document.getElementById('scrollTitle_'+this.boxId);
                leftScrollTitle.innerHTML = elemCont; 
            } else {
                this.title.innerHTML = elemCont;    
            }
            
            overBtnTableClose(this.boxId);            
            this.closeLink.innerHTML = (engine == 'fewo' ? 'Objektinfos' : 'Hotelinfos') + ' schließen';
            break;
            
        case 'termine':
            var elem = document.getElementById('idBtn_' + this.boxId + '_' + this.title.getAttribute('type'));
            if (elem) {
                elem.setAttribute('onclick', '');
                var elemPrev = elem.previousSibling;
                var elemNext = elem.nextSibling;
                elemPrev.setAttribute('onclick', '');
                elemNext.setAttribute('onclick', '');                
            } else {
                var elemTextLink = this.title.childNodes[1];
                
                if (elemTextLink) {
                    elemTextLink.setAttribute('onclick', '');
                }
            }   
            if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
            }else{
                if (!this.isHbw) {
                    setBorderAroundBox(this.boxId, true);  
                }                 
            }
            
            if (this.isMf) {
                linkStr = 'weitere Flüge schließen';
                this.closeLink.innerHTML = linkStr; 
                this.closeLink.className = 'arrowUpLinkTermine';
            } else if (this.isAfh) {
                linkStr = 'Flughafeninfo schließen';
                this.closeLink.innerHTML = linkStr; 
                this.closeLink.className = 'arrowUpLinkTermine';
            } else if (this.isFz) {
                if (typeof(isMerkzettel) != 'undefined' && isMerkzettel == 1) {
                    linkStr = '<span style="color: #3B4148; font-family: Verdana; font-size: 11px; text-decoration: underline; cursro: pointer;">Infos schließen</span>';
                } else {
                    linkStr = 'Infos schließen';
                }
                
                this.closeLink.innerHTML = linkStr; 
                this.closeLink.className = 'arrowUpLinkTermine';
            } else if (this.isHbw) {
                var elemScrollContent = document.getElementById('scrollContentHbw_' + this.boxId);
                if (elemScrollContent) {
                    elemScrollContent.style.borderLeft = '1px solid #E25B1B';
                    elemScrollContent.style.borderTop = '1px solid #E25B1B';
                    elemScrollContent.style.borderRight = '1px solid #E25B1B';
                    
                    this.closeLink.parentNode.style.borderLeft = '1px solid #E25B1B';
                    this.closeLink.parentNode.style.borderRight = '1px solid #E25B1B';
                    this.closeLink.parentNode.style.borderBottom = '1px solid #E25B1B';
                    
                linkStr = 'Hotelbewertungen schließen';
                this.closeLink.innerHTML = linkStr; 
                this.closeLink.className = 'arrowUpLinkTermine';                    
                }
            } else {
                linkStr = this.boxId == 105 ? 'Umgebung & Regionsinfos schließen' : 'Hotelinfos schließen';
                linkStr = engine == 'fewo' ? 'Objektinfos schließen' : linkStr;
                
                this.closeLink.innerHTML = linkStr; 
                this.closeLink.className = 'arrowUpLinkTermine';                
            }               
             
            break;
            
        case 'buchung':            
            this.title.innerHTML = genSpecBtnTableBooking(1, this.title.id); 
            var tmpTitle = this.title.id; 
            if (tmpTitle.indexOf('scrollTitleAfh_') >= 0) {
                overBtnTableClose('airport_'+this.boxId);
            } else if (tmpTitle.indexOf('scrollTitleFz_') >= 0) {
                overBtnTableClose('flytime_'+this.boxId);
            }                               
            break;
            
        default:
            this.title.innerHTML = '<span class="arrowUpLink">' + linkStr + '</span>';
    }   
}
//_________________________________________________________________________________________________
Box.prototype.setOldClassesOfBox = function(){
    switch (this.detail) {
        case 'zielgebiet':
            var scrollLine = document.getElementById('scrollLine_' + this.boxId);
            var boxClass = scrollLine.className;
            if (boxClass.indexOf('ALT') != '-1') {
                this.oldClassName = 'tt_regTab';
                this.isAlt = '1';
            } else {
                this.oldClassName = 'tt_regTab';
                this.isAlt = '0';
            }
            break;
        case 'hotel':
            var scrollLine = document.getElementById('scrollLine_' + this.boxId);
            var boxClass = scrollLine.className;
            if (boxClass.indexOf('ALT') != '-1') {
                this.oldClassName = 'tt_HotResult';
                this.isAlt = '1';
            } else {
                this.oldClassName = 'tt_HotResult';
                this.isAlt = '0';
            }
            break;
        case 'termine':
            if (document.getElementById('scrollLine_' + this.boxId)) {
                var scrollLine = document.getElementById('scrollLine_' + this.boxId);
                var boxClass = scrollLine.className;
            } else {
                var boxClass = scrollLine.className;
            }
            if (boxClass.indexOf('ALT') != '-1') {
                this.oldClassName = scrollLine.className;
                this.isAlt = '1';
            } else {
                this.oldClassName = scrollLine.className;
                this.isAlt = '0';
            }
            if (boxClass.indexOf('_dark') != '-1') {
                this.boxColor = '';
            } else {
                this.boxColor = '';
            }
            break;
    }
}


function setBoxHeight(id, height, elemId) {
    if (typeof(id) != 'undefined' && id >= 0) {
        var paddingHeight = 10;
        var bottomHeight = 0;
        var innerHeight = 0;
        var nameContent = 'scrollContent_';
        var nameBottom = 'scrollContentBottom_';
        if (openedIsHbw) {
            nameContent = 'scrollContentHbw_';
            nameBottom = 'scrollContentBottomHbw_';
        } else if (openedIsClip) {
            nameContent = 'scrollContentClip_';
            nameBottom = 'scrollContentBottomClip_';
        } else if (openedIsAfh) {
            nameContent = 'scrollContentAfh_';
            nameBottom = 'scrollContentBottomAfh_';
        } else if (openedIsFz) {
            nameContent = 'scrollContentFz_';
            nameBottom = 'scrollContentBottomFz_';
        } else if (openedIsMf) {
            nameContent = 'scrollContentMf_';
            nameBottom = 'scrollContentBottomMf_';
        } else if (openedIsSki) {
            nameContent = 'scrollContentSki_';
            nameBottom = 'scrollContentBottomSki_';
        } else if (openedIsKli) {
            nameContent = 'scrollContentKli_';
            nameBottom = 'scrollContentBottomKli_';
        } else if (openedIsThumb) {
            nameContent = 'scrollContentThumb_';
            nameBottom = 'scrollContentBottomThumb_';
        }
        var theBoxOut = document.getElementById(nameContent + id);
        var rowBottom = document.getElementById(nameBottom + id);
        if (typeof(rowBottom) != 'undefined') {
            bottomHeight = rowBottom.offsetHeight;
        }
        if (height == null || typeof(height) == 'undefined') {
            if (typeof(elemId) != 'undefined') {
                var theBoxInn = document.getElementById(elemId);
                if (typeof(theBoxInn) != 'undefined') {
                    innerHeight = theBoxInn.offsetHeight;
                }
            }            
            if (innerHeight > 0 && bottomHeight > 0) {
                theBoxOut.style.height = (innerHeight + bottomHeight + paddingHeight) + 'px';                
            } else {                
                setTimeout("setBoxHeight("+id+", "+height+", '"+elemId+"')", 50);
            }                        
        } else {
            theBoxOut.style.height = (height + bottomHeight + paddingHeight) + 'px';
        }
    }
}