




var nav="";

if (document.layers) nav = "ns4"
else if (document.getElementById && !document.all) nav = "ns6"
else if (document.all && document.getElementById) nav = "ie5ns6"


function moucapes()
{
	moverA("juga","reg_box");
	moverA("apren","reg_box");
	moverA("coneix","reg_box");

}

var vAvance = 30;
var tEspera = 2000;
var tSiguiente = 50;
var posJuga=0.0;
var posApren=0.0;
var posConeix=0.0;
var htJuga;
var htApren;
var htConeix;

function setupAnim() {
	moverAen("juga", "reg_box", posJuga);

	if (nav=="ns4" || nav=="ns6")
		mostrar("juga");
	else
		ju.Appear(3);

	htJuga=slideJuga();

}

function slideJuga() {

	if (posJuga<100) {
		moverAen("juga", "reg_box", posJuga);
		posJuga += 0.5;
		htJuga=setTimeout("slideJuga()",vAvance);
	} else {
		if (nav=="ns4" || nav=="ns6")
			setTimeout("ocultar('juga')",tEspera);
		else
			setTimeout("ju.Disappear(1)",tEspera);
		posJuga=0.0;
		setTimeout("setupAnim2()",tSiguiente);
	}
}

function setupAnim2() {
	moverAen("apren", "reg_box", posApren);

	if (nav=="ns4" || nav=="ns6")
		mostrar("apren");
	else
		ap.Appear(3);

	htApren=slideApren();

}

function slideApren() {

	if (posApren<100) {
		moverAen("apren", "reg_box", posApren);
		posApren += 0.5;
		htApren=setTimeout("slideApren()",vAvance);
	} else {
		if (nav=="ns4" || nav=="ns6")
			setTimeout("ocultar('apren')",tEspera);
		else
			setTimeout("ap.Disappear(1)",tEspera);
		posApren=0.0;
		setTimeout("setupAnim3()",tSiguiente);
	}
}

function setupAnim3() {
	moverAen("coneix", "reg_box", posConeix);

	if (nav=="ns4" || nav=="ns6")
		mostrar("coneix");
	else
		co.Appear(3);

	htConeix=slideConeix();

}

function slideConeix() {

	if (posConeix<100) {
		moverAen("coneix", "reg_box", posConeix);
		posConeix += 0.5;
		htConeix=setTimeout("slideConeix()",vAvance);
	} else {
		if (nav=="ns4")
			setTimeout("ocultar('coneix')",tEspera);
		else
			setTimeout("co.Disappear(1)",tEspera);
		posConeix=0.0;
		setTimeout("setupAnim()",tSiguiente);
	}
}

function stopSlides () {
	clearTimeout(htJuga);
	clearTimeout(htApren);
	clearTimeout(htConeix);
}

function continueSlides () {
	if (posJuga>0.0 && posJuga<100) slideJuga();
	if (posApren>0.0 && posApren<100) slideApren();
	if (posConeix>0.0 && posConeix<100) slideConeix();
}

// fi fade

var fading=false;

function Fade(nom,capa,primer)
{
	this.name = nom;
	this.value = primer;
	this.layer = capa;
	this.Appear = FAppear;
	this.Disappear = FDisappear;
}

function FAppear(inc)
{
if (this.value<100) {
	fading=true;
	eval(this.layer+".style.filter='alpha(opacity="+this.value+",enabled=1)'");
	this.value+=inc;
	eval("setTimeout('"+this.name+".Appear("+inc+")',2)");
	mostrar(this.layer);
}
else {
	fading=false;
	this.value=100;
	eval(this.layer+".style.filter='alpha(opacity=100,enabled=1)'");
}
}

function FDisappear(inc)
{
if (this.value>0) {
	fading=true;
	eval(this.layer+".style.filter='alpha(opacity="+this.value+",enabled=1)'");
	this.value-=inc;
	eval("setTimeout('"+this.name+".Disappear("+inc+")',2)");
}
else {
	fading=false;
	this.value=0;
	ocultar(this.layer);
	eval(this.layer+".style.filter='alpha(opacity=0,enabled=1)'");
	}
}

function obtenerCapa(nom_capa){
    if (nav == "ie5ns6" || nav=="ns6") return "document.getElementById('" + nom_capa + "').style.";
 	else if (nav == "ie4") return "document.all['" + nom_capa + "'].style.";
	else return "document." + nom_capa + ".";
}

function mostrar(nom_capa){

	eval(obtenerCapa(nom_capa) + "visibility = 'visible'");

}

function ocultar(nom_capa){
    eval(obtenerCapa(nom_capa) + "visibility = 'hidden'");
}

function moverA(nomCapaToMove, nomObjectiu){

	if(nav == "ns4") {
		asignarProp(nomCapaToMove, "left", eval("findPosX(document.images[nomObjectiu])"));
		asignarProp(nomCapaToMove, "top", eval("findPosY(document.images[nomObjectiu])"));
	}
	if(nav == "ie4") {
		asignarProp(nomCapaToMove, "style.left", eval("findPosX(document.all('" + nomObjectiu + "'))"));
		asignarProp(nomCapaToMove, "style.top", eval("findPosY(document.all('" + nomObjectiu + "'))"));
	}
	if(nav == "ns6") {
		asignarProp(nomCapaToMove, "style.left", eval("findPosX(document.images[nomObjectiu])-1"));
		asignarProp(nomCapaToMove, "style.top", eval("findPosY(document.images[nomObjectiu])-1"));

	}
	if(nav == "ie5ns6") {
		asignarProp(nomCapaToMove, "style.left", eval("findPosX(document.getElementById('" + nomObjectiu + "'))"));
		asignarProp(nomCapaToMove, "style.top", eval("findPosY(document.getElementById('" + nomObjectiu + "'))"));
	}

}

function moverAen(nomCapaToMove, nomObjectiu, u){
	ptx=0;
	pty=0;
	w=678;
	h=77;

	if(nav == "ns4") {
		ptx = eval("findPosX(document.images['" + nomObjectiu + "'])");
		pty = eval("findPosY(document.images['" + nomObjectiu + "'])");
		h = document.images[nomObjectiu].height-25;
		w = document.images[nomObjectiu].width-148;
		ptx = ptx + Math.round((100-u)/100.0*w);
		pty = pty + h - Math.round((100-u)/100.0*h);
		asignarProp(nomCapaToMove, "left", ptx);
		asignarProp(nomCapaToMove, "top", pty);
	}
	if(nav == "ie4") {
		ptx = eval("findPosX(document.all('" + nomObjectiu + "'))");
		pty = eval("findPosY(document.all('" + nomObjectiu + "'))");
		h = document.all('" + nomObjectiu + "').height-25;
		w = document.all('" + nomObjectiu + "').width-148;
		ptx = ptx + Math.round((100-u)/100.0*w);
		pty = pty + h - Math.round((100-u)/100.0*h);
		asignarProp(nomCapaToMove, "style.left", ptx);
		asignarProp(nomCapaToMove, "style.top", pty);
	}
	if(nav == "ns6") {
		ptx = eval("findPosX(document.images['" + nomObjectiu + "'])");
		pty = eval("findPosY(document.images['" + nomObjectiu + "'])");
		h = document.images[nomObjectiu].height-25;
		w = document.images[nomObjectiu].width-148;
		ptx = ptx + Math.round((100-u)/100.0*w);
		pty = pty + h - Math.round((100-u)/100.0*h);
		asignarProp(nomCapaToMove, "style.left", ptx);
		asignarProp(nomCapaToMove, "style.top", pty);

	}
	if(nav == "ie5ns6") {

		ptx = eval("findPosX(document.getElementById('" + nomObjectiu + "'))");
		pty = eval("findPosY(document.getElementById('" + nomObjectiu + "'))");
		h = document.getElementById(nomObjectiu).height-25;
		w = document.getElementById(nomObjectiu).width-148;

		ptx = ptx + Math.round((100-u)/100.0*w);
		pty = pty + h - Math.round((100-u)/100.0*h);

		asignarProp(nomCapaToMove, "style.left", ptx);
		asignarProp(nomCapaToMove, "style.top", pty);
	}

}

	function MM_findObj(n, d) { //v4.0

	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && document.getElementById) x=document.getElementById(n); return x;
	}
	function MM_swapImage() { //v3.0

	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

function asignarProp(nomCapa, nomProp, valor){

	if(nav == "ns4") {
		eval("document.layers['" + nomCapa+ "']." + nomProp + "='" + valor +"'");
	}
	if(nav == "ie4") {
		eval("document.all('" + nomCapa+ "')." + nomProp + "='" + valor +"'");
	}
	if(nav == "ie5ns6" || nav=="ns6" ) {
		eval("document.getElementById('" + nomCapa+ "')." + nomProp + "='" + valor +"'");
	}

}


var ju = new Fade("ju","juga",0);
var ap = new Fade("ap","apren",0);
var co = new Fade("co","coneix",0);