
function init(){

}


function loadData_findAll() {
	DWRUtil.useLoadingMessage("LOADING......");
	service_findAll();
}
function service_findAll() {
	 TaskBoard.findAll(fillTable);
}
function loadData_findByPrimaryKey(id) {
	DWRUtil.useLoadingMessage("LOADING......");
	service_findByPrimaryKey(id);
}
function service_findByPrimaryKey(id) {
	 TaskBoard.findByPrimaryKey(fillTable);
}
function loadData_findByConditions(id,title,author) {
	DWRUtil.useLoadingMessage("LOADING......");
	service_findByConditions(id,title,author);
}
function service_findByConditions(id,title,author) {
	 TaskBoard.findByConditions(fillTable);
}
function loadData_getAuthorHistory(id) {
	DWRUtil.useLoadingMessage("LOADING......");
	service_getAuthorHistory(id);
}
function service_getAuthorHistory(id) {
	 TaskBoard.getAuthorHistory(fillTable);
}
var dataCache = { };
var viewed = -1;
function fillTable(dataList) {
	dwr.util.removeAllRows("dataTableBody", { filter:function(tr) {
		return (tr.id != "pattern");
		}});
	var data, id;
	for (var i = 0; i < dataList.length; i++) { 
		data = dataList[i]; 
		id = data.id;
		dwr.util.setValue("id", id);
		dwr.util.cloneNode("pattern", { idSuffix:data.id });
		var title = data.title;
		dwr.util.setValue("title" + id, title);
		var author = data.author;
		dwr.util.setValue("author" + id, author);
		var status = data.status;
		dwr.util.setValue("status" + id, status);
		if ($("pattern" + id).style.getPropertyValue) {
			$("pattern" + id).style.display = "table-row";
		} else {
			$("pattern" + id).style.setAttribute('display', '');
			$("pattern" + id).style.setAttribute('display', 'table-row');
		}
		dataCache[id] = data;
		clearInputData();
	}
}

function saveData(){
	 var id = DWRUtil.getValue("inputData_id");
	 var title = DWRUtil.getValue("inputData_title");
	 var author = DWRUtil.getValue("inputData_author");
	 var status = DWRUtil.getValue("inputData_status");
	if(id == -1) {
		TaskBoard.add(title,author,status);
	} else {
		TaskBoard.update(id,title,author,status);
	}
	DWRUtil.useLoadingMessage("LOADING......");
	loadData_findAll();
}

function editData(eleid){
 		DWRUtil.useLoadingMessage("LOADING......");
		var data = dataCache[eleid.substring(4)];
	 DWRUtil.setValue("inputData_id",data.id);
	 DWRUtil.setValue("inputData_title",data.title);
	 DWRUtil.setValue("inputData_author",data.author);
	 DWRUtil.setValue("inputData_status",data.status);
}

function deleteData(eleid) {
	alert('DELETE.');
	dwr.engine.beginBatch();
	TaskBoard.remove(eleid.substring(6));
	loadData_findAll();
	dwr.engine.endBatch();
 }

function clearInputData(){
	DWRUtil.setValue("inputData_id",-1);
	DWRUtil.setValue("inputData_title","");
	DWRUtil.setValue("inputData_author","");
	DWRUtil.setValue("inputData_status","");
}

function LinkButton3() {
} 


function lineChart_LetsAjaxChartModel4(){
	DWRUtil.useLoadingMessage("LOADING......");
	Chart.getLineChartData(drawLineChart_LetsAjaxChartModel4);
}
LetsAjaxChartModel4Options = {
	padding: {left: 60, right: 0, top: 10, bottom: 30},
	// Set a custom colorScheme
	// 色の設定をします
	colorScheme: 'blue',
	//colorScheme: new Hash({
	//'January': '#1c4a7e',
		//'February': '#bb5b3d',
		//'March': '#3a8133',
		//'April': '#813379'
	//}),
	// Background color to render.
	backgroundColor: '#f2f2f2',
	shouldFill: false,
	// Set the labels.
	//X軸のラベル設定
	//グラフ表示するデータ件数分label設定をする
	// 縦軸、横軸のフォントカラーの設定
	labelColor: '#000000',
	xTicks: [
		{v:0, label:'label1'},
		{v:1, label:'label2'},
		{v:2, label:'label3'},
		{v:3, label:'label4'}
	],
	//Y軸のラベル設定	//yTicks: [
		//{v:0, label:'100'},
		//{v:1, label:'200'},
		//{v:2, label:'300'},
		//{v:3, label:'400'}
	//],
	legend: {
		position: {
		top: '48.0px',
		left: '240.0px'
	}
}
};
function drawLineChart_LetsAjaxChartModel4(data){
	var line = new Plotr.LineChart('LetsAjaxChartModel4',LetsAjaxChartModel4Options);
	line.addDataset(data.evalJSON());
	line.render();
}

