var win = Ti.UI.currentWindow;

win.hideNavBar();

// Background image view
var bgImage = Ti.UI.createImageView({
	height	: 500,
	top		: -30,
	image	: 'images/bg.png',
	zIndex	: 0
});
win.add(bgImage);



// List of data
var data = [
	{ 
		title		: 'Call',
		name		: 'phone',
		leftImage	: 'images/icon_036.png',
		height		: 50,
		color		: '#fff',
		selectedBackgroundColor: '#fff',
        backgroundColor	: 'transparent',		
		hasChild	: true
	},
    { 
		title		: 'Email', 
		name		: 'email',
		leftImage	: 'images/icon_036.png',
		height		: 50,		
		color		: '#fff',		
		selectedBackgroundColor: '#fff',
		backgroundColor	: 'transparent',		
		hasChild	: true 
	},
	
	
	{ 
		title		: 'Map', 
		name		: 'directions',
		leftImage	: 'images/icon_036.png',
		height		: 50,
		color		: '#fff',				
		selectedBackgroundColor: '#fff',
        backgroundColor	: 'transparent',		
		hasChild	: true 
	},
	{ 
		title		: 'Web', 
		name		: 'website',
		leftImage	: 'images/icon_036.png',
		height		: 50,	
		color		: '#fff',	
		selectedBackgroundColor: '#fff',
        backgroundColor	: 'transparent',				
		hasChild	: true 
	}	

];

// ----- Create the actual tableView for the page ----- //
var tableview = Titanium.UI.createTableView({
	data			: data,
	layout			: 'vertical',
	height			: '70%',
	bottom			: 0,
	backgroundImage	: 'transparent',
	background		: 'transparent',
    backgroundColor	: 'transparent',
	separatorColor	: 'transparent',
	style			: Titanium.UI.iPhone.TableViewStyle.GROUPED
});
win.add(tableview);

// ----- Create an event listener for the tableView ----- //
tableview.addEventListener('click', function(e) {
	// Determine what to do by the 'name' property stored in the rowData
	switch(e.rowData.name)
	{
		// Email / contact submission
		case 'email':
			var emailDialog = Titanium.UI.createEmailDialog();	// Create the email dialog object
			emailDialog.subject = "iPhone App";  // Set the subject
			emailDialog.toRecipients = ['info@oliblanton.com'];  // Set the recipients email addy (your company addy)
			emailDialog.messageBody = '';  // If you need to, set body message
			emailDialog.open();  // Open the email dialog
			break;
		// Phone call (won't work in simulator)
		case 'phone':
			Ti.Platform.openURL('tel: 8008008001');  // Call your company number (only works on live phone)
			break;
		// Directions / map
		case 'directions':
			// Paste in the directions / link to your business (Use Google maps).
			// In the simulator it will open Safari.  On the phone it will open the Google maps app
			Ti.Platform.openURL('http://maps.google.com/maps?f=d&source=s_d&saddr=555+Barrington,+South+Barrington+Avenue,+Los+Angeles,+CA&daddr=201+Presidents+Circle,+Salt+Lake+City,+UT+84112+(The+University+of+Utah)&hl=en&geocode=FXqwBwIdo07w-CHwniim4le6Vw%3BFSTtbQIdA3lV-SFuCTre0PyU3Q&mra=ls&sll=40.756555,-111.844511&sspn=0.051298,0.062656&ie=UTF8&ll=37.274053,-115.059814&spn=7.114341,8.02002&z=7');
			break;
		// Login opens website
		case 'login':
			// Paste in your customer login area and it will open in Safari
			Ti.Platform.openURL('http://theoryandrobots.com');
			break;	
		// Paste in your website address here
		case 'website':
			// Paste in your customer login area and it will open in Safari
			Ti.Platform.openURL('http://oliblanton.com');
			break;								
	}
});

