/*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 isValidKey(event)
{
	var symbol = String.fromCharCode((window.event ? event.keyCode : event.charCode)).toUpperCase();
	if (!event.ctrlKey && !event.altKey && (window.ActiveXObject || event.keyCode == 0) && isNaN(symbol))
	{
		return false;
	}
	else if (symbol == 'V') return false;
}


function TabsMenu(id_root, tag_name)
{
	this.id_root = id_root;
	this.parent = document.getElementById(id_root);
	this.tag_name = tag_name;
	this.activeClass = 'active_tab';
	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';
	}
}

/* Change default text for username and password fields */
function changeDefaultValue(sender, default_value, change_value, classN)
{
	if (sender.value == default_value)
	{
		sender.value = change_value;
		sender.className = classN;
	}
}

/* Gallery Popups */
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_bar = 'no';
	if (top < 0)
	{
		top = 0;
		height = scr_h;
		scroll_bar = 'yes';
	}

	if (left < 0)
	{
		left = 0;
		width = scr_w;
		scroll_bar = 'yes';
	}

	var pop_up = window.open(url, 'big_galery_pic', 'scrollbars=' + scroll_bar);
	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();
}
/*end // Gallery Popups*/

function setActivePic(sender)
{
	document.getElementById('active').id = '';
	sender.id = 'active';
}

// start facebook widget
function ShowWidget() {	document.getElementById('facebook_widget').style.display = 'block';
}
function HideWidget() {
	document.getElementById('facebook_widget').style.display = 'none';
}
// end facebook widget