// include the data
Titanium.include('../DataArrays/pokeData.js');
 
win = Titanium.UI.currentWindow;
 
var type = '';
var abil = '';
var hp = '';
var atk = '';
var def = '';
var satk = '';
var sdef = '';
var spd = ''; 
 
var data = [
			//this is making a verticle list tab for each entry, headers denote seperations
			{title:type, header:'Type'},
			{title:abil, header:'Abilities'},
			{title:'HP: ' + hp, header:'Base Stats'},
			{title:'ATTACK: ' + atk},
			{title:'DEFENSE: ' + def},
			{title:'SPECIAL ATTACK: ' + satk},
			{title:'SPECIAL DEFENSE: ' + sdef},
			{title:'SPEED: ' + spd}
			];
 
// create scroll view for the content
var scrollView = Titanium.UI.createScrollView({
	contentWidth:'auto',
	contentHeight:'auto',
	top:0,
	showVerticalScrollIndicator:true,
	showHorizontalScrollIndicator:false
});
 
 
// loop through data and get correct item by 'name' (this is easier than using Id's incase you add new items later)
for (var i = 0; i < pokeData.length; i++)
{
    if(pokeData[i].name == win.currentItem)
    {
    	//defiines all of those blank variable at the top
        type = pokeData[i].type;
        abil = pokeData[i].abilities;
        hp = pokeData[i].hp;
        atk = pokeData[i].attack;
        def = pokeData[i].defense;
        satk = pokeData[i].sAttack;
        sdef = pokeData[i].sDefense;
        spd = pokeData[i].speed;  
    }
}
// This HAS to be after all the calls to the variables in this setup, else it will be blank
var data = [
			{title:type, header:'Type'},
			{title:abil, header:'Abilities'},
			{title:'HP: ' + hp, header:'Base Stats'},
			{title:'ATTACK: ' + atk},
			{title:'DEFENSE: ' + def},
			{title:'SPECIAL ATTACK: ' + satk},
			{title:'SPECIAL DEFENSE: ' + sdef},
			{title:'SPEED: ' + spd}
			];
 
// create table view
var tableview = Titanium.UI.createTableView({
    data:data
});

win.add(tableview)
