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

componentDefinedBookmarks = function(name)
{
	this.componentElement = componentBookmarks;
	this.componentElement(name);

	this.onSelectUrl = this.componentSelectUrl;
};

componentDefinedBookmarks.prototype 		= new componentBookmarks();
componentDefinedBookmarks.prototype.type 	= "componentDefinedBookmarks";

componentDefinedBookmarks.prototype.componentDefinedBookmarksBaseOnCreate = componentDefinedBookmarks.prototype.onCreate;
componentDefinedBookmarks.prototype.onCreate = function(text)
{
	this.componentDefinedBookmarksBaseOnCreate();
	this.buttonAdd.noDisplay();
};

componentDefinedBookmarks.prototype.onPaint = function(e)
{
	var elements = this.bookmarks.split("||");
	var t = "<SELECT onClick='page.all[\""+this.id+"\"].onSelectUrl(this.selectedIndex)' id='"+this.id+"SELECT' size='5' style='width: 100%; height:"+eval(this.popup.h-22)+"'>";
	for (var i = 0; i < Math.floor(elements.length/2); i++){
		t += "<OPTION id="+elements[2*i + 1]+">"+elements[2*i]+"</OPTION>"
	};
	t += "</SELECT>";
	this.popup.text.text = t;
	this.popup.text.stopPropagation = true;
};

componentDefinedBookmarks.prototype.setPagesName = function(e)
{
	return;
};

componentDefinedBookmarks.prototype.setListValues = function(e)
{
	var elements = this.bookmarks.split("||");
	var select = document.getElementById(this.id+"SELECT");
	for (var i = 0; i < Math.floor(elements.length/2); i++){
		var option = new Option(elements[2*i]);
		option.id = elements[2*i + 1];
		select.options[select.length] = option;
	};
};

componentBookmarks.prototype.componentSelectUrl = function(i)
{
	var select = document.getElementById(this.id+'SELECT');
	if (select.selectedIndex != -1) page.gotoPage(select.options[i].id);
};
