var UpdateLangBox = function (t) {
	LoadOverlay();
	$('overlay').show();
	$('overlay').setOpacity(0.3);
	if(!$('alert'))
	{
		alertdiv=new Element('div',{id: 'alert',});
		$('header').appendChild(alertdiv);
	}
	else
	{
		alertdiv=$('alert');
		alertdiv.show();
		alertdiv.innerHTML='';
	}
	alertdiv.innerHTML=t.responseText;
	$$('.close').each(function (close) { 
			close.onclick=function () {
				$('alert').hide();
				$('overlay').hide();
			}
	});
}

function SetupLangView()
{
	$$('#flags a').each(function (link) {
		link.onclick=function () {
			new Ajax.Request(link.href,{parameters: 'js=1',onSuccess:UpdateLangBox });
			return false;
		}
	});
}

function LoadOverlay()
{
	if($('overlay'))
		return false;
	overlay = new Element('div',{
            id: 'overlay'
        });
        $(document.body).appendChild(overlay);
        if(Prototype.Browser.IE){
            overlay.setStyle({position: 'absolute',
	    	    top: 0,
    		    left: 0,
	        	zIndex: 9998
			});
            Event.observe(window,'scroll',overlay.setStyle({
        	    width: document.body.clientWidth + 'px',
    	        height: document.body.clientHeight + 'px'
	        }));
            Event.observe(window,'resize',overlay.setStyle({
	            width: document.body.clientWidth + 'px',
    	        height: document.body.clientHeight + 'px'
        	}));
            Control.Overlay.observe('beforeShow',overlay.setStyle({
            	width: document.body.clientWidth + 'px',
	            height: document.body.clientHeight + 'px'
    	    }));


        }else{
            overlay.setStyle({
		        position: 'fixed',
		        top: 0,
        		left: 0,
		        width: '100%',
		        height: '100%',
		        zIndex: 9998
		    });
		}
        iFrameShim = new IframeShim();
		iFrameShim.hide();
		iFrameShim.positionIFrameShim=function() {
			if($('overlay').visible())
				iFrameShim.positionUnder($('overlay'));

		}
        Event.observe(window,'resize',iFrameShim.positionIFrameShim);
        overlay.hide();
        return true;
}


