
// dopuszczalne parametry
//  view: [ regdesc ]
//  ref_id: \''+parts_2[3]+'\',
//  mainElement: element w którym znajdować się będzie HIB
//
var hib_cache = {
    WSresults:{}
}

var hib = {
    
    pfadImages : "/kunden_parameter/millos/ibe_v2/images/",
        
    config : {
        areasPerPage:5,
        areaMoreLinkTxt:'[ + ]',
        areaListContentSelector:'#poilist',
        areaListPagerSelector:'#poipager',
        menuType:'ONELIST',   // TWOLINES
        menuMainElement:'#menu',
        contentElement : '#content',
        starImage: "/kunden_parameter/millos/ibe_v2/images/hstar.png",
        starHalfImage:"/kunden_parameter/millos/ibe_v2/images/hstar_half.png",        
        loadingAnimationHTML : '<div class="loading" id="content"><img src="/kunden_parameter/millos/ibe_v2/images/ajax-loader.gif" alt="" class="varHeight"><b>Ładowanie danych</b></div>',
        structureHTML : '<div id="menu"></div><div id="content"></div><div class="closebar"><span onclick="hib.hideCurrentBox()">zwiń opis</span></div>',
        onMenuClick : null,
        autoHeightFit : true,
        areaInfoOrder : 'H|S|L|SW|O|P|Y|T|F|A|K|E|R|N|V|PE|FE|IMP|WK|G|MU',
        menuStructure : null,
        runAfterLoadingContent : null,
        //pathModifierForConnector : '', //   <- nie używać tej zmiennej lepiej użyć connector
        slideshowInitialSize:null,
        connector: ((document.location.href.search(/\/erde\//)!=-1 || document.location.href.search(/\/fewo\//)!=-1 )?'../':'') + "../inc/hib_connector.php",
        noDescriptionText:'<p>Przepraszamy, opis tego hotelu jest w trakcie przygotowywania</p>',
        dataErrorText:'<p class="nodataerror">Niestety nie można wyświetlić w tym momencie danych. Proszę ponowić próbę za chwilę.</p>',
        displayModeForSlideShow:'center',
        animationTime:1000,
        skiHeadLinesTranslation:{
            positionAndDistance:'Położenie',
            season:'Sezon',
            familyFriendly:'Oferta rodzinna',
            apresSki:'Apres Ski',
            crossCountry:'Narciarstwo biegowe',
            otherActivities:'Pozostałe oferty',
            contact:'Kontakt'
        },
        skiPanoramaDimensions:{width:445,height:350}
    },

    parameters : {},
    mainElement : false,        // przychodzi z wywołania funkcji show()
    elementToRemove : false,
    menu : {},
    KID:111002,
    currentView:null,
    currentRefID:null,
    currentIFF:null,
    currentVA:null,
    afterInit : false,
    currentDataNode : false,

    // funkcja wywoływana przez linki kierujące do HIB
    // otwiera (lub zamyka HIB) oraz pobiera dane a następnie je wyświetla
    show : function( params ){
        
        // zamykanie HIB jeżeli jest otwarty
        if (this.mainElement && !params.replace) {

            if (this.isNewHIB( params, this.parameters )) {
                // otwarty już jest ten sam HIB
                
                if (params.elements.remove) $(params.elements.remove).remove();
                this.hideCurrentBox();
                return
            } else {
                // HIB jest już otwarty, ale to nie ten sam

                this.hideCurrentBox();
            }
        }
        
        // jeżeli są wymagane parametry...
        if (params.elements) {
            this.mainElement = params.elements.main;
            this.elementToRemove = params.elements.remove;
        }        

        this.currentView = (params.view)?params.view:null;
        if (params.ref_id) this.currentRefID = params.ref_id;
        if (params.iff) this.currentIFF = params.iff;
        if (params.va) this.currentVA = params.va;
        if (params.time) this.currentTime = params.time;
        if (params.airport) this.currentAirport = params.airport;
        if (params.weatherAirport) this.currentWeatherAirport = params.weatherAirport;
        if (params.crs) this.currentCRS = params.crs;
        if (params.catalogs) this.currentCatalogs = params.catalogs;
		
        this.parameters = params;
        
        if (this.afterInit==false) this.showLoadingAnimation();
        if (this.afterInit==false && params.onWSFailure) {
            setTimeout(this.onWSFailure,params.onWSFailure)
            
        }
        //this.clearContent();
        this.getDataForContent();
    },
    
    onWSFailure:function(){
        hib.setHeight(0);
    },
    
    refreshMenu:function(){
        // odświeżamy menu
        var mpos = this.getCurrentPositionInMenu();
        this.menu.SelectAndShowOne( mpos[0], mpos[1] );
        this.fixAirportMenu();
    },
    
    
    // tu znajduje się logika określająca czy nowootwierany HIB z linka zewnętrznego (spoza menu) jest tym samym HIB który jest już otwarty (false) lub nowym obiektem (true)
    isNewHIB : function( paramsA, paramsB ){
        for( var n in paramsA){
            if ((n!='elements') && (paramsA[n] != paramsB[n]))  return false
        }
        return true;            
    },

    // usunięcie aktualnej zawartości HIB
    hideCurrentBox : function(){
        $(this.mainElement).data('remove',hib.elementToRemove).slideUp('slow',function(){
            // po zwinięciu usuwamy box ze struktury
            $(this).data('remove').remove();
        });
        hib.mainElement = false;
        hib.elementToRemove = false;
        hib.parameters={};
        hib.afterInit = false;
        hib.currentDataNode = false;
        hib.currentPois = false;
        hib.currentVA = false;
        hib.currentTime = false;
        hib.currentHPoiRefID = false;
        hib.hasArealImages = false;
        hib.hasPanoramas = false;
        hib.hasPictures = false;
        hib.currentCRS = false;
        hib.currentCatalogs = false;
    },
    
    stopLoadingAnimation : function(){ 
        $(this.mainElement).height($(this.mainElement).height()).html('');
    },
    
    showLoadingAnimation : function(){
        if (this.config.loadingAnimationHTML!='')
            $(this.mainElement).html(this.config.loadingAnimationHTML);
        this.fitHeight(true);
    },
    
    // funkcja wywołuje odpowiednie dla danego parametru view zapytanie do WebService
    getDataForContent : function( x ){
        
        if (this.afterInit) this.refreshMenu();
        
        // obsługa przycisków niestandardowych
        if (this.currentView=='') {
            if (x.onclick) x.onclick.apply( this );
            return;    
        };

        // obsługa akcji standardowych
        switch ( this.currentView ) {
            case 'regdesc' : 
            case 'regfood' :
            case 'regattr' :
            case 'regfun' :
            case 'regcountry' :
            case 'regfacts' :
            case 'regslide' :
                this.getData('TTWSAlmanach/getRegionInfo', {
                regionRefId : (this.currentRefID)?this.currentRefID:'', 
                iffCode:(this.currentIFF)?this.currentIFF:''
            } );
            break;
            case 'weather' :
            case 'climma' :
                this.getData('TTWSWeather/getWeather', {
                weatherAirport : (this.currentWeatherAirport)?this.currentWeatherAirport:'', 
                iffCode:(this.currentIFF)?this.currentIFF:''
            });
            break;
            case 'hotdesc' :
                this.getData('TTWSHotel/getDescriptionForHotel', {
                iffCode : this.currentIFF,
                customerid:this.KID,
                country:'pl',
                time:this.currentTime,
                accomCode:(this.currentCRS)?this.currentCRS:'',
                touroperator:(this.currentVA)?this.currentVA:'',
                catalogs:(this.currentCatalogs)?this.currentCatalogs:''
            });
            break;
            case 'hotareaH':
            case 'hotareaS':
            case 'hotareaL':
            case 'hotareaSW':
            case 'hotareaO':
            case 'hotareaP':
            case 'hotareaY':
            case 'hotareaT':
            case 'hotareaF':
            case 'hotareaA':
            case 'hotareaK':
            case 'hotareaE':
            case 'hotareaR':
            case 'hotareaN':
            case 'hotareaV':
            case 'hotareaPE':
            case 'hotareaFE':
            case 'hotareaIMP':
            case 'hotareaWK':
            case 'hotareaG':
            case 'hotareaMU':
                this.getData('TTWSPOI/getPOIs', {
                iffCode : this.currentIFF
                });
            break;
            //case 'hotmap':
            case 'gMaps':            
            case 'hotpic':
            case 'hotfly':
            case 'hotslide':
            case 'hotgalery':
            case 'hotpan':
                this.getData('TTWSPOI/getPOIDetail', {
                poiRefID : this.currentHPoiRefID
            });
            break;
                
            case 'hotmap':
                this.getData('TTWSAlmanach/getMap', {
                iffCode : this.currentIFF
            });
            break;
            case 'hotopinion' :
                this.showHIBdata();			
                break;

            case 'airarrive':
            case 'airpark':
            case 'aircar':
            case 'airnight':
            case 'airbag':
            case 'aircontact':
                this.getData('TTWSAirport/getAirportInfo', {
                airport : this.currentAirport
            });
            break;
            case 'skimain':
            case 'skiguide': 
            case 'skislide':
            case 'skipano':
                this.getData('TTWSWintersports/getWintersportRegionInfo', {
                iffCode : this.currentIFF
                });
            break;
            
            case 'guestfoto':
                this.getData('TTWSHotelRating/getPicturesFromTravellers', {
                iffCode : this.currentIFF
                });
            break;
            
            
            default :
                alert('undfined value');
        }
    },

    getSuitablePlace:function(){

        var where = $(hib.config.contentElement);
        if (where.length>0) return where.get(0);
        
        var where = $(hib.mainElement);
        if (where.length>0) {
            return where.get(0);
        } else {
            return false;
        }
    },



    dataError:function(){ //console.log('dataError')
        var place = this.getSuitablePlace();
        if (place==false) {
            alert( hib.config.dataErrorText );
        } else {
			/* warning: qs dependency !!! */
            if (window.qs && qs.fields.detail=='termine' && !hib.afterInit ) {
                
                if (hib.currentView=='hotdesc') {
                    $(place).html('').removeClass();
                    this.config.runAfterLoadingContent = null
                } else {
                    $(place).html( hib.config.dataErrorText );
                }
                $('.terminelist').show();
            //console.log('1')
            //console.log(hib.currentView);
            } else {
                $(place).html( hib.config.dataErrorText );
            //console.log('2')
            }
            hib.fitHeight();
        }
    },
 
    getData : function( file, params, callback ){ //console.log('getData()');
        
        // funkcja wykonuje zapytanie AJAX do Web service do pliku file ze zmiennymi params
        $('div#content:last').ajaxError(
            function(){
                hib.dataError();
            }
            );
    
        // parametry stałe    
        var data = {
            WSfile:file, 
            language: "pl", 
            contenttype: "json", 
            rand:parseInt(Math.random()*100000)
        };
        // podłaczanie parametrów ze zmiennej params
        for (var n in params) data[n] = params[n];

        // sprawdzamy czy dane nie zostały wcześniej pobrane
        var tmp_id = makeId(file,data);
	
        if (hib_cache.WSresults[ tmp_id ]){
            // dane były pobierane wcześniej

            if (callback){
                //callback( tmp_id );
                callback( hib_cache.WSresults[ tmp_id ] );
                
                
                return;
            }
            this.currentDataNode = hib_cache.WSresults[ tmp_id ];
            this.showHIBdata();
        } else {
            // pobieramy dane
            $.ajaxSetup({
                async:false
            });
            $.getJSON( this.config.connector, data, (callback)?callback : this.parseData  );
        }
        
        // funkcja tworzy unikalne ID dla danego zestawu parametrów
        function makeId(file,data){
            var id=''; //file;
            for(var n in data) {
                if (n!='rand') id+=n+data[n];
            }
            return id;
        }
    },

    // funkcja przetwarza dane pobrane z WebService wywoływana jest jako pierwsza po otrzymaniu odpowiedzi AJAX
    parseData : function(data){
        
        // wpisywanie danych do tablicy z unikalnym kluczem tworzonym na podstawie parametrów zapytania
        // zapobiega to dublowaniu zapytań
        hib_cache.WSresults[data.id] = data;
        hib.currentDataNode = hib_cache.WSresults[data.id];
        
        var cNode = hib.currentDataNode;
        
        if (cNode.tourOperator) hib.currentVA = cNode.tourOperator.tourOperatorShort;
        if (cNode.hasArealImages) hib.hasArealImages = cNode.hasArealImages;
        if (cNode.hasPanoramas) hib.hasPanoramas = cNode.hasPanoramas;
        if (cNode.hasPictures) hib.hasPictures = cNode.hasPictures;
        if (cNode.idsForMoreContent){
            cNode = cNode.idsForMoreContent;
            if (cNode.regionRefId) hib.currentRefID = cNode.regionRefId;
            if (cNode.airportWeather) hib.currentWeatherAirport = cNode.airportWeather;
            if (cNode.poiRefID) hib.currentHPoiRefID = cNode.poiRefID;
            if (cNode.localAreaInformation && cNode.localAreaInformation.poiTypes) hib.currentPois = cNode.localAreaInformation.poiTypes;
        }
        hib.showHIBdata();
    },  
    
    // funkcja wypełnia pusty element zawartością struktury, następnie tworzy menu oraz wypełnia zawartością
    showHIBdata : function() {
       // return
        if (!this.afterInit) {
            
            hib.stopLoadingAnimation();
            // tworzenie struktury i menu tylko jednorazowo na początku
            $(this.mainElement).html(this.config.structureHTML);
            this.createMenu();
            this.afterInit = true;
            this.refreshMenu();
        }
        try {
            this.displayContent();
        } catch (e){
            this.dataError();
        }
    },
    
    // funkcja wywołuje funkcję rysującą zawartość na podstawie this.currentView
    displayContent : function(){
        
        //console.log('display');


        switch ( this.currentView ){
            case 'regdesc':
                this.showRegInfo('regionGeneralInfo');
                break;
            case 'regfood':
                this.showRegInfo('regionFoodAndDrink');
                break;
            case 'regattr':
                this.showRegInfo('regionActivities');
                break;
            case 'regfun':
                this.showRegInfo('regionOutAndAbout');
                break;
            case 'regcountry':
                this.showRegInfo('regionCountryAndPeople');
                break;
            case 'regfacts':
                this.showRegFacts();
                break;
            case 'regslide':
                this.showRegSlide();        
                break;
            case 'weather':
                this.showWeather();
                break;
            case 'climma':
                this.showClimma();
                break;
            case 'hotdesc':
                this.showHotelDescription();
                break;
            case 'hotpic':
                this.showMoreFotos( this.currentDataNode.images );
                break;
            case 'hotfly':
                this.showMoreFotos( this.currentDataNode.aerialImages );
                break;
            case 'hotgalery':
                this.showGallery();
                break;
            case 'hotpan':
                this.showPanoramas();
                break;
            case 'hotmap':
                this.showHotelMap();
                break;
            case 'gMaps':
                this.showGoogleMap();
                break;
            case 'hotareaH':
            case 'hotareaS':
            case 'hotareaL':
            case 'hotareaSW':
            case 'hotareaO':
            case 'hotareaP':
            case 'hotareaY':
            case 'hotareaT':
            case 'hotareaF':
            case 'hotareaA':
            case 'hotareaK':
            case 'hotareaE':
            case 'hotareaR':
            case 'hotareaN':
            case 'hotareaV':
            case 'hotareaPE':
            case 'hotareaFE':
            case 'hotareaIMP':
            case 'hotareaWK':
            case 'hotareaG':
                this.checkCurrentViewForArea();
                this.showAreaInfo( this.currentView.substring(7));
                break;
            case 'airarrive':
            case 'airpark':
            case 'aircar':
            case 'airnight':
            case 'airbag':
            case 'aircontact':
                this.showAirportInfo( this.currentView.substring(3));
                break;
            case 'skimain':
                this.showSkiMainInfo();
                break;
            case 'skiguide':
                this.showSkiGuideInfo();
                break;
            case 'skislide':
                this.showSkiSlideShow();
                break;
            case 'skipano':
                this.showSkiPanorama();
                break;
            case 'guestfoto':
                this.showGuestFoto();
                break;
            case 'hotopinion' :

                this.showHotelOpinions();
                break;				
            default :
                alert ('undefined value');
                
        }
        
        if (this.config.runAfterLoadingContent) this.config.runAfterLoadingContent();

        // automatycznie dopasuj wysokość. Pierwszy parametr true wymusza dopasowywanie wysokości także po załadowaniu obrazków (opatrzonych klasą 'varHeight').
        
        if ( this.currentView=='gMaps' ) {
            this.fitHeight( false, false, 'div'); 
        } else {
            this.fitHeight(true); 
        }
        
    //console.log('end of display');
        
    },
    
    fixAirportMenu : function (){
        if (this.currentView.substring(0,3)=='air') {
            // wyświetlenie tylko tych pozycji w submenu airport, które zawierają dane
            this.menu.hideAll(true,true);
            this.menu.show(6);
            this.menu.showGroup(6);
            var nodes = ['arrival', 'parking', 'carRental', 'hotel', 'luggage', 'serviceAndContact' ];
            for (var n in nodes ){
                if (!this.currentDataNode[nodes[n]]) this.menu.hide(6,n);                
            }
        } else { 
            // ukrycie menu airport
            if(this.menu) {
                //this.menu.hide(6);

                var mpos = this.getCurrentPositionInMenu();
                try  {
                    this.menu.SelectAndShowOne( mpos[0], mpos[1] )
                    } catch(e){}
                this.menu.hideGroup(6);
            }
        }
    },


    checkCurrentViewForArea : function(){ 
        // w przypadku gdy klikamy na okolica musimy przełączyć widok na pierwszy dostępny
        var tmp = this.currentDataNode.poiTypes.poiTypes.split('|');
        
        if( $.inArray(this.currentView.substring(7), tmp )==-1) {
        
            var order = this.config.areaInfoOrder.split('|');
            for (var n=0; n<order.length; n++){

                if( $.inArray( order[n], tmp )!=-1){
                    this.currentView = 'hotarea'+order[n];
                    this.refreshMenu();
                    return
                }
            }
        }
    },
    
    // funkcja płynnie animuje wysokość HIB w zależnosci od zawartości
    // wywołuje samą siebie dla invokeOnImagesLoad==TRUE aby reagować na doczytujące się obrazki
    fitHeight : function( invokeOnImagesLoad, noAnimation, selector ){
        
        if (this.config.autoHeightFit == false ) return;

        if (typeof selector=='undefined') selector='*:visible';
        
        if (invokeOnImagesLoad) {
            $( this.config.contentElement+' img.varHeight' ).load(function(){
                //$( hib.mainElement ).stop();
                hib.fitHeight( false, noAnimation);
                return;
            });
        }

        var ch = 0;
        this.tmpMainOffsetTop = $(hib.mainElement).offset().top
        $(selector,this.mainElement).each(function(){
            var h = parseInt( $(this).offset().top + this.offsetHeight - hib.tmpMainOffsetTop);
            if (ch<h) ch = h;
        });
       
        if (this.contentHeight!=ch) {

            this.contentHeight=ch;
            delete this.tmpMainOffsetTop;
            if (noAnimation)
                this.setHeight(this.contentHeight);
            else
                $( this.mainElement ).stop(true,false);
                $( this.mainElement ).animate( {
                    height: this.contentHeight +'px'
                    }, this.config.animationTime );
        //console.log('animation to '+this.contentHeight +'px')
        }
    },
    
    setHeight : function( h ){
        $( this.mainElement ).stop().height( h );    
    },
    
    clearContent : function(x){ 
        $( this.config.contentElement ).empty();
        if (x!==true) this.fitHeight( false, true );
    },


    createMenu : function(){
        
        this.menu = new menu($(this.config.menuMainElement, this.mainElement ), hib.makeMenuStructure() );        
        this.menu.type = this.config.menuType;
        this.menu.draw();
        //this.menu.showAll(true,true);

        // podłączenie funkcji wywoływanej po kliknieciu na menu
        this.menu.appendHandler( 
            function(z){
                
                //hib.clearContent(true);
                $( hib.config.contentElement ).html(hib.config.loadingAnimationHTML).removeClass();
                setTimeout(function(){
                    hib.fitHeight()
                    },200);
                
                // wyświetlanie podmenu tylko z aktualnego menu
                //hib.menu.SelectAndShowOne(z.group,z.subgroup);
                                
                // wywołanie funkcji z ewnętrznej
                if (hib.config.onMenuClick) hib.config.onMenuClick.apply(this, [z] );
                
                if (typeof timer!='undefined') timer.clear();
                // ustawienie aktualnego widoku
                hib.currentView = z.menuStruct.viewID;
                // wywołanie funkcji pobierającej dane dla nowego widoku
                if (hib.currentView!='') hib.getDataForContent( z.menuStruct );
            });
        
    },
    
    /*
    // funkcja zaznacza wybraną pozycję menu na podstawie hib.currentView
    selectByViewID : function(){
        hib.menu.deselectAll();
        hib.menu.iterateAll(
            function(x,gr,sgr){
                with (hib.menu.structure.fields[gr]){
                    if (fields[sgr].viewID==hib.currentView) {
                        hib.menu.select(gr);
                        hib.menu.select(gr,sgr);
                    }
                }
        }, false, true);            
    },
    */
    getCurrentPositionInMenu : function(){
        var struct = this.menu.structure.fields;
        for( var n=0; n<struct.length; n++){
            for( var m=0; m<struct[n].fields.length; m++){
                if (struct[n].fields[m].viewID==this.currentView) return [n,m];
            }
        }
        return [null, null];
    },
    
    
    // funkcje zwracają logiczną wartość true w przypadku gdy dany element menu ma być ukryty
    // wywoływane są przy budowie menu w funkcji createMenu
    hideHotelMenu : function(){
        // ukrycie tego menu gdy wchodzimy do hib z linka regdesc
        if (this.currentView=='regdesc' || this.currentView=='weather' ) return true
        return false
    },
    hideMapMenu : function(){
        if (this.currentView=='regdesc' || this.currentView=='weather') return true
        return false
    },
    hideRegionMenu : function(){
        return false
        },
    
    hideOpinionsMenu : function(){
        return !this.parameters.opinions;
        
    },
    
    hideWeatherMenu : function(){
        try {
			/* warning: qs dependency !!! */			
            if (window.qs && qs.fields.engine == 'fewo') {
                return true;
            } else {
                return false;
            }
        } catch (e) {
            return false;
        }
    },
    hideAirportMenu : function(){
        return false;
    },
    hideFotos : function(){
        return !this.hasPictures;        
    },
    hidePanorama : function(){
        return !this.hasPanoramas;
    },
    hideAerial : function(){
        return !this.hasArealImages;
    },
    
    hideGmaps : function(){
        return !this.hasPictures ;
    },
    
    hideGallery : function(){
        return !(this.hasArealImages || this.hasPictures);
    },
    
    hideGuestFoto :function() {
        var isFotoUnavailable = true;
        this.getData('TTWSHotelRating/getPicturesFromTravellers', {iffCode:this.currentIFF},
            function(x){
                if (x.picturesFromTravellers && x.picturesFromTravellers.length>0) isFotoUnavailable = false;
                hib_cache.WSresults[x.id] = x;
            }
        )
        return isFotoUnavailable;        
    },
    
    hideAreaMenu : function(){
        try {
			/* warning: qs dependency !!! */			
            if (window.qs && qs.fields.engine == 'fewo') return true;
        } catch (e) {}
        if (this.currentDataNode.idsForMoreContent && this.currentDataNode.idsForMoreContent.localAreaInformation){
            return this.currentDataNode.idsForMoreContent.localAreaInformation.poiTypes=='';
        }
        return true;
    },
    hideAreaSubMenu : function( x ){
        if (this.currentDataNode.idsForMoreContent && this.currentDataNode.idsForMoreContent.localAreaInformation ){
            return this.currentDataNode.idsForMoreContent.localAreaInformation.poiTypes.search(x)==-1;
        }
        return true;
    },

    hideSkiMenu:function(){ 
        var isSkiInfoAvailable = true;
        this.getData('TTWSWintersports/getWintersportRegionInfo', {iffCode:this.currentIFF},
            function(x){
                if (x.ErrorDetails) isSkiInfoAvailable = false;
                hib_cache.WSresults[x.id] = x;
            }
        )
        return !isSkiInfoAvailable;
    },
    
    hideSkiSubMenu:function( subMenuType ){ 
        var WSData;
        this.getData('TTWSWintersports/getWintersportRegionInfo', {iffCode:this.currentIFF},
            function(x){
                hib_cache.WSresults[x.id] = x;
                WSData = x;
            }
        )
        if (!WSData.navigation) return true;
        switch (subMenuType) {
            case 'main' : return !WSData.navigation.doesAtAGlanceExist;
            case 'guide' : return !WSData.navigation.doesGeneralInfoExist;
            case 'slide' : return !(WSData.navigation.doesSlideShowExist && WSData.slideShow.images.length);
            case 'pano' : return !(WSData.navigation.doesPanoramaExist && WSData.panorama.panorama);
            default : return true;
        }
    },
    
    isTerminHidden : function(){
        if (this.parameters.terminyON && this.parameters.terminyON==true) return false; else return true;
    },
    
    showTerminy : function(){
        //console.log('showTerminy()');
        $( this.mainElement ).stop(true,false);
        this.currentView='';
        this.clearContent();
        this.setHeight(32);
        this.fixAirportMenu();
        $('.terminelist').show();
        f.setElementValue( {
            'showTermineList':1
        } );
    },
    
    hideTerminy : function(){
        //console.log('hideTerminy()');
        $('.terminelist').hide();
        f.setElementValue( {
            'showTermineList':0
        } );
        hib.config.autoHeightFit  = true;
        this.fitHeight();
    },
    
    showAirport : function(aID){
        $('.terminelist').hide();
        hib.config.autoHeightFit = true;
        this.show({
            view:'airarrive',
            airport:aID,
            replace:true,
            terminyON:true
        });
    },
    
    // wyszukanie rezultatu w gąszczu danych w cache
    findResult : function( type, params ) { 
        
        for (var res in hib_cache.WSresults ){
            
            if ( type == res.substr(0,type.length)) {

                var pass=true;
                for (var p in params ) {
                    if (res.search(p+params[p])==-1) {
                        pass=false;
                        break;
                    }
                }
                if (pass) return hib_cache.WSresults[res];
            }
        }
    }
}
