﻿if (!window.DPE_delivery)
	window.DPE_delivery = {};
	
var SLPlugin;
var animationLibrary;
var soundfxLibrary;

// Loop Video Tracking Data Arrays //
var CanvasLeft_loop_dataX = new Array();
var CanvasLeft_loop_dataY = new Array();
var CanvasRight_loop_dataX = new Array();
var CanvasRight_loop_dataY = new Array();
var RotationLeft_loop_data = new Array();
var RotationRight_loop_data = new Array();
var ScaleLeft_loop_data = new Array();
var ScaleRight_loop_data = new Array();


DPE_delivery.Shell = function() 
{
}

DPE_delivery.Shell.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		// set external Varibale to root element object so to use in downloader.
		SLPlugin = rootElement;
		
		this.rootCanvas = rootElement.findName("rootCanvas");
		this.timeoutTimer = new TimeoutTimer(Silverlight.createDelegate(this, this.loopTimeout),30000);
	    //this.timerReference = this.rootCanvas.addEventListener("MouseMove", Silverlight.createDelegate(this, this.resetTimer));
	   
	
		
		
		this.timer = rootElement.findName("timer");
		this.timer.addEventListener("completed", Silverlight.createDelegate(this, this.timerTick));
		
	    this.fontLoader = this.control.createObject("downloader");
        this.fontLoader.addEventListener("completed", Silverlight.createDelegate(this, this.onFontsReady));
        this.fontLoader.open("GET", "localization/fonts/fonts.zip");
        this.fontLoader.send();
	    
		// load tracking data
		new TrackingDataLoader("xml/DPE_manL_loop_data.xml", rootElement); /// <reference path="xml/DPE_manL_loop_data.xml" /> 
        new TrackingDataLoader("xml/DPE_manR_loop_data.xml", rootElement); /// <reference path="xml/DPE_manR_loop_data.xml" />
                      
        this.LeftShirtCloseAnimation = rootElement.findName("LeftShirtClose");
        //this.LeftShirtCloseAnimation.addEventListener("completed", Silverlight.createDelegate(this,this.attractWordSwitch));
       
       //Preloader Text Referance Index Number
        this.currentTextListNumber = 0;
        this.LeftShirtOpenAnimation = rootElement.findName("LeftShirtOpen");
        //this.LeftShirtOpenAnimation.addEventListener("completed", Silverlight.createDelegate(this,this.attractWordReset));
        
        /* Banner Video */
       
        this.bannerText = new BannerTextLoader("localization/text/banner.xml", rootElement);
		this.bannerText.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.bannerTextReady));
		
		this.bannerTransitionVideo = rootElement.findName("BannerTransition");
		this.bannerTransitionVideo.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.onBannerReady));
	    this.bannerTransitionVideo.addEventListener("MediaEnded", Silverlight.createDelegate(this, this.onBannerLoop));
	    this.bannerTransitionVideo.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.onBannerClick));
	    this.BannerMockup = rootElement.findName("BannerMockup");
	    this.BannerTransitionBG = rootElement.findName("BannerTransitionBG");
	    // variable to show if experience is in banner state
	    this.inBannerState = true; 
	    this.BannerAnimation = rootElement.findName("BannerFullAnimation");
	   
	    // banner opening storyboard
	    this.CollapseOpenStoryboard = rootElement.findName("CollapseOpenStoryboard");
	    this.CollapseOpenStoryboard.addEventListener("completed", Silverlight.createDelegate(this, this.showPreloader));
	    
	    /* Background Videos */
	    this.introVideo = rootElement.findName("introVideo");
		this.introVideo.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.onMediaOpened));
		//this.introVideo.addEventListener("MarkerReached", onMarkerReached);
		this.introVideo.addEventListener("MediaEnded", Silverlight.createDelegate(this, this.onMediaEnded));
		this.introVideoPlayed = false;
		this.outroVideo = rootElement.findName("outroVideo");
		this.outroVideo.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.onMediaOpened));
		//this.outroVideo.addEventListener("MarkerReached", onMarkerReached);
		this.outroVideo.addEventListener("MediaEnded", Silverlight.createDelegate(this, this.onMediaEnded));
	    
	    this.bgVideo = rootElement.findName("bgVideo");
		this.bgVideo.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.onMediaOpened));
		this.bgVideo.addEventListener("MarkerReached", onMarkerReached);
		this.bgVideo.addEventListener("MediaEnded", Silverlight.createDelegate(this, this.onMediaEnded));
		
		/* Background Music */
		this.bgMusic = rootElement.findName("bgMusic");
		this.bgMusic.addEventListener("MediaOpened", Silverlight.createDelegate(this, this.onStartMusic));
		this.bgMusic.addEventListener("MediaEnded", Silverlight.createDelegate(this, this.onLoopMusic));
		
		/* Load the Ticker Text */
		/// <reference path="localization/rants/rants.xml" />
		this.tickerText = new TickerLoader("localization/text/ticker.xml", rootElement);
		this.tickerUpdate;
		this.tickerText.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.startTicker));
		
		this.preloaderText = new PreloaderTextLoader("localization/text/preloader.xml", rootElement);
		this.preloaderText.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.setupPreloader));
		
		this.PreloadReady = rootElement.findName("PreloadReady");
		
		// Seting up the HEADER BUTTON CONTENT
		this.headerText = new HeaderTextLoader("localization/text/header.xml", rootElement);
		this.headerText.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.startHeader));
        this.HeaderTextBlock = rootElement.findName("HeaderTextBlock");
        this.HeaderTextSwitch = rootElement.findName("HeaderTextSwitch");
        this.HeaderTextSwitch.addEventListener("completed", Silverlight.createDelegate(this, this.HeaderWordSwitch));
        this.HeaderColor1 = rootElement.findName("HeaderColor1");
        this.HeaderColor2 = rootElement.findName("HeaderColor2");
        this.HeaderColor3 = rootElement.findName("HeaderColor3");
        this.headerColorIndexNum = 2; 
        this.headerTextSection = "attract";
        
        this.HeaderBG = rootElement.findName("HeaderBG");
        this.HeaderGradientAnimation = rootElement.findName("HeaderGradientAnimation");
        this.HeaderBGColorStart = rootElement.findName("HeaderBGColorStart");
        this.HeaderBGColorChange1 = rootElement.findName("HeaderBGColorChange1");
        this.HeaderBGColorChange2 = rootElement.findName("HeaderBGColorChange2");
        this.HeaderGradientAnimation.addEventListener("completed",Silverlight.createDelegate(this, this.HeaderGradientStart));
        this.headerGradientStartColor = "#ffe8e8e8";
        
        
        
        this.buttonText = new ButtonTextLoader("localization/text/buttons.xml", rootElement);
		this.buttonText.downloader.addEventListener("completed", Silverlight.createDelegate(this, this.setupButtonText));
		this.buttonSound = rootElement.findName("buttonSound");
		
        this.localizationDownloader =  this.control.createObject("downloader");
        this.localizationDownloader.addEventListener("completed", Silverlight.createDelegate(this, this.localizationXAMLReady));
        this.localizationDownloader.open("GET", "localization/XAML/localizationXAML.zip");
        this.localizationDownloader.send();
        
       
	    
        /*  Loading Aniamtions */
        
		// download animations
        animationLibrary = new AnimationDownloader(SLPlugin);
		animationLibrary.downloader.addEventListener("DownloadProgressChanged",Silverlight.createDelegate(this, this.onDownloadProgressChanged));
		//animationLibrary.downloader.addEventListener("completed",Silverlight.createDelegate(this, this.onDownloadFinished));
		animationLibrary.downloader.addEventListener("completed",Silverlight.createDelegate(this, this.StartExperience));
        animationLibrary.DownloadAssets("media/animations/animationsLibrary.zip");
        this.PreloaderAnimation = rootElement.findName("PreloaderSequence");
        this.animationsLoaded = false;
        this.shirtsAni = rootElement.findName("shirtsAni");
        this.shirtRightCanvas = rootElement.findName("shirtRightCanvas");
	    this.shirtLeftCanvas = rootElement.findName("shirtLeftCanvas");
        // set up to swtich word behind brackets
        this.PreloaderAnimation.addEventListener("completed",Silverlight.createDelegate(this, this.OnPreloaderSwitchWord)); 
        this.PreloaderTextBlock = rootElement.findName("PreloaderTextBlock");
        this.BannerTransitonBlack = rootElement.findName("BannerTransitonBlack");
        this.PreloaderPercentText = rootElement.findName("PreloadPrecentText");
        // hide preloader until banner is clicked
        this.Preloader = rootElement.findName("Preloader");
        this.Preloader.Visibility = "Collapsed";
        
        this.colorIndexNum = 0;
        this.LoaderBG = rootElement.findName("LoaderBG");
        this.LoaderFill = rootElement.findName("LoaderFill");
        
        /* Loading Sound Effects */
        
        //download soundfx Library.
        this.soundfxLoader = this.control.createObject("downloader");
        this.soundfxLoader.addEventListener("completed", Silverlight.createDelegate(this, this.onSoundEffectsFinished));
        this.soundfxLoader.open("GET", "media/soundfx/soundfx.zip");
        this.soundfxLoader.send();
       
	    this.soundEffect1 = rootElement.findName("SoundEffect1");
	    this.soundEffect2 = rootElement.findName("SoundEffect2");
	    this.soundEffect3 = rootElement.findName("SoundEffect3");
        
        this.MainButton = rootElement.findName("MainButton");
        this.MainButton.addEventListener("mouseEnter", Silverlight.createDelegate(this, this.MainButtonRollOver));
        this.MainButton.addEventListener("mouseLeave", Silverlight.createDelegate(this, this.MainButtonRollOut));
        this.MainButton.addEventListener("mouseLeftButtonUp", Silverlight.createDelegate(this, this.MainButtonReleased));
        
                
        //creating header button
	    new button(
	        rootElement.findName("Header"),
		    rootElement.findName("Header"),
		    rootElement.findName("HeaderButtonRollOver"),
		    rootElement.findName("HeaderButtonRollOut"),
		    "none",
		    "none",
		    "none",
		    Silverlight.createDelegate(this, this.HeaderButtonReleased),
		    "none",
		    "header",
		    "none" 
		);
		
		//creating collapse button
	    new button(
	        rootElement.findName("CollapseButton"),
		    rootElement.findName("CollapseButton"),
		    rootElement.findName("CollapseButtonRollOver"),
		    rootElement.findName("CollapseButtonRollOut"),
		    "none",
		    "none",
		    "none",
		    Silverlight.createDelegate(this, this.CollapseButtonReleased),
		    "none",
		    "collapse",
		    "none" 
		);
		
		//creating mute button
		
	
	    new button(
	        rootElement.findName("MuteButton"),
		    rootElement.findName("MuteButton"),
		    "none",
		    "none",
		    "none",
		    "none",
		    "none",
		    Silverlight.createDelegate(this, this.muteToggle),
		    "none",
		    "mute",
		    "none" 
		);
		//Hooks and creates the MainNav Buttons that change the shirts
		for(i = 1; i <= 4; i++)
		{			
		    var tempTarget = "q" + i + "_Button";
			var tempBackground = "q" + i + "_Over";
			var tempDown = "q" + i + "_Down";
			var tempAnimation = "q" + i + "ButtonAnimation";
			var tempID = "q" + i;
			new button(
				rootElement.findName(tempTarget), //target
				rootElement.findName(tempBackground), //backgroundElement
				rootElement.findName("ButtonRollOver"),
				rootElement.findName("ButtonRollOut"),
				rootElement.findName("ButtonRollOverTarget"),
				rootElement.findName("ButtonRollOutTarget"),
				rootElement.findName(tempDown),
				Silverlight.createDelegate(this, this.onButtonUp), //clickHandler -- the action that the button triggers on Release
				Silverlight.createDelegate(this, this.onButtonDown), //DownHandler -- the action that the button triggers on Down
				tempID, //holds id name of the button
				rootElement.findName(tempAnimation)
			);
		}
		//end of addtional code
        
        // Volume Contol Value - Set to String value of "50" or "0" for initial volume
        this.VolumeControl = "50";
        // ALL ELEMENTS that have sound should be included in this array so that functions can easly loop to toggle sound 
        // Add additional sound elements here.
		this.soundGroup = new Array(this.bgMusic,  this.introVideo, this.outroVideo, this.bgVideo,this.soundEffect1,this.soundEffect2, this.soundEffect3, this.buttonSound);
		// set initial volume for objects
		for(i=0;i<this.soundGroup.length;i++){
		    this.soundGroup[i].Volume = this.VolumeControl;
		}
		
	},
	
	// Add Localized XAML elements to the main canvas 
	localizationXAMLReady: function(sender, args)
	{
	    var MainButtonXAML = sender.getResponseText("MainButtonDesign.xaml");
        // Create the objects from the XAML content.
        var MainButtonCreator = this.control.content.createFromXaml(MainButtonXAML);
        // Add localized XAML content to the MainButton Canvas 
        sender.findName("MainButton").children.insert(1, MainButtonCreator);

               
        var TickerStartXAML = sender.getResponseText("TickerStart.xaml");
        // Create the objects from the XAML content.
        var TickerStartCreator = this.control.content.createFromXaml(TickerStartXAML);
        // Add localized XAML content to the MainButton Canvas 
        sender.findName("Ticker").children.insert(2, TickerStartCreator);
        
         var ShirtRightCanvasXAML = sender.getResponseText("shirtRightCanvas.xaml");
        // Create the objects from the XAML content.
        var ShirtRightCanvasCreator = this.control.content.createFromXaml(ShirtRightCanvasXAML);
        // Add localized XAML content to the MainButton Canvas 
       this.shirtRightCanvas.children.insert(1, ShirtRightCanvasCreator);
        
          var ShirtLeftCanvasXAML = sender.getResponseText("shirtLeftCanvas.xaml");
        // Create the objects from the XAML content.
        var ShirtLeftCanvasCreator = this.control.content.createFromXaml(ShirtLeftCanvasXAML);
        // Add localized XAML content to the MainButton Canvas 
       this.shirtLeftCanvas.children.insert(1, ShirtLeftCanvasCreator);
        
      
	},
	
	// Set up the Preloader Text from localized XML
	setupPreloader: function(sender, args)
	{
	    this.preloaderTextArray = this.preloaderText.getValues();
	},
	
	// Set up the MainNav Button Text from localized XML
	setupButtonText: function(sender, args)
	{
	    // put button text values into array from XML
	    this.buttonTextArray = this.buttonText.getValues();
	    // Set Button Text Values
	    for (i=1;i<5;i++){
	    //Silverlight needs the String Value for the findName method to already be constructed before its called.
	        var searchElement = "q"+i+"_TextBlock";
	        sender.findName(searchElement).text = this.buttonTextArray[i-1];
	    }
	    sender.removeEventListener("completed", 0);
	},
	
	// Set up the Header Text from localized XML
	startHeader: function(sender, args)
	{
	    this.headerTextArray = this.headerText.getValues(this.headerTextSection);
	    this.HeaderTextSwitch.begin();
        this.HeaderTextBlockIndex = 1;
	},
	
	// function to control the Header Animation
	HeaderWordSwitch: function(sender, args)
	{
	   
	    this.headerTextArray = this.headerText.getValues(this.headerTextSection);
	    
	    if (this.HeaderTextBlockIndex < this.headerTextArray.length){
	       
	         this.HeaderTextBlock.text = this.headerTextArray[this.HeaderTextBlockIndex];
	          this.HeaderTextBlockIndex++;
	     }else{
	        this.HeaderTextBlockIndex = 0;
	        this.HeaderTextBlock.text = this.headerTextArray[this.HeaderTextBlockIndex];
	        this.HeaderTextBlockIndex++;
	     }
	     if(this.headerColorIndexNum < 3){
            
            this.headerColorIndexNum++;
            
        }else{
           
            this.headerColorIndexNum = 0;
        }
        if (this.headerTextSection == "attract"){
	        this.HeaderColor1["Value"]= MSColors[this.headerColorIndexNum];
	        this.HeaderColor2["Value"]= MSColors[this.headerColorIndexNum];
	        this.HeaderColor3["Value"]= MSColors[this.headerColorIndexNum];
	    }else{
	        this.HeaderColor1["Value"]= "#ff363636";
	        this.HeaderColor2["Value"]= "#ff363636";
	        this.HeaderColor3["Value"]= "#ff363636";
	    }
	    this.HeaderTextSwitch.stop();
	    this.HeaderTextSwitch.begin();

	},
	HeaderGradientStart: function(sender, args)
	{
	    
	},
	// function to control the Preloader Animation
	OnPreloaderSwitchWord: function(sender, args)
	{
	    
	    if (this.currentTextListNumber < this.preloaderTextArray.length){
	   
	       this.PreloaderTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	       this.currentTextListNumber++;
	       
	    }else {
	        this.currentTextListNumber = 0;
	        this.PreloaderTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	        this.currentTextListNumber++;
	    }
	    
	    var newLeft = (( this.PreloaderTextBlock.Width -  this.PreloaderTextBlock.ActualWidth) / 2)+ 234 ;
        this.PreloaderTextBlock.SetValue("Canvas.Left", newLeft); 
        
        sender.findName("RightBracketGoTo1")["Value"] = (newLeft*-1)+ 256;//this.PreloaderTextBlock.ActualWidth + 234;
        sender.findName("RightBracketGoTo2")["Value"] = (newLeft*-1)+ 256;//this.PreloaderTextBlock.ActualWidth + 234;
        sender.findName("LeftBracketGoTo1")["Value"] = (newLeft)- 250; 
        sender.findName("LeftBracketGoTo2")["Value"] = (newLeft)- 250; 
        
        if(this.colorIndexNum < 3){
            
            this.colorIndexNum++;
            
        }else{
           
            this.colorIndexNum = 0;
        }
        sender.findName("LoaderColorStart")["Value"]= MSColors[this.colorIndexNum];
        sender.findName("RightColorStart")["Value"]= MSColors[this.colorIndexNum];
        sender.findName("LeftColorStart")["Value"]= MSColors[this.colorIndexNum];
        sender.findName("LoaderColorEnd")["Value"]= MSColors[this.colorIndexNum];
        sender.findName("RightColorEnd")["Value"]= MSColors[this.colorIndexNum];
        sender.findName("LeftColorEnd")["Value"]= MSColors[this.colorIndexNum];
        
          
	    this.PreloaderAnimation.stop();
	    this.PreloaderAnimation.begin();
	},
	
	// function to control the Attract Loop Animation
	attractWordSwitch: function(sender, args){
	    if(this.currentTextListNumber < 2){
	        this.currentTextListNumber++;
	        this.attractTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	    }else {
	        this.currentTextListNumber = 0;
	        this.attractTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	    }
	           
        this.LeftShirtCloseAnimation.stop();
	    this.LeftShirtOpenAnimation.begin();
	    
	},
	attractWordReset: function(sender, args)
	{
	   this.LeftShirtCloseAnimation.begin();
	},
	
	// Reveal the Preloader on Banner Click
	showPreloader: function(sender, args)
	{
	    
	    this.Preloader.Visibility = "Visible";
	    if (this.currentTextListNumber < this.preloaderTextArray.length){
	   
	       this.PreloaderTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	       this.currentTextListNumber++;
	       
	    }else {
	        this.currentTextListNumber = 0;
	        this.PreloaderTextBlock.text = this.preloaderTextArray[this.currentTextListNumber];
	    }
	    
	    var newLeft = (( this.PreloaderTextBlock.Width -  this.PreloaderTextBlock.ActualWidth) / 2)+ 234 ;
        this.PreloaderTextBlock.SetValue("Canvas.Left", newLeft); 
        
        sender.findName("RightBracketGoTo1")["Value"] = (newLeft*-1)+ 258;//this.PreloaderTextBlock.ActualWidth + 234;
        sender.findName("RightBracketGoTo2")["Value"] = (newLeft*-1)+ 258;//this.PreloaderTextBlock.ActualWidth + 234;
        sender.findName("LeftBracketGoTo1")["Value"] = (newLeft)- 250; 
        sender.findName("LeftBracketGoTo2")["Value"] = (newLeft)- 250;  
         
	    this.PreloaderAnimation.stop();
	    this.PreloaderAnimation.begin();
	    
	    
	},
	onDownloadProgressChanged:function(sender, args)
	{
	   this.LoaderFill["Width"] = Math.floor(animationLibrary.percentageDownload * 299);
	   //this.PreloaderPercentText["Canvas.Left"] = Math.floor(animationLibrary.percentageDownload * 299)+85;
	   this.PreloaderPercentText.text = Math.floor(animationLibrary.percentageDownload*100)+"%";
	},
	onSoundEffectsFinished: function(sender, args)
	{
	   // Set Up Sound FX
	   soundfxLibrary = sender;
	   sender.removeEventListener("completed", 0);
	},
	
	StartExperience: function(sender, args)
	{
	    // Tell Shell that animations are ready to use.
	    this.animationsLoaded = true;
	    
	    //Check if Banner has been clicked. 
	    if (this.inBannerState){
	        // WAIT FOR USER TO CLICK BANNER
	    }else{
	        
	        this.timerReference = this.rootCanvas.addEventListener("MouseMove", Silverlight.createDelegate(this, this.resetTimer));
	        
	        if (!this.introVideoPlayed){
	            this.introVideoPlayed = true;
	            this.introVideo.Visibility = "Visible";
    	        this.bannerTransitionVideo.Visibility = "Collapsed";
	            this.BannerMockup.Visibility = "Collapsed";
	            this.Preloader.Visibility = "Collapsed";
	            this.BannerTransitonBlack.Visibility = "Collapsed";
	            this.BannerTransitionBG.Visibility = "Collapsed";
	            this.introVideo.Play();
	            currentVideo = "intro";
	       
	                 this.rootCanvas.findName("q1_Glow")["Opacity"] = 100;
	                this.rootCanvas.findName("q1_Active")["Opacity"] = 100;
	                this.rootCanvas.findName("q1_Shadow")["Opacity"] = 0;
	                this.rootCanvas.findName("bambi1")["Fill"] = "#ffffffff";
	                this.rootCanvas.findName("bambi2")["Fill"] = "#ffffffff";
	        }else{
	            
    	        this.bannerTransitionVideo.Visibility = "Collapsed";
	            this.BannerMockup.Visibility = "Collapsed";
	            this.Preloader.Visibility = "Collapsed";
	            this.BannerTransitonBlack.Visibility = "Collapsed";
	            this.BannerTransitionBG.Visibility = "Collapsed";
	            this.bgVideo.Visibility = "Visible";
	            this.bgMusic.stop();
	            this.bgMusic.play();
	            this.bgVideo.stop();
	            this.bgVideo.Play();
	            currentVideo = "loop";
	             aniSelect = "q1";
	                this.rootCanvas.findName("q1_Glow")["Opacity"] = 100;
	                this.rootCanvas.findName("q1_Active")["Opacity"] = 100;
	                this.rootCanvas.findName("q1_Shadow")["Opacity"] = 0;
	                this.rootCanvas.findName("bambi1")["Fill"] = "#ffffffff";
	                this.rootCanvas.findName("bambi2")["Fill"] = "#ffffffff";
	        }
	       
	                
	         }
	},
	resetTimer: function(sender, args)
	{
	    if (aniSelect != "attract"){
	        this.timeoutTimer.resetTimer("loopTimout()");
	        
	    }
	},
	loopTimeout: function()
	{
	    
	    this.rootCanvas.RemoveEventListener("MouseMove", this.timerReference);
	   
	    //Check if Experience is still loading
	    if (this.animationsLoaded == false){
	       
	    }else{
	        //stop all sounds
	        for(i=0;i<this.soundGroup.length;i++){
	            this.soundGroup[i].stop(); 
	        }
	        aniSelect = "attract";
	        this.headerTextSection = aniSelect;
	        this.HeaderBGColorStart["Value"] = "#ffe8e8e8";
		    this.HeaderBGColorChange1["Value"] = "#ffe8e8e8";
		    this.HeaderBGColorChange2["Value"] = "#ffe8e8e8";
		    this.headerGradientStartColor = "#ffe8e8e8";
	        this.HeaderGradientAnimation.begin();
	        this.outroVideo.Visibility = "Visible";
	        this.shirtsAni.Visibility = "Collapsed";
	        this.outroVideo.stop();
	        this.outroVideo.play();
	        currentVideo = "outro";
	        for (i=1;i<5;i++){
	        //Silverlight needs the String Value for the findName method to already be constructed before its called.
	            var glowElement = "q"+i+"_Glow";
	            var activeElement = "q"+i+"_Active";
	            var shadowElement = "q"+i+"_Shadow";
	            this.rootCanvas.findName(glowElement)["Opacity"] = 0;
	            this.rootCanvas.findName(activeElement)["Opacity"] = 0;
	            this.rootCanvas.findName(shadowElement)["Opacity"] = 100;
	        }
	         this.rootCanvas.findName("bambi1")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("bambi2")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("Pacman")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("path20")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("path21")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("QuestionMark")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("Antena1")["Fill"] = "#ff666666";
	         this.rootCanvas.findName("Antena2")["Fill"] = "#ff666666";  
	     }
	},
	MainButtonRollOver: function(sender, args)
	{
	    var overAnimation = sender.findName("MainButtonRollOver");
	    overAnimation.stop();
	    overAnimation.begin();
	},
	MainButtonRollOut: function(sender, args)
	{
	    var overAnimation = sender.findName("MainButtonRollOut");
	    overAnimation.stop();
	    overAnimation.begin();
	},
	MainButtonReleased: function(sender, args)
	{
	    MainButtonClick();
	    buttonClickHook(sender);
	},
	
	HeaderButtonReleased: function(sender, args)
	{
	    HeaderButtonClick();
	    buttonClickHook(sender);
	},
	
	CollapseButtonReleased: function(sender, args)
	{
        // stop all sounds!
        for(i=0;i<this.soundGroup.length;i++){
	        this.soundGroup[i].stop(); 
	    }
	    this.inBannerState = true;
	    this.rootCanvas.RemoveEventListener("MouseMove", this.timerReference);
	   
	    this.timeoutTimer.clearTimer();
        aniSelect = "attract";	
        this.CollapseOpenStoryboard.stop();  
	    this.bannerTransitionVideo.stop();
	    this.bannerTransitionVideo.play();
	    this.bannerTransitionVideo.Visibility = "Visible";
	    this.BannerTransitionBG.Visibility = "Visible";
	    this.BannerTransitonBlack.Visibility = "Visible";
	    this.BannerMockup.Visibility = "Visible";
	    this.BannerAnimation.stop();
	    this.BannerAnimation.begin();
	    this.BannerTransitionBG.Visibility  = "Visible";
	    this.introVideo.Visibility = "Collapsed";
	    this.outroVideo.Visibility = "Collapsed";
	    this.bgVideo.Visibility = "Collapsed";
	    this.shirtsAni.Visibility = "Collapsed";
	    this.shirtRightCanvas.Visibility = "Collapsed";
	    this.shirtLeftCanvas.Visibility = "Collapsed";
	    buttonClickHook(sender);
	},
	onOutroEnded: function(sender, args)
	{
	    
	   
	},

	muteToggle: function(sender, args)
	{
	    if (this.VolumeControl == "50"){
	        // set all media elements volume to ZERO
	        this.VolumeControl = "0";
	        sender.findName("SoundWaves").Visibility = "Collapsed";
	        for(i=0;i<this.soundGroup.length;i++){
		        this.soundGroup[i].Volume = this.VolumeControl;
		    }
	    }else{
	        sender.findName("SoundWaves").Visibility = "Visible";
	        this.VolumeControl = "50";
	        // set all media elements volume to 50
	        for(i=0;i<this.soundGroup.length;i++){
		        this.soundGroup[i].Volume = this.VolumeControl;
		    }
	     }
	},
	startTicker: function(sender, args)
	{
	    
	    var tickerTextArea = sender.findName("TickerText");
	    this.tickerUpdate = this.tickerText.tickerStringData;
	    tickerTextArea.Text = this.tickerText.tickerStringData;
	    this.timer.begin();
	},
	timerTick: function(sender, args){
	    
	    var tickerTextArea = sender.findName("TickerText");
	    var breakString = this.tickerUpdate;
	    if (breakString.length > 100){
	        var updateString = breakString.substring(1,breakString.length);
	        this.tickerUpdate = updateString;
	        tickerTextArea.Text = this.tickerUpdate;
	    } else{
	        var updateString = this.tickerText.tickerStringData;;
	        this.tickerUpdate = updateString;
	        tickerTextArea.Text = this.tickerUpdate;
	    }
	    this.timer.begin();
	},
		onMediaOpened: function(sender, eventArgs)
    {
       
            var frameRate = 15;
            var vidDuration = this.bgVideo.NaturalDuration.seconds;
            var frameLength = Math.abs(1/frameRate);
            totalFrames = Math.floor(vidDuration/frameLength);
                        
            var frameRef = Math.round(0*100000000)/100000000;
                for (i=0;i<totalFrames;i++){
               
                    var marker = 
                         sender.getHost().content.createFromXaml
                         (
                              '<TimelineMarker Time="0:0:'+frameRef+'" Type="Dynamic Marker" Text="'+i+'" />'
                         );
                         
                    sender.markers.add(marker);
                    frameRef = Math.round((frameRef + frameLength)*100000000)/100000000;
                    
                }
                sender.removeEventListener("mediaOpened", 0);

    },
    onMediaEnded: function(sender, args)
    {
        
       
       if (sender.name == "introVideo"){
            this.introVideo.Visibility = "Collapsed";
            this.bgVideo.Visibility = "Visible";
            this.bgMusic.Play();
            this.bgVideo.play();
            currentVideo = "loop";
            this.shirtLeftCanvas.Visibility = "Collapsed";
            this.shirtRightCanvas.Visibility = "Collapsed";
            this.shirtsAni.Visibility = "Collapsed";
       } else if (sender.name == "outroVideo"){
            this.introVideo.Visibility = "Collapsed";
            this.outroVideo.Visibility = "Collapsed";
            this.bgVideo.Visibility = "Visible";
            //this.bgMusic.Play();
            this.bgVideo.stop();
            this.bgVideo.play();
            currentVideo = "loop";
            aniSelect = "attract";
            this.shirtLeftCanvas.Visibility = "Collapsed";
            this.shirtRightCanvas.Visibility = "Collapsed";
            this.shirtsAni.Visibility = "Collapsed";
        }else if (sender.name == "bgVideo"){
            this.outroVideo.Visibility = "Collapsed";
            this.introVideo.Visibility = "Collapsed";
            this.bgVideo.stop();
            this.bgVideo.play();
            currentVideo = "loop";
        }
    },
	onStartMusic: function(sender, args)
	{
	    //this.bgMusic.play();
	},
	onLoopMusic: function(sender, args)
	{
	   this.bgMusic.Stop();
	   this.bgMusic.Play();
	},
	onButtonUp: function(sender, eventArgs) 
	{
		// The following line of code shows how to find an element by name and call a method on it.
		// this.control.content.findName("Storyboard1").Begin();
		//alert("Setting Animation Library "+ sender.name);
		// Get the Previous Button Color
		
		// Stop the HeaderGradientAnimation
		this.HeaderGradientAnimation.stop();
		if (this.outroVideo.CurrentState == "playing"){
		    this.outroVideo.stop();
		}
		if(aniSelect == "attract" ){
		    this.HeaderBGColorStart["Value"] = "#ffe8e8e8";
		    this.HeaderBGColorChange1["Value"] = "#ffe8e8e8";
		    this.HeaderBGColorChange2["Value"] = "#ffe8e8e8";
		    this.headerGradientStartColor = "#ffe8e8e8";
		    this.outroVideo.Visibility = "Collapsed";
            this.introVideo.Visibility = "Collapsed";
            this.bgVideo.stop();
            this.bgVideo.play();
            this.bgMusic.stop();
            this.bgMusic.play();
            currentVideo = "loop";
            this.timerReference = this.rootCanvas.addEventListener("MouseMove", Silverlight.createDelegate(this, this.resetTimer));
            }
        for (i=1;i<5;i++){
	    //Silverlight needs the String Value for the findName method to already be constructed before its called.
	        var glowElement = "q"+i+"_Glow";
	        var activeElement = "q"+i+"_Active";
	        var shadowElement = "q"+i+"_Shadow";
	        sender.findName(glowElement)["Opacity"] = 0;
	        sender.findName(activeElement)["Opacity"] = 0;
	        sender.findName(shadowElement)["Opacity"] = 100;
	    }
	        sender.findName("bambi1")["Fill"] = "#ff666666";
	        sender.findName("bambi2")["Fill"] = "#ff666666";
	        sender.findName("Pacman")["Fill"] = "#ff666666";
	        sender.findName("path20")["Fill"] = "#ff666666";
	        sender.findName("path21")["Fill"] = "#ff666666";
	        sender.findName("QuestionMark")["Fill"] = "#ff666666";
	        sender.findName("Antena1")["Fill"] = "#ff666666";
	        sender.findName("Antena2")["Fill"] = "#ff666666";
		if (sender.name == "q2_Button")
		    {
    		    var q2Check = animationLibrary.ReturnAssets();
    		    if (q2Check != null){
    		        this.HeaderBGColorStart["Value"] = this.headerGradientStartColor;
		            this.HeaderBGColorChange1["Value"] = MSColors[0];
		            this.HeaderBGColorChange2["Value"] = MSColors[0];
		            this.headerGradientStartColor = MSColors[0];
    		        aniSelect = "q2";
    		        sender.findName("q2_Glow")["Opacity"] = 100;
	                sender.findName("q2_Active")["Opacity"] = 100;
	                sender.findName("q2_Shadow")["Opacity"] = 0;
	                sender.findName("Pacman")["Fill"] = "#ffffffff";
	                sender.findName("path20")["Fill"] = "#ffffffff";
	                sender.findName("path21")["Fill"] = "#ffffffff";
    		    }
		    }
		else if (sender.name == "q1_Button")
		    {
    		    var q1Check = animationLibrary.ReturnAssets();
    		    if (q1Check != null){
    		        this.HeaderBGColorStart["Value"] = this.headerGradientStartColor;
		            this.HeaderBGColorChange1["Value"] = MSColors[2];
		            this.HeaderBGColorChange2["Value"] = MSColors[2];
		            this.headerGradientStartColor = MSColors[2];
    		        aniSelect = "q1";
    		        sender.findName("q1_Glow")["Opacity"] = 100;
	                sender.findName("q1_Active")["Opacity"] = 100;
	                sender.findName("q1_Shadow")["Opacity"] = 0;
	                sender.findName("bambi1")["Fill"] = "#ffffffff";
	                sender.findName("bambi2")["Fill"] = "#ffffffff";
    		    }
		    }
		else if (sender.name == "q3_Button")
		    {
    		    var q3Check = animationLibrary.ReturnAssets();
    		    if (q3Check != null){
    		        this.HeaderBGColorStart["Value"] = this.headerGradientStartColor;
		            this.HeaderBGColorChange1["Value"] = MSColors[3];
		            this.HeaderBGColorChange2["Value"] = MSColors[3];
		            this.headerGradientStartColor = MSColors[3];
    		        aniSelect = "q3";
    		        sender.findName("q3_Glow")["Opacity"] = 100;
	                sender.findName("q3_Active")["Opacity"] = 100;
	                sender.findName("q3_Shadow")["Opacity"] = 0;
	                sender.findName("Antena1")["Fill"] = "#ffffffff";
	                sender.findName("Antena2")["Fill"] = "#ffffffff";
    		    }
		    }
		else if (sender.name == "q4_Button")
		    {
    		    var q4Check = animationLibrary.ReturnAssets();
    		    if (q4Check != null){
    		        this.HeaderBGColorStart["Value"] = this.headerGradientStartColor;
		            this.HeaderBGColorChange1["Value"] = MSColors[1];
		            this.HeaderBGColorChange2["Value"] = MSColors[1];
		            this.headerGradientStartColor = MSColors[1];
    		        aniSelect = "q4";
    		        sender.findName("q4_Glow")["Opacity"] = 100;
	                sender.findName("q4_Active")["Opacity"] = 100;
	                sender.findName("q4_Shadow")["Opacity"] = 0;
	                sender.findName("QuestionMark")["Fill"] = "#ffffffff";
	                
    		    }
		    }
		this.HeaderTextBlockIndex = 0;
		this.headerTextSection = aniSelect;
		this.HeaderWordSwitch();
		this.HeaderGradientAnimation.begin();
		
		
		buttonClickHook(sender);
		
	},
	onButtonDown: function(sender, eventArgs) 
	{
		this.buttonSound.stop();
		this.buttonSound.play();
				
	},
	bannerTextReady: function(sender, args)
	{
	    this.bannerTextArray = this.bannerText.getValues();
	    sender.findName("BannerText1").text = this.bannerTextArray[0];
	    sender.findName("BannerText2").text = this.bannerTextArray[1];
	    sender.findName("BannerText3").text = this.bannerTextArray[2];
	    sender.findName("BannerText4").text = this.bannerTextArray[3];
	},
	onBannerReady: function(sender, args)
	{
	    // begin Banner Animation
	    this.BannerMockup.Visibility = "Visible";
	    this.BannerAnimation.begin();
	    this.bannerTransitionVideo.stop();
	    this.bannerTransitionVideo.play();
	},
	onBannerLoop: function(sender, args)
	{
	    // loop Banner Animation
	    this.BannerAnimation.stop();
	    this.BannerAnimation.begin();
	    this.bannerTransitionVideo.stop();
	    this.bannerTransitionVideo.play();
	},
	onBannerClick: function(sender, args)
	{
	  
	  
	  
	   this.inBannerState = false;
	   //Check if Animations are done downloading. If they are, startExperience, otherwise show Preloader
	    if (this.animationsLoaded == false){
	        this.bannerTransitionVideo.Visibility = "Collapsed";
	        this.BannerMockup.Visibility = "Collapsed";
	        this.BannerTransitonBlack.Visibility = "Visible";
	        this.CollapseOpenStoryboard.begin();
	    } else {
	        this.bannerTransitionVideo.Visibility = "Collapsed";
	        this.BannerMockup.Visibility = "Collapsed";
	        this.BannerTransitonBlack.Visibility = "Collapsed";
	        this.StartExperience();
	    }
	    
	    buttonClickHook(sender);
	},
	onFontsReady: function(sender, args)
	{
	    //this.PreloaderTextBlock
	    //this.textBlock = sender.findName("font1_TB");
	    var fontLibrary = sender;
	    
	    this.PreloaderTextBlock.setFontSource(fontLibrary);
	    this.PreloaderTextBlock.fontFamily = "Segoe Light";
	    
	    this.PreloaderPercentText.setFontSource(fontLibrary);
	    this.PreloaderTextBlock.fontFamily = "Segoe";
	     
	    this.HeaderTextBlock.setFontSource(fontLibrary);
	    this.HeaderTextBlock.fontFamily = "Segoe Semibold";
	    
	    this.BannerText1 = sender.findName("BannerText1");
	    this.BannerText1.setFontSource(fontLibrary);
	    this.BannerText1.fontFamily = "Segoe";
	    this.BannerText2 =sender.findName("BannerText2");
	     this.BannerText2.setFontSource(fontLibrary);
	    this.BannerText2.fontFamily = "Segoe";
	    this.BannerText3 =sender.findName("BannerText3");
	     this.BannerText3.setFontSource(fontLibrary);
	    this.BannerText3.fontFamily = "Segoe";
	    this.BannerText4 = sender.findName("BannerText4");
	     this.BannerText4.setFontSource(fontLibrary);
	    this.BannerText4.fontFamily = "Segoe";
	    localizeFonts(sender, fontLibrary);
	    
	    sender.removeEventListener("completed", 0);
	}
}

var MSColors = new Array("#FFFFDA00","#FF0099FF", "#FFFF3300","#FF66CC33");

function updateText(sender, args){
    
    var txt = sender.findName("loaderText");
    var rect = sender.findName("loaderRect");
    txt.Text = q2Ref.percentageDownload+" %";
    rect.Width = q2Ref.percentageDownload;
}

var totalFrames = 0;
var currentVideo = "intro";
aniSelect = "q1";



function onMarkerReached(sender, args)
    {
        var indexNum = args.marker.text;
        var shirts = sender.findName("shirts");
        var feedback = sender.findName("Feedback"); 
        var soundFX1 = sender.findName("SoundEffect1");
        var soundFX2 = sender.findName("SoundEffect2");
        var soundFX3 = sender.findName("SoundEffect3");
        var soundFX4 = sender.findName("SoundEffect4");
       
        if (args.marker.type == "Dynamic Marker")
        {
                
            //var shirtLeft = sender.findName("shirtLeft");
            //var shirtRight = sender.findName("shirtRight");
            
            var shirtLeftCanvas = sender.findName("shirtLeftCanvas");
            var shirtLeftCanvasRotate = sender.findName("shirtLeftCanvasRotate");
            var shirtLeftCanvasScale = sender.findName("shirtLeftCanvasScale");
            var shirtRightCanvas = sender.findName("shirtRightCanvas");
            var shirtRightCanvasRotate = sender.findName("shirtRightCanvasRotate");
            var shirtRightCanvasScale = sender.findName("shirtRightCanvasScale");
            
            
            var shirtAni = sender.findName("shirtsAni");
             shirtAni["Visibility"] = "Collapsed";
                shirtAni["Opacity"] = "0.9";
               shirtLeftCanvas["Visibility"] = "Collapsed";
                shirtRightCanvas["Visibility"] = "Collapsed";  
                shirtLeftCanvas["Opacity"] = "0.9";
                shirtRightCanvas["Opacity"] = "0.9";
                 
		        
    // Set the ImageSource property to the contents of the downloaded object,
    // named [animation]_00000.png as a zip part in the download
    // deal with frame number change for string value
            var imageSelect = "";
            if (indexNum > 0 && indexNum< 10){
                imageSelect = "00"+indexNum;
            }else if (indexNum > 10 && indexNum <100){
                imageSelect = "0"+indexNum;
            }else if (indexNum > 100){
                imageSelect = indexNum;
            }
                
                   var soundMediaElement;
                  // see if the current sound effect is playing
                  if (soundFX1.CurrentState != "playing"){
                    soundMediaElement = soundFX1;
                    //soundMediaElement.stop();
                  }else if (soundFX2.CurrentState != "playing"){
                    soundMediaElement = soundFX2;
                    //soundMediaElement.stop();
                  }else if (soundFX3.CurrentState != "playing"){
                    soundMediaElement = soundFX3;
                    //soundMediaElement.stop();
                  }else if (soundFX1.CurrentState != "playing"){
                   soundMediaElement = soundFX4;
                  }else{
                    alert("no media element available to play");
                  }
                  
 
		     if (aniSelect == "q1"){
		        shirtAni["Visibility"] = "Visible";
		        shirtLeftCanvas["Visibility"] = "Collapsed";
                shirtRightCanvas["Visibility"] = "Collapsed";
                aniList = animationLibrary.ReturnAssets();
                shirtAni.setSource(aniList, ''+aniSelect+'_00'+imageSelect+'.png'); 
                 switch (indexNum){
                     case "1":
                        soundMediaElement.setSource(soundfxLibrary,'q1_sound_00000.wma');
                     break;
                     case "69":
                        soundMediaElement.setSource(soundfxLibrary,'q1_sound_00069.wma');
                     break;
                     case "107":
                        soundMediaElement.setSource(soundfxLibrary,'q1_sound_00107.wma');
                     break;
                     case "131":
                        soundMediaElement.setSource(soundfxLibrary,'q1_sound_00133.wma');
                     break;
                     case "168":
                        soundMediaElement.setSource(soundfxLibrary,'q1_sound_00168.wma');
                     break;
                 }
		     }   
             if (aniSelect == "q2"){
                shirtAni["Visibility"] = "Visible";
                shirtLeftCanvas["Visibility"] = "Collapsed";
                shirtRightCanvas["Visibility"] = "Collapsed"; 
                aniList = animationLibrary.ReturnAssets();
                shirtAni.setSource(aniList, ''+aniSelect+'_00'+imageSelect+'.png');
		        switch (indexNum){
                 case "55":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                 break;
                 case "65":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                 break;
                 case "71":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "77":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "83":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "90":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "96":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "104":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "109":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "115":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "121":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "128":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "131":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "138":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "144":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "152":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                 break;
                 case "156":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00055.wma');
                  break;
                 case "164":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00065.wma');
                  break;
                 case "4":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00004.wma');
                  break;
                 case "145":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00145.wma');
                  break;
                 case "153":
                 soundMediaElement.setSource(soundfxLibrary,'q2_sound_00153.wma');
                 break;
                 } 
		    }
		    if (aniSelect == "q3"){
		        shirtAni["Visibility"] = "Visible";
		        shirtLeftCanvas["Visibility"] = "Collapsed";
                shirtRightCanvas["Visibility"] = "Collapsed"; 
		        aniList = animationLibrary.ReturnAssets();
		        shirtAni.setSource(aniList, ''+aniSelect+'_00'+imageSelect+'.png');
		        switch (indexNum){
                    case "1":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00000.wma');
                    break;
                    case "66":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00066.wma');
                    break;
                    case "70":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00070.wma');
                    break;
                    case "94":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00094.wma');
                    break;
                    case "143":
                   soundMediaElement.setSource(soundfxLibrary,'q3_sound_00143.wma');
                    break;
                    case "145":
                   soundMediaElement.setSource(soundfxLibrary,'q3_sound_00145.wma');
                    break;
                    case "152":
                   soundMediaElement.setSource(soundfxLibrary,'q3_sound_00152.wma');
                    break;
                    case "167":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00167.wma');
                    break;
                    case "183":
                    soundMediaElement.setSource(soundfxLibrary,'q3_sound_00183.wma');
                    break;
                    case "195":
                   soundMediaElement.setSource(soundfxLibrary,'q3_sound_00197.wma');
                    break;
                }
  
		     }
		    
		     if (aniSelect == "q4"){
		        shirtAni["Visibility"] = "Visible";
                shirtLeftCanvas["Visibility"] = "Collapsed";
                shirtRightCanvas["Visibility"] = "Collapsed"; 
                aniList = animationLibrary.ReturnAssets();
                shirtAni.setSource(aniList, ''+aniSelect+'_00'+imageSelect+'.png'); 
		        switch (indexNum){
                    case "9":
                     soundMediaElement.setSource(soundfxLibrary,'q4_sound_00009.wma');
                     break;
                    case "109":
                    soundMediaElement.setSource(soundfxLibrary,'q4_sound_00059.wma');
                     break;
                }
		     }
             // play any sounds neede for current frame   
		     if (soundMediaElement.CurrentState != "playing"){
		        soundMediaElement.play();
		     }
		     
		     if (aniSelect == "attract"){
		       if (currentVideo == "loop"){
		           shirtAni["Visibility"] = "Collapsed";
		           shirtLeftCanvas["Visibility"] = "Visible";
                   shirtRightCanvas["Visibility"] = "Visible"; 
                   //feedback.Text = currentVideo+" "+indexNum+" "+aniSelect+" Y:"+CanvasLeft_loop_dataY[indexNum]+" X:"+CanvasLeft_loop_dataX[indexNum];  
		           shirtLeftCanvas["Canvas.Top"] =  CanvasLeft_loop_dataY[indexNum];
		           shirtLeftCanvas["Canvas.Left"] = CanvasLeft_loop_dataX[indexNum]-100;
		           shirtLeftCanvasScale["ScaleX"] = ScaleLeft_loop_data[indexNum];
		           shirtLeftCanvasScale["ScaleY"] = ScaleLeft_loop_data[indexNum];
		           shirtLeftCanvasRotate["Angle"] = RotationLeft_loop_data[indexNum];
    		       
		           shirtRightCanvas["Canvas.Top"]=  CanvasRight_loop_dataY[indexNum];
		           shirtRightCanvas["Canvas.Left"]= CanvasRight_loop_dataX[indexNum]-100;
		           shirtRightCanvasScale["ScaleX"] = ScaleRight_loop_data[indexNum];
		           shirtRightCanvasScale["ScaleY"] = ScaleRight_loop_data[indexNum];
		           shirtRightCanvasRotate["Angle"] = RotationRight_loop_data[indexNum];
		       }
		       
		    }
		    
           
        }  
  
   }
    
  
