Mission.tasks(3).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 : {
						cycle : [
							{ min : 0.3, max : 0.5, time : 2500 },
							{ min : 0.0, max : 0.2, time : 2500 }
						]
					},
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				happiness : {
					target : {
						cycle : [
							{ min : 0.3, max : 0.5, time : 2500 },
							{ min : 0.6, max : 0.8, time : 2500 }
						]
					},
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				sadness : {
					target : { min : 0.5, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				hatred : {
					target : { min : 0.5, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.03
				}
				*/
				love : {
					target : { min : 0.5, 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 : {
						cycle : [
							{ min : 0.3, max : 0.5, time : 2500 },
							{ min : 0.6, max : 0.8, time : 2500 }
						]
					},
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				sadness : {
					target : { min : 0.5, max : 0.7 },
					bar : 0.1,
					click : 0.1,
					decay : 0.05
				},
				hatred : {
					target : { min : 0.5, 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 : "t3bg"
				} );
			} );
			setTimeout( function() {
				Emometer.start ( function ( ) {
					timer.stop();
					setTimeout ( function ( ) {
						if ( bg && bg.loaded() ) bg.stop();
						loadConversation ( '/scripts/replay/conversations/task-3.js', function ( s ) {
							showStatusUpdate ( "Before Max's Party" );
							Portal.loadPage ( null, 'fb-max/', function ( ) {
								loadScript ( '/scripts/chat/thoughts.js', function ( s ) {
									var t = new Thoughts ( window.scripts.TASK_3, 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 );
	}

} );
