// jk: fashionshow variables
var fashionshow = {};
	fashionshow.silverlight = {};
	fashionshow.silverlight.id = "silverlight_fashionshow_application";
	fashionshow.silverlight.source = "main.xap?config_url=xml/config.xml&deeplink=" + $.address.value();
	fashionshow.silverlight.onApplicationLoaded = function($sender,$args)
	{
		fashionshow.silverlight.application = $sender.Content;

		var state = SLS.getClientState();
		if (state.isSlVersionInstalled && state.isLogInstallFlowCookieDefined)
		{
			SLS.logInstallFlow(4);
			SLS.initialize();
		}
	}
	
	fashionshow.silverlight.onApplicationError = function($sender,$args)
	{
		 if ($args.ErrorCode == 8002) Silverlight.onRestartRequired();
	}


// jk: silverlight detection
Silverlight.onRequiredVersionAvailable = function() {};

Silverlight.onInstallRequired = function()
{
	fashionshow.installState = 1;

	SLS.installState = 0;
	SLS.logInstallFlow(0);
	
	$("#silverlight-container").hide();
	$("#no-silverlight-frame").show();

	$("#sl_download_click").click(function()
	{
		SLS.installState = fashionshow.installState;	
		SLS.logInstallFlow(fashionshow.installState);
		window.location = "http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0";
	});
	
	$("#sl_download_click").attr("target","_blank");

	cmCreatePageviewTag("FASHION SHOW - NO SILVERLIGHT",null,"FASHION SHOW");
}

Silverlight.onUpgradeRequired = function()
{
	Silverlight.onInstallRequired();
	fashionshow.installState = 2;
}

Silverlight.onRestartRequired = function() {}

// jk: page load
$(document).ready(function()
{
	SLS.logEntryFlow();
	SLS.initialize();

	$(window).bind('beforeunload', function() { SLS.onPlayerPageBeforeUnload(); });

	var silverlightSupported =  Silverlight.supportedUserAgent();
	if(!silverlightSupported)
	{
		Silverlight.onInstallRequired();
		$("#no-silverlightcontent-body-copy").hide();		
		$("#no-silverlight-content-body-header").css({backgroundPosition:"0 -32px"});
	}
	else
	{
		Silverlight.createObjectEx( { 	id:				fashionshow.silverlight.id,
										source: 		fashionshow.silverlight.source,
									  	parentElement:	document.getElementById("silverlight-stage"),
										properties:		{
										  					width:				"100%",
										  					height:				"100%",
										  					background:			"black",
										  					version:			"3.0.40624.0",
										  					enableGPUAcceleration: "true",
										  					splashscreensource:	"black.xaml"
									  					},
									  events:			{
									  						onError:			fashionshow.silverlight.onApplicationError,
									  						onLoad:				fashionshow.silverlight.onApplicationLoaded
								  						},
									  context:			null
								  	}
							  	);
	
		$.address.change(function(event)
		{
			if(fashionshow.silverlight.application != null)
			{
				fashionshow["silverlight"]["application"].BrowserUtils.javascriptChangedURL($.address.value());
			}		
		});
	}
});

// jk: deep linking
function silverlightChangedURL($deeplink){ $.address.value($deeplink); }
function silverlightActionTrack($type,$action)
{
	var url = 'http://view.atdmt.com/jaction/' + $action + '/?' + Math.random();
	
	if($type == "js") $.getScript(url);
	else
	{
		var img = new Image();
	    img.src = url;
	    imgs.push(img);		
	}
}