var win = Ti.UI.currentWindow;

var dateField = Ti.UI.createTextField({
	value: win.record.at,
	hintText: '日付を入力してください',
	top:20, left:50, right:50, height:40,
	borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(dateField);

var weightField = Ti.UI.createTextField({
	value: win.record.weight,
	hintText: '体重を入力してください',
	top:80, left:50, right:50, height:40,
	borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(weightField);

var saveButton = Ti.UI.createButton({
	title: 'この値で保存する',
	top:140, left:50, right:50, height:40
});
win.add(saveButton);

saveButton.addEventListener(
'click', function () {
	var record = {};
	record.id = win.record.id;
	record.weight = weightField.value;
	var at = new Date(dateField.value)
	record.at = at.toDateString();
	Ti.App.fireEvent(win.func, record);
	win.close();
});

var deleteCallback = function(e) {
	Ti.App.fireEvent('delete_row', win.record);
	win.close();
}; 

Ti.include('navigation.js');
var navi = new Navigation();
navi.setup({
	android: {
		rightButton: {title: 'Delete', icon: 'dark_x.png', callback : deleteCallback}		
	}
});
