var flashIndex = {
	setGlobals: function(){
		$bodyId = $('body').attr('id');
		$bodyIdJs = $bodyId.replace(/-/g, '');

		var seenHomepageMovie = "false";
		var seenWhatsNewMovie = "false";
		if(jQuery.cookie) { // checks if plugin is loaded
			if($.cookie('homepageflash') != null) { seenHomepageMovie = "true"; }
		};
		if(jQuery.cookie) { // checks if plugin is loaded
			if($.cookie('whatsnewflash') != null) { seenWhatsNewMovie = "true"; }
		};
		if(typeof(inspirationGallerySourceFLVString) === 'undefined' || inspirationGallerySourceFLVString === undefined || inspirationGallerySourceFLVString === null) {
			inspirationGallerySourceFLVString = "";
		};
		if(typeof(inspirationGalleryFloorPlanSWF) === 'undefined' || inspirationGalleryFloorPlanSWF === undefined || inspirationGalleryFloorPlanSWF === null) {
			inspirationGalleryFloorPlanSWF = "";
		};
		if (typeof (inspirationGalleryView360SWF) === 'undefined' || inspirationGalleryView360SWF === undefined || inspirationGalleryView360SWF === null) {
			inspirationGalleryView360SWF = "";
		};
		if (typeof (inspirationGalleryView360Layout) === 'undefined' || inspirationGalleryView360Layout === undefined || inspirationGalleryView360Layout === null) {
			inspirationGalleryView360Layout = "";
		};			
		if(typeof(hotspotVideoFLV) === 'undefined' || hotspotVideoFLV === undefined || hotspotVideoFLV === null || hotspotVideoFLV === '') {
			hotspotVideoFLV = "";
		};
		if(typeof(featuresAccessoriesFLVurl) === 'undefined' || featuresAccessoriesFLVurl === undefined || featuresAccessoriesFLVurl === null || featuresAccessoriesFLVurl === '') {
			featuresAccessoriesFLVurl = "";
		};
		if(typeof(curWizardSWF) === 'undefined' || curWizardSWF === undefined || curWizardSWF === null || curWizardSWF === '') {
			curWizardSWF = "";
		};
		if(typeof(curWizardFLV) === 'undefined' || curWizardFLV === undefined || curWizardFLV === null || curWizardFLV === '') {
			curWizardFLV = "";
		};
		if(typeof(wizardInterstitial) === 'undefined' || wizardInterstitial === undefined || wizardInterstitial === null || wizardInterstitial === '') {
			wizardInterstitial = "";
		};
		if(typeof(webservicePath) === 'undefined' || webservicePath === undefined || webservicePath === null || webservicePath === '') {
			webservicePath = "";
		};
		if(typeof(folioUserGuid) === 'undefined' || folioUserGuid === undefined || folioUserGuid === null || folioUserGuid === '') {
			folioUserGuid = "";
		};
		if(typeof(folioDataSpacePlanId) === 'undefined' || folioDataSpacePlanId === undefined || folioDataSpacePlanId === null || folioDataSpacePlanId === '') {
			folioDataSpacePlanId = "";
		};
		if(typeof(actionSourceConfig) === 'undefined' || actionSourceConfig === undefined || actionSourceConfig === null || actionSourceConfig === '') {
			actionSourceConfig = "{}";
		};
		if(typeof(omParams) === 'undefined' || omParams === undefined || omParams === null || omParams === '') {
			omParams = "{}";
		};
		if(typeof(warrantySWF) === 'undefined' || warrantySWF === undefined || warrantySWF === null) {
			warrantySWF = "";
		};
		
		
/*------------ Flash config begins here ------------*/
		flashSettings = {
			homepage: {
				container: '#whats-new-flash',
				swf: '/flash/whatsnew/preloader-480.swf',
				id: 'whatsnewflash',
				name: 'whatsnewflash',
				width: 910,
				height: 465,
				flashvars: {
					assetToLoad: '/flash/whatsnew/whatsnewFlash.swf',
					xmlPath: '/flash/whatsnew/xml/whatsnewFlash.xml',
					seenMovie: seenHomepageMovie
				}
			},
			inspirationDesignHome: {
				container: '#landing-container',
				swf: '/flash/landing/Preloader.swf',
				id: 'inspirationDesignFlash',
				width: 940,
				height: 290,
				flashvars: {
					scene: 'inspiration',
					assetToLoad: '/flash/landing/LandingFlash.swf',
					xmlPath: '/flash/landing/xml/LandingFlash.xml'
				}
			},
			doorStylesAccessoriesHome: {
				container: '#landing-container',
				swf: '/flash/landing/Preloader.swf',
				id: 'doorStylesAccessoriesFlash',
				width: 940,
				height: 290,
				flashvars: {
					scene: 'doorstyles',
					assetToLoad: '/flash/landing/LandingFlash.swf',
					xmlPath: '/flash/landing/xml/LandingFlash.xml'
				}
			},
			planYourSpaceHome: {
				container: '#landing-container',
				swf: '/flash/landing/Preloader.swf',
				id: 'planYourSpaceFlash',
				width: 940,
				height: 290,
				flashvars: {
					scene: 'floorplanner',
					assetToLoad: '/flash/landing/LandingFlash.swf',
					xmlPath: '/flash/landing/xml/LandingFlash.xml'
				}
			},
			kitchenChroniclesLandingPage: {
				container: '#chronicles-container',
				swf: '/flash/chronicles/preloader.swf',
				id: 'kitchenChroniclesFlash',
				width: 780,
				height: 550,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					dataFile: '/flash/chronicles/xml/merillatvideos_production.xml',
					loadDir: '/flash/chronicles/',
					contents: '/flash/chronicles/MerillatVideoPlayer.swf'
				}
			},
			inspirationGalleryVideoPlayer: {
				container: '#inspiration-gallery-video-wrapper #player',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'inspiration-gallery-main-video',
				name: 'inspiration-gallery-main-video',
				width: 640,
				height: 400,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: inspirationGallerySourceFLVString,
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			designConsiderationsLighting: {
				container: '#lighting-container',
				swf: '/flash/inspiration-design/design-considerations/lighting.swf',
				id: 'lightingflash',
				name: 'lightingflash',
				width: 820,
				height: 560
			},
			inspirationGalleryFloorPlanViewer: {
				container: '#floor-plan-container',
				swf: inspirationGalleryFloorPlanSWF,
				id: 'inspirationGalleryFloorPlanFlash',
				width: 800,
				height: '100%'
			},
			inspirationGalleryHotspotPage: {
				container: '#hotspot-video',
				swf: '/flash/video/hotspot-video-player.swf',
				id: 'hotspotFlash',
				name: 'hotspotFlash',
				width: 360,
				height: 350,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: hotspotVideoFLV,
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			inspirationGalleryView360: {
				container: '#view360-container',
				swf: inspirationGalleryView360SWF,
				id: 'test',
				name: 'test',
				width: 780,
				height: 350,
				params: {
					allowFullScreen: 'false',
					wmode: 'opaque',
					base: '/Content/InspirationDesign/GalleryDetail/360View'
				},
				flashvars: {
					panorama: inspirationGalleryView360Layout
				}
			},
			featuresAccessoriesVideoPlayer: {
				container: '#features-accessories-video-wrapper #player',
				swf: '/flash/video/hotspot-video-player.swf',
				id: 'features-accessories-video-wrapper',
				name: 'features-accessories-video-wrapper',
				width: 360,
				height: 250,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: featuresAccessoriesFLVurl,
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			bathLanding: {
				container: '#bath-video',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'bathVideo',
				name: 'bathVideo',
				width: 510,
				height: 328,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/landing/bath-video.flv',
					imageURL: '/flash/landing/bath-video.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			softactionFeaturesVideo: {
				container: '#features-video',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'softActionVideo',
				name: 'softActionVideo',
				width: 640,
				height: 400,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: '/flash/softaction/softaction.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			softactionInstallationVideo: {
				container: '#installation-video',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'softActionInstallationVideo',
				name: 'softActionInstallationVideo',
				width: 640,
				height: 400,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: '/flash/softaction/installation.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}

			},
			environment: {
				container: '#green-video',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'environmentVideo',
				name: 'environmentVideo',
				width: 522,
				height: 350,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent'
				},
				flashvars: {
					sourceFLV: '/flash/green/environment.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			dreamKitchen: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'dreamKitchenVideo',
				name: 'dreamKitchenVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/dream-kitchen/video/dream-kitchen-welcome.flv',
					imageURL: '/flash/dream-kitchen/video/dream-kitchen-welcome.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			dreamKitchenVideo: {
				container: '#commercial-container',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'dreamKitchenCommercial',
				name: 'dreamKitchenCommercial',
				width: 768,
				height: 492,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/dream-kitchen/video/Cooking Demo-high.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			coreguardVideo: {
				container: '#coreguard-video-container',
				swf: '/flash/video/gallery-video-player.swf',
				id: 'coreguardVideo',
				name: 'coreguardVideo',
				width: 768,
				height: 492,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/video/Coreguard.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			warrantyViewer: {
				container: '#warranty-container',
				swf: warrantySWF,
				id: 'warrantyFlash',
				width: 800,
				height: '100%'
			},
			
			freshFood: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'freshFoodVideo',
				name: 'freshFoodVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/webisodes/video/freshfood.flv',
					imageURL: '/flash/webisodes/video/freshfood.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			twiceAsSweet: {
				container: '#main-video-container-2',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'twiceAsSweetVideo',
				name: 'twiceAsSweetVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/webisodes/video/twiceassweet.flv',
					imageURL: '/flash/webisodes/video/twiceassweet.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			entertain: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'entertainVideo',
				name: 'entertainVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/webisodes/video/entertain.flv',
					imageURL: '/flash/webisodes/video/entertain.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			kuppersmithKitchenStorage: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'KuppersmithKitchenStorageVideo',
				name: 'KuppersmithKitchenStorageVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/kuppersmith/videos/merillat-new-products.flv',
					imageURL: '/flash/kuppersmith/videos/merillat-new-products.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			kuppersmithMerillatCoreguard: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'KuppersmithMerillatCoreguardVideo',
				name: 'KuppersmithMerillatCoreguardVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/kuppersmith/videos/KBIS-coreGuard.flv',
					imageURL: '/flash/kuppersmith/videos/KBIS-coreGuard.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			brandVideo: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'brandVideo',
				name: 'brandVideo',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/video/brand-video.flv',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},

			curtisStone: {
				container: '#main-video-container',
				swf: '/flash/video/videoplayer-beautyshot.swf',
				id: 'curtisStone',
				name: 'curtisStone',
				width: 688,
				height: 442,
				params: {
					allowFullScreen: 'true',
					wmode: 'transparent',
					quality: 'high'
				},
				flashvars: {
					sourceFLV: '/flash/curtis-stone/video/curtisQA.flv',
					imageURL: '/flash/curtis-stone/video/curtisQA.jpg',
					actionSource: actionSourceConfig,
					params: omParams
				}
			},
			
			// gettingStartedIndex: {
			// 				container: '#wizardFlashBox',
			// 				swf: curWizardSWF,
			// 				id: 'wizardFlashObject',
				// name: 'wizardFlashObject',
			// 				width: 600,
			// 				height: 551,
			// 				params: {
			// 					allowScriptAccess: 'always',
			// 					wmode: 'transparent',
			// 					flashvars: 'loadFlvUrl='+curWizardFLV
			// 				}
			// 			},
			// 			
			// 			inspirationIndex: {
			// 				container: '#wizardFlashBox',
			// 				swf: curWizardSWF,
			// 				width: 600,
			// 				height: 551,
			// 				params: {
			// 					allowScriptAccess: 'always',
			// 					wmode: 'transparent',
			// 					flashvars: 'loadFlvUrl='+curWizardFLV
			// 				}
			// 			},
			
			floorPlanner: {
				container: '#SpacePlanner',
				swf: '/flash/space-plan/SpacePlanner.swf',
				width: '100%',
				height: '540',
				id: 'SpacePlannerFlash',
				name: 'SpacePannerFlash',
				params: {
					play: 'true',
					loop: 'false',
					quality: 'high',
					bgcolor: '#ffffff',
					allowScriptAccess: 'sameDomain',
					wmode: 'transparent'
				},
				flashvars: {
					folioUserGuid: folioUserGuid,
					resourcePath: '/flash/space-plan/',
					folioDataSpacePlanId: folioDataSpacePlanId,
					webservicePath: webservicePath
				}
			},
			
			stopTheGlop: {
				container: '#StopTheGlopGameWrapper',
				swf: '/flash/stoptheglop/main.swf',
				width: '750',
				height: '500',
				id: 'StopTheGlopGame',
				name: '',
				params: {
					play: 'true',
					loop: 'false',
					quality: 'high',
					bgcolor: '#ffffff',
					allowScriptAccess: 'always',
					wmode: 'opaque'
				},
				flashvars: {
					siteXML: "/flash/stoptheglop/xml/site.xml"
				}
			}
		};
	},
	
/*------------ Talk to Warren before editing anything below this line ------------*/

	// Check body ID against list of Flash movies
	// and return appropriate Flash params if there is a match
	compareBodyId: function(){
		var found = false;
		var returnVal = {};
		var neg = 'sorry';
		var flashParams;
		
		$.each(flashSettings, function(i, val){
			if($bodyIdJs === i.toString().toLowerCase()){
				found = true;
				flashParams = this;
				return false;				
			}
		});
		
		if(found === true){
			returnVal = {
				container: flashParams.container,
				swf: flashParams.swf,
				width: flashParams.width,
				height: flashParams.height,
				id: flashParams.id,
				params: flashParams.params,
				flashvars: flashParams.flashvars
			};
			return returnVal;
		} else {
			return neg;
		}		
	},
	
	// Initializes Flash movies based on output from compareBodyId
	initFlash: function(fp){
		if(fp.swf){
				$(fp.container).flash({
					flashvars: fp.flashvars,
					params: fp.params,
					swf: fp.swf,
					id: fp.id,
					width: fp.width,
					height: fp.height,
					hasVersion: 9
				});
				// Remove alternative content once we verify
				// that Flash is available
				if($.flash.available) {
					$('*', fp.container).not('object, param, embed').remove();
				}
		}
	}
};

$(document).ready(function(){
	flashIndex.setGlobals();
	flashIndex.initFlash(flashIndex.compareBodyId());
	
});
