<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx"
					   skinClass="org.umbraco.desktopmediauploader.skins.ApplicationSkin" 
					   width="330" height="600" showStatusBar="false" 
					   xmlns:views="org.umbraco.desktopmediauploader.views.*"
					   windowComplete="init();" >
	
	<fx:Style source="DesktopMediaUploader.css"/>
	
	<fx:Script>
		<![CDATA[
			
			import org.umbraco.desktopmediauploader.events.*;
			import org.umbraco.desktopmediauploader.util.*;
			
			import mx.controls.Alert;
			
			protected function init():void
			{
				StageHelper.stage = stage;
				
				NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE, app_BrowserInvoke);
				
				vwSignIn.addEventListener(SignedInEvent.SIGNED_IN, vwSignIn_SignedIn);
				vwUpload.addEventListener(SignedOutEvent.SIGNED_OUT, vwUpload_SignOut);
				
				vwSignIn.init();
			}
			
			protected function app_BrowserInvoke(e:BrowserInvokeEvent):void
			{
				vwSignIn.visible = true;
				vwUpload.visible = false;
			}
			
			protected function vwSignIn_SignedIn(e:SignedInEvent):void
			{				
				vwSignIn.visible = false;
				vwUpload.visible = true;
			}
			
			protected function vwUpload_SignOut(e:SignedOutEvent):void
			{
				vwSignIn.visible = true;
				vwUpload.visible = false;
			}
			
		]]>
	</fx:Script>
	
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>

	
	<views:SignInView id="vwSignIn" left="0" top="0" right="0" bottom="0">
	</views:SignInView>
	
	<views:UploadView id="vwUpload" left="0" top="0" bottom="0" right="0" 
					  visible="false">
	</views:UploadView>
	
</s:WindowedApplication>
