function LanguageSelection()
{
	this.init();
};

LanguageSelection.prototype.init = function()
{
	window[ ( this._self = "LanguageSelectionObject" ) ] = this;
	this._timer = null;
	this._delay = 500;
	
	this._wrapper = document.getElementById( "languageselection" );
	if ( this._wrapper )
		this._wrapper._parent = this;
	
	this._current = document.getElementById( "languageselectioncurrent" );
	if ( this._current && !this._current.className.match( /disabled/gi ) )
	{
		this._current._parent = this;	

		this._countrylist = document.getElementById( "languageselectioncountrylist" );
		this._countrylist._parent = this;

		this._wrapper.onmouseout = this.__hide;
		this._current.onmouseover = this.__show;
		this._countrylist.onmouseover = this.__show;

		aSpan = this._countrylist.getElementsByTagName( "SPAN" );
		for ( var i=0; i < aSpan.length; i++ )
		{
			aSpan[ i ]._parent = this;
			aSpan[ i ].onclick = this.change;
		}

		this._confirm = document.getElementById( "languageselectionconfirm" );
	}
};

LanguageSelection.prototype.show = function()
{
	clearTimeout( this._timer );
	this._countrylist.style.display = "block";
};

LanguageSelection.prototype.hide = function()
{
	clearTimeout( this._timer );
	this._timer = setTimeout( this._self + "._hide();", this._delay );
}

LanguageSelection.prototype.change = function()
{
	if ( confirm( this._parent._confirm.innerHTML ) )
		window.location.href = "/change-locale/" + this.id + "/?goto=" + (window.location.href.indexOf("/sorry") !== -1 || window.location.href.indexOf("/global") !== -1 ? "/" : window.location.href);
};

LanguageSelection.prototype._hide = function()
{
	this._countrylist.style.display = "none";
}

LanguageSelection.prototype.__show = function()
{
	this._parent.show();
};


LanguageSelection.prototype.__hide = function()
{
	this._parent.hide();
};
