/** * Hotel-Details der Fairplay-Hotels */ function cat_data (pcon_id, pcon_parent, pcon_list) { this.pcon_id = pcon_id; this.pcon_parent = pcon_parent; this.pcon_list = pcon_list; this.parent = false; this.childs = new Array(); this.data = new Array(); this.add_data = function (name, value) { this.data[name] = value; } this.get_data = function (id) { return this.data[id]; } this.get_sort_data = function () { return this.data[77]; } this.addChild = function (pcon_id, child_o) { this.childs[pcon_id] = child_o; child_o.parent = this; } } function stringSort(a_o, b_o) { a=a_o.get_sort_data(); b=b_o.get_sort_data(); a = a.toLowerCase(); a = a.replace(/ä/g,"a"); a = a.replace(/ö/g,"o"); a = a.replace(/ü/g,"u"); a = a.replace(/ß/g,"s"); b = b.toLowerCase(); b = b.replace(/ä/g,"a"); b = b.replace(/ö/g,"o"); b = b.replace(/ü/g,"u"); b = b.replace(/ß/g,"s"); return(a==b)?0:(a>b)?1:-1; } ps.Fairplay = { laender : Array(), regionen : Array(), countTimer : false, Init : function () { if ($$('body')[0].hasClassName('fairplay') && $('details') != null) { if ($('photos') != null) { $('photos').setStyle({ width: (244 * $$('#photos li').length) + 'px' }); } if ($('small_photos') != null) { $$('#small_photos img').each( function (n, i) { n.observe('mouseover', function () { n.setStyle({'cursor': 'pointer'}); }); n.observe('mouseout', function () { n.setStyle({'cursor': 'default'}); }); n.observe('mousedown', function () { $('photos').setStyle({'left': '-' + (244*i) + 'px'}); }); }); } } if ($('detailsuche') != null) this.Detailsuche(); if ($('panorama') != null) this.Panorama.init(); }, addLand : function (pcon_id, pcon_parent, pcon_list) { this.laender[pcon_id] = new cat_data(pcon_id, pcon_parent, pcon_list); }, addLandData : function (pcon_id, setup_id, value) { this.laender[pcon_id].add_data(setup_id, value); }, addRegion : function (pcon_id, pcon_parent, pcon_list) { this.regionen[pcon_id] = new cat_data(pcon_id, pcon_parent, pcon_list); }, addRegionData : function (pcon_id, setup_id, value) { this.regionen[pcon_id].add_data(setup_id, value); }, addRegionToLand : function () { for( var pcon_id in this.regionen ) { if(typeof this.regionen[pcon_id] == "function") continue; this.laender[ this.regionen[pcon_id].pcon_parent ].addChild(pcon_id, this.regionen[pcon_id]); } }, sortLand : function () { var dummy = new Array(); for( var pcon_id in this.laender ) { if(typeof this.laender[pcon_id] == "function") continue; dummy[dummy.length] = this.laender[pcon_id]; } this.laender = new Array(); dummy.sort(stringSort); for( var idx in dummy ) { if(typeof dummy[idx] == "function") continue; this.laender[dummy[idx].pcon_id] = dummy[idx]; } }, getPcon_idByPcon_list : function (pcon_list) { for( var pcon_id in this.laender ) { if(typeof this.laender[pcon_id] == "function") continue; if(this.laender[pcon_id].pcon_list == pcon_list) return pcon_id; } return "30"; }, /** * Detailsuche */ Detailsuche : function () { $$('#reisemonate li label').each(function (n, i) { n.observe('click', function () { n.up('li').toggleClassName('bevorzugt'); }); }); var form = $('suche'); var form = $('suche'); var reiseziel = form['reiseziel']; $(reiseziel).observe('change', function (evt) { ps.Fairplay.regionWechsel(""); }); new Form.EventObserver(form, function (evt) { if(ps.Fairplay.countTimer) return; ps.Fairplay.countTimer = window.setTimeout("ps.Fairplay.checkCountHotels()", 100); }); this.checkCountHotels(); }, /** * check anzahl hotels */ checkCountHotels : function () { var url = '/inc/suche_count.php'; var params = $('suche').request(); var ajax = new Ajax.Updater({ success: 'hotelCounter' }, url,{ parameters: params }); ps.Fairplay.countTimer = false; }, /** * zeige anzahl an */ showResult : function (originalRequest) { alert(originalRequest.responseText); }, /** * Regionwechsel */ regionWechsel : function (preset_pcon_id) { var reiseziel = $('suche')['reiseziel']; l_pcon_id = ps.Fairplay.getPcon_idByPcon_list(reiseziel.options[reiseziel.selectedIndex].value); this.regionReplace( l_pcon_id, preset_pcon_id) }, regionReplace : function (l_pcon_id, preset_pcon_id) { $("region").length = 0; if(typeof this.laender[l_pcon_id] == "undefined") { neu = new Option("beliebig","30"); $("region").options[$("region").length] = neu; } else { neu = new Option("beliebig", this.laender[l_pcon_id].pcon_list); $("region").options[$("region").length] = neu; for ( var r_pcon_id in this.laender[l_pcon_id].childs ) { if(typeof this.regionen[r_pcon_id] == "function") continue; neu = new Option(this.regionen[r_pcon_id].get_data(77), this.regionen[r_pcon_id].pcon_list, false, ( preset_pcon_id == this.regionen[r_pcon_id].pcon_list ? true : false )); $("region").options[$("region").length] = neu; } } }, /** * Reisemonate wechseln */ setReisemonate : function (wert) { var feld = $(wert); if(feld.disabled){ feld.enable(); feld.disabled = false; this.checkCountHotels(); }else{ feld.disable(); feld.disabled = true; this.checkCountHotels(); } }, /** * Panoramagalerie */ Panorama : { // Vorschaubild wechseln vorschau_wechseln : function (event) { var me = Event.element(event); if ( $(me.readAttribute('class')).hasClassName('visible_img') ) return; Effect.Fade( $$('.visible_img')[0], { afterFinish : function () { $$('.visible_img')[0].removeClassName('visible_img'); } }); if ( $($$('.visible_img')[0].id.replace(/bild/g, "text")).visible() ) Effect.Fade( $($$('.visible_img')[0].id.replace(/bild/g, "text"))); Effect.Appear( $(me.readAttribute('class')), { afterFinish : function () { $(me.readAttribute('class')).addClassName('visible_img'); } }); }, // Text ein-/ausblenden toggle_text : function () { if ( $($$('.visible_img')[0].id.replace(/bild/g, "text")).visible() ) Effect.Fade( $($$('.visible_img')[0].id.replace(/bild/g, "text")), { duration: .5 } ); else Effect.Appear( $($$('.visible_img')[0].id.replace(/bild/g, "text")), { duration: .5 } ); }, // Initialisierung init : function () { $$('#panorama .vorschau img').each(function (n, i) { // grosse Bilder und Texte ausblenden $(n.readAttribute('class')).setStyle({ opacity : i == 0 ? 1 : 0 }); $(n.readAttribute('class').replace(/bild_/, "text_") ).setStyle({ display: 'none' }); $(n.readAttribute('class')).addClassName( i == 0 ? 'visible_img' : '' ); // Vorschau-Bilder anklickbar machen Event.observe( n, 'click', ps.Fairplay.Panorama.vorschau_wechseln ); Event.observe( n, 'mouseover', function (evt) { var element = Event.element(evt); element.setStyle({ cursor: 'pointer' }); } ); Event.observe( n, 'mouseout', function (evt) { var element = Event.element(evt); element.setStyle({ cursor: 'auto' }); } ); // Texte einblenden Event.observe( $('info_button'), 'click', ps.Fairplay.Panorama.toggle_text ); Event.observe( $('info_button'), 'mouseover', function (evt) { var element = Event.element(evt); element.setStyle({ cursor: 'pointer' }); } ); Event.observe( $('info_button'), 'mouseout', function (evt) { var element = Event.element(evt); element.setStyle({ cursor: 'auto' }); } ); }, this); } } }