// Table RECORD

var RECORD_FLAG_Action = 0x01;
var RECORD_FLAG_NewItem = 0x02;

function RECORD_add (ID, Name, Code, Price, Description, Group_ID, Picture, Picture_Args, Flags, Measurement, ItemCount, PriceWithVAT)
{
	this.ID=ID;
	this.Code=Code;
	this.Name=Name;
	
	this.Flags = Flags;

	var re = new RegExp (',', 'gi') ;
	this.Price = Price.replace(re, '.') ;
	this.Description=Description;
	this.Picture=Picture;
	this.Picture_Args=Picture_Args;
	this.Group_ID=Group_ID;
	this.Measurement = Measurement;
	this.ItemCount = ItemCount;
	this.PriceWithVAT = PriceWithVAT.replace (",", ".");
}

function RECORD_Name (offset)
{
	name="RECORD"+offset;
	return name;
}

function RECORD (offset)
{
	return eval(RECORD_Name(offset));
}

function RECORD_getID (id)
{
	for (i=0;i<RECORD_count;i++)
	{
		if (eval (RECORD(i)).ID==id) return i;
	}

	return null;
}

function RECORD_search (offset, value, flags)
{
	if (offset<RECORD_count)
	{
		T_record=RECORD(offset);
		
		if ((T_record.Flags & flags) == flags)
		{
			//alert (T_record.Name + ";" + value);
			if (T_record.Name.search (value)!=-1) return true;
			if (T_record.Description.search (value)!=-1) return true;
			if (T_record.Code.search (value)!=-1) return true;
		}
	}

	return false;
}

function checkForDataLoad (groupId)
{
	if ( typeof(progressRow) != 'undefined')
	{
		var offset = GROUP_getID(groupId);
		progressRow.cells.item(offset).childNodes.item(0).src='./images/progress.png';
	}
}

var RECORD_count = 198;

