var LocaleSwitch = function() {
	
	this.screenWindow = false;
	
	this.init = function() {
		if(jQuery('#menu-LocaleSelector').length) {
			jQuery('#menu-LocaleSelector').click(jQuery.proxy(this.click,this));
		}
	};
	
	this.click = function(event)
	{
		event.preventDefault();
		
		if (event.target.href === 'undefined') return;
		
		this.target = event.target;
		// load and open screen window
		jQuery.ajax(event.target.href,{
			context    : this,
			dataType   : 'html',
			complete   : function(){ jQuery(this.target).removeClass('loading');},
			beforeSend : function(){ jQuery(this.target).addClass('loading');},
			success    : this.showWindow
		});
		
	};
	
	this.showWindow = function(data, textStatus, jqXHR) 
	{
		if (this.screenWindow === false) {
			this.screenWindow = new onScreenWindow();
			
		};
		this.screenWindow.setContent(data);
		this.screenWindow.show();
	};
	
	this.init();
};

jQuery(document).ready(function(){LocaleSwitch = new LocaleSwitch();});
