Mission.tasks(1).extend ( {

	setup : function ( cb ) {
		Portal.loadPage ( this, 'emometer/', null, function() { cb(); } );
	},

	start : function ( cb ) {
		setStoppableTimeout ( this, function ( ) {
			Emometer.init ( {
				love : {
					target : { min : 0.6, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.02
				},
				empathy : {
					target : { min : 0.3, max : 0.5 },
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				happiness : {
					target : { min : 0.5, max : 0.6 },
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				sadness : {
					target : { min : 0.3, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.01
				},
				hatred : {
					target : { min : 0.4, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.03
				}
			} );
			var bg = null;
			SoundStage.whenReady ( function ( ) {
				bg = new SoundStage.Sound ( '/audio/replay/m12_bg2.mp3', {
					noSubtitles : true,
					autoPlay : true,
					id : "t1bg"
				} );
			} );
			setTimeout( function() {
				Emometer.start ( function ( ) {
					timer.stop();
					setTimeout ( function ( ) {
						if ( bg && bg.loaded() ) bg.stop();
						loadScript ( '/scripts/chat/audio.js', function ( s ) {
							loadConversation ( '/scripts/replay/conversations/task-1.js', function ( s ) {
								Portal.loadPage ( null, 'blank/', function ( ) {
									showStatusUpdate ( "5 days after Jamie's death" );
									var audio = new Audio ( window.scripts.TASK_1_0, true, function ( ) {
										Portal.loadPage ( null, 'ws-billy/2/', function ( ) {
											loadScript ( '/scripts/chat/thoughts.js', function ( s ) {
												var t = new Thoughts ( window.scripts.TASK_1_1, true, cb );
											} );
										} );
									} );
								} );
							} );
						} );
					}, 2000 );
				} );
				var timer = Timer.start ( 60, function ( t ) {
					if ( !t.remaining ) {
						Emometer.stop ( false );
						setTimeout( function() { Mission.fail( "Too slow" ); }, 2000 );
					}
				} );
			}, 2000 );
		}, 500 );
	}

} );

