var fadeToBlack;
var imageAppearance;
var uncover;
var shrink;
var target = new Array();
target["catala"] = "ca/";
target["castellano"] = "es/";
target["english"] = "en/"; 
target["francais"] = "fr/";

function redirigir()
{
   //Obté la cookie
   var idioma = Cookie.get("lozanoLanguage"); 
   //Si hi ha idioma
   if(idioma==null) 
   	return false;
   else if(target[idioma]) document.location.href=target[idioma];

}

function goTo(idioma, doEffect)
{
	setIdioma(idioma)
	if(doEffect) executeFadeToBlack(target[idioma])
		else document.location.href = target[idioma];
	
}
//Seteja la cookie d'idioma per a 30 dies
function setIdioma(idioma)
{
	Cookie.set("lozanoLanguage", idioma, 30); 
}

function executeFadeToBlack(href)
{

	$('blackCover').style.visibility = 'visible';	
	$('blackCover').style.height = Window.getHeight() + 'px';	
  	fadeToBlack.custom(0,1).chain(function(){
		document.location.href = href;
	});
}

function mostrar() {

//if(!redirigir()) setIdioma();

//Setejem la cobertura per als idiomes
$('idiomesCover').style.top = $('idiomes').getTop() + 'px';
$('idiomesCover').style.left = $('idiomes').getLeft() + 'px';
$('idiomesCover').style.width = $('idiomes').offsetWidth + 'px';
$('idiomesCover').style.height = $('idiomes').offsetHeight + 'px';
$('idiomes').style.visibility = 'visible';

//Declarem els efectes
uncover = new Fx.Style('idiomesCover', 'left', {duration:5000});
shrink = new Fx.Style('idiomesCover', 'width', {duration:5000});
imageAppearance = new Fx.Style('logo', 'opacity', {duration: 5000});

fadeToBlack = new Fx.Style('blackCover', 'opacity', {duration: 2000});	

//Executem els efectes inicials
var divLeft=$('idiomesCover').getLeft();
var divWidth=$('idiomesCover').offsetWidth;

uncover.custom(divLeft,divLeft+divWidth);
shrink.custom(divWidth,  0);

imageAppearance.custom(0,1);
}