	//form change default value
	function changeDefaultValue(sender, default_value, change_value)
	{
		if (sender.value == default_value) sender.value = change_value;
	}

	//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;
		}
	}


	//change content info
	function MoveActiveContent(root_id, tag, active_id, ms_move, index)
	{
		this.obj = document.getElementById(root_id).getElementsByTagName(tag);
		this.active_id = active_id;
		this.active_element = document.getElementById(this.active_id);

		this.index = index;
		this.ms_move = ms_move;
		this.timer = null;
	}

	MoveActiveContent.prototype.startMove = function()
	{
		var self = this;
		this.timer = setInterval(function(){self.moveNextContent()}, this.ms_move);
	}

	MoveActiveContent.prototype.stopMove = function()
	{
		clearInterval(this.timer);
	}

	MoveActiveContent.prototype.removeActive = function()
	{
			document.getElementById(this.active_element.getAttribute('title')).className = 'hidden';
			this.active_element.id = '';
	}

	MoveActiveContent.prototype.setActive = function(sender)
	{
		if (!isNaN(sender))
		{
			if (sender == this.index) return;

			this.index = sender;
		}

		this.removeActive();

		var obj = this.obj[this.index];
			document.getElementById(obj.getAttribute('title')).className = 'visible';
			obj.id = this.active_id;
			this.active_element = obj;
	}

	MoveActiveContent.prototype.moveNextContent = function()
	{
		if (++this.index >= this.obj.length) this.index = 0;

		this.setActive();
	}

	MoveActiveContent.prototype.movePreviousContent = function()
	{
		if (--this.index < 0) this.index = this.obj.length - 1;

		this.setActive();
	}

	//user tools for zoom text, print, send friend

	var curFont = 10;

	function replaceClassNameObj(obj, regExp, replacer)
	{
		obj.className = obj.className.replace(regExp, replacer);
	}

	function incrementDecrementFont(obj_id, cur_button, ot_button_id, step)
	{
		if (cur_button.className.indexOf(' disable') > -1) return;

		curFont += step;
		document.getElementById(obj_id).style.fontSize = curFont + 'px';

		if (curFont <= 10 || curFont >= 13)
		{
			cur_button.className += ' disable';
		}
		else replaceClassNameObj(document.getElementById(ot_button_id), / disable$/, '');
	}

	//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></div>';
		combo_root.innerHTML = htmlCode;
		document.getElementById(id_element).appendChild(combo_root);
	}


	addEvent(document, 'click', hideComboBox, false);

	function checkActiveLiveScores()
	{
		var row = document.getElementById('ls_p1_container').getElementsByTagName('tr');
		var i = 0;
		while(i < row.length && row[i].className != 'active_match') i++;

		if (i < row.length) setActiveLiveScores();
	}
	
	function updateFileValue(sender, id_element)
	{
		document.getElementById(id_element).value = sender.value;
	}
	
	function MM_preloadImages() { //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function changePrice(){
		args=changePrice.arguments;
		if(!args[0]) return false;
		
		var pr = document.getElementById('price'+args[0]);
		pr.innerHTML = args[1];
		if(!args[3]) var sn = document.getElementById('signrate'+args[0]);
		
		switch(args[2]){
			case 1:
				if(!args[3]) sn.innerHTML = 'лв';
				document.getElementById('rateimage1_'+args[0]).src = 'templates/site/images/valuta1.jpg';
				document.getElementById('rateimage2_'+args[0]).src = 'templates/site/images/valuta2_inact.jpg';
				document.getElementById('rateimage3_'+args[0]).src = 'templates/site/images/valuta3_inact.jpg';
				document.getElementById('rateimage4_'+args[0]).src = 'templates/site/images/valuta4_inact.jpg';
			break;
			case 2:
				if(!args[3]) sn.innerHTML = '$';
				document.getElementById('rateimage1_'+args[0]).src = 'templates/site/images/valuta1_inact.jpg';
				document.getElementById('rateimage2_'+args[0]).src = 'templates/site/images/valuta2.jpg';
				document.getElementById('rateimage3_'+args[0]).src = 'templates/site/images/valuta3_inact.jpg';
				document.getElementById('rateimage4_'+args[0]).src = 'templates/site/images/valuta4_inact.jpg';
			break;
			case 3:
				if(!args[3]) sn.innerHTML = '&#8364;';
				document.getElementById('rateimage1_'+args[0]).src = 'templates/site/images/valuta1_inact.jpg';
				document.getElementById('rateimage2_'+args[0]).src = 'templates/site/images/valuta2_inact.jpg';
				document.getElementById('rateimage3_'+args[0]).src = 'templates/site/images/valuta3.jpg';
				document.getElementById('rateimage4_'+args[0]).src = 'templates/site/images/valuta4_inact.jpg';
			break;
			case 4:
				if(!args[3]) sn.innerHTML = '&pound;';
				document.getElementById('rateimage1_'+args[0]).src = 'templates/site/images/valuta1_inact.jpg';
				document.getElementById('rateimage2_'+args[0]).src = 'templates/site/images/valuta2_inact.jpg';
				document.getElementById('rateimage3_'+args[0]).src = 'templates/site/images/valuta3_inact.jpg';
				document.getElementById('rateimage4_'+args[0]).src = 'templates/site/images/valuta4.jpg';
			break;
		}
	}

	var arrayOfRolloverClasses = new Array();
	var arrayOfClickClasses = new Array();
	var activeRow = false;
	var activeRowClickArray = new Array();

	function highlightTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(this!=activeRow){
			this.setAttribute('origCl',this.className);
			this.origCl = this.className;
		}
		this.className = arrayOfRolloverClasses[tableObj.id];
		
		activeRow = this;
		
	}

	function clickOnTableRow()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;		
		
		if(activeRowClickArray[tableObj.id] && this!=activeRowClickArray[tableObj.id]){
			activeRowClickArray[tableObj.id].className='';
		}
		this.className = arrayOfClickClasses[tableObj.id];
		
		activeRowClickArray[tableObj.id] = this;
				
	}

	function resetRowStyle()
	{
		var tableObj = this.parentNode;
		if(tableObj.tagName!='TABLE')tableObj = tableObj.parentNode;

		if(activeRowClickArray[tableObj.id] && this==activeRowClickArray[tableObj.id]){
			this.className = arrayOfClickClasses[tableObj.id];
			return;	
		}
		
		var origCl = this.getAttribute('origCl');
		if(!origCl)origCl = this.origCl;
		this.className=origCl;
		
	}
		
	function addTableRolloverEffect(tableId,whichClass,whichClassOnClick)
	{
		arrayOfRolloverClasses[tableId] = whichClass;
		arrayOfClickClasses[tableId] = whichClassOnClick;
		
		var tableObj = document.getElementById(tableId);
		var tBody = tableObj.getElementsByTagName('TBODY');
		if(tBody){
			var rows = tBody[0].getElementsByTagName('TR');
		}else{
			var rows = tableObj.getElementsByTagName('TR');
		}
		for(var no=0;no<rows.length;no++){
			rows[no].onmouseover = highlightTableRow;
			rows[no].onmouseout = resetRowStyle;
			
			if(whichClassOnClick){
				rows[no].onclick = clickOnTableRow;	
			}
		}
		
	}