(function($){ var SchifferEngine = function() { } SchifferEngine.prototype = { //Constants daylight: '#838488', moonlight: '#4e5054', dark: '#1f2021', day_length: 30000, initial_rainfall_length: 8000, average_rainfall_length: 10000, rainfall_gap: 20000, rainfall_random_gap: 10000, spider_gap: 10000, spider_random_gap: 5000, moth_gap: 4000, moth_random_gap: 1000, dew_persist_duration: 5000, boar_gap: 20000, boar_random_gap: 10000, //Variables content: null, clouded_sky: null, skyline: null, foreground_trees: null, moon: null, sun: null, treetops: null, intro: null, feather: null, web: null, spider: null, moth: null, stage_ratio: 0, light_transitioning: false, boared: false, show_form: false, day_night_timer: 0, rain_timeout: 0, spider_timer: 0, moth_timer: 0, boar_timer: 0, random_rainer: 0, using_flash: false, ready: false, is_ie_8: false, try_to_start: function() { var t = this; if (t.using_flash) { return; } else { if (t.ready) { t.init_engine(); } else { //Try again shortly setTimeout('$engine.try_to_start()', 1000); } } }, init_engine: function() { var t = this; //Populate our variables with stuff we're going to be referring to often setTimeout("$engine.hide_chrome()", 100); t.content = $('#content'); t.skyline = t.content.children('.skyline'); t.clouded_sky = t.skyline.children('.clouded_sky'); t.moon = t.skyline.children('.moon'); t.sun = t.skyline.children('.sun'); t.treetops = t.content.children('.treetops'); t.intro = $('#intro'); t.web = t.content.children('.cobweb_holder'); t.spider = t.web.children('.spider_container'); t.moth = t.web.children('.moth'); t.feather = t.content.find('.small_feather'); t.foreground_trees = t.content.children('.tree_foreground'); $boar.init(); $moon.init(); $stars.init(); //Initialize the rotaterator t.stage_ratio = Math.min(t.content.width(), t.content.height())/Math.max(t.content.width(), t.content.height()); $rotate.init(); //Switch the loading graphic $('#loading').remove(); t.chain_intro_functions(); $intro.start(); if (t.show_form) { $signup.show(); } }, chain_intro_functions: function() { var t = this; $intro.intro_complete = function(){setTimeout('$moon.cloud()', 100)}; $moon.cloud_complete = function(){ $rain.start(); setTimeout('$rain.stop()', t.initial_rainfall_length); }; $rain.stop_complete = function(){ if($engine.is_ie_8 == false) { $web.dew(); } $moon.decloud(); setTimeout('$stars.shine()', 2000); }; $moon.decloud_complete = function(){$engine.standard_cycle_functions()}; /*if ($engine.is_ie_8 == false) $web.dew_complete = function(){setTimeout('$web.undew()', t.dew_persist_duration);setTimeout('$web.show_signup()', t.dew_persist_duration);}; else { $engine.web.children('.cobweb_signup').removeClass('.cobweb_signup').addClass('.cobweb_signup_fixed'); }*/ }, standard_cycle_functions: function() { var t = this; //Release the old handlers $intro.intro_complete = $moon.cloud_complete = $rain.stop_complete = $moon.decloud_complete = $.noop; //Start chaining together new functionality //Day-night chaining $moon.moonrise_out_complete = function(){$web.spider_saturate();$stars.fade();$sun.sunrise()}; $sun.sunrise_out_complete = function(){$stars.shine();$moon.moonrise()}; $moon.moonrise_complete = $sun.sunrise_complete = function(){t.day_night_timer = setTimeout('$engine.toggle_day_night()', t.day_length)}; //Rainstorm chaining $moon.cloud_complete = function(){$stars.destroy_all();$rain.start(); t.set_rain_timeout()}; $rain.stop_complete = function(){ t.rain_timeout = 0; if($moon.shining) { $moon.decloud(); } t.random_rainer = setTimeout('$engine.start_rain()', t.rainfall_gap + Math.floor(Math.random()*t.rainfall_random_gap) - t.rainfall_random_gap); }; $moon.decloud_complete = function(){$stars.shine()}; t.day_night_timer = setTimeout('$engine.toggle_day_night()', t.day_length); t.random_rainer = setTimeout('$engine.start_rain()', t.rainfall_gap + Math.floor(Math.random()*t.rainfall_random_gap)-t.rainfall_random_gap); $web.spider_complete = function(){$engine.spider_timer = setTimeout('$engine.start_spider()', $engine.spider_gap + Math.floor(Math.random()*$engine.spider_random_gap) - ($engine.spider_random_gap/2))}; $web.spider_complete(); $web.moth_complete = function(){$engine.moth_timer = setTimeout('$engine.start_moth()', $engine.moth_gap + Math.floor(Math.random()*$engine.moth_random_gap) - ($engine.moth_random_gap/2))}; $web.moth_complete(); t.boar_timer = setTimeout('$engine.random_boar()', t.boar_gap + Math.floor(Math.random() * (t.boar_random_gap * 2))-t.boar_random_gap); }, toggle_day_night: function() { var t = this; if (t.rain_timeout != 0 || $moon.clouded || t.boaring) { $rain.stop(); //Try again in a few moments t.day_night_timer = setTimeout('$engine.toggle_day_night()', 3000); } else { if ($sun.shining) { $sun.sunrise_out(); $web.spider_desaturate(); $boar.boar.removeClass('boar_daytime').addClass('boar_nighttime'); } else { $moon.moonrise_out(); $boar.boar.removeClass('boar_nighttime').addClass('boar_daytime'); } } }, set_rain_timeout: function() { var t = this; clearTimeout(t.rain_timeout); t.rain_timeout = 0; t.rain_timeout = setTimeout('$rain.stop()', t.average_rainfall_length + Math.floor(Math.random()*2000) - 1000); }, start_rain: function() { var t = this; if (!t.light_transitioning && !t.boared && !$sun.shining) { $stars.fade(); if ($moon.shining) { $moon.cloud(); } else { t.set_rain_timeout(); $rain.start(); } } else { //Try again later t.random_rainer = setTimeout('$engine.start_rain()', t.rainfall_gap + Math.floor(Math.random()*t.rainfall_random_gap) - t.rainfall_random_gap); } }, start_spider: function() { $web.animate_spider(); }, start_moth: function() { $web.animate_moth(); }, hide_chrome: function() { window.scrollTo(0, 1); }, left_boar: function() { var t = this; t.boared = true; $boar.move_on_left_complete = function(){$boar.play_sequence(2, 2, 3, 15)}; $boar.sequence_complete = function(){$boar.move_off_left()}; $boar.move_off_left_complete = function(){$engine.boared = false}; $boar.move_on_left(); }, right_boar: function() { var t = this; t.boared = true; $boar.move_on_right_complete = function(){$boar.play_sequence(2, 0, 1, 15)}; $boar.sequence_complete = function(){$boar.move_off_right()}; $boar.move_off_right_complete = function(){$engine.boared = false}; $boar.move_on_right(); }, random_boar: function() { var t = this; if (!t.boared && !t.light_transitioning && !t.rain_timeout > 0 && !$moon.clouded) (Math.floor(Math.random() * 2) == 0)?$engine.left_boar():$engine.right_boar(); t.boar_timer = setTimeout('$engine.random_boar()', t.boar_gap + Math.floor(Math.random() * (t.boar_random_gap * 2))-t.boar_random_gap); } }; window.$engine = window.SchifferEngine = new SchifferEngine(); })(jQuery); (function($){ var RainManager = function() { } RainManager.prototype = { start_complete: function(){}, stop_complete: function(){}, raindrop_complete: function(){}, //Constants raindrop_duration: 1500, raindrops_per_burst: 5, rain_interval: 500, //Variables raining: false, //raindrops: [], rain_timer: 0, start: function() { var t = this; clearInterval(t.rain_timer); //Clear the rain timer if we're already raining t.raining = true; t.rain_timer = setInterval('$rain.raindrop()', t.rain_interval); t.start_complete(); }, stop: function() { var t = this; t.raining = false; clearInterval(t.rain_timer); t.rain_timer = 0; t.stop_complete(); }, raindrop: function() { var t = this; if (t.raining) { for (var i = 0; i < t.raindrops_per_burst; ++i) new Raindrop(); } else { clearInterval(t.rain_timer); t.rain_timer = 0; } }, update_positions: function() { $engine.content.children('.raindrop').stop(true, false).remove(); } }; //Raindrop class var Raindrop = function() { var t = this; t.dom = $(document.createElement('div')).addClass('raindrop'); $engine.content.append(t.dom); //Pick a random position t.dom.css('left', Math.floor(Math.random()*($engine.content.width()-t.dom.width()))); //Pick a random sprite t.frame_x = (Math.floor(Math.random()*5) * t.dom.width() * -1 ); t.dom.css('backgroundPosition', t.frame_x+'px 0px'); //And a random death point t.death_y = Math.floor(Math.random()*($engine.content.height()-$engine.skyline.height()))+$engine.skyline.height(); //Work out the z-level based on the death point if (t.death_y < ($engine.skyline.height()+($engine.foreground_trees.position().top+($engine.foreground_trees.height()*0.84)))) { t.dom.css('z-index', 101); } else { t.dom.css('z-index', 302); } t.dom.animate( { top: t.death_y }, { duration: $rain.raindrop_duration + Math.floor(Math.random()*500), easing: 'linear', complete: function(){t.on_death()} } ); } Raindrop.prototype = { dom: null, death_y: 0, frame_x: 0, splash_life: 200, on_death: function() { var t = this; t.dom.css('backgroundPosition', t.frame_x+'px -'+t.dom.height()+'px'); t.dom.delay(t.splash_life).queue(function() {t.on_death_complete()}); }, on_death_complete: function() { var t = this; t.dom.remove(); delete t; } }; window.$rain = window.RainManager = new RainManager(); })(jQuery); (function($){ var MoonManager = function() { } MoonManager.prototype = { //Constants moon_duration: 20000, cloud_duration: 6000, cloud_out_duration: 6000, final_left: 0.479, final_right: 0.361, //Variables left_cloud: null, right_cloud: null, clouded: false, animating_decloud: false, shining: true, //Event handlers moonrise_complete: function(){}, moonset_complete: function(){}, moonrise_out_complete: function(){}, cloud_complete: function(){}, decloud_complete: function(){}, //Functions init: function() { var t = this; t.left_cloud = $engine.moon.find('.left_cloud').css('opacity', 0); t.right_cloud = $engine.moon.find('.right_cloud').css('opacity', 0); }, moonrise: function() { var t = this; t.shining=true; $engine.moon.show(); $engine.moon.animate( { top: ($engine.moon.height()/2)*-1 }, { duration: t.moon_duration, easing: 'easeOutQuad', complete: function(){$engine.moon.children('.mask').show(); $engine.light_transitioning=false; $engine.content.css('backgroundColor', $engine.moonlight); t.moonrise_complete()} } ); $engine.content.animate( { backgroundColor: $engine.moonlight }, { duration: t.moon_duration/2, easing: 'easeOutQuad' } ); }, moonrise_out: function() { var t = this; $engine.clouded_sky.stop(true, true); $engine.light_transitioning=true; $engine.moon.children('.mask').hide(); $engine.content.stop(true, false); $engine.moon.animate( { top: $engine.moon.height()*-1 }, { duration: t.moon_duration/4, easing: 'easeInQuad', complete: function(){t.shining=false; t.cleanup(); $engine.moon.hide(); $engine.moon.css('top', $engine.skyline.height()); $engine.content.css('backgroundColor', $engine.dark); t.moonrise_out_complete()} } ); $engine.content.animate( { backgroundColor: $engine.dark }, { duration: t.moon_duration/4, easing: 'easeInQuad' } ); }, moonset: function() { var t = this; $engine.clouded_sky.stop(true, true); $engine.light_transitioning=true; $engine.moon.children('.mask').hide(); $engine.content.stop(true, false); $engine.moon.animate( { top: $engine.skyline.height() }, { duration: t.moon_duration, easing: 'easeInQuad', complete: function(){t.shining=false; t.cleanup(); $engine.moon.hide(); $engine.content.css('backgroundColor', $engine.dark); t.moonset_complete()} } ); $engine.content.animate( { backgroundColor: $engine.dark }, { duration: t.moon_duration, easing: 'easeInQuad' } ); }, cloud: function() { var t = this; if (t.clouded == false) { t.clouded = true; //Start animating them in t.left_cloud.css('left', '').css('opacity', 1); t.right_cloud.css('left', '').css('opacity', 1); t.left_cloud.animate( { left: t.left_cloud.width() * t.final_left * -1 }, { duration: t.cloud_duration, easing: 'easeInOutSine', complete: function(){t.fade_moon()} } ); t.right_cloud.animate( { left: t.right_cloud.width() * t.final_right }, { duration: t.cloud_duration, easing: 'easeInOutSine' } ); } }, fade_moon: function() { var t = this; $engine.clouded_sky.stop(true, true); $engine.clouded_sky.animate({ opacity: 1 }, { duration: t.cloud_duration/2, easing: 'easeInSine', complete: function(){$moon.cloud_complete()} } ); }, decloud: function() { var t = this; if (t.clouded) { t.animating_decloud = true; t.left_cloud.css('opacity', 0); t.right_cloud.css('opacity', 0); $engine.clouded_sky.stop(true, true); $engine.clouded_sky.animate({ opacity: 0 }, { duration: t.cloud_duration/2, easing: 'easeOutSine', complete: function(){t.animating_decloud=false;t.clouded=false;$moon.decloud_complete()} } ); } }, fade_out: function() { $engine.moon.css('opacity', 0.5); }, cleanup: function() { var t = this; t.clouded = false; t.animating_decloud = false; $engine.clouded_sky.stop(true, false); $engine.clouded_sky.css('opacity', 0); t.left_cloud.css('opacity', 0); t.right_cloud.css('opacity', 0); }, update_positions: function() { var t = this; if (t.clouded && !t.animating_decloud) { t.left_cloud.stop(true, true); t.right_cloud.stop(true, true); t.left_cloud.css('left', t.left_cloud.width() * t.final_left * -1); t.right_cloud.css('left', t.right_cloud.width() * t.final_right); } } }; window.$moon = window.MoonManager = new MoonManager(); })(jQuery); (function($){ var SunManager = function() { } SunManager.prototype = { //Constants sun_duration: 20000, //Variables shining: false, //Event handlers sunrise_complete: function(){}, sunset_complete: function(){}, sunrise_out_complete: function(){}, //Functions sunrise: function() { var t = this; t.shining = true; $engine.sun.css('top', $engine.skyline.height()); $engine.sun.show(); $engine.content.stop(true, false); $engine.sun.animate( { top: ($engine.sun.height()/2)*-1 }, { duration: t.sun_duration, easing: 'easeOutQuad', complete: function(){t.sunrise_complete(); $engine.light_transitioning=false; $engine.content.css('backgroundColor', $engine.daylight); } } ); $engine.content.animate( { backgroundColor: $engine.daylight }, { duration: t.sun_duration/2, easing: 'easeOutQuad' } ); }, sunrise_out: function() { var t = this; $engine.light_transitioning=true; $engine.content.stop(true, false); $engine.sun.animate( { top: $engine.sun.height()*-1 }, { duration: t.sun_duration/4, easing: 'easeInQuad', complete: function(){t.shining=false; $engine.sun.hide(); $engine.sun.css('top', $engine.skyline.height()); $engine.content.css('backgroundColor', $engine.dark); t.sunrise_out_complete()} } ); $engine.content.animate( { backgroundColor: $engine.dark }, { duration: t.sun_duration/4, easing: 'easeInQuad' } ); }, sunset: function() { var t = this; $engine.light_transitioning=true; $engine.content.stop(true, false); $engine.sun.animate( { top: $engine.skyline.height() }, { duration: t.moon_duration, easing: 'easeInQuad', complete: function(){t.shining=false; $engine.sun.hide(); $engine.content.css('backgroundColor', $engine.dark); t.sunset_complete()} } ); $engine.content.animate( { backgroundColor: $engine.dark }, { duration: t.sun_duration, neasing: 'easeInQuad' } ); } }; window.$sun = window.SunManager = new SunManager(); })(jQuery); (function($){ var WebManager = function() { } WebManager.prototype = { dew_duration: 2000, spider_frames: 2, spider_frame_duration: 100, moth_frames: 5, moth_frame_duration: 25, //Variables dewed: false, signup: false, spider_frame: 0, spider_timer: 0, spider_timeout: 0, spider_animate_average: 500, spider_animate_random: 200, moth_frame: 0, moth_timer: 0, moth_timeout: 0, moth_animate_average: 500, moth_animate_random: 100, moth_direction: 0, //Event handlers dew_complete: function(){}, undew_complete: function(){}, signup_complete: function(){}, unsignup_complete: function(){}, spider_complete: function(){}, spider_saturate_complete: function(){}, spider_desaturate_complete: function(){}, //Functions dew: function() { var t = this, dew_web = $('.cobweb_dew'); t.dewed = true; dew_web.animate( { opacity: 0.6 }, { duration: t.dew_duration, easing: 'easeInOutQuad', complete: function(){t.dew_complete()} } ); }, undew: function() { var t = this, dew_web = $('.cobweb_dew'); dew_web.animate( { opacity: 0 }, { duration: t.dew_duration, easing: 'easeInOutQuad', complete: function(){t.dewed=false;t.undew_complete()} } ); }, show_signup: function() { var t = this, signup_web = $('.cobweb_signup'); t.signup = true; signup_web.animate( { opacity: 1 }, { duration: t.dew_duration, easing: 'easeInOutQuad', complete: function(){t.signup_complete()} } ); }, hide_signup: function() { var t = this, signup_web = $('.cobweb_signup'); signup_web.animate( { opacity: 0 }, { duration: t.dew_duration, easing: 'easeInOutQuad', complete: function(){t.signup=false;t.unsignup_complete()} } ); }, animate_spider: function() { var t = this; t.spider_timer = setInterval('$web.spider_tick()', t.spider_frame_duration); t.spider_timeout = setTimeout('$web.stop_spider()', t.spider_animate_average + Math.floor(Math.random() * t.spider_animate_random)-(t.spider_animate_random/2)); }, stop_spider: function() { var t = this; clearInterval(t.spider_timer); clearTimeout(t.spider_timeout); t.spider_timer = 0; t.spider_timeout = 0; t.spider_complete(); }, spider_tick: function() { var t = this; ++t.spider_frame; if (t.spider_frame >= t.spider_frames) { t.spider_frame = 0; } $engine.spider.children('.shell').css('backgroundPosition', $engine.spider.width() * t.spider_frame * -1); }, spider_saturate: function() { var t = this; $engine.spider.children('.colour').animate( { opacity: 1 }, { duration: $sun.sun_duration/2, easing: 'easeOutQuad', complete: function(){t.spider_saturate_complete()} } ); }, spider_desaturate: function() { var t = this; $engine.spider.children('.colour').animate( { opacity: 0 }, { duration: $sun.sun_duration/4, easing: 'easeOutQuad', complete: function(){t.spider_desaturate_complete()} } ); }, update_positions: function() { var t = this; $engine.spider.children('.shell').css('backgroundPosition', $engine.spider.width() * t.spider_frame * -1); }, animate_moth: function() { var t = this; t.moth_timer = setInterval('$web.moth_tick()', t.moth_frame_duration); t.moth_timeout = setTimeout('$web.stop_moth()', t.moth_animate_average + Math.floor(Math.random() * t.moth_animate_random)-(t.moth_animate_random/2)); }, stop_moth: function() { var t = this; clearInterval(t.moth_timer); clearTimeout(t.moth_timeout); t.moth_timer = 0; t.moth_timeout = 0; t.moth_frame = 0; $engine.moth.css('backgroundPosition', $engine.moth.width() * t.moth_frame * -1); t.moth_complete(); }, moth_tick: function() { var t = this; if (t.moth_direction) { --t.moth_frame; if (t.moth_frame <= 0) { t.moth_direction = 0; } } else { ++t.moth_frame; if (t.moth_frame >= t.moth_frames - 1) { t.moth_direction = 1; } } $engine.moth.css('backgroundPosition', $engine.moth.width() * t.moth_frame * -1); } }; window.$web = window.WebManager = new WebManager(); })(jQuery); (function($){ var StarManager = function() { } StarManager.prototype = { shine_complete:function(){}, fade_complete: function(){}, shining: false, max_stars: 6, stars: [], fade_duration: 1500, twinkle_duration: 500, twinkler_timer: 0, init: function() { var t = this; for (var i = 0; i < t.max_stars; ++i) { t.stars.push(new Star()); } }, shine: function() { var t = this; if (!t.shining) { t.shining = true; for (var i in t.stars) { t.stars[i].shine(i % 2); } t.shine_complete(); clearInterval(t.twinkler_timer); t.twinkler_timer = setInterval('$stars.twinkle()', t.twinkle_duration*2); } }, fade: function() { var t = this; t.shining = false; clearInterval(t.twinkler_timer); for(var i in t.stars) { t.stars[i].fade(); } t.fade_complete(); }, twinkle: function() { var t = this; if (t.shining && t.stars.length > 0) { t.stars[Math.floor(Math.random()*t.stars.length)].twinkle(); } else { clearInterval(t.twinkler_timer); } }, destroy_all: function() { var t = this; for (var i in t.stars) { t.stars[i].destroy(); } }, update_positions: function(new_orientation, last_orientation) { var t = this; for(var i in t.stars) { t.stars[i].dom.css('top', $engine.content.height() * t.stars[i].ratio_from_top); if (t.stars[i].ratio_from_left < t.stars[i].ratio_from_right) { t.stars[i].dom.css('left', $engine.content.width() * t.stars[i].ratio_from_left); } else { t.stars[i].dom.css('left', $engine.content.width() - ($engine.content.width() * t.stars[i].ratio_from_right)); } t.stars[i].dom.css('backgroundPosition', (t.frame * t.stars[i].dom.width() * -1 )+'px 0px'); } } }; var Star = function() { var t = this, offset = 0; t.dom = $(document.createElement('div')).addClass('star').css('opacity', 0); $engine.content.append(t.dom); } Star.prototype = { dom: null, frame: 0, ratio_from_left: 0, ratio_from_right: 0, ratio_from_top: 0, shine: function(right_hand_side) { var t = this, offset = 0; t.destroy(); //Pick a random frame t.frame = Math.floor(Math.random()*5); t.dom.css('backgroundPosition', (t.frame * t.dom.width() * -1 )+'px 0px'); if (right_hand_side == 1) { offset = ($engine.content.width()/2)+($engine.moon.width()/2); } //Pick a random position t.dom.css('left', Math.floor(Math.random()*(($engine.content.width()/2)-($engine.moon.width()/2)-t.dom.width()))+offset); t.dom.css('top', Math.floor(Math.random()*($engine.treetops.position().top-t.dom.height()))); //Set our ratios t.ratio_from_left = t.dom.position().left / $engine.content.width(); t.ratio_from_right = ($engine.content.width() - t.dom.position().left) / $engine.content.width(); t.ratio_from_top = t.dom.position().top / $engine.content.height(); t.dom.animate( { opacity: 1 }, { duration: $stars.fade_duration + (Math.floor(Math.random()*200)-100), easing: 'easeInSine', complete: function(){} } ); }, twinkle: function() { var t = this; t.dom.stop(true, true); t.dom.animate( { opacity:0.5 }, { duration: $stars.twinkle_duration, easing: 'easeInOutSine' }).animate( { opacity:1 }, { duration: $stars.twinkle_duration, easing: 'easeInOutSine' }); }, fade: function() { var t = this; t.dom.stop(true, false); t.dom.animate( { opacity: 0 }, { duration: $stars.fade_duration, easing: 'easeInOutSine', complete: function(){t.destroy()} } ); }, destroy: function() { var t = this; t.dom.stop(true, false); t.dom.css('opacity', 0); } }; window.$stars = window.StarManager = new StarManager(); })(jQuery); (function($){ var BoarManager = function() { } BoarManager.prototype = { //Constants boar_frames: 4, boar_sequences: 3, boar_animation_speed: 100, //Lower is faster walk_duration: 5000, //Variables boar: null, start_frame: 0, current_frame: 0, current_sequence: 0, target_frame: 0, target_frame_wait: 0, reverse: false, sequence_complete: function(){}, move_on_left_complete: function(){}, move_on_right_complete: function(){}, move_off_left_complete: function(){}, move_off_right_complete: function(){}, animate_timer: 0, init: function() { var t = this; t.boar = $engine.content.find('.boar'); }, animate: function() { var t = this; t.stop_animation(); t.animate_timer = setInterval('$boar.increment_frame()', t.boar_animation_speed); }, increment_frame: function() { var t = this; if (t.reverse) { --t.current_frame; if (t.current_frame == 0) t.reverse = false; } else { ++t.current_frame; if (t.current_frame == t.boar_frames - 1) t.reverse = true; } t.update_frame(); }, set_sequence: function(sequence) { var t = this; t.current_frame = 0; t.current_sequence = sequence; }, play_sequence: function(sequence, start_frame, end_frame, final_frame_wait) { var t = this; t.stop_animation(); t.set_sequence(sequence); t.current_frame = t.start_frame = start_frame; t.target_frame = end_frame; t.target_frame_wait = final_frame_wait; t.animate_timer = setInterval('$boar.increment_sequence_frame()', t.boar_animation_speed); }, increment_sequence_frame: function() { var t = this; if (t.reverse) { if (t.current_frame == t.start_frame) { t.stop_animation(); t.sequence_complete(); } else { --t.current_frame; } } else { if (t.current_frame < t.target_frame + t.target_frame_wait) { ++t.current_frame; } else { t.reverse = true; } } t.force_frame(t.current_sequence, (t.current_frame <= t.target_frame)?t.current_frame:t.target_frame); }, update_frame: function() { var t = this; t.boar.css('backgroundPosition', (t.boar.width() * t.current_frame * -1) + "px " + (t.boar.height() * t.current_sequence * -1) + 'px'); }, force_frame: function(sequence, index) { var t = this; t.boar.css('backgroundPosition', (t.boar.width() * index * -1) + "px " + (t.boar.height() * sequence * -1) + 'px'); }, stop_animation: function() { var t = this; clearInterval(t.animate_timer); t.reverse = false; }, move_on_left: function() { var t = this; t.stop_animation(); t.boar.css('top', $engine.foreground_trees.position().top + $engine.foreground_trees.height() - (t.boar.height()*1.5)); t.boar.css('left', t.boar.width() * -1); t.set_sequence(1); t.animate(); t.boar.animate( { left: $engine.web.position().left - ($engine.content.width() * 0.0976) - ($boar.boar.width()*.85) }, { duration: t.walk_duration, easing: 'linear', complete: function(){$boar.stop_animation();$boar.move_on_left_complete()} }); }, move_on_right: function() { var t = this; t.stop_animation(); t.boar.css('top', $engine.foreground_trees.position().top + $engine.foreground_trees.height() - (t.boar.height()*1.5)); t.boar.css('left', $engine.content.width() + t.boar.width()); t.set_sequence(0); t.animate(); t.boar.animate( { left: $engine.web.position().left + $engine.web.width() - ($engine.content.width() * 0.078) + ($boar.boar.width()*.60) }, { duration: t.walk_duration, easing: 'linear', complete: function(){$boar.stop_animation();$boar.move_on_right_complete()} }); }, move_off_left: function() { var t = this; t.stop_animation(); t.set_sequence(0); t.animate(); t.boar.animate( { left: t.boar.width() *-1 }, { duration: t.walk_duration, easing: 'linear', complete: function(){$boar.stop_animation();$boar.move_off_left_complete()} }); }, move_off_right: function() { var t = this; t.stop_animation(); t.set_sequence(1); t.animate(); t.boar.animate( { left: $engine.content.width() + t.boar.width() }, { duration: t.walk_duration, easing: 'linear', complete: function(){$boar.stop_animation();$boar.move_off_right_complete()} }); }, update_positions: function() { var t = this; t.stop_animation(); t.boar.stop(true, false); t.boar.css('top', 0); t.boar.css('left',-9999); $engine.boared = false; } }; window.$boar = window.BoarManager = new BoarManager(); })(jQuery); (function($){ var IntroManager = function() { } IntroManager.prototype = { intro_complete: function(){}, fall_duration: 7000, web_stick_ratio: 0.7, intro_running: false, start: function() { var t = this; t.skip(); }, skip: function() { var t = this; if ($engine.intro) { $engine.intro.remove(); $engine.intro = null; } t.intro_complete(); }, update_positions: function() { var t = this; } }; window.$intro = window.IntroManager = new IntroManager(); })(jQuery); (function($){ var RotateHandler = function() { } RotateHandler.prototype = { last_orientation: 0, supportsOrientationChange: false, init: function() { var t = this; t.supportsOrientationChange = "onorientationchange" in window; if (t.supportsOrientationChange == true) { window.onorientationchange = function(){$rotate.handle_rotation()}; window.onresize = function(){}; } else { window.onresize = function(){$rotate.handle_rotation()}; } t.last_orientation = window.orientation; }, handle_rotation: function() { var t = this, orientation = window.orientation; if (!t.supportsOrientationChange || (orientation != t.last_orientation && orientation != t.last_orientation *-1)) { t.update_positions(orientation, t.last_orientation); } t.last_orientation = orientation; }, update_positions: function(new_orientation, last_orientation) { var t = this; $intro.update_positions(); $stars.update_positions(new_orientation, last_orientation); $web.update_positions(); $rain.update_positions(); $moon.update_positions(); $boar.update_positions(); $engine.hide_chrome(); } }; window.$rotate = window.RotateHandler = new RotateHandler(); })(jQuery); (function($){ var ResizeHandler = function() { } ResizeHandler.prototype = { init: function() { var t = this; window.onresize = function(){$resize.handle_resize()}; }, handle_resize: function() { var width = $(window).width(), height = $(window).height(), base_width = 1200, base_height = 840, r_wh = base_width / base_height, r_hw = base_height / base_width; //This needs to be at an aspect ratio of 1.333, so cap our sizes if (height > width * r_hw) { height=Math.floor(width*r_hw); } else if (width > height * r_wh) { width=Math.floor(height*r_wh); } if (width > base_width) { $('#flash_wrapper').css('width', base_width+'px').css('height', base_height+'px'); } else { $('#flash_wrapper').css('width', width+'px').css('height', height+'px'); } $('#flash_wrapper').css('top', Math.floor(($(window).height()/2)-($('#flash_wrapper').height()/2))); } }; window.$resize = window.ResizeHandler = new ResizeHandler(); })(jQuery); (function($){ var SignupHandler = function() { } SignupHandler.prototype = { init: function() { $('.signup_wrapper').css('top', '9999px'); var options = { beforeSubmit: $signup.validation, success: $signup.form_submit_success, failure: $signup.form_submit_error, dataType: 'xml' }, t = this; $('.signup_container').ajaxForm(options); $('input').each(function() { if ($(this).val() != "") { $(this).parent().find('label').css({'color':'#FFF'}); } else { $(this).parent().find('label').css({'color':'#000'}); } }); $('input').focus(function() { $(this).parent().find('label').css({'color':'#FFF'}); }).blur(function() { if($(this).val() == "") { $(this).parent().find('label').css({'color':'#000'}); } }); $('#signup_link, .small_feather, .feather_caption, .fallback_signup').click(function() { t.show(); }); $('.moth, .moth_caption').click(function() { window.location = $('.moth').children('a').attr('href'); }); $('.fallback_cashmere').click(function() { window.location = $('.fallback_cashmere').children('a').attr('href'); }); $('.close_button').click(function() { $('.signup_wrapper').css('top', '9999px'); }); }, show: function() { $('.signup_wrapper').css('top', ''); }, validation: function() { //Currently, does nothing as we no longer have a TC checkbox return true; }, form_submit_success: function(xml,st,xhr) { my_xml = $(xml); if (my_xml.find('success').length > 0) { //Yay! $('.signup_container').html('
Thank you for signing up.
'); } else if (my_xml.find('error').length > 0) { //Display a specific error $('.errors').text(my_xml.find('error').text()); } else { //Nondescript error $('.errors').text('Please fill in all fields with valid data.'); } }, form_submit_error: function() { $('.errors').text('Please fill in all fields with valid data.'); } }; window.$signup = window.SignupHandler = new SignupHandler(); })(jQuery);