



var SFO_SPAN_CHECK = 0;
var SFO_SPAN_OPTION = 1;
var SFO_SPAN_PRICE_NETTO = 2;
var SFO_SPAN_SETUP_NETTO = 3;
var SFO_SPAN_PRICE_BRUTTO = 4;
var SFO_SPAN_SETUP_BRUTTO = 5;
var SFO_SPAN_DROPDOWN = 6;
var SFO_SPAN_CHILDS = 7;

var _isIE = (navigator.appName=='Microsoft Internet Explorer');




function Price(netto, brutto){
	this.netto = netto;
	this.brutto = brutto;
}
Price.prototype = {
	
	Clear: function(){
		this.netto = 0;
		this.brutto = 0;
	},
	
	Add: function(netto, brutto){
		this.netto += this._strin2Num(netto);
		this.brutto += this._strin2Num(brutto);
	},
	
	_strin2Num: function(valstr){
		var _val_num = valstr.toString();
		_val_num = _val_num.replace(/ /g,'');
		_val_num = _val_num.replace(/,/g,'.');
		return Number(_val_num);
	}
	
}// Price.prototype



function PriceServer(bond_netto, bond_brutto, setup_netto, setup_brutto){
	this.bond = new Price(bond_netto, bond_brutto);
	this.setup = new Price(setup_netto, setup_brutto);
}
PriceServer.prototype = {
	
}



function BondsScheme(base_price, base_setup){
	this.base_price = new PriceServer(base_price, base_price*1.19, base_setup, base_setup*1.19);
}


BondsScheme.prototype = {
	
	count: 0,
	SelectedIndex: 0,
	_keys: Array(),
	_names: Array(),
	_price: Array(),
	_promotion_months: Array(),
	_promotion_price: Array(),
	_promotionTitle: '',
	_promotionMonth: 0,
	_promotionPrice: 0,
	
	
	/* --------------------------------------------------------------------------------------------
	#		AddBond
	*/
	Add: function(key, name, ratio_price, ratio_setup, promotion_months, promotion_price){
		//
		this._keys[this.count] = key;
		this._names[this.count] = name;
		this._price[this.count] = new PriceServer(
			ratio_price * this.base_price.bond.netto, ratio_price * this.base_price.bond.brutto,
			ratio_setup * this.base_price.setup.netto, ratio_setup * this.base_price.setup.brutto
		);
		this._promotion_months[this.count] = promotion_months;
		this._promotion_price[this.count] = new Price(promotion_price, promotion_price*1.19);
		//
		this.count++;
	},
	
	key: function(index){
		return this._keys[index];
	},
	name: function(index){
		return this._names[index];
	},
	setup: function(index){
		return this._setups[index];
	},
	price: function(index){
		return this._prices[index];
	},
	promotion_months: function(index){
		return this._promotion_months[index];
	},
	promotion_price: function(index){
		return this._promotion_price[index];
	},
	IndexByKey: function(key){
		for ( keyVar in this._keys ) {
			if( this._keys[keyVar]==key ) return keyVar;
		}
		return undefined;
	},
	
	AddPromotion: function(promotionTitle, promotionMonth, promotionPrice){
		this._promotionTitle = promotionTitle;
		this._promotionMonth = promotionMonth;
		if( this._promotionMonth > 0 ){
			this._promotionPrice = promotionPrice;
		}else{
			this._promotionPrice = 0;
		}
	},
	
	
	OutputPrices: function(price_features){
		
		var _key = 0
		
		// pokazać wartości w tabelce total
		var cell_total_info;
		for( var i=0; i<this.count; i++ ){
			//
			_key = this._keys[i];
			// result.setup: Aktywacja (opłata jednorazowa):
			this._print_price('result.setup:netto:'+_key, this._price[i].setup.netto + price_features.setup.netto);
			this._print_price('result.setup:brutto:'+_key, this._price[i].setup.brutto + price_features.setup.brutto);
			
			// result.price: Abonament podstawowy:
			this._print_price('result.price:netto:'+_key, this._price[i].bond.netto);
			this._print_price('result.price:brutto:'+_key, this._price[i].bond.brutto);
			
			// result.featuresadd: Opcje dodane:
			this._print_price('result.featuresadd:netto:'+_key, price_features.bond.netto);
			this._print_price('result.featuresadd:brutto:'+_key, price_features.bond.brutto);
			
			// result.total.price: Abonament miesięczny:
			this._print_price('result.total.price:netto:'+_key, price_features.bond.netto + this._price[i].bond.netto);
			this._print_price('result.total.price:brutto:'+_key, price_features.bond.brutto + this._price[i].bond.brutto);
			
			// result.total.bill: Kwota do zapłaty za X miesiące:
			var _total = new Price(_key * this._price[i].bond.netto, _key * this._price[i].bond.brutto);
			if( this.promotion_months(i) > 0 ){
				_total.netto -= (this._promotion_months[i] * this._price[i].bond.netto) - (this._promotion_months[i] * this._promotion_price[i].netto);
				_total.brutto -= (this._promotion_months[i] * this._price[i].bond.brutto) - (this._promotion_months[i] * this._promotion_price[i].brutto);
			}
			_total.netto += ((_key * price_features.bond.netto) + this._price[i].setup.netto + price_features.setup.netto);
			_total.brutto += ((_key * price_features.bond.brutto) + this._price[i].setup.brutto + price_features.setup.brutto);
			this._print_price('result.total.bill:netto:'+_key, _total.netto);
			this._print_price('result.total.bill:brutto:'+_key, _total.brutto);
			//
		}// for( var i=0; i<this.count; i++ )
		
	},
	
	/** -------------------------------------------------------------------------------------------------------- /
	#		RecalculateAddFeatures
			funkcja leci po wszystkich tagach LI w konfiguratorze i jeżeli tag, jest widzialny, wtedy pobiera z inputu hidden wartości
			i pokazuje je w tabelce
	*/
	RecalculateAddFeatures: function(){
		//
		var price_features = new PriceServer(0,0,0,0);
		//
		var feature_configurator = document.getElementById('feature_configurator');
		var items = feature_configurator.getElementsByTagName('LI');
		var RegExpItemId = new RegExp("^(scItem:)([0-9]{1,})$", "ig");
		for(var i=0; i<items.length; i++){
			var isValidItem = items[i].id.match(RegExpItemId);
			if(isValidItem && items[i].style.display!='none'){
				var OptionKey = RegExp.$2;
				var user_choice_price_netto = document.getElementById('user_choice:price:netto:' + OptionKey);
				var user_choice_setup_netto = document.getElementById('user_choice:setup:netto:' + OptionKey);
				var user_choice_price_brutto = document.getElementById('user_choice:price:brutto:' + OptionKey);
				var user_choice_setup_brutto = document.getElementById('user_choice:setup:brutto:' + OptionKey);				
				price_features.bond.Add(user_choice_price_netto.value, user_choice_price_brutto.value);
				price_features.setup.Add(user_choice_setup_netto.value, user_choice_setup_brutto.value);
			}// if(isThisItem)
		}// for(var i=0; i<items.length; i++)
		//alert(features_price_brutto);
		//
		this.OutputPrices(price_features);
		
	},// end function RecalculateAddFeatures
	
	
	_currency2number: function(value){
		var _val_num = value.toString();
		//_val_num = _val_num.replace(/ /g,'');
		//_val_num = _val_num.replace(/,/g,'.');
		return Number(_val_num);
	},
	
	
	_print_price: function(object_id, price_value){
		var obj = document.getElementById(object_id);
		obj.innerHTML = CurrencyLocalFormat(price_value);
	}
	
	
}// BondsScheme.prototype



/*	___________________________________________________________________________________________ //
##	AttachEventForOptionItem
		dodaje obsługę events do LI zawierającego opcje
*/
function AttachEventForOptionItem(){
	
	var useAccelatorJS = (browser.name=='msie' && Number(browser.version<7));
	
	var fconf = document.getElementById('feature_configurator');
	
	var items, i;
	
	
	items = fconf.getElementsByTagName('DIV');
	//
	for(i=0; i<items.length; i++){
		if(items[i].className=='option_item'){
			
			if(items[i].parentNode.className=='scChild'){
				
			}
			
			/* ----------------------------------------------------------------------------------------- /
			#  items[i].onclick
			*/
			items[i].onclick = function(){
				
				var aid = this.id.split(/:/);
				
				// ## zmienić przycisk check
				// wszystkie przyciski ustawić na off
				var parent_list = document.getElementById('options:' + aid[1]);
				var items = parent_list.getElementsByTagName('DIV');
				var spans, i;
				for(i=0; i<items.length; i++){
					if(items[i].className=='option_item'){
						spans = items[i].getElementsByTagName('SPAN');
						spans[SFO_SPAN_CHECK].className = 'oi_check';
					}
				}
				// kliknięty przycisk ustawić na on
				spans = this.getElementsByTagName('SPAN');
				spans[SFO_SPAN_CHECK].className = 'oi_check oichckChecked';
				
				
				//alert(this.id);
				// sprawdzić jaka wartość jest w tej chwili w tym type
				var selected_key_before = document.getElementById('user_choice:pkey:' + aid[1]).value;
				var selected_key_now = aid[2];
				if(selected_key_before!=null){
					if(selected_key_before!=selected_key_now){
						
						//document.title = ('selected_key_before:' + selected_key_before + ', selected_key_now:' + selected_key_now);
						
						var r = new RegExp("^(links_parent:)([0-9]{1,})$", "ig");
						var input_childs = fconf.getElementsByTagName('INPUT');
						for(var iich=0; iich<input_childs.length; iich++){
							if(input_childs[iich].type=="hidden"){
								var a = input_childs[iich].id.match(r);
								if(a){
									var exist_before = exists_in_child(selected_key_before, input_childs[iich].value);
									var exist_now = exists_in_child(selected_key_now, input_childs[iich].value);
									if(exist_before && !exist_now){
									// ukryć opcje
										var _item = document.getElementById('scItem:' + RegExp.$2);
										_item.style.display = 'none';
										
										var _this_user_choice = document.getElementById('user_choice:pkey:'  + RegExp.$2);
										var _option_tag = document.getElementById('option:' + RegExp.$2 + ':' + _this_user_choice.value);
										var _option_tag_spans = _option_tag.getElementsByTagName('SPAN');
										if(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;'){
											var a_sub_childs = _links2array(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML);
											for(var iasch=0; iasch<a_sub_childs.length; iasch++){
												var _sub_item = document.getElementById('scItem:' + a_sub_childs[iasch]);
												_sub_item.style.display = 'none';
											}// for(var iasch=0
										}// if(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;')
										
										//alert('Ukryć: ' + RegExp.$2);
									}else if(!exist_before && exist_now){
									// pokazać opcje
										var _item = document.getElementById('scItem:' + RegExp.$2);
										_item.style.display = 'block';
										
										var _this_user_choice = document.getElementById('user_choice:pkey:'  + RegExp.$2);
										var _option_tag = document.getElementById('option:' + RegExp.$2 + ':' + _this_user_choice.value);
										var _option_tag_spans = _option_tag.getElementsByTagName('SPAN');
										if(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;'){
											var a_sub_childs = _links2array(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML);
											for(var iasch=0; iasch<a_sub_childs.length; iasch++){
												var _sub_item = document.getElementById('scItem:' + a_sub_childs[iasch]);
												_sub_item.style.display = 'block';
											}// for(var iasch=0
										}// if(_option_tag_spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;')
										
										//alert('Pokazać: ' + RegExp.$2);
									}
									//alert(RegExp.$2 + '->' + input_childs[iich].id + '->' + input_childs[iich].value);
								}
							}
						}// for(var iich
						
						//alert('before:' + selected_key_before + ', now:' + selected_key_now);
						var key_childs = spans[SFO_SPAN_CHILDS].innerHTML.split(',');
						if(key_childs.length){
							for(var i=0; i<key_childs.length; i++){
								var child = document.getElementById('links_parent:' + key_childs[i]);
								if(child!=null){
									//alert(child.value);
								}
							}
						}
						
						
						// sprawdzić czy zmiana wartości nie spowoduje pokazania jakiejś opcji
						
					}// if(input_selected_key.value!=aid[2])
				}// if(input_selected_key!=null)
				
				
				
				var this_data = new Array(7);
								
				// ## wpisać do user_choice wartości wybrane przez usera
				var user_choice = document.getElementById('user_choice:' + aid[1]);
				var user_choice_spans = user_choice.getElementsByTagName('SPAN');
				for(i=0; i<user_choice_spans.length; i++){
					this_data[i] = spans[i].innerHTML;
					user_choice_spans[i].innerHTML = this_data[i]==0 ? '&nbsp;' : this_data[i];
				}
				
				//alert(this_data.toString());
				
				// ## wpisać do inputów wartości wybrane przez usera
				Value2Inputs(aid[1], aid[2], this_data);
								
				// ## pokazać wartości na dole w tabelce
				bond.RecalculateAddFeatures();
				
				//alert('onclick');
				
			}; //items[i].onclick
			
			
			
		}// if(items[i].className=='option_item')
	}// for i++
	
	
	/* ----------------------------------------------------------------------------------------- /
	#  items[i].onmousemove
	*/
	if(useAccelatorJS){
	
		items = fconf.getElementsByTagName('LI');
		//
		for(i=0; i<items.length; i++){
			if(items[i].className=='scItem'){
			
				items[i].onmouseover = function(){
					this.className = 'scItem scItemHover';
					var submenu = this.getElementsByTagName('UL');
					for(var is=0; is<submenu.length; is++){
						if(submenu[is].className=='scOptions'){
							var litems = submenu[is].getElementsByTagName('LI');
							for(var il=0; il<litems.length; il++){
								litems[il].onmouseover = function(){
									this.className = this.className + ' ' + this.className + 'Hover';
								}
							}
						}
					}
				};// items[i].onmousemove = function()
				
				items[i].onmouseout = function(){
					this.className = 'scItem';
					var submenu = this.getElementsByTagName('UL');
					for(var is=0; is<submenu.length; is++){
						if(submenu[is].className=='scOptions'){
							var litems = submenu[is].getElementsByTagName('LI');
							for(var il=0; il<litems.length; il++){
								litems[il].onmouseout = function(){
									var _css = this.className.split(' ');
									this.className = _css[0];
								}
							}
						}
					}
				};// items[i].onmouseout = function()
				
			}
		}
		
	}// if(useAccelatorJS){
		
}



function _links2array(string_links){
	var a = Array();
	a = string_links.split(",");
	return a;
}

function in_array(argv_item, argv_array){
	var isExistsValue = false;
	for(var i=0; i<argv_array.length; i++){
		if(argv_item==argv_array[i]){
			isExistsValue = true;
			break;
		}
	}
	return isExistsValue;
}

function exists_in_child(argv_item, string_links){
	var a = _links2array(string_links);
	return in_array(argv_item, a);
}

/*	___________________________________________________________________________________________ //
##	getAbsolutePosition
*/
function getAbsolutePosition(what){
	var pos = Array();
	pos[0] = what.offsetLeft;
	pos[1] = what.offsetTop;
	var parentEl = what.offsetParent;
	while( parentEl!=null ){
		pos[0] += parentEl.offsetLeft;
		pos[1] += parentEl.offsetTop;
		parentEl = parentEl.offsetParent;
	}
	return pos;
}// end function getAbsolutePosition


/*	___________________________________________________________________________________________ //
##	sfoListItem_onClick
		zdarzenie onclick na LI
		funkcja nieużywana!!!
*/
function sfoListItem_onClick(thisListItemId){
	
	
	var thisListItem = document.getElementById(thisListItemId);
	if(thisListItem==undefined){
		alert( 'thisListItem undefined: ' +  thisListItemId );
		return;
	}
	
	
	
	
	// pobrać wartości z zaznaczonego Item
	var this_spans = thisListItem.getElementsByTagName('span');
	var this_data = new Array(7);
	this_data[SFO_SPAN_OPTION] = this_spans[SFO_SPAN_OPTION].innerHTML;
	this_data[SFO_SPAN_PRICE_NETTO] = this_spans[SFO_SPAN_PRICE_NETTO].innerHTML;
	this_data[SFO_SPAN_SETUP_NETTO] = this_spans[SFO_SPAN_SETUP_NETTO].innerHTML;
	this_data[SFO_SPAN_PRICE_BRUTTO] = this_spans[SFO_SPAN_PRICE_BRUTTO].innerHTML;
	this_data[SFO_SPAN_SETUP_BRUTTO] = this_spans[SFO_SPAN_SETUP_BRUTTO].innerHTML;
	this_data[SFO_SPAN_CHECK] = this_spans[SFO_SPAN_CHECK].innerHTML;
	//
	
	var aid = new Array();
	aid = thisListItem.id.split(/:/);
	
	
	// sprawdzić czy opcja ma dzieci
	//var frm = document.forms['frm_feature_configurator'];
	//var this_input_childs = frm.elements['sfo_childs:' + aid[1]];
	//alert(thisListItemId + ', childs:' + this_input_childs.value);
	
	
	
	// wpisać wartości do inputów:hidden
	Value2Inputs(aid[1], aid[2], this_data);
	
	// wpisać wartości do choice
	Value2Choice(aid[1], aid[2], this_data);
	
	alert('#' + thisListItem.id + ', price:' + this_data[SFO_SPAN_PRICE] + ', Number:' + PriceValue(this_data[SFO_SPAN_PRICE]) );
	//
	
}// end function sfoListItem_onClick



/*	___________________________________________________________________________________________ //
##	getOptionName
		pobiera nazwę opcji na podstawie klucza typu i opcji 
*/
function getOptionName(sft_pkey, sfo_pkey){
	var li = document.getElementById('sfo_option:' + sft_pkey + ':' + sfo_pkey);
	var spans = li.getElementsByTagName('span');
	return spans[SFO_SPAN_OPTION].innerHTML;
}// end function getOptionName



/*	___________________________________________________________________________________________ //
##	PriceValue
		zamienia string HTML na number
*/
function PriceValue(string_value){
	var num_value = string_value;
	num_value = num_value.replace(/ /g,'');
	num_value = num_value.replace(/,/g,'.');
	num_value = Number(num_value);
	
	if( isNaN(num_value) ){
		return 0;
	}else{
		return num_value;
	}
}// end function PriceValue


/*	___________________________________________________________________________________________ //
##	CurrencyLocalFormat
		zamienia number na string w polskiej notacji (1 234,00)
*/
function CurrencyLocalFormat(currency_value){
	var svalue = currency_value.toString();
	var sval = new Array('', '');
	var s = '';
	if(currency_value==0){
		sval[0] = '0';
		sval[1] = '00';
	}else{
		sval[0] = (Math.floor(currency_value)).toString();
		sval[1] = (Math.floor(currency_value % Math.floor(currency_value) * 100)).toString();
	}
	if(sval[0].length>3){
		s = sval[0].substr(0, sval[0].length-3) + ' ' + sval[0].substr(sval[0].length-3); 
	}else{
		s = sval[0];
	}
	if(sval[1].length==1){
		sval[1] = sval[1] + '0';
	}
	s = s + ',' + sval[1];
	return s;
}// end function CurrencyLocalFormat


// funkcja niewykorzystywana
/*	___________________________________________________________________________________________ //
##	Value2Choice
		wpisuje do pól choice wartości przekazane w argumencie
		funkcja nieużywana
*/
function Value2Choice(argv_pkey, argv_pkey_option, argv_option, argv_price, argv_setup){
	var feature_value_choice = document.getElementById('sfo_choice:' + argv_pkey);
	var feature_value_choice_spans = feature_value_choice.getElementsByTagName('span');
	
	argv_price = (argv_price==0) ? ('&nbsp;') : (argv_price);
	feature_value_choice_spans[SFO_SPAN_OPTION].innerHTML = argv_option;
	feature_value_choice_spans[SFO_SPAN_PRICE_NETTO].innerHTML = argv_price;
	feature_value_choice_spans[SFO_SPAN_SETUP_NETTO].innerHTML = argv_setup;
	//
	// pokazać symbol check i usunąć poprzednio zaznaczony
	var ListParent = document.getElementById('sfo_list:' + argv_pkey);
	var ListItemsBorderer = ListParent.getElementsByTagName('li');
	for(var ili=0; ili<ListItemsBorderer.length; ili++){
		var this_spans = ListItemsBorderer[ili].getElementsByTagName('span');
		this_spans[SFO_SPAN_CHECK].className = 'sfo_check' + ((ListItemsBorderer[ili].id=='sfo_option:' + argv_pkey + ':' + argv_pkey_option) ? (' sfo_check_selected') : (''));
	}
	alert('Value2Choice');
	//
}// end function Value2Choice



/*	___________________________________________________________________________________________ //
##	Value2Inputs
		wpisuje do inputów (hidden) wartości przekazane w argumencie
*/
function Value2Inputs(argv_pkey, argv_option, prices){
	
	var frm = document.forms['frm_feature_configurator'];
	
	var input_value = frm.elements['user_choice:pkey:' + argv_pkey];
	input_value.value = argv_option;
	
	var input_price_netto = frm.elements['user_choice:price:netto:' + argv_pkey];
	input_price_netto.value = PriceValue(prices[SFO_SPAN_PRICE_NETTO]);
	
	var input_setup_netto = frm.elements['user_choice:setup:netto:' + argv_pkey];
	input_setup_netto.value = PriceValue(prices[SFO_SPAN_SETUP_NETTO]);
	
	var input_price_brutto = frm.elements['user_choice:price:brutto:' + argv_pkey];
	input_price_brutto.value = PriceValue(prices[SFO_SPAN_PRICE_BRUTTO]);
	
	var input_setup_brutto = frm.elements['user_choice:setup:brutto:' + argv_pkey];
	input_setup_brutto.value = PriceValue(prices[SFO_SPAN_SETUP_BRUTTO]);
	/*
	alert(
		'netto: ' + PriceValue(prices[SFO_SPAN_PRICE_NETTO]) + ' | ' + PriceValue(prices[SFO_SPAN_SETUP_NETTO]) + 
		'\nbrutto: ' + PriceValue(prices[SFO_SPAN_PRICE_BRUTTO]) + ' | ' + PriceValue(prices[SFO_SPAN_SETUP_BRUTTO])
	);
	*/
}// end function Value2Inputs



/*	___________________________________________________________________________________________ //
##	DisplayTab
		zmiana tab zawierającego rozliczenie abonamentu na dany okres
*/
function DisplayTab(tabKey){
	var tab_content;
	var tab_button;
	for(var itab=0; itab < bond.count; itab++){
		tab_content = document.getElementById('options_result_content:' + bond.key(itab));
		tab_button = document.getElementById('rtTabBtt:' + bond.key(itab));
		if( bond.key(itab)==tabKey ){
			tab_content.style.display = 'block';
			tab_button.className = 'rtTabBtt rtTabBttSelected';
			bond.SelectedIndex = itab;
			// zmienić input hidden
			var inp_pay_scope = document.forms['frm_feature_configurator'].elements['pay_scope'];
			inp_pay_scope.value = tabKey;
		}else{
			tab_content.style.display = 'none';
			tab_button.className = 'rtTabBtt';
		}
	}
}// end function DisplayTab






function DisplayOptionsList(e, itemID){
	var list = document.getElementById('server_feature_list:' + itemID);
	/*
	var toElement;
	
	switch(e.type){
		case 'mouseover':
				list.style.display = 'block';
				if(document.all){toElement = e.toElement;}else{toElement = e.target;}
				document.title = e.type + ': ' + toElement.tagName + '#' + toElement.id + '.' + toElement.className;
			break;
		case 'mouseout':
				list.style.display = 'none';
				if(document.all){toElement = e.toElement;}else{toElement = e.target;}
				document.title = e.type + ': ' + toElement.tagName + '#' + toElement.id + '.' + toElement.className;
			break;
	}
	
	return;
	*/
}

function _currency2number(value){
	var _val = value.toString().replace(/ /g,'');
	return parseInt(_val);
}



function ChildItems_Init(){
	var i;
	var fconf = document.getElementById('feature_configurator');
	var inputs_hidden = fconf.getElementsByTagName('INPUT');
	
	// ukryć wszystkie items, które mogą być childem
	var r_parents = new RegExp("^(links_parent:)([0-9]{1,})$", "ig");
	for(i=0; i<inputs_hidden.length; i++){
		if(inputs_hidden[i].type=="hidden"){
			var a = inputs_hidden[i].id.match(r_parents);
			if(a && inputs_hidden[i].value!=''){
				var _item_child = document.getElementById('scItem:' + RegExp.$2);
				_item_child.style.display = 'none';
			}// if(a && inputs_hidden[i].value!='')
		}// if(inputs_hidden[i].type=="hidden")
	}// for(i=0;
	
	// zobaczyć, czy user nie wybrał opcji, która pokazuje opcję podrzędną
	var r_user_choice = new RegExp("^(user_choice:pkey:)([0-9]{1,})$", "ig");
	for(i=0; i<inputs_hidden.length; i++){
		if(inputs_hidden[i].type=="hidden"){
			var a = inputs_hidden[i].id.match(r_user_choice);
			if(a){
				var _parent_item = document.getElementById('scItem:' + RegExp.$2);
				if(_parent_item.style.display!='none'){
				
					var option_item = document.getElementById('option:' + RegExp.$2 + ':' + inputs_hidden[i].value);
					var spans = option_item.getElementsByTagName('SPAN');
					if(spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;'){
						var a_childs_key = _links2array(spans[SFO_SPAN_CHILDS].innerHTML);
						for(var ichk=0; ichk<a_childs_key.length; ichk++){
							var _item = document.getElementById('scItem:' + a_childs_key[ichk]);
							_item.style.display = 'block';			
						}
					}// if(spans[SFO_SPAN_CHILDS].innerHTML!='&nbsp;')
				
				}else{
					
					
					
				}// if(_parent_item.style.display!='none')
			}// if(a){
		}// if(inputs_hidden[i].type=="hidden")
	}// for(i
	
}// ChildItems_Init()
