var preloader_app = Class.create({ appname: 'preloader_app', verbose: false, images: [], images_to_load: [], loaded: 0, images_count: 0, progress_deferrer: 1800, initialize: function() { this.debug('Preloader wurde gestartet.'); tmpImage = new Image(); tmpImage.src = '/imgs/no_javascript.jpg'; if(!tmpImage.complete) { this.images.push('/imgs/b_back.png'); this.images.push('/imgs/b_bereisen.png'); this.images.push('/imgs/b_contentclose.png'); this.images.push('/imgs/b_entdecken.png'); this.images.push('/imgs/b_erleben.png'); this.images.push('/imgs/b_homelogo.png'); this.images.push('/imgs/b_info.png'); this.images.push('/imgs/b_lang_de.png'); this.images.push('/imgs/b_navscroll_left.png'); this.images.push('/imgs/b_navscroll_right.png'); this.images.push('/imgs/b_suche.png'); this.images.push('/imgs/ber_bus.png'); this.images.push('/imgs/ber_flughaefen.png'); this.images.push('/imgs/ber_hbf.png'); this.images.push('/imgs/ber_hotels.png'); this.images.push('/imgs/ber_laterne.png'); this.images.push('/imgs/ber_rad.png'); this.images.push('/imgs/ber_schiff.png'); this.images.push('/imgs/ber_taxi.png'); this.images.push('/imgs/ber_ubahn.png'); this.images.push('/imgs/ber_voegel.png'); this.images.push('/imgs/bg_blend_left.png'); this.images.push('/imgs/bg_blend_right.png'); this.images.push('/imgs/bg_body.gif'); this.images.push('/imgs/bg_content.png'); this.images.push('/imgs/bg_detail.png'); this.images.push('/imgs/bg_filter.gif'); this.images.push('/imgs/bg_filters.gif'); this.images.push('/imgs/bg_filters_li.gif'); this.images.push('/imgs/bg_h3.gif'); this.images.push('/imgs/bg_li_suche.png'); this.images.push('/imgs/bg_preloader.jpg'); this.images.push('/imgs/bg_preloader_percentage.png'); this.images.push('/imgs/bg_preloader_visual.gif'); this.images.push('/imgs/bg_scrollcontent.jpg'); this.images.push('/imgs/bg_scrollhandle.png'); this.images.push('/imgs/bg_scrolltrack.gif'); this.images.push('/imgs/bg_subnav.png'); this.images.push('/imgs/bg_tooltip_left.png'); this.images.push('/imgs/bg_tooltip_middle.png'); this.images.push('/imgs/bg_tooltip_right.png'); this.images.push('/imgs/bg_visuals.jpg'); this.images.push('/imgs/ent_baeume.png'); this.images.push('/imgs/ent_baum.png'); this.images.push('/imgs/ent_brandenburgertor.png'); this.images.push('/imgs/ent_dom.png'); this.images.push('/imgs/ent_fernsehturm.png'); this.images.push('/imgs/ent_mauer.png'); this.images.push('/imgs/ent_parkinn.png'); this.images.push('/imgs/ent_potsdamerplatz.png'); this.images.push('/imgs/ent_rathaus.png'); this.images.push('/imgs/ent_reichstag.png'); this.images.push('/imgs/ent_siegessaeule.png'); this.images.push('/imgs/ent_sonycenter.png'); this.images.push('/imgs/ent_voegel.png'); this.images.push('/imgs/erl_alexa.png'); this.images.push('/imgs/erl_altesmuseum.png'); this.images.push('/imgs/erl_baeume.png'); this.images.push('/imgs/erl_ballonfahrt.png'); this.images.push('/imgs/erl_baum.png'); this.images.push('/imgs/erl_fernsehturm.png'); this.images.push('/imgs/erl_friedrichstadtpalast.png'); this.images.push('/imgs/erl_kadewe.png'); this.images.push('/imgs/erl_kino.png'); this.images.push('/imgs/erl_laterne.png'); this.images.push('/imgs/erl_schillertheater.png'); this.images.push('/imgs/erl_voegel.png'); this.images.push('/imgs/logo1.png'); this.images.push('/imgs/no_javascript.jpg'); this.images.push('/imgs/scroll_alexa.png'); this.images.push('/imgs/scroll_altesmuseum.png'); this.images.push('/imgs/scroll_brandenburgertor.png'); this.images.push('/imgs/scroll_dom.png'); this.images.push('/imgs/scroll_fernsehturm.png'); this.images.push('/imgs/scroll_friedrichstadtpalast.png'); this.images.push('/imgs/scroll_hbf.png'); this.images.push('/imgs/scroll_kadewe.png'); this.images.push('/imgs/scroll_nahverkehr.png'); this.images.push('/imgs/scroll_parkinn.png'); this.images.push('/imgs/scroll_potsdamerplatz.png'); this.images.push('/imgs/scroll_prater.png'); this.images.push('/imgs/scroll_rathaus.png'); this.images.push('/imgs/scroll_reichstag.png'); this.images.push('/imgs/scroll_siegessaeule.png'); this.images.push('/imgs/scroll_tegel.png'); this.images.push('/imgs/scroll_ubahn.png'); this.images_to_load = this.images; this.images_count = this.images.length; this.build(); this.start(); } else { this.debug('Preloader wurde gestoppt, da alle Bilder bereits im Cache liegen.'); } }, build: function() { new Insertion.Top($$('body')[0], '
'); $('container').setOpacity(0.01); this.debug('HTML-Elemente wurden erstellt.'); }, start: function() { c = 0; this.images.each(function(a) { window['preloaderimg'+c] = new Image(); window['preloaderimg'+c].src = a; c++; }); this.pe = new PeriodicalExecuter(function() { this.preload(); }.bind(this), 0.01); this.debug('Bilder wurden zum Laden vorbereitet.'); }, preload: function() { c = 0; this.images_to_load.each(function(a,b) { if(window['preloaderimg'+c].complete) { this.images_to_load = this.images_to_load.without(a); this.loaded++; this.progress(); this.debug('Bild "'+a+'" wurde geladen.'); } c++; }.bind(this)); if(this.loaded == this.images_count) { this.debug('Alle Bilder wurden erfolgreich geladen.'); this.pe.stop(); } }, progress: function() { percentage = Math.floor((this.loaded/this.images_count)*100); visualheight = Math.floor((percentage/100)*138); this.updateprogress(percentage, visualheight); }, updateprogress: function(percentage, height) { this.progress_deferrer += 70; window.setTimeout(function() { this.updateprogressnow(percentage, height); if(percentage == 100) { this.finish(); } }.bind(this, percentage, height), this.progress_deferrer); }, updateprogressnow: function(percentage, height) { $('preloader-percentage').update(percentage+'%'); $('preloader-visual').setStyle('height: '+height+'px;'); this.debug('Fortschritt: '+percentage); }, finish: function() { $('preloader-percentage').morph('top: -1500px;'); $('preloader').fade({ afterFinish: function() { $('preloader').remove(); } }); $('container').appear(); this.debug('Preloader wurde beendet.'); }, debug: function(msg) { if(window.console && this.verbose) { window.console.log(this.appname+': '+msg); } } });