LocalDataLogger.prototype._CheckFileLength_ = function(that)
{
	Global_LocalDataLogger["FileLength"] = $(that).val();
};

LocalDataLogger.prototype._CheckLogInterval_ = function(that)
{
	Global_LocalDataLogger["LogInterval"] = parseInt($(that).val());
};

LocalDataLogger.prototype._CheckFolderName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Class = new Type();
	var FolderName = $(that).val();
	if(FolderName == "")
	{
		$(that).val("Datalog");
	}
	else if(Class.EnglishDigitalAndBottomline(FolderName) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
		return 0;
	}
	Global_LocalDataLogger["FolderName"] = $(that).val();
};

LocalDataLogger.prototype._CheckDiskUsageRate_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Class = new Type();
	var DiskUsageRate = parseInt($(that).val());
	if(DiskUsageRate > 95)
	{
		DiskUsageRate = 95;
	}
	else if(DiskUsageRate < 7)
	{
		DiskUsageRate = 7;
	}
	else if(isNaN(DiskUsageRate) || DiskUsageRate == "")
	{
		DiskUsageRate = 90;
	}
	$(that).val(DiskUsageRate);
	Global_LocalDataLogger["DiskUsageRate"] = $(that).val()/100;
};

LocalDataLogger.prototype._ShowUi_ = function()
{
	var FolderName;  var DiskUsageRate;  var FileLength;  var LogInterval;
	var VariableData = LocalDataLogger.prototype._GetVariableData_();
	FolderName = VariableData[0];
	FileLength = VariableData[1];
	LogInterval = VariableData[2];
	DiskUsageRate = VariableData[3];
	var SdCardUsageRate = LocalDataLogger.prototype._GetSdCardUsageRate_();
	var Row = $("#Main_Center-Content").find(".Form").find(".Row");
	var Radio=Row.eq(5).find(":radio");
	Row.eq(4).find(".Message").hide();
	if(SdCardUsageRate != "")
	{
		Row.eq(4).find(".Message").eq(0).show();
		Radio.get(0).checked=true;
	}
	else
	{
		Row.eq(4).find(".Message").eq(1).show();
		Radio.get(1).checked=true;
	}
	Row.eq(0).find(".Text").val(FolderName);
	Row.eq(1).find(".Select").val(FileLength);
	Row.eq(2).find(".Select").val(LogInterval);
	Row.eq(3).find(".Text").val(parseInt(DiskUsageRate*100));
	Row.eq(4).find(".Message").eq(0).text(SdCardUsageRate);
};

LocalDataLogger.prototype._GetSdCardUsageRate_ = function()
{
	var Class = new Cgi();
	var Return = Class.RestApi("GetSdCardUsageRate", new Array(), false);
	return Return;
};

LocalDataLogger.prototype._GetVariableData_ = function()
{
	var Variable = Global_LocalDataLogger;
	var FolderName    = Variable["FolderName"];
	var FileLength    = Variable["FileLength"];
	var LogInterval   = Variable["LogInterval"];
	var DiskUsageRate = Variable["DiskUsageRate"];
	var Return = new Array(FolderName, FileLength, LogInterval, DiskUsageRate);
	return Return;
};

LocalDataLogger.prototype._AllDataIsCorrect_ = function()
{
	var Return = true;
	var Form = $("#Main_Center-Content").find(".Form").eq(0);
	var length = Form.find(".Row").length;
	for(var i=0; i<length; i++)
	{
		if(i == 4)  {continue;}
		var Message = Form.find(".Row").eq(i).find(".Message");
		var Messagelength = Message.length;
		for(var j=0; j<Messagelength; j++)
		{
			var ShowMessage = Message.eq(j).is(":visible");
			if(ShowMessage == true)
			{
				Return = false;
			}
		}
	}
	return Return;
};

LocalDataLogger.prototype._TransmissionSetting_ = function(that)
{
	var SetInterval = setInterval(function()
	{
		var ClassCgi = new Cgi();
		var ParameterArray = new Array(JSON.stringify(Global_LocalDataLogger));
		var ReturnValue = ClassCgi.RestApi("SaveLocalDataLogger", ParameterArray, false);
		$(that).closest('.Row').find(".Loading").hide();
		if(ReturnValue == true)
		{
			$(that).closest('.Row').find(".Message").eq(0).show();
		}
		else if(ReturnValue == false)
		{
			$(that).closest('.Row').find(".Message").eq(2).show();
		}
		clearInterval(SetInterval);
	},100);
};

LocalDataLogger.prototype._SaveButton_ = function(that)
{
	$(that).closest('.Row').find(".Loading").show();
	$(that).closest('.Row').find(".Message").hide();
	if(LocalDataLogger.prototype._AllDataIsCorrect_() == false)
	{
		$(that).closest('.Row').find(".Loading").hide();
		$(that).closest('.Row').find(".Message").eq(1).show();
		return;
	}
	LocalDataLogger.prototype._TransmissionSetting_(that);
};

LocalDataLogger.prototype._MountSdCard_ = function()
{
	var Class = new Cgi();
	var Return = Class.RestApi("MountSdCard", new Array(), false);
	LocalDataLogger.prototype._ShowUi_();
};

LocalDataLogger.prototype._UnMountSdCard_ = function()
{
	var Class = new Cgi();
	var Return = Class.RestApi("UnMountSdCard", new Array(), false);
	LocalDataLogger.prototype._ShowUi_();
};