			var flashvars = {}; 
			var params = { wmode: "transparent", allowFullScreen: "true", allowScriptAccess: "always" };
			var attributes = { id: "jsAS3", name: "jsAS3" };
			swfobject.embedSWF("flash/flash-shell.swf", "tran", "100%", "100%", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);	
			var contentLoaded = false; /////// Content loaded flag ////////
			var flashDoneTransitionReadyForNext = true;
			
			//This function is called from hijack.js whenever a transition link is click on. It will take the flash div from the top left corner 1 by 1 px
			//and expand it to 100% width and height. Than it will call the flash shell via callAS3 with the currentPage and click on page as variables. 
			//Finally it will check to see if the ajax content has finished loading, and when complete will alert flash
			function loadFlash(currentPage,targetPage) {
				
				//Make the user wait for flash to load before changing screens, unless they are viewing a portfolio video 
				if(targetPage != "view-portfolio") {flashDoneTransitionReadyForNext = false;}
				
				document.getElementById('flashDiv').style.width = "100%";	//Expand the flash div
				document.getElementById('flashDiv').style.height = "100%";	//Expand the flash div
				
				callAS3(currentPage,targetPage);	//Call the flash shell with the current page and clicke on page 
				
				contentLoaded = false; //Reset the variable
				tellFlashContentLoaded();	//This function is a recursive function that will wait for the content to load and than alert flash
			}
			
			//This call the flash shell and passses the current page and clicked on page
			function callAS3(currentPage,targetPage)
			{
				if(navigator.appName.indexOf("Microsoft") != -1) {
					jsAS3.callToAS(currentPage,targetPage);
				} else {
					window.document.jsAS3.callToAS(currentPage,targetPage);
				}
			}
			
			//Called from loadFlash above when a link is clicked. It will recursively wait to see it the contentLoaded flag has been set to true. Once the content
			//has been successfully loaded, it will alert flash
			function tellFlashContentLoaded() {
				if(!contentLoaded) {
					return setTimeout(function() {tellFlashContentLoaded();},500); ////////If not loaded, wait 100 milliseconds and try again ///////
				} else {
					//alert('Content Loaded');
					if(navigator.appName.indexOf("Microsoft") != -1) {
						jsAS3.contentLoadedFinishFlashTransition();
					} else {
						window.document.jsAS3.contentLoadedFinishFlashTransition();
					}
				}
			}
			
			//////// Load New Content Flag //////
			var loadNewContent = true;
			var neverLoadContent = false;
			
			//Called from flash once the flash has convered the whole screen. Will set a loadNewContent variable which is used in swfaddress/samples/ajax/scripts.js 
			//in the getNewContent function to determine if the system is ready to get the content, if it's not ready. The system will continue checking every .5 seconds
			//until it is ready.
			function readyForNewContentDisplay() {
				//alert('loadNewContent: ' + loadNewContent + ' - flash says its ok to load content');
				//From flash when it's to a point in the transition where the entire stage/screen is covered
				loadNewContent = true;
			}
			
			//Return the flash div to the upper left hand corner of the screen.
			function hideFlash() {
				document.getElementById('flashDiv').style.width = "1px";
				document.getElementById('flashDiv').style.height = "1px";
				
				flashDoneTransitionReadyForNext = true; 
				//alert(value)
				//document.forms["form1"].output.value += "ActionScript says: " + value + "\n";
			 }
			 
			//////////// In case flash is still being displayed once it's minimized, we tell flash to unload itself //////////
			function tellFlashToStop() {
				if(navigator.appName.indexOf("Microsoft") != -1) {
					jsAS3.clearShell();
				} else {
					window.document.jsAS3.clearShell();
				}
			}
			
			////////////Is flash done it's intial load, if not, than do not allow a user to view any transitions ///////////
			var flashDoneInitialLoad = false;

			//var turnOffFlashTransitions = false;
			//turnOffFlashTransitions = confirm("Press OK to turn off Flash Transitions"); //A debug feature to turn on/off flash transitions
			
			// Major version of Flash required
			var requiredMajorVersion = 9;
			// Minor version of Flash required
			var requiredMinorVersion = 0;
			// Minor version of Flash required
			var requiredRevision = 0;

			var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
			//hasReqestedVersion = false;
			if(!hasReqestedVersion) {flashLoadComplete();}
			
			///////// Flash tells js that it's done loading ////////
			function flashLoadComplete() {
				if(hasReqestedVersion) {flashDoneInitialLoad = true;} //Set this to false to run through site w/o flash transitions 
				$(function(){
					///////// Display the main avatars ////////
					$('.main-avatar').livequery(function() {
						$('.main-avatar').css('display','inline');
					});
					
					//////////// Hide the avatar preloaders and index preloader
					$('#preloader, .preloaders').livequery(function() {
						$('#mainHeaderHider, #preloader, .preloaders').css('display','none');
					});
					
					//////////// Hide the main menu preloader //////////
					$('#mainMenuPreloader').css('display','none');
					
					//////////// Display the main menu /////////////
					$('#avatarnavContainer, #openavatar, #mainnav, #mainnav-bg').css('display','inline');
				});
			}
			
			var numberOfPolaroidsOnScreen = 0;
			
			///////// Tells flash the initial x position and number of photos on screen for polaroid transition //////
			function sendFlashPolaroidLocation(xPosition,num) {
				numberOfPolaroidsOnScreen = num;
				
				if(flashDoneInitialLoad) {
					if(navigator.appName.indexOf("Microsoft") != -1) {
						jsAS3.polaroidPlacement(xPosition,num);
					} else {
						window.document.jsAS3.polaroidPlacement(xPosition,num);
					}
				}
				
				//$('#jsDebugger').html(xPosition+":"+num);
			}
			
			////////////////////// Tell flash if css is positioning elements odd or even //////////////
			function tellFlashBrowserWidth(counter) {
				if(flashDoneInitialLoad) {
					var widthOfBrowser = "even";
					if($(window).width()%2 == 1) {
						widthOfBrowser = "odd";
					}
					
					if(navigator.appName.indexOf("Microsoft") != -1) {
						jsAS3.browserWidth(widthOfBrowser);
					} else {
						window.document.jsAS3.browserWidth(widthOfBrowser);
					}
					//alert(widthOfBrowser);
				} else if (counter < 30) {
					//alert('not loaded yet');
					return setTimeout(function() {tellFlashBrowserWidth(++counter);},1000);
				} else {
					//alert('failed');
					return false;
				}
			}
			
			function changeStory(storyPage) {
				loadNewContent = true;
				SWFAddress.setValue("/portfolio-results/stories/"+storyPage+".php");
			}
			
			function flashWantsToChangePage(page) {
				loadNewContent = true;
				SWFAddress.setValue(page);
			}
			
			tellFlashBrowserWidth(0);
			
			$(window).resize(function() {tellFlashBrowserWidth(0);});
