core.env.nav = {
	'videosURI': '/hawker/assets/video/navigation/'
}

//Hawker Landing
core.action.HawkerLanding = (function () {

	var HawkerLanding = core.action.AbstractAction('hawker', 'hawker_landing');
	HawkerLanding.initialize = function () {

		var Marquee = core.ui.Marquee({'state': '4000_aircraft'}),
			CallToActionList,
			FourThousandSlideshow,
			NineHundredXPSlideshow,
			SevenHundredFiftySlideshow,
			FourHundredXPSlideshow,
			AircraftCopyList = new core.ui.List({'list': $('#aircraft_copy ')}),
			Overlay = new core.ui.Overlay({'opacity': .75}),
			ModalWindow = new core.ui.Modal({}),
			VideoPlayer = new core.ui.VideoPlayer({}),
			hawkerVideo = {
				'height': 636,
				'width': 1024,
				'debug': false,
				'bufferTime': 1,
				'autoDispose': true,
				'controls': {
					'nav': false,
					'dragControl': false,
					'muteControl': true,
					'pausePlayControl': false,
					'seekbarControl': false,
					'textControl': {
						'text': 'SKIP VIDEO',
						'action': 'disposed'
					},
					'timeDisplayControl': false,
					'volumeControl': false,
					'x': 0,
					'y': 520
				}
			},
			cookie = 'hawker_videoPlayed',
			videoPlayerInstanceKey = 'hawker_video';

		if ($.cookie(cookie) !== cookie) {
			Overlay.show();
			$.cookie(cookie, cookie, {
				'path': '/',
				'expires': 10
			})
		}

		Overlay.bind('shown', function () {
			ModalWindow.open();
		});

		ModalWindow.bind('opened', function () {
			$('#modal_window-content').append('<div id="hawker_video" class="video"><div id="hawker_embed" class="embed"></div>')

			VideoPlayerInstance = VideoPlayer.VideoPlayerInstance({'target': $('#hawker_video')}).getId();

			var VideoPlayerInstance = VideoPlayer.getInstance(videoPlayerInstanceKey);

			$('#hawker_video').bind('initialize', function (event) {
				hawkerVideo.flv = '/assets/video/hawker/landing/hawker_24fps_1024x636.flv';
				FlashGateway('configuration', VideoPlayerInstance.getId(), hawkerVideo);
			});

			$('#hawker_video').bind('disposed', function (event) {
				VideoPlayerInstance.dispose();
				ModalWindow.close();
				$('#hawker_video').unbind('initialize');
				$('#hawker_video').unbind('disposed');
			});

			VideoPlayerInstance.embed();

		});

		$('#marquee-replay a').click(function (event) {
			event.preventDefault();
			Overlay.show();
		});

		swfobject.embedSWF('/assets/plugins/corporate/landing/replay.swf','replay-animation',216,77,'6.0.0',false,{},{
			'menu': 'false',
			'wmode': 'transparent',
			'allowScriptAccess': 'always',
			'scale': 'noscale',
			'salign': 'tl'
		},{}, function(event) {});

		ModalWindow.bind('closed', function () {
			Overlay.hide();
		});

		CallToActionList = new core.ui.List({
			'list': $('#marquee-call_to_action')
		});

		CallToActionList.items.hover(function (event) {
			Marquee.setState($(this).attr('id').split('-')[1]);
		}, function () {});

		FourThousandSlideshow = new core.ui.Slideshow({
			'frames': new core.ui.List({
				'list': $('#4000_aircraft > ol')
			}),
			'slides': new core.ui.List({}),
			'speed': 100,
			'easing': 'linear'
		});

		NineHundredXPSlideshow = new core.ui.Slideshow({
			'frames': new core.ui.List({
				'list': $('#900xp_aircraft > ol')
			}),
			'slides': new core.ui.List({}),
			'speed': 100,
			'easing': 'linear'
		});

		SevenHundredFiftySlideshow = new core.ui.Slideshow({
			'frames': new core.ui.List({
				'list': $('#750_aircraft > ol')
			}),
			'slides': new core.ui.List({}),
			'speed': 250,
			'easing': 'swing'
		});

		FourHundredXPSlideshow = new core.ui.Slideshow({
			'frames': new core.ui.List({
				'list': $('#400xp_aircraft > ol')
			}),
			'slides': new core.ui.List({}),
			'speed': 250,
			'easing': 'swing'
		});

		Marquee.bind('stateChanged', function (event, state) {
			console.log(state);
			switch (state) {
				case '4000_aircraft':
					FourHundredXPSlideshow.gotoFrame($('#400xp_aircraft-inactive'));
					SevenHundredFiftySlideshow.gotoFrame($('#750_aircraft-inactive'));
					NineHundredXPSlideshow.gotoFrame($('#900xp_aircraft-inactive'));
					FourThousandSlideshow.gotoFrame($('#4000_aircraft-active'));
					CallToActionList.select($('#call_to_action-4000_aircraft'));
					AircraftCopyList.select($('#4000_aircraft-copy'));
					break;
				case '900xp_aircraft':
					FourHundredXPSlideshow.gotoFrame($('#400xp_aircraft-inactive'));
					SevenHundredFiftySlideshow.gotoFrame($('#750_aircraft-inactive'));
					NineHundredXPSlideshow.gotoFrame($('#900xp_aircraft-active'));
					FourThousandSlideshow.gotoFrame($('#4000_aircraft-inactive'));
					CallToActionList.select($('#call_to_action-900xp_aircraft'));
					AircraftCopyList.select($('#900xp_aircraft-copy'));
					break;
				case '400xp_aircraft':
					FourHundredXPSlideshow.gotoFrame($('#400xp_aircraft-active'));
					SevenHundredFiftySlideshow.gotoFrame($('#750_aircraft-inactive'));
					NineHundredXPSlideshow.gotoFrame($('#900xp_aircraft-inactive'));
					FourThousandSlideshow.gotoFrame($('#4000_aircraft-inactive'));
					CallToActionList.select($('#call_to_action-400xp_aircraft'));
					AircraftCopyList.select($('#400xp_aircraft-copy'));
					break;
				case '750_aircraft':
					FourHundredXPSlideshow.gotoFrame($('#400xp_aircraft-inactive'));
					SevenHundredFiftySlideshow.gotoFrame($('#750_aircraft-active'));
					NineHundredXPSlideshow.gotoFrame($('#900xp_aircraft-inactive'));
					FourThousandSlideshow.gotoFrame($('#4000_aircraft-inactive'));
					CallToActionList.select($('#call_to_action-750_aircraft'));
					AircraftCopyList.select($('#750_aircraft-copy'));
					break;
				default:
					break;
			}
		});

		$('#hotspot-4000_aircraft').mouseover(function (event) {
			Marquee.setState('4000_aircraft');
		});

		$('#hotspot-900xp_aircraft').mouseover(function (event) {
			Marquee.setState('900xp_aircraft');
		});

		$('#hotspot-400xp_aircraft').mouseover(function (event) {
			Marquee.setState('400xp_aircraft');
		});

		$('#hotspot-750_aircraft').mouseover(function (event) {
			Marquee.setState('750_aircraft');
		});

	};

	return HawkerLanding;

}());