function changeDefaultValue(sender, default_value, change_value)
{
	if (sender.value == default_value)
	{
		sender.value = change_value;
	}
}

function TabsMenu(id_root, tag_name, active_class)
{
	this.id_root = id_root;
	this.parent = document.getElementById(id_root);
	this.tag_name = tag_name;
	this.activeClass = active_class || 'active';
	this.active_index = null;
	this.active_tab = null;
	this.tabs_length = null;
	
	this.initializedContent();
}

TabsMenu.prototype.setActiveTab = function(index)
{
	if (this.active_index == index) return;
	
	try {
			this.active_tab.className = '';
			this.active_tab.content.style.display = 'none';
	}catch(e){};
	
	var obj = this.parent.getElementsByTagName(this.tag_name)[index];
		obj.className = this.activeClass;
		obj.content.style.display = 'block';
	
	this.active_tab = obj;
	this.active_index = index;
}

TabsMenu.prototype.nextTab = function()
{
	var curr_index = this.active_index + 1;
	if (curr_index >= this.tabs_length) curr_index = 0;
	this.setActiveTab(curr_index);
}

TabsMenu.prototype.previousTab = function()
{
	var curr_index = this.active_index - 1;
	if (curr_index < 0) curr_index = this.tabs_length - 1;
	this.setActiveTab(curr_index);
}

TabsMenu.prototype.initializedContent = function()
{
	var obj = this.parent.getElementsByTagName(this.tag_name);
	this.tabs_length = obj.length;
	for (var i = 0; i < this.tabs_length; i++)
	{
		obj[i].content = document.getElementById(this.id_root + '_' + i);
		obj[i].content.style.display = 'none';
	}
}


/*Radio Button and checkbox beta version*/
	function Checkbox(name, value, checked, id)
	{
		this.button = null;
		this.checked = checked;
		this.initializedComponent();
		this.button.className = 'hidden_component';
		this.button.name = name;
		this.button.value = value;
		this.button.id = id;
		this.button.defaultChecked = checked;
		
		
		this.custom_button = document.createElement('label');
		this.custom_button.par_button = this.button;
		this.custom_button.className = 'checkbox' + (this.checked ? ' ch_checked' : '');
		this.custom_button.onclick = function(){this.par_button.click();};
		
		this.button.custom_button = this.custom_button;
		this.changeCheckedListener();
	}
	
	Checkbox.prototype.changeCheckedListener = function()
	{
		this.button.onclick = function()
		{
			this.custom_button.className = 'checkbox' + (this.checked ? ' ch_checked' : '');
		}
	}
	
	Checkbox.prototype.writeComponent = function(id_element)
	{
		var obj = document.getElementById(id_element);
		obj.appendChild(this.button);
		obj.appendChild(this.custom_button);
	}
	
	Checkbox.prototype.initializedComponent = function()
	{
		this.button = document.createElement('input');
		this.button.type = 'checkbox';
	}
	
	var radio_button_reference = [];
	function changeRadioButtonChecked(sender)
	{
		if (radio_button_reference[sender.name]) 
		{
			radio_button_reference[sender.name].custom_button.className = 'radio';
			radio_button_reference[sender.name].checked = false;
			radio_button_reference[sender.name].defaultChecked = false;
		}
		
		sender.checked = sender.defaultChecked = true;
		sender.custom_button.className = 'radio r_checked';
		radio_button_reference[sender.name] = sender;
	}
	
	RadioButton.prototype = new Checkbox;
	RadioButton.constructor = RadioButton;
	
	function RadioButton(name, value, checked, id)
	{
		Checkbox.call(this, name, value, checked, id);
		this.custom_button.className = 'radio';
		if (this.checked)
		{
			changeRadioButtonChecked(this.button);
		}
	}
	
	RadioButton.prototype.changeCheckedListener = function()
	{
		this.button.onclick = function()
		{
			changeRadioButtonChecked(this);
		}
	}
	
	RadioButton.prototype.initializedComponent = function()
	{
		this.button = document.createElement((!window.ActiveXObject ? 'input' : '<input type="radio">'));
		this.button.type = 'radio';
	}
/*end radio button and checkbox*/

/*Update Label file field*/
function updateFileField(oFileField, index)
{
	document.getElementById('file[' + index + ']').value = oFileField.value;
}

function changeNewsContent(index, old_index)
{
	var id = 'short_news_';
	document.getElementById(id + old_index).style.display = 'none';
	document.getElementById(id + index).style.display = 'block';
}

/*large small font size*/
function IncreaseDecreaseFont(id_element)
{
	this.root = document.getElementById(id_element);
	
	var MAX = 13;
	var MIN = 10;
	var curr = 11;
	var class_name = 'font_size_';
	var self = this;
	
	
	this.setMax = function(max)
	{
		if (parseInt(max) == max)
		{
			MAX = max;
		}
	}
	
	this.setMin = function(min)
	{
		if (parseInt(min) == min)
		{
			MIN = min;
		}
	}
	
	this.increase = function()
	{
		increaseDecrease(-1);
	}
	
	this.decrease = function()
	{
		increaseDecrease(1);
	}
	
	function increaseDecrease(step)
	{
		if ((curr > MIN && step > 0) || (curr < MAX && step < 0))
		{
			curr -= step;
			self.root.className = class_name + curr;
		}
	}
}

var scr_w = window.screen.availWidth;
var scr_h = window.screen.availHeight;

function openPopUpPic(url, width, height)
{
	var left = Math.round((scr_w - width) / 2);
	var top =  Math.round((scr_h - height) / 2);
	var scroll = 'no';

	if (top < 0)
	{
		top = 0;
		width = scr_w;
		scroll = 'yes';
	}

	if (left < 0)
	{
		left = 0;
		height = scr_h;
		scroll = 'yes';
	}

	var pop_up = window.open(url, 'big_galery_pic', 'scrollbars=' + scroll);
	pop_up.resizeTo(width, height);
	pop_up.moveTo(left, top);

	pop_up.document.open();
	pop_up.document.write('<style type="text/css">* {margin: 0; padding: 0;}</style><img src="' + url + '" alt="" />');
	pop_up.document.close();
	pop_up.focus();
}
	
//counter for video on index page
function hitCounterMovie(sender)
{
	var xmlHttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
	xmlHttp.open('GET', sender, true);
	xmlHttp.send(null);
}

