	//clasirane box
	function changeListContent(sender_select, active)
	{
		if (sender_select.value == window[active]) return;

		document.getElementById(window[active]).className = 'hidden';
		document.getElementById(sender_select.value).className = 'visible';
		window[active] = sender_select.value;
	}

	function radioButton(sender, form_name, hidden, value)
	{
		var obj = sender.parentNode.getElementsByTagName('span')[0];

		if (obj.id != 'checked_radio_button_' + form_name + hidden)
		{
			var active = document.getElementById('checked_radio_button_' + form_name + hidden);
			if (active)
			{
				active.id = '';
				active.className = 'radio_button';
			}

			obj.id = 'checked_radio_button_' + form_name + hidden;
			obj.className = 'radio_button checked_radio';

			document.forms[form_name].elements[hidden].value = value;
		}
	}

	//checkbox
	function checkbox(obj, formR, hiddenEl)
	{
		var hiddenElement = document.forms[formR].elements[hiddenEl];
		if (obj.className == 'checkbox')
		{
			obj.className += ' checked';
			hiddenElement.value = 'true'
			return;
		}

		replaceClassNameObj(obj, / checked$/, '');
		hiddenElement.value = '';
	}

	function checkbox2(obj, formR, hiddenEl, index)
	{
		var hiddenElement = document.forms[formR].elements[hiddenEl];
		if (hiddenElement.length > 0) hiddenElement = hiddenElement[index];

		if (obj.className == 'checkbox')
		{
			obj.className += ' checked';
			hiddenElement.checked = true;
			return;
		}

		replaceClassNameObj(obj, / checked$/, '');
		hiddenElement.checked = false;
	}


	//ComboBox
	function addEvent(element, handler, callback, capture)
	{
		if (window.addEventListener) element.addEventListener(handler, callback, capture);
		else element.attachEvent('on' + handler, callback);
	}

	function removeEvent(element, handler, callback, capture)
	{
		if (window.removeEventListener) element.removeEventListener(handler, callback, capture);
		else element.detachEvent('on' + handler, callback);
	}


	var currentComboBox = null;
	var flagComboBox = false;
	function moveSelected(sender, index)
	{
		if (sender.className == 'selected') return;

		currentComboBox.getElementsByTagName('li')[currentComboBox.currentSelected].className = '';
		sender.className = 'selected';
		currentComboBox.currentSelected = index;
	}

	function changeSelected(index, text, value)
	{
		if (index == currentComboBox.selectedIndex) return;

		currentComboBox.selectedIndex = index;
		updateTextValue(text, value);
		
		if (currentComboBox.listener) currentComboBox.listener.call(this, currentComboBox);
	}

	function showComboBox(combo_dom)
	{
		if (combo_dom != currentComboBox) hideComboBox();

		currentComboBox = combo_dom;
		currentComboBox.parentNode.style.zIndex = 9999; //M$ stupid browser hack!!!
		var combo = combo_dom.getElementsByTagName('div')[0];
			moveSelected(combo.getElementsByTagName('li')[combo_dom.selectedIndex], combo_dom.selectedIndex);
			combo.style.display = (combo.style.display != 'block') ? 'block' : 'none';
			flagComboBox = false;
	}

	function hideComboBox()
	{
		if (!currentComboBox || !flagComboBox)
		{
			flagComboBox = true;
			return;
		}
		currentComboBox.parentNode.style.zIndex = 100; //M$ stupid browser hack!!!
		currentComboBox.getElementsByTagName('div')[0].style.display = 'none';
		currentComboBox = null;
	}

	function updateTextValue(text, value)
	{
		var obj = currentComboBox.getElementsByTagName('input');
		currentComboBox.value =  obj[0].value = value;
		currentComboBox.getElementsByTagName('span')[0].innerHTML = text;
	}

	function OptionItem(text, value, selected)
	{
		this.text = text;
		this.value = (!value) ? this.text : value;
		this.selected = selected;
	}

	function ComboBox(name)
	{
		this.name = name;
		this.options = new Array();
		this.selectedIndex = 0;
		this.onchange_listener = null;
	}

	ComboBox.prototype.addOption = function(Option)
	{
		this.options.push(Option);

		if (Option.selected) this.selectedIndex = this.options.length - 1;
	}

	ComboBox.prototype.removeOption = function(index)
	{
		this.options.splice(index, 1);
	}

	ComboBox.prototype.setOnChangeListener = function(callback)
	{
		if (!(callback instanceof Function))
		{
			throw new Error('Arguments must be Function!!!');
		}

		this.onchange_listener = callback;
	}

	ComboBox.prototype.renderComboBox = function(id_element)
	{
		if (!this.options.length) return;

		var selectedElement = this.options[this.selectedIndex];

		var combo_root = document.createElement('div');
			combo_root.className = 'combo_box';
			combo_root.selectedIndex = this.selectedIndex;
			combo_root.currentSelected = this.selectedIndex;
			combo_root.value = this.options[this.selectedIndex].value;
			combo_root.listener = this.onchange_listener;
			combo_root.onclick = function(){showComboBox(this);};
		var htmlCode = '<span>' + selectedElement.text + '</span><input type="hidden" name="' + this.name + '" value="' + selectedElement.value + '"><div><ul>';

		for (var i = 0, len = this.options.length; i < len; i++)
		{
			htmlCode += '<li onclick="changeSelected(' + i + ',\'' + this.options[i].text + '\',\'' + this.options[i].value + '\')" onmouseover="moveSelected(this, '+ i +')">' + this.options[i].text + '</li>';
		}

		htmlCode += '</ul></div>';
		combo_root.innerHTML = htmlCode;
		document.getElementById(id_element).appendChild(combo_root);
	}

	addEvent(document, 'click', hideComboBox, false);
