// plik zawiera szablony do każdego z widoków HIB

hib.slideshowTemplate = function(){
    var out = ['<div id="divImg"></div>']; //<img id="hotelbild" alt="" src="" class="varHeight"/><img id="spare" alt="" src="" class="varHeight"/></div>'];
    out.push('<p id="subline">&nbsp;</p><p id="bildvon">&nbsp;</p>');
    out.push('<ul id="divNavi">');
    out.push('<li><img id="zurueck_2" onclick="if(this.slideObj)this.slideObj.showFirst();" alt="" src="" class="varHeight" /></li>');
    out.push('<li><img id="zurueck_1" onclick="if(this.slideObj)this.slideObj.showPrev();" alt="" src="" class="varHeight" /></li>');
    out.push('<li id="auto" title="uruchom automatyczną zmianę zdjęć" onclick="this.slideObj.auto()"></li>');
    out.push('<li id="resize" title="zmień rozmiar zdjęcia" onclick="this.slideObj.resize()"></li>');
    out.push('<li><img id="vor_1" alt="" onclick="if(this.slideObj)this.slideObj.showNext();" src="" class="varHeight" /></li>');
    out.push('<li><img id="vor_2" alt="" onclick="if(this.slideObj)this.slideObj.showLast();" src="" class="varHeight" /></li>');
    out.push('</ul>');
    return out.join('\n');
};



hib.showRegInfo = function ( nodeName ){
    var infoNode = nodeName.substr(6);
    var out= ['<img src="' + this.currentDataNode[nodeName].thumbnail.name + '" alt="" class="varHeight"/>'];
    out.push('<h1>' + this.currentDataNode.navigation['menuItem'+infoNode] + '</h1>');
    out.push('<h2>' + this.currentDataNode[nodeName].region + ' (' + this.currentDataNode[nodeName].country + ')</h2>');
    out.push('<p class="teaser">' + this.currentDataNode[nodeName].teaser + '</p>');
    out.push('<p class="desc">' + this.currentDataNode[nodeName].description.replace( this.currentDataNode[nodeName].teaser, '' ) + '</p>');

    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('reginfo');
};

hib.showRegFacts = function() {
    var nodePart = this.currentDataNode.regionFactsAndFigures;

    var out = ['<h1>Dane i fakty</h1>'];
    with (nodePart){
        out.push('<h2>'+region+' ('+country+')</h2>');
        out.push('<img src="'+flag.name+'" alt="" class="varHeight"/>');
        out.push('<h3>Najlepszy czas podróży</h3><p>'+bestTimeToTravel+'</p>');
        out.push('<h3>Regulacje dotyczące wjazdu</h3><p>'+entryRequirements+'</p>');
        out.push('<h3>Regulacje dotyczące szczepień</h3><p>'+vaccinationRequirements+'</p>');
        out.push('<h3>Zalecenia szczepień:</h3><p>'+vaccinationRecommendation+'</p>');
        out.push('<h3>Położenie geograficzne:</h3><p>'+geographicalPosition+'</p>');
        out.push('<h3>Język urzędowy:</h3><p>'+officialLanguage+'</p>');
        out.push('<h3>Stolica regionu:</h3><p>'+capital+'</p>');
        out.push('<h3>Waluta:</h3><p>'+currency+'</p>');
        out.push('<h3>Numer kierunkowy kraju:</h3><p>'+countryCode+'</p>');
        out.push('<h3>Przesunięcie czasu:</h3><p>'+timeShift+'</p>');
        out.push('<h3>Zasilanie/napięcie:</h3><p>'+powerSupplyAndVoltage+'</p>');
    }
    with (nodePart.embassy) {
        out.push('<h3>Adres ambasady:</h3><p>' + name + '</br>' + address + '</br>' + village + '</br>' + web + '</br>' + email + '</br>' + phone + '</br>' + fax + '</br></p>');
    }
    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('reginfofacts');
};

hib.showRegSlide = function() {
    var out = [], bigPictures = [];
    for (var n in this.currentDataNode.regionSlideShow.slideShowImages) {
        out.push('<div class="himg"><img src="' + this.currentDataNode.regionSlideShow.slideShowImages[n].name + '" alt="' + this.currentDataNode.regionSlideShow.slideShowImages[n].subline + '" class="varHeight" /></div>');
        bigPictures.push(this.currentDataNode.regionSlideShow.slideShowImages[n].name);
    }
    $(this.config.contentElement, this.mainElement ).html(out.join('')).removeClass().addClass('gallery');
    showBigImage('img', this.config.contentElement, bigPictures);
};


hib.showWeather = function() {
    var cNode = this.currentDataNode, out = [];
    var cNode2 = cNode.weatherForecastsOneDay[0];

    var dayPrognose=[];
    for (var a=0;a<5;a++){
        if (cNode.weatherForecastsOneDay[a]) {
            var dateNode = cNode.weatherForecastsOneDay[a].date;
            var dateObject = new Date(dateNode.substr(0,4)+'/'+dateNode.substr(5,2)+'/'+dateNode.substr(8,2));
            dayPrognose.push({day: this.makeDate(dateObject.getTime()),
                                img: cNode.weatherForecastsOneDay[a].iconWeatherSituation.name,
                                tempDay: cNode.weatherForecastsOneDay[a].temperatureAirDay,
                                tempNight: cNode.weatherForecastsOneDay[a].temperatureAirNight});
        }
    }

    out = ['<h1>'+cNode.area+' ('+cNode.country+')</h1>'];
    out.push('<h2>Aktualna progrnoza pogody na '+dayPrognose[0].day+'</h2>');
    out.push('<table class="actual_weather">');
        out.push('<tbody>');
            out.push('<tr>');
                out.push('<td><h3>Sytuacja pogodowa</h3></td>');
                out.push('<td><h3>Temperatura</h3></td>');
                out.push('<td><h3>Prawdopodobieństwo deszczu</h3></td>');
                out.push('<td><h3>Kierunek wiatru i jego prędkość</h3></td>');
            out.push('</tr>');
            out.push('<tr>');
                out.push('<td><img src="/images/content/wetter/'+dayPrognose[0].img+'" alt="" class="varHeight"/></td>');
                out.push('<td><img src="/images/content/wetter/temperatur.gif" alt="" class="temperatures"/></td>');
                out.push('<td><img src="'+cNode2.iconRain.name+'" alt="" class="varHeight"/></td>');
                out.push('<td><img src="'+cNode2.iconWindDirectionAndSpeed.name+'" alt="" class="varHeight" /></td>');
            out.push('</tr>');
            out.push('<tr>');
                out.push('<td>' + cNode2.iconWeatherSituation.subline + '</td>');
                out.push('<td>');
                    out.push('<strong>dzień</strong>&nbsp;'+dayPrognose[0].tempDay+'°C<br /><strong>noc</strong>&nbsp;&nbsp;&nbsp;&nbsp;'+dayPrognose[0].tempNight+'°C');
                    if (cNode2.temperatureWater!=-999) {
                        out.push('<br /><strong>woda</strong>&nbsp;&nbsp;' + cNode2.temperatureWater + '°C');
                    }
                out.push('</td>');
                out.push('<td>' + cNode2.chanceForRain + '%</td>');
                out.push('<td>' + cNode2.windSpeedMinKmph+' - ' + cNode2.windSpeedMaxKmph + ' km/h</td>');
            out.push('</tr>');
        out.push('</tbody>');
    out.push('</table>');
    out.push('<h2>Prognoza pogody na najbliższe dni</h2>');
    out.push('<div class="dayprognose">');
    for (var n=1; n<dayPrognose.length ;n++ ){
            out.push('<div class="day"><h1>'+dayPrognose[n].day.replace(/,/,'')+'</h1><p><img src="/images/content/wetter/'+dayPrognose[n].img+'" alt="" class="varHeight"/>');
            out.push('<p>Dzień: '+dayPrognose[n].tempDay+'°C</p><p>Noc: '+dayPrognose[n].tempNight+'°C</p></p></div>');
    }
    out.push('</div>');

    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('weather');
};

hib.climmaRows = [	{name:'Maks. temperatura',img:'/images/content/wetter/klimatabelle/temp_plus.gif',dataName:'max'},
            {name:'Min. temperatura',img:'/images/content/wetter/klimatabelle/temp_min.gif',dataName:'min'},
            {name:'Temperatura wody',img:'/images/content/wetter/klimatabelle/wassertemp.gif',dataName:'water'},
            {name:'Godziny słoneczne',img:'/images/content/wetter/klimatabelle/sonnenstunden.gif',dataName:'sunhours'},
            {name:'Dni deszczowe',img:'/images/content/wetter/klimatabelle/regentage.gif',dataName:'raindays'},
            {name:'Wilgotność wzgl.',img:'/images/content/wetter/klimatabelle/luftfeuchte.gif',dataName:'humidity'},
        ],

hib.showClimma = function() {
    var cNode = this.currentDataNode;
    var monthsArray = ['sty','lut','mar','kwi','maj','cze','lip','sie','wrz','paź','lis','gru'];

    var monthData=[];
    if (
        cNode.climaMaxTemperature.length !== 0 &&
        cNode.climaMinTemperature.length !== 0 &&
        cNode.climaSeaTemperature.length !== 0
    ) {
        with (cNode){
            for(var a=0;a<12;a++){
                monthData.push({max : climaMaxTemperature[a],
                                    min : climaMinTemperature[a],
                                    water : (climaSeaTemperature[a]<-100)?'-':climaSeaTemperature[a],
                                    sunhours : climaHoursOfSunshine[a],
                                    raindays : climaDaysOfRain[a],
                                    humidity : climaRelativeHumidity[a],
                                    name : monthsArray[a]});
            }
        }
        var out = ['<h1>'+cNode.area+' ('+cNode.country+')</h1>'];
        out.push('<h2>Tabela klimatyczna</h2>');
        out.push('<table><tr><th class="col1"></th>');
        for (var n=0; n<12 ;n++ ){
            out.push('<th>'+monthData[n].name+'</th>');
        }
        out.push('</tr><tr>');
        for (var row=0; row<6; row++ ){
            out.push('<td class="col1"><img src="'+this.climmaRows[row].img+'" alt="" class="varHeight" />'+this.climmaRows[row].name+'</td>');
            for (var col=0; col<12 ; col++ ){
                out.push('<td>'+monthData[col][this.climmaRows[row].dataName]+'</td>');
            }
            out.push('</tr>');
        }
        out.push('</table>');
    } else {
        out.push('<p class="nodataerror">Niestety nie można wyświetlić w tym momencie danych. Proszę ponowić próbę za chwilę.</p>');
    }
    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('climma');
};


hib.makeDate = function( ts ){
    var weekFullDaysArray = ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'];
    var d = new Date( ts );
    var day = d.getDate();
    var month = d.getMonth()+1;
    if(day<10) day = '0' + day;
    if(month<10) month = '0'+month;
    return weekFullDaysArray[ d.getDay() ]+', ' + day + '.' + month + '.' + d.getFullYear();
};

hib.showHotelDescription = function(){
    var cNode = this.currentDataNode;
    var out = [];
    // opis hotelu istnieje
    if (cNode.description && cNode.description.length != 0) {
        out.push(this.makeOperatorsList());
        //out.push('<div class="imageview">' + this.slideshowTemplate() + '</div>');
        out.push('<span class="hdesc"></span>');

        $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('hotdesc');

        $('.hdesc').html(cNode.description); // treść opisu należy wkleić później ze względu na IE który wywala się przy niedomknietych tagach, które moga być w opisie

        // w przypadku gdy nie ma żadnego obrazka dorzucamy miniaturkę
//        if (this.currentDataNode.images.length == 0) {
//
//            this.currentDataNode.images=[{direction:"horizontal", subline:"", name:"http://images.traveltainment.de/images/content/booking_thumbs_gr/" + IFF5000(cNode.idsForMoreContent.iffCode) +"/THB_999_H" + cNode.idsForMoreContent.iffCode + ".jpg"}];
//        }

        //this.slide = new slideshow(this.currentDataNode.images, this.pfadImages, this.mainElement);
//		this.slide.context = this.slide;
        //this.slide.cfgAllowAuto = false;
        //this.slide.cfgAllowResize = false;
        //this.slide.currentResize = 0;
        //this.slide.init();
        $('ul > li > img', this.config.contentElement).fadeTo('fast', 0.5);
        $('ul > li > img.sel', this.config.contentElement).fadeTo('fast', 1);
        $('ul > li > img', this.config.contentElement).mouseover(
            function () {
                $(this).fadeTo('fast', 1);
            }
        );
        $('ul > li > img.nosel', this.config.contentElement).mouseout(
            function () {
                $(this).fadeTo('fast', 0.5);
            }
        );
        $('ul > li > img.sel', this.config.contentElement).mouseout(
            function () {
                $(this).fadeTo('fast', 1);
            }
        );
    } else {

        $(this.config.contentElement, this.mainElement ).html(this.config.noDescriptionText).removeClass().addClass('nohoteldesc');
    }

    function IFF5000(iff){
        return ('0000' + parseInt(iff/5000)*5000 ).slice(-5);
    }
};

hib.makeStars = function( cat ){
    var strStars="";
    while(cat>0){
        strStars+='<img src="'+((cat>0.5)?this.config.starImage:this.config.starHalfImage)+'" alt="">';
        cat--;
    }
    return strStars;
}

hib.selectHotDescVA = function(el){
    hib.currentVA = el.src.split('/').slice(-1).toString().slice(0,-4);
    hib.getDataForContent();
};

hib.makeOperatorsList = function(){

    var out = [];
    with (this.currentDataNode){

        // zabezpieczenie przed błędem w przypadku braku danych o TO
        if ( !allTourOperatorsInHotel || allTourOperatorsInHotel.length==0) return '';

        if (allTourOperatorsInHotel.length > 1) {
            out.push('<ul class="valogos">');
            for (var n in allTourOperatorsInHotel){
                out.push('<li>');
                var actual = (tourOperator.tourOperatorShort == allTourOperatorsInHotel[n].tourOperatorShort )?'class="sel varHeight"':'class="nosel varHeight"';
                if (n!='len') out.push('<img src="'+allTourOperatorsInHotel[n].logo.name+'" '+actual+' alt="'+allTourOperatorsInHotel[n].tourOperatorLong+'" onclick="hib.selectHotDescVA(this)" title="'+allTourOperatorsInHotel[n].tourOperatorLong+'"/>');
                var to = allTourOperatorsInHotel[n].tourOperatorShort;
                if (to=='NEC' || to=='TUI') out.push('<span>DE</span>');
                out.push('</li>');
            }
            out.push('</ul>');
        } else if (allTourOperatorsInHotel.length == 1) {
            out.push('<ul class="valogos">');
                out.push('<li>');
                    out.push('<img src="' + allTourOperatorsInHotel[0].logo.name + '" alt="' + allTourOperatorsInHotel[0].tourOperatorLong + '" title="' + allTourOperatorsInHotel[0].tourOperatorLong + '" class="sel varHeight" />');
                out.push('</li>');
            out.push('</ul>');
        }
        out.push('<p class="currentVA' + ((allTourOperatorsInHotel.length==1)?' onlyonedesc':'')+ '">Opis pochodzi z katalogu <strong>'+ tourOperator.tourOperatorLong+ '</strong></p>');
    }
    return out.join('\n');
};

hib.showMoreFotos = function( iNode ){
    var out = this.slideshowTemplate( );
    $(this.config.contentElement, this.mainElement ).html(out).removeClass().addClass('hotpic');
    this.slide = new slideshow( iNode , this.pfadImages, this.mainElement  );
    this.slide.init();

};

hib.showHotelMap = function(){
    var cNode = this.currentDataNode, out = [];
    out = ['<h1>'+cNode.country+', '+cNode.area+', '+cNode.village+'</h1>'];
    out.push('<div class="hmap"><img src="'+cNode.image.name+'" alt="" id="hmap" class="varHeight" />');
    out.push('<img id="hpoint" src="'+this.pfadImages+'/hotel_ani.gif" alt="" /></div>');
    $(this.config.contentElement, this.mainElement ).html(out.join('')).removeClass().addClass('hotmap');
    $('#hmap').load(this.placeHotelMap);
};

hib.placeHotelMap = function(){
    var movex = ($(this.parentNode).width()-$(this).width())/2;
    $(this).css('left',movex+'px').fadeIn('slow');
    $('#hpoint').css( {left:hib.currentDataNode.mapPositionX-9+movex+'px',top:hib.currentDataNode.mapPositionY-9+'px'}).fadeIn('slow');
};

hib.showPanoramas = function(){
    $(this.config.contentElement, this.mainElement ).html( this.panoramaTemplate() ).removeClass().addClass('hotpan');
    this.panorama = new panorama( this.currentDataNode.panoramas );
};

hib.panoramaTemplate = function(){
    var out=['<div id="winpan"></div>'];
    out.push('<div class="pan_navi"><img src="'+this.pfadImages+'/plus.gif" alt="plus" onclick="hib.panorama.panview.zoomPlus( 1.1 )" class="varHeight" />');
    out.push('<img src="'+this.pfadImages+'/zero.gif" alt="rozmiar normalny" onclick="hib.panorama.panview.zoomFactor( 1 )" class="varHeight" />');
    out.push('<img src="'+this.pfadImages+'/minus.gif" alt="minus" onclick="hib.panorama.panview.zoomMinus( 1.1 )" class="varHeight" />');
    out.push('<img src="'+this.pfadImages+'/stop.gif" alt="stop" onclick="hib.panorama.panview.stopMoving()" class="varHeight" />');
    out.push('<img src="'+this.pfadImages+'/anim_right.gif" alt="w lewo" onclick="hib.panorama.panview.startRotate(\'left\')" class="varHeight" />');
    out.push('<img src="'+this.pfadImages+'/anim_left.gif" alt="w prawo" onclick="hib.panorama.panview.startRotate(\'right\')" class="varHeight" />');
    out.push('</div><div id="panselect"></div>');
    return out.join('');
};

hib.showHotelOpinions = function(){
    op.init(this.currentIFF, $(this.config.contentElement, this.mainElement ) );
    $(this.config.contentElement, this.mainElement ).removeClass().addClass('hopinios');
};

hib.showAreaInfo = function ( selectedPOItype ) {
    var cNode = this.currentDataNode;
    var out = ['<div class="poilist"><table id="poilist" cellspacing="0" cellpadding="0"></table><div id="poipager"></div></div>'];
    out.push('<div class="poipanorama"><h1></h1>'+this.panoramaTemplate()+'<ul class="menu"><li onclick="hib.areashow.switchToList()">powrót</li><li onclick="hib.areashow.switchToImages()">zdjęcia</li></ul></div>');
    out.push('<div class="poiimages"><h1></h1>'+this.slideshowTemplate()+'<ul class="menu"><li onclick="hib.areashow.switchToList()">powrót</li><li onclick="hib.areashow.switchToPanorama()">panoramy</li></ul><p class="desc"></p></div>');


    $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('hotarea');

    if (!this.areashow) {
        this.areashow = new areainfo( cNode, selectedPOItype, this.config );
    } else {
        this.areashow.currentPoiType = selectedPOItype;
        this.areashow.currentSubpage = 0;
        this.areashow.menu = null;
    }

    this.areashow.drawPOIsList();
};

hib.showGoogleMap = function() {
    var cNode = this.currentDataNode;
    if (cNode.coordinates.latitude && cNode.coordinates.longitude){
        var out = ['<div id="gmap"></div>'];
        $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('gmap');

        load();
    } else {
        $(this.config.contentElement, this.mainElement ).html( '<p class="nogmap"> Niestety nie możemy wyświetlić położenia tego hotelu</p>' ).removeClass().addClass('gmap');
    }
    function load() {
        var latlng = new google.maps.LatLng(cNode.coordinates.latitude, cNode.coordinates.longitude),
            myOptions = {
              zoom: 12,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.HYBRID,
              streetViewControl: true
            },
            map = new google.maps.Map($('#gmap').get(0), myOptions),
            marker = new google.maps.Marker({
                position: latlng,
                map: map
            });
    }
};

hib.showHotelGoogleMap = function() {
    var cNode = this.currentDataNode;
    if (cNode.hotelCoordinates.latitude && cNode.hotelCoordinates.longitude){
        var out = ['<div id="gmap"></div>'];
        $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('gmap');

        load();
    } else {
        $(this.config.contentElement, this.mainElement ).html( '<p class="nogmap"> Niestety nie możemy wyświetlić położenia tego hotelu</p>' ).removeClass().addClass('gmap');
    }
    function load() {
        var latlng = new google.maps.LatLng(cNode.hotelCoordinates.latitude, cNode.hotelCoordinates.longitude);
        var myOptions = {
          zoom: 18,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.HYBRID,
          streetViewControl: true
        };
        var map = new google.maps.Map($('#gmap').get(0), myOptions);
        var marker = new google.maps.Marker({
            position: latlng,
            map: map
        });
    }
};


hib.showAirportInfo = function (view) {

    var out=[];

    if (this.currentDataNode.logo) out.push('<img src="'+this.currentDataNode.logo.name+'" alt="" class="logo varHeight"/><h1>'+this.currentDataNode.airportName+'</h1>');

    switch (view) {
        case 'arrive' :
            if (!this.currentDataNode.arrival) return;
            with (this.currentDataNode.arrival) {
                if (byCar!='') out.push('<h2>'+headLineByCar+'</h2><img src="' + mapArrival.name.replace(/anfahrt_flughafen/ ,'anfahrt_flughafen/pl') + '" alt="" class="varHeight"/><p>'+byCar+'</p>');
                if (byPublicTransport!='') out.push('<h2>'+headLineByPublicTransport+'</h2><p>'+byPublicTransport+'</p>');
                if (byTaxi!='') out.push('<h2>'+headLineByTaxi+'</h2><p>'+byTaxi+'</p>');
                if (byTrain!='') out.push('<h2>'+headLineByTrain+'</h2><p>'+byTrain+'</p>');
            }break;

        case 'park':
            if (!this.currentDataNode.parking) return;
            with (this.currentDataNode.parking) {
                if (commonDescription!='') out.push('<h2>'+headLineCommonDescription+'</h2><p>'+commonDescription+'</p>');
                if (longStay!='') out.push('<h2>'+headLineLongStay+'</h2><p>'+longStay+'</p>');
                if (longtimeStay!='') out.push('<h2>'+headLineLongtimeStay+'</h2><p>'+longtimeStay+'</p>');
                if (shortStay!='') out.push('<h2>'+headLineShortStay+'</h2><p>'+shortStay+'</p>');
                if (specialNeeds!='') out.push('<h2>'+headLineSpecialNeeds+'</h2><p>'+specialNeeds+'</p>');
            }
            break;

        case 'car':
            if (!this.currentDataNode.carRental) return;
            with (this.currentDataNode.carRental) {
                out.push('<h2>'+headLineCarRentalNearby+'</h2><p>'+carRentalNearby+'</p>');
            }
            break;

        case 'night':
            if (!this.currentDataNode.hotel) return;
            with (this.currentDataNode.hotel) {
                out.push('<h2>'+headLineHotelsNearby+'</h2><p>'+hotelsNearby+'</p>');
            }
            break;

        case 'bag':
            if (!this.currentDataNode.luggage) return;
            with (this.currentDataNode.luggage) {
                out.push('<h2>'+headLineLeftLuggageAndLockers+'</h2><p>'+leftLuggageAndLockers+'</p>');
            }
            break;

        case 'contact':
            if (!this.currentDataNode.serviceAndContact) return;
            with (this.currentDataNode.serviceAndContact) {
                if (banks!='') out.push('<h2>'+headLineBanks+'</h2><p>'+banks+'</p>');
                if (cashDispensers!='') out.push('<h2>'+headLineCashDispensers+'</h2><p>'+cashDispensers+'</p>');
                if (chaplaincyOrPrayerRoom!='') out.push('<h2>'+headLineChaplaincyOrPrayerRoom+'</h2><p>'+chaplaincyOrPrayerRoom+'</p>');
                if (commonDescription!='') out.push('<h2>'+headLineCommonDescription+'</h2><p>'+commonDescription+'</p>');
                if (moreServiceFacilities!='') out.push('<h2>'+headLineMoreServiceFacilities+'</h2><p>'+moreServiceFacilities+'</p>');
                if (postalOffice!='') out.push('<h2>'+headLinePostalOffice+'</h2><p>'+postalOffice+'</p>');
                if (usefulTelephoneNumbers!='') out.push('<h2>'+headLineUsefulTelephoneNumbers+'</h2><p>'+usefulTelephoneNumbers+'</p>');
            }
            break;
    }
    $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('airport');

};

hib.showSkiMainInfo = function() {
    var cdn = this.currentDataNode.generalInfo;
    var out = [
		'<img src="' , cdn.thumbnail.nameSizeLow, '" alt="" class="varHeight"/>',
		'<h1>Informacje o regionie narciarskim</h1>',
		'<h2>' + cdn.region + ' (' + cdn.country + ')</h2>',
		'<h2>' + cdn.subHeadLine + '</h2>',
		'<p class="teaser">' + cdn.teaser + '</p>'
		];                  
    for( var n in hib.config.skiHeadLinesTranslation){
        var nodeName = hib.config.skiHeadLinesTranslation[n];
        if (cdn[n]) out.push( '<h3>'+nodeName+'</h3><p>'+cdn[n]+'</p>');
    }
    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('skimain');
};
        
hib.showSkiGuideInfo = function () {
    var cdn = this.currentDataNode;
    var out = [
		'<h1>Informacje o regionie narciarskim</h1>',
		'<h2>' + cdn.region + ' (' + cdn.country + ')</h2>',
        '<h1>Informacje podstawowe</h1>',
        '<table>',
            '<tr><th>Stoki narciarskie:</th><td>' + writeSkiRating(cdn.atAGlance.ratingSkiRuns) + '</td></tr>',
            '<tr><th>Trasy biegowe:</th><td>' + writeSkiRating(cdn.atAGlance.ratingCrossCountrySkiRuns) + '</td></tr>',
            '<tr><th>Après Ski - oferta:</th><td>' + writeSkiRating(cdn.atAGlance.ratingApresSki) + '</td></tr>',
            '<tr><th>Inne sporty zimowe:</th><td>' + writeSkiRating(cdn.atAGlance.ratingOtherWintersportsActivities) + '</td></tr>',
            '<tr><th>Przyjazdny dla rodzin:</th><td>' + writeSkiRating(cdn.atAGlance.ratingFamilyFriendly) + '</td></tr>',
            '<tr><th>Snowboard - oferta:</th><td>' + writeSkiRating(cdn.atAGlance.ratingSnowboardSpecials) + '</td></tr>',
            '<tr><th>Ski pass dla dorosłych:</th><td><b>' + cdn.atAGlance.skiPassAdult + '</td></tr>',
            '<tr><th>Ski Pass dla dzieci:</th><td><b>' + cdn.atAGlance.skiPassChild + '</td></tr>',
            '<tr><th>Sezon narciarski:</th><td><b>' + cdn.atAGlance.seasonDate + '</td></tr>',
        '</table>',
        '<p>' + cdn.atAGlance.skiSlope + '</p>'
    ];                  
    $(this.config.contentElement, this.mainElement ).html(out.join('\n')).removeClass().addClass('skimain');
    function writeSkiRating( value ){
        return  value + '.0 /6.0';
    }
};

hib.showGuestFoto = function () {
    var cdn = this.currentDataNode.picturesFromTravellers,
        out = [], bigPictures = [];
    for(var n in cdn){
        out.push('<div class="himg"><img src="http://hotelbewertung.traveltainment.de/urlaubsbilder/320_260/' + cdn[n].name + '" alt="' + cdn[n].subline + '" class="varHeight" /></div>');
        bigPictures.push('http://hotelbewertung.traveltainment.de/urlaubsbilder/320_260/' + cdn[n].name);
    }
    $(this.config.contentElement, this.mainElement ).html(out.join('')).removeClass().addClass('gallery');
    showBigImage('img', this.config.contentElement, bigPictures);
};

hib.showSkiSlideShow = function () {
    var cdn = this.currentDataNode;
    var out = this.slideshowTemplate( );
    $(this.config.contentElement, this.mainElement ).html(out).removeClass().addClass('regslide');
    this.slide = new slideshow( cdn.slideShow.images , this.pfadImages, this.mainElement  );
    this.slide.init();
};

hib.showSkiPanorama = function () {
    var out = [
        '<div style="width:' + hib.config.skiPanoramaDimensions.width+'px;height:'+hib.config.skiPanoramaDimensions.height+'px">',
        this.config.loadingAnimationHTML,
        '</div>'
    ];    
    $(hib.config.contentElement, hib.mainElement ).html(out.join('\n')).removeClass().addClass('tt_floatRight tt_hibRightContent tt_hibSkiInfo');
    
    setTimeout(function() {
        var out = [
            '<div style="width:' + hib.config.skiPanoramaDimensions.width+'px;height:'+hib.config.skiPanoramaDimensions.height+'px">',
            '<object width="'+hib.config.skiPanoramaDimensions.width+'" height="'+hib.config.skiPanoramaDimensions.height+'" type="application/x-shockwave-flash">',
                '<param name="menu" value="false"><param name="flashvars" value="zoomifyImagePath=http://cluster1.loc1.ffm.synaix.de/images/content/skigebiete/pois/Fotos/high/'+hib.currentDataNode.panorama.panorama+'">',
                '<param value="http://ttibe.traveltainment.pl/booking_pl/zoomify/ZoomifyDesignViewer.swf" name="src">',
            '</object>',
            '</div>'
        ];
        $(hib.config.contentElement, hib.mainElement ).html(out.join('\n')).removeClass().addClass('tt_floatRight tt_hibRightContent tt_hibSkiInfo');
    }
    ,hib.config.animationTime);
};

hib.showGallery = function (operator, pan, tt) {
    var bigPictures = [], out = [''], i = 0, len = 0,
        hotelData = getHotelData(operator), poiData = getPoiData(), picTTdata = getPicTT();
    out.push('<ul class="valogos">');
        for (i = 0, len = hotelData.allTourOperatorsInHotel.length; i < len; i += 1) {
            out.push('<li' + (typeof operator === 'undefined' && i === 0 ? ' class="sel"' : operator == hotelData.allTourOperatorsInHotel[i].tourOperatorShort ? ' class="sel"' : ' class="nosel"') + '>');
                out.push('<img src="' + hotelData.allTourOperatorsInHotel[i].logo.name + '" alt="' + hotelData.allTourOperatorsInHotel[i].tourOperatorShort + '" class="varHeight" onclick="hib.showGallery(\'' + hotelData.allTourOperatorsInHotel[i].tourOperatorShort + '\',false, false)" />');
            out.push('</li>');
        }
    //out.push('</ul>');
    //out.push('<ul class="valogos">');
        if (picTTdata.regionSlideShow.slideShowImages.length > 0) {
            out.push('<li' + ((tt) ? ' class="sel"' : ' class="nosel"') + '>');
                out.push('<span onclick="hib.showGallery(null, false, true);">Inne</span>');
            out.push('</li>');
        }
        if (hotelData.hasPanoramas) {
            out.push('<li' + ((pan) ? ' class="sel"' : ' class="nosel"') + '>');
                out.push('<span onclick="hib.showGallery(null, true, false);">Panorama</span>');
            out.push('</li>');
        }
    out.push('</ul>');
    if (pan) {
        out.push(this.panoramaTemplate());
        $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('gallery');
        this.panorama = new panorama( poiData.panoramas );
    } else if (tt) {
        for (i = 0, len = picTTdata.regionSlideShow.slideShowImages.length; i < len; i += 1){
            out.push('<div class="himg">');
                out.push('<img src="' + picTTdata.regionSlideShow.slideShowImages[i].name + '" alt="' + picTTdata.regionSlideShow.slideShowImages[i].subline + '" class="varHeight" />');
            out.push('</div>');
            bigPictures.push(picTTdata.regionSlideShow.slideShowImages[i].name);
        }
        $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('gallery');
        showBigImage('div.himg > img', this.config.contentElement, bigPictures);
    } else {
        if (hotelData && hotelData.images) {
            if (hotelData.images.length > 0) {
                for (i = 0, len = hotelData.images.length; i < len; i += 1) {
                    out.push('<div class="himg">');
                        out.push('<img src="' + (hotelData.images[i].name).replace('images_pl', 'images') + '" alt="" class="varHeight" />');
                    out.push('</div>');
                    bigPictures.push((hotelData.images[i].name).replace('images_pl', 'images'));
                }
            } else {
                out.push('<p class="nodataerror">Niestety zdjęcia od tego organizatora są niedostępne.</p>');
            }
        }
        $(this.config.contentElement, this.mainElement ).html( out.join('') ).removeClass().addClass('gallery');
        showBigImage('div.himg > img', this.config.contentElement, bigPictures);
    }
    $('ul > li', this.config.contentElement).fadeTo('fast', 0.5);
    $('ul > li.sel', this.config.contentElement).fadeTo('fast', 1);
    $('ul > li', this.config.contentElement).mouseover(
        function () {
            $(this).fadeTo('fast', 1);
        }
    );
    $('ul > li.nosel', this.config.contentElement).mouseout(
        function () {
            $(this).fadeTo('fast', 0.5);
        }
    );
    $('ul > li.sel', this.config.contentElement).mouseout(
        function () {
            $(this).fadeTo('fast', 1);
        }
    );
    //Po ponownym wywołaniu galerii ustalenie nowej wysokości
    if (typeof operator !== 'undefined') {
        this.fitHeight(true);
    }
    function getHotelData(operator) {
        var data;
        if (typeof operator !== 'undefined' && operator !== null) {
            //pobieranie danych z cache
            data = hib.findResult('WSfileTTWSHotel/getDescriptionForHotel',{iffCode:hib.currentIFF, touroperator:operator});
            if (typeof data === 'undefined') {
                hib.getData('TTWSHotel/getDescriptionForHotel', {iffCode : hib.currentIFF,
                    customerid:hib.KID,
                    country:'pl',
                    time:hib.currentTime,
                    accomCode:(hib.currentCRS)?hib.currentCRS:'',
                    touroperator:operator,
                    catalogs:(hib.currentCatalogs)?hib.currentCatalogs:''
                });
                data = hib.findResult('WSfileTTWSHotel/getDescriptionForHotel',{iffCode:hib.currentIFF, touroperator:operator});
            }
        } else {
            data = hib.findResult('WSfileTTWSHotel/getDescriptionForHotel',{iffCode:hib.currentIFF});
        }
        return data;
    };
    function getPoiData() {
        if (typeof hib.currentHPoiRefID !== 'undefined') {
            var data = hib.findResult('WSfileTTWSPOI/getPOIDetail',{poiRefID : hib.currentHPoiRefID});
            if (typeof data === 'undefined') {
                this.getData('TTWSPOI/getPOIDetail', {
                    poiRefID : hib.currentHPoiRefID
                });
                data = hib.findResult('WSfileTTWSPOI/getPOIDetail',{poiRefID : hib.currentHPoiRefID});
            }
            return data;
        } else {
            return [];
        }
    }
    function getPicTT() {
        var data = hib.findResult('WSfileTTWSAlmanach/getRegionInfo', {
            regionRefId : (hib.currentRefID) ? hib.currentRefID : '',
            iffCode : (hib.currentIFF) ? hib.currentIFF : ''
        });
        if (typeof data === 'undefined') {
            hib.getData('TTWSAlmanach/getRegionInfo', {
                regionRefId : (hib.currentRefID) ? hib.currentRefID : '',
                iffCode : (hib.currentIFF) ? hib.currentIFF : ''
            });
            data = hib.findResult('WSfileTTWSAlmanach/getRegionInfo',{
                regionRefId : (hib.currentRefID) ? hib.currentRefID : '',
                iffCode : (hib.currentIFF) ? hib.currentIFF : ''
            });
        }
        return data;
    }
};


function showBigImage(el, content, picture) {
    var x=0, posX, posY, deltaX = 50, deltaY = 40;
    $(el, content).each(function(){
        $(this)
            .data('image',picture[x++])
            .mouseover(
                function( event ){
                    posX = event.pageX
                    posY = event.pageY
                    $(hib.config.contentElement).parent().parent()
                        .append('<div id="cloudImg" ><div class="rShadow"><div class="imgContainer"><img src="'+$(this).data('image')+'"/></div></div><div class="bShadow"></div><div class="rbShadow"></div></div>') ;
                    $('.imgContainer img').load( fixWidthForIE7 );
                    fixWidthForIE7();
                    setCloudPosition();
                }
            ).mouseout(
                function(){
                    $('#cloudImg')
                        .remove();
                }
            ).mousemove(
                function( event ){
                    posX = event.pageX;
                    posY = event.pageY;
                    setCloudPosition();
                }
            )
    });

    function setCloudPosition(e) {
        var x = posX + deltaX;
        var y = posY + deltaY;
        var ob = $('#cloudImg');

        var maxY = window.pageYOffset+window.innerHeight;
        var maxX = window.pageXOffset+window.innerWidth;
        if (!maxX) {
            var d = document.documentElement;
            var maxY = d.scrollTop + d.offsetHeight;
            var maxX = d.scrollLeft + d.offsetWidth;
        }

        var h = ob.height() + 20;
        if (y+h>maxY) {
            y = maxY - h - deltaY;
        }
        var w = ob.width() + 20;

        if ( x + w > maxX) {
            x = x - w - deltaX;
        }
        ob.css( {left: (x - 10) +'px', top: (y + 10) +'px'})
    }

    function fixWidthForIE7(){

        // wyjdź gdy przeglądarka inna niż IE7
        if ( navigator.appVersion.search('MSIE 7.0')==-1 && navigator.appVersion.search('MSIE 8.0')==-1 ) return;

        // specjalnie dla ie7
        // trzeba na "twardo" ustalić szerokość DIVA, bo 100% nie działa
        var w = $('.imgContainer img').width();
        if (w!=0) $('.bShadow', $(hib.config.contentElement).parent()).width( $('.imgContainer').parent().parent().width() );

    }
}
