// Rutinas dHtml desarrolladas por Carles Reverter
// www.carlesrever.com · mail@carlesrever.com
// Puedes usarlas y molificarlas libremente, manteniendo estas 3 líneas
var ns4=false; var ie4=false; var standard=false;
var capaCom=false;
var capaActiva="";
var nomsCapes = new Array()
var posCapesX = new Array()
var noflash=false;

if (document.getElementById) {
    standard=true
} else if (document.all) {
	ie4=true
} else if (document.layers) {
    ns4=true
} else {
}

if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.indexOf("Mac") != -1)) {
	noflash=true;
}

function canviaImatge (nomCapa,nomImatge,arxiu){
if (ns4) {
	if (nomCapa != "") {
    eval("document.layers."+nomCapa+".document.images['"+nomImatge+"'].src="+arxiu);
	} else {
    eval("document.images['"+nomImatge+"'].src="+arxiu);
	}
}
if (ie4) {
 	eval("document.images['"+nomImatge+"'].src="+arxiu);
}
if (standard) {
	eval("document.images['"+nomImatge+"'].src="+arxiu);
}
}

if (navigator.userAgent.indexOf("Mac",0) != -1) {
	var mac=true
} else {
	var mac=false
}

function mouCapa(nomCapa, x, y) {
if (ns4) {
	document.layers[nomCapa].left=x;
	document.layers[nomCapa].top=y;
}
if (ie4) {
	document.all[nomCapa].style.left=x;
	document.all[nomCapa].style.top=y;
}
if (standard) {
	document.getElementById(nomCapa).style.left=x;
	document.getElementById(nomCapa).style.top=y;
}
}

function vistaCapa(nomCapa,accio) {
if (ns4) {
   document.layers[nomCapa].visibility = accio;
}
if (ie4) {
   document.all[nomCapa].style.visibility = accio;
}
if (standard) {
   document.getElementById(nomCapa).style.visibility = accio;
}
}

function preLoad(objecte,arxiu) {
	for (var i=0; i<preLoad.arguments.length; i=i+2) {
		eval(preLoad.arguments[i] + "= new Image()")
		isrc=preLoad.arguments[i+1]
		eval(preLoad.arguments[i] + ".src = '"+isrc+"'")
	}
} 

function popup (tamanyX, tamanyY, adre, nom, posX, posY, attr) {
				var x=(screen.width-tamanyX) * posX / 100;
                var y=(screen.height-tamanyY) * posY / 100;
                if (attr=="") {attr='resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0'}

                finestra=open(adre,nom,attr+',width='+tamanyX+',height='+tamanyY+',left='+x+',top='+y+',screenX='+x+',screenY='+y+'');
                if (mac && !ns4) {finestra.moveTo(x,y)}
}

//-------------------------------------------------------------------------------------------

function vistaCapaPro(nomCapa,accio) {
proactiv=false;
for (a=0; a < nomsCapes.length; a++){
	if (nomCapa==nomsCapes[a]) {
		proactiv=true;
		if ((vist=="inici" || botonumeric != 0 || vist==13) && (!noflash)) {
			tt='calaix';
			mouCapa('calaixdetall', -1000, 100)
		} else {
			tt='calaixdetall'
			mouCapa('calaix', -1000, 100)
		}
		//mouCapa(tt, 20, posCapesY[a])
		if (calaixY<posCapesY[a]) {
			despla(tt, 20, calaixY, 20, posCapesY[a], 8, 200, 2,'vistaCapa("'+nomCapa+'","'+accio+'")');
		} else {
			despla(tt, 20, calaixY, 20, posCapesY[a], 12, 400, 2,'');
			vistaCapa(nomCapa,accio);
		}
		calaixY=posCapesY[a];
	}
	if (!proactiv) {
		//vistaCapa(nomCapa,accio)
	}
}
}

function bucledespla(nomCapa, x, y,incx,incy,pas,passos,alpha,incalpha,temps,mode,alacabar) {
alpha=alpha+incalpha
if (mode==0) {
factor=1-(pas-1)/passos
} else if (mode==1) {
factor=1-Math.sin(alpha)
} else if (mode==2) {
factor=Math.sin(alpha)
} else {
alert(mode)
}
xx=x+(incx*factor)
yy=y+(incy*factor)
mouCapa(nomCapa,xx,yy)
pas=pas-1
if (pas>0) {
	setTimeout("bucledespla('"+nomCapa+"', "+x+", "+y+","+incx+","+incy+","+pas+","+passos+","+alpha+","+incalpha+","+temps+","+mode+",'"+alacabar+"')",temps)
} else {
	eval(alacabar);
}
}

function despla(nomCapa, x1, y1, x2, y2, passos,temps,mode,alacabar) {
incx=(x2-x1)
incy=(y2-y1)
t=temps/passos
alpha=0
incalpha=0
if (mode==1) {
alpha=Math.PI/2
incalpha=(Math.PI/2)/passos
} else if (mode==2) {
alpha=0
incalpha=(Math.PI/2)/passos
} else if (mode != 0){
alert(mode)
}
bucledespla(nomCapa, x1, y1,incx,incy,passos,passos,alpha,incalpha,t,mode,alacabar)
}

//variables control
vist="inici";
botonumeric=0;
calaixY=438;
var nomsCapes = new Array("txt1","txt2","txt3","c1","c2","c3","c4","c5","c6","c7","c8","c9","c10","c11","c12","cmaleta")
//                        txt1,txt2,txt3,c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,c11,c12,maleta
var posCapesY = new Array(452, 480, 506, 620,598,598,598,598,598,598,598,598,640,598,598,598)

//inicial
function inic() {
	vistaCapa('loading','hidden');
	despla('superior', 9, 265, 9, 65, 15, 1500, 2, 'inic2()');
}
function inic2() {
	vistaCapa('fixe','visible');
	despla('cotxets', -311, 70, 9, 70, 15, 800, 2, 'inic3()');
}
function inic3() {
	vistaCapa('adesp','visible');
	vistaCapa('afonsd','visible');
	if (noflash) {
		mouCapa('calaixdetall',20,438);
	} else {
		mouCapa('calaix',20,438);
}
	mouCapa('formulari',787,34);
}

//funcions rollover textes desplegats
function a_dins(n) {
	canviaImatge('afonsd','des'+n+'1','des'+n+'1_hi.src');
	canviaImatge('afonsd','des'+n+'2','des1_hi.src');
}
function a_fora(n) {
	canviaImatge('afonsd','des'+n+'1','des'+n+'1_lo.src');
	canviaImatge('afonsd','des'+n+'2','des1_lo.src');
}
function a_clica(n) {
	botonumeric=n;
	vistaCapa('afonsd','hidden');
	vistaCapa('adesp','hidden');
	vistaCapa('aplegat','visible');
	vistaCapaPro('txt'+n,'visible');
	ap_dins(n);
	vist="txt"+n
}
// rollovers textes plegats
function ap_dins(n) {
	canviaImatge('aplegat','ple'+n,'ple'+n+'_hi.src');
}
function ap_fora(n) {
	if (botonumeric != n) {
		canviaImatge('aplegat','ple'+n,'ple'+n+'_lo.src');
	}
}
function ap_clica(n) {
	if (botonumeric != 0) {
		vistaCapa('txt'+botonumeric,'hidden');	
		an=botonumeric;
		botonumeric=n;
		ap_fora(an);
	} else if (vist==13) {
		vistaCapa('cmaleta','hidden');		
	} else {
		vistaCapa('fletxes','hidden');
		vistaCapa("c"+vist,'hidden');
	}
	botonumeric=n;
	vistaCapaPro('txt'+n,'visible');	
	vist="txt"+n
}
// ensenya cotxes
function mostraCotxe(quin) {
	if (botonumeric != 0) {
		vistaCapa('txt'+botonumeric,'hidden');	
		an=botonumeric;
		botonumeric=0;
		ap_fora(an);
		vistaCapa('fletxes','visible');
	} else if (vist=="inici") {
		vistaCapa('afonsd','hidden');
		vistaCapa('adesp','hidden');
		vistaCapa('aplegat','visible');
		vistaCapa('fletxes','visible');
	} else if (vist==13) {
		vistaCapa('fletxes','visible');
		vistaCapa('cmaleta','hidden');		
	} else {
		vistaCapa("c"+vist,'hidden');
	}
	vist=quin;
	vistaCapaPro("c"+quin,'visible');
}

function maleta() {
	if (botonumeric != 0) {
		vistaCapa('txt'+botonumeric,'hidden');	
		an=botonumeric;
		botonumeric=0;
		ap_fora(an);
	} else if (vist=="inici") {
		vistaCapa('afonsd','hidden');
		vistaCapa('adesp','hidden');
		vistaCapa('aplegat','visible');
	} else if (vist!=13) {
		vistaCapa("fletxes","hidden");
		vistaCapa("c"+vist,'hidden');
	}
	vist=13;
	vistaCapaPro("cmaleta",'visible');
}

function anterior() {
	vistaCapa("c"+vist,'hidden');
	vist=vist-1;
	if (vist==0) {
		vist=12;
	}
	vistaCapaPro("c"+vist,'visible');
}
function seguent(){
	vistaCapa("c"+vist,'hidden');
	vist=vist+1;
	if (vist==13) {
		vist=1;
	}
	vistaCapaPro("c"+vist,'visible');
}

preLoad("des11_lo","img/a1dlo.gif","des11_hi","img/a1dhi.gif","des21_lo","img/a2dlo.gif","des21_hi","img/a2dhi.gif","des31_lo","img/a3dlo.gif","des31_hi","img/a3dhi.gif","des1_lo","img/adlo.gif","des1_hi","img/adhi.gif","ple1_lo","img/a1plo.gif","ple1_hi","img/a1phi.gif","ple2_lo","img/a2plo.gif","ple2_hi","img/a2phi.gif","ple3_lo","img/a3plo.gif","ple3_hi","img/a3phi.gif","bot_lo","img/form5lo.gif","bot_hi","img/form5hi.gif","ant_lo","img/anteriorlo.gif","ant_hi","img/anteriorhi.gif","seg_lo","img/seguentlo.gif","seg_hi","img/seguenthi.gif")


