var win 			= Ti.UI.currentWindow;

//-- Create the sub windows
var crusts 			= Ti.UI.createWindow();
var toppings 		= Ti.UI.createWindow();
var details			= Ti.UI.createWindow();

//-- We set the background here since this wont change
win.backgroundImage = '../images/bg_main.png';

//-- Include our clock
Ti.include('../includes/clock.js');

//-- This method will close the crusts/details window and open the toppings window
function openToppings(e)
{
	crusts.close();

	toppings.url 			= 'toppings.js';
	toppings.crust 			= e.crust;
	toppings.path			= e.path;
	toppings.returnToppings = e.toppings;
	
	toppings.open();
}

//-- The method will close the toppings window and open the crusts window
function openCrust(e)
{
	toppings.close();
	//-- If the event has a crust property, that means the user hit cancel once in the toppings window
	if (e.crust)
	{
		crusts.crust = e.crust;
	}
	crusts.url = 'crusts.js';
	crusts.open();
}

//-- Have our app listen for our custom events
Ti.App.addEventListener('toppings',openToppings);
Ti.App.addEventListener('cancelToppings',openCrust);

openCrust({});