<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="absolute"
	xmlns:v="views.*"
	backgroundColor="#000000"
	creationComplete="initApp()">

	<mx:Style>
		global 
		{
			color: #63769E;
		}
		.windowStyles 
		{
			color: #ffffff;	
		}
		ComboBox 
		{
			fontWeight: normal;
			selection-color: #63769E;
			roll-over-color: #B5D2FA;
		}
		Button 
		{
			fontWeight: normal;
		}
	</mx:Style>
	
	<mx:Script>
		<![CDATA[
			import events.PhotoEvent;
			import valueObjects.Photo;
			import mx.rpc.events.ResultEvent;
			import mx.collections.ArrayCollection;
			
			[Bindable]
			private var photoData:ArrayCollection=new ArrayCollection();
			[Bindable]
			private var purchasedPhotos:ArrayCollection=new ArrayCollection();

			private function photosInHandler(event:ResultEvent):void
			{
				var photoRaw:ArrayCollection=event.result.photos.image;
				for(var i:int=0;i<photoRaw.length;i++)
				{
					var tempPhoto:Photo=new Photo();
					tempPhoto.filename=photoRaw[i].filename;
					tempPhoto.photographer=photoRaw[i].photographer;
					tempPhoto.desc=photoRaw[i].desc;
					tempPhoto.category=photoRaw[i].category;
					photoData.addItem(tempPhoto);
				}				
			}
			private function initApp():void
			{
				photosIn.send();
			}
			private function photoSelectedHandler(event:PhotoEvent):void
			{
				purchasedPhotos.addItem(event.selectedPhoto);
			}
		]]>
	</mx:Script>
	
	<mx:HTTPService id="photosIn"
		url="assets/photos.xml"
		result="photosInHandler(event)"/> 
	
	<mx:LinkBar 
		dataProvider="{fStopContent}" 
		color="#ffffff"
		x="101" y="5"
		rollOverColor="#B5D2FA" />
	
	<mx:Image 
		y="30" 
		x="101"
		source="assets/fstop/header.jpg" />
		
	<v:ShoppingCart 
		x="626" y="118"  
		purchasedPhotos="{purchasedPhotos}"/>
		
	<mx:ViewStack id="fStopContent" 
		x="101" y="118"
		paddingBottom="0" 
		paddingLeft="0" 
		paddingRight="0" 
		paddingTop="0" 
		resizeToContent="true">
		<v:Home id="home" 
			label="Home" />
		<v:Contribute id="contribute" 
			label="Contribute" />
		<v:Gallery id="gallery" 
			label="Gallery" 
			photoData="{photoData}"
			photoSelected="photoSelectedHandler(event)"/>
		<v:CheckOut label="Check Out"/>	
	</mx:ViewStack>
		
</mx:Application>
