/**
 * @author Bjorn
 */
function LibraryWindow() {
	var self = Ti.UI.createWindow({
		title:L('radiophoenix'),
		backgroundColor:'red'
	});
	
	var button = Ti.UI.createButton({
		height:44,
		width:200,
		title:L('openWindow'),
		top:20
	});
	self.add(button);
	//songs();
	//var songs = getSongs();
	// button.addEventListener('click', function() {
		// //containingTab attribute must be set by parent tab group on
		// //the window for this work
		// self.containingTab.open(Ti.UI.createWindow({
			// title: L('newWindow'),
			// backgroundColor: 'white'
		// }));
	// });
	
	return self;
};

var songs = function getSongs() {
	var file = Ti.Filesystem.getFile('data/songs.xml');
	if(file.exists()) {
		Ti.API.info("xml found");
		var xml = file.read().text;
		var doc = Ti.XML.parseString(xml);
		var songs = doc.getElementsByTagName('SONG');
		
		var data = [];
		for(var i = 0; i<songs.length;i++) {
			console.log(songs.item(i));
			data.push({
				name: songs.item(i).getElementsByTagName('TITLE').item(0).text(),
				link: songs.item(i).getElementsByTagName('LINK').item(0).text(),
				id: songs.item(i).getElementsByTagName('ID').item(0).text()
			});
		}
		TI.API.info(data);
		console.log(data);
		return data;
	}
};
module.exports = LibraryWindow;
