	
	
	
	/** component: ComboBox **/
	function comboShow(combo, hide) {
		
		var select = getChild(combo, 'select');
		
		if (hide == false || select.style.display == 'block') {
			select.style.display = 'none';
		} else {
			select.style.display = 'block';
			select.focus();
		}
		
	}
	
	
	function comboChange(select) {
		
		var div = getChild(select.parentNode, 'div');
		
		div.innerHTML = select.options[select.options.selectedIndex].text;
		
	}
	/** ------------------- **/
	
	
	function comboSetval(combo, value) {
		
		var combo = document.getElementById(combo);
		combo.value = value;
		
		var div = getChild(combo.parentNode, 'div');
		div.innerHTML = combo.options[combo.options.selectedIndex].text;
		
	}
	
	
	/** component: CheckBox **/
	function checkBoxField(id,li,value,last) {
		
		var a = getChild(li,'a');
		
		if (a.className == 'choose') {
			
			a.className = '';
			if (!last) {
				li.className = 'NonChoose';
			}
			
			checkBoxUncheck(id,value);
			
		} else {
			
			a.className = 'choose';
			if (!last) {
				li.className = '';
			}
			
			checkBoxCheck(id,value);
			
		}
		
		
	}
	
	function checkBoxUncheck(id,value) {
		
		var field = document.getElementById(id);
		
		var arr = field.value.split(';');
		
		field.value = '';
		
		for (i=0;i<arr.length-1;i++) {
			if (arr[i] != value) {
				field.value += arr[i] + ';';
			}
		}
		
		
	}
	
	function checkBoxCheck(id,value) {
		document.getElementById(id).value += value + ';';
		
	}
	
	
	/** ------------------- **/
	
	
	function check(span, id) {
		
		if (span.className == 'check') {
			
			span.className = 'no-check';
			document.getElementById(id).value = 0;
		} else {
			
			span.className = 'check';
			document.getElementById(id).value = 1;
		}
		
	}
	
	function setCheckBoxValue(value, checkbox) {
		
		var span = document.getElementById('cb_'+checkbox);
		var hidden = document.getElementById(checkbox);
		
		if (value == 0) {
			span.className = 'no-check';
			hidden.value = 0;
		} else {
			span.className = 'check';
			hidden.value = 1;
		}
		
	}
	
	
	/** radioField **/
	
	function radioSelect(div,id,value) {
		
		var group =  div.parentNode.parentNode;
		
		
		
		for (i=0;i<group.childNodes.length;i++) {
			
			if (group.childNodes[i].nodeType == 1  && group.childNodes[i].tagName.toLowerCase() == 'div') {
				
				var radio = getChild(group.childNodes[i],'div','radio');
				radio.firstChild.className = 'no-check';
				
			}
			
		}
		
		div.firstChild.className = 'check';
		
		return document.getElementById(id).value = value;
		
	}
	
	
	
	/** checkbox set **/
	function checkBoxSet(id, value) {
		
		var thisId = id;
		this.checkBoxYesClass = 'checkboxYes';
		this.checkBoxNoClass = 'checkboxNo';
		
		this.group = document.getElementById(value);
		
		this.checkBoxes = new Array();
		
		
		this.values = new Tqueue('');
		var loadStr = ''
		
		/*
			id... string, uklada se do seznamu vybranych checkboxu
			params... ve formatu nazev:hodnota;nazev:hodnota  - ruzna dodatecna nastaveni checkboxu:
				  zatim funguje:
				  	- value: hodnota s jakou je checkbox nacten - true/false
				  	- title: pokud je zadan, je k checkboxu pridan i titulek ve spanu
				  	- onchange: funkce ktera je zavolana pri zmene checkboxu (tzn pri onclick)
		*/
		this.add = function (id, params, parentNode) {
			
			var params = new Tparams(params);
			
			var optionDiv = document.createElement('div');
			optionDiv.className = 'checkbox';
			
			if (parentNode) {
				parentNode.appendChild(optionDiv);
			} else {
				appendNode(optionDiv);
			}
			
			
			var onclick = thisId + '.check(\'' + id + '\'); ' + params.params['onchange'] + '; return false;';
			var nodeId = thisId + '.' + id;
			
			// loading
			if (params.params['onchange'] != '' && params.params['value'] == 'true') {
				loadStr += params.params['onchange'] + ';'
			}
			
			
			if (params.params['value'] == 'true') {
				this.group.value = this.values.add(id);
				var defaultValue = this.checkBoxYesClass;
			} else {
				var defaultValue = this.checkBoxNoClass;
			}
			
			
			var checkbox = '<span class="' + defaultValue + '" id="' + nodeId + '" onclick="' + onclick + '" onmousedown="return false;" >&nbsp;</span>';
			
			
			if (params.params['title']) {
				var title = '<span style="float:left;cursor:pointer;" onclick="' + onclick + '" onmousedown="return false;">' + params.params['title'] + '</span>';
			} else {
				var title = '';
			}
			
			
			var clear = '<div style="clear:both; width:1px; height:1px; margin:0px; padding:0px; font-size:1px;">&nbsp;</div>';
			
			optionDiv.innerHTML = checkbox + title + clear;
			
			this.checkBoxes.push(id);
			
			
		}
		
		
		this.check = function (id) {
			
			var checkbox = document.getElementById(thisId + '.' + id);
			
			if (this.values.contains(id) == true) {
				this.group.value = this.values.remove(id);
				checkbox.className = this.checkBoxNoClass;
				checkbox.style.opacity = '1';
			} else {
				this.group.value = this.values.add(id);
				checkbox.className = this.checkBoxYesClass;
				checkbox.style.opacity = '1';
			}
			
		}
		
		
		this.forceCheck = function(id) {
			
			var checkbox = document.getElementById(thisId + '.' + id);
			
			if (this.values.contains(id) == false) {
				this.group.value = this.values.add(id);
			}
			
			checkbox.className = this.checkBoxYesClass;
			checkbox.style.opacity = '1';
			
		}
		
		this.forceUncheck = function(id) {
			
			var checkbox = document.getElementById(thisId + '.' + id);
			
			if (this.values.contains(id) == true) {
				this.group.value = this.values.remove(id);
				
			}
			
			checkbox.className = this.checkBoxNoClass;
			checkbox.style.opacity = '1';
			
		}
		
		
		this.semiCheck = function (id) {
			
			var checkbox = document.getElementById(thisId + '.' + id);
			
			this.group.value = this.values.add(id);
			checkbox.className = this.checkBoxYesClass;
			checkbox.style.opacity = '0.5';
			
		}
		
		
		this.invertSel = function() {
			
			var x;
			
			for (x in this.checkBoxes) {
				this.check(this.checkBoxes[x]);
				
			}
			
		}
		
		this.test = function(id) {
			
			if (this.values.contains(id)) {
				return true;
			} else {
				return false;
			}
			
		}
		
		this.extTest = function (id) {
			
			if (this.values.contains(id)) {
				
				var checkbox = document.getElementById(thisId + '.' + id);
				
				if (checkbox.style.opacity == '1' || !checkbox.style.opacity) {
					return true;
				} else {
					return 2;
				}
				
			} else {
				return false;
			}
			
		}
		
		
		
		this.invoke = function() {
			eval(loadStr);
		}
		
		
	}
	
	
	

