var module = baseRootURL + "list/";

function doSearchClick()
{	
	var data = {};
	data.dummy = ""; //we seem to get errors from the first value, so always add a dummy value first.
	data.sId = document.getElementById('sId').value;
	/*
	data.page = document.getElementById('page').value;
	data.offset = document.getElementById('offset').value;
	data.orderField = document.getElementById('orderField').value;
	data.orderDirection = document.getElementById('orderDirection').value;
	data.sql = document.getElementById('sql').value;
	*/
	var inputs = document.getElementsByClassName("searchTextBox");
	var i, data = {};
	
	for (i=0; i<inputs.length; i++) 
	{
	  //eval("data." + inputs[i].id + " = '" + inputs[i].value + "'");
	  //alert("data.input" + i + " = '" + inputs[i].value + "'");
	  eval("data.input" + i + " = '" + inputs[i].value + "'");
	}

	var url = document.getElementById('url').value;
	data.dummy			= "dummy";
	data.outputField	= 'data_list'; //'sableDashboardContent';
	data.resetList		= 0;
	data.refinedList	= 1;
	callModule(url, data);
}

function doClearSearchClick()
{	
	var i, data = {};
	var inputs = document.getElementsByClassName("searchTextBox");
	
	data.dummy			= ""; //we seem to get errors from the first value, so always add a dummy value first.
	data.sId			= document.getElementById('sId').value;
	data.offset			= document.getElementById('offset').value;
	data.page			= document.getElementById('page').value;
	data.orderField		= document.getElementById('orderField').value;
	data.orderDirection = document.getElementById('orderDirection').value;
	data.resetList		= 1;
	data.refinedList	= 0;

	for (i=0; i<inputs.length; i++)
	{
		eval("data.input" + i + " = ''");
		inputs[i].value = ''; //clear the text
	}

	var url = document.getElementById('url').value;

	data.outputField = 'data_list';
	callModule(url, data);
}

function doSortClick(column, direction, params=0)
{
	var data = {};
	data.dummy 			= ""; //we seem to get errors from the first value, so always add a dummy value first.
	data.sId 			= document.getElementById('sId').value;
	data.page 			= document.getElementById('page').value;
	data.offset 		= document.getElementById('offset').value;
	data.orderField 	= column; //document.getElementById('orderField').value;
	data.orderDirection = direction; //document.getElementById('orderDirection').value;
	data.resetList		= 0;
	data.refinedList	= 1;
	//data.params 		= params;
	//console.log(data);
	if ((params !== 0) && (params.length))
	{
		//console.log('B: '+params);
		for (i=0; i<params.length; i++) 
		{
		  eval("data.params" + i + " = '" + params[i] + "'");
		}
	}
	
	var inputs = document.getElementsByClassName("searchTextBox");
	
	for (i=0; i<inputs.length; i++) 
	{
	  eval("data.input" + i + " = '" + inputs[i].value + "'");
	}

	var url = document.getElementById('url').value;
	//console.log(url);
	data.outputField = 'data_list';
	//wDebug(data, 8, 'list.js');
	callModule(url, data);
}

function pagenav(sId, offset, page, orderField, orderDirection)
{
	var i, data = {};
	data.dummy = ""; //we seem to get errors from the first value, so always add a dummy value first.

	data.outputField 	= 'data_list';
	data.sId 			= sId;
	data.offset 		= offset;
	data.page 			= page;
	data.orderField 	= orderField;
	data.orderDirection = orderDirection;
	data.resetList		= 0;
	data.refinedList	= 1;

	var inputs = document.getElementsByClassName("searchTextBox");
	for (i=0; i<inputs.length; i++){eval("data.input" + i + " = '"+inputs[i].value+"'");}
	var url = document.getElementById('url').value;
	callModule(url, data);	
}