/*
 * Copyright (C) 1995-2014 by 4system Polska Sp. z o.o.
 * All Rights Reserved. v4
 */

componentDictionaryGroups = function(name)
{
	this.__componentText = __componentText;
	this.__componentText(name);

	this.groups = "";
};

componentDictionaryGroups.prototype = new __componentText;
componentDictionaryGroups.prototype.type = "componentDictionaryGroups";

componentDictionaryGroups.prototype.onBaseCreate = function(obj)
{
	this.captureMouseEvents();
};

componentDictionaryGroups.prototype.componentDictionaryGroupsBaseOnCreate = componentDictionaryGroups.prototype.onCreate;
componentDictionaryGroups.prototype.onCreate = function(obj)
{
	this.componentDictionaryGroupsBaseOnCreate();
	if (this.scrollable) {
		this.scrollOffset = 14;
		this.stopPropagation = true;
	};
	this.groups = this.text;
};

componentDictionaryGroups.prototype.onPaint = function(obj)
{
	/*this.text = "";
	for (var i=0; i<dictionary.items.length; i++) { //for (var i=0; i<dictionary.groups.length; i++) {
		var group = dictionary.items[i]; //var group = dictionary.groups[i];
		//this.text += '<a href="javascript:void(0);" title="' + group.caption + '" onclick="pc.' + this.id + '.doClick(\'' + group.id + '\');">' + group.caption + '</a> ';
		this.text += '<a href="javascript:void(0);" title="' + group.key + '" onclick="pc.' + this.id + '.doClick(\'' + group.id + '\');">' + group.key + '</a> ';
	}
	this.setValue(this.text);*/
	this.groups = this.groups.replace(new RegExp('&nbsp;', "g"), ' '); //pg2
	this.groups = this.groups.replace(new RegExp('  ', "g"), ' '); //pg2
	var parsedGroups = this.groups.replace(/<[^>]*>/g, ""); //pg2-get text without html formatting
	//var f_list = this.groups.split(" ");
	var f_list = parsedGroups.split(" ");
	this.text = "";
	for (var i=0; i<f_list.length; i++) {
		var filter = f_list[i];
		if (filter.length > 1 && filter != "0-9") filter = "";
		if (filter != "" && !dictionary.existsKey(f_list[i], true)) {
			this.text += "<SPAN style='color: " + this.font.color + ";'>" + f_list[i] + " " + "</SPAN>";
		} else {
			//this.text += '<a href="javascript:void(0);" title="' + f_list[i] + '" onclick="pc.' + this.id + '.doClick(\'' + filter + '\');">' + /*f_list[i]*/ fList_i_formatted + '</a> ';
			this.text += '<a href="javascript:void(0);" title="' /*+ f_list[i]*/ + '" style="color: ' + this.font.activeColor + ';" onclick="pc.' + this.id + '.doClick(\'' + filter + '\');">' + f_list[i] + '</a> ';
		};
	};
	this.setValue(this.text);
};

componentDictionaryGroups.prototype.doClick = function(value)
{
	dictionary.setFilter(value);
};
