1 // *************************AJAX**************** var XMLHttpObject = function() { try{ var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { var xmlhttp = false; } } return (!xmlhttp && typeof XMLHttpRequest!='undefined')? new XMLHttpRequest():xmlhttp || new function(){}; } function pillacodi (url, id_contenedor,opcio) { // Versió sincrona var target = document.getElementById(id_contenedor); target.innerHTML="..··¨:¨··.."; var rpc = new XMLHttpObject(); rpc.open("POST",url,false); rpc.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); try{rpc.send(opcio);} catch(e) {pilacodi(url, id_contenedor,opcio);} target.innerHTML = rpc.responseText; } function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; // IE/Win obj.style.filter = "alpha(opacity:"+opacity+")"; // Safari<1.2, Konqueror obj.style.KHTMLOpacity = opacity/100; // Older Mozilla and Firefox obj.style.MozOpacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3 obj.style.opacity = opacity/100; } var jspos=new Array(); var jsamp=new Array(); var anem=''; var ini=0; var fin=0; var dif=0; var speed=2; // Velocitat var accel=5; // frenada var laterals=0; var atelo=0; var iafec=''; var obert=0; var iant=''; var inm=0; var inl=0; var intm=0; var intl=0; var outm=0; var outl=0; var outtm=0; var outtl=0; var pas=0; var decx=0; var decy=0; var posmenux=0; var posmenuy=0; var menuw=0; var menuh=0; var slo=''; var delaysld=5000; var xmoure=false; var total=0; var ci=0; var totample; var totalt; var foto=new Array(); var alcafoto=450; function pillavars(idg){ foto=new Array(); dmis.style.display='none'; tpad.innerHTML=""; jspos=new Array(); jsamp=new Array(); mant.value='x0'; antafec.value='f0'; pillacodi('galeria.php','vars','que=vars&idg='+idg); var valors=vars.innerHTML; eval(valors); //alert (jspos[5]+" / "+jsamp[5]+" / ci="+ci+" / total="+total); pillacodi('galeria.php','tpad','que=barra&idg='+idg); pillacodi('galeria.php','subcont','que=fotos&idg='+idg); for (a=0;a0) var amptelons=(espai-intm)/2-3; else var amptelons=0; teloe.style.width=amptelons; telod.style.width=amptelons; cont.style.display='block'; initmenu(); } function coloca(quina) { var idfoto='f'+quina; if (antafec.value!=idfoto || outtm==0) { actual.value=quina; var pos=jspos[quina]; var iamp=jsamp[quina]; document.getElementById(mant.value).style.borderBottomColor='white'; document.getElementById('x'+quina).style.borderBottomColor='orange'; mant.value='x'+quina; pas=20; paso=90; recoloca(); ini=cont.scrollLeft; //-(totample/2); fin=pos;//+laterals; atelo=laterals-(iamp/2)-3; iant=document.getElementById(antafec.value); iant.style.border="0px"; // variables mides imatge que surt outtm=iafec.width; outm=antamp.value; outl=200; outtl=alcafoto; //450; //iafec.height; iafec=document.getElementById(idfoto); iafec.style.border="3px white ridge"; antafec.value=idfoto; antamp.value=iafec.width; // variables mides imatge que entra inm=iamp; intm=iafec.width; inl=alcafoto; //450; intl=iafec.height; moure(); } } function moure(){ if (obert!=atelo) { // Obertura laterals traslucids if (obert>atelo) { obert-=15; if (atelo>obert) obert=atelo; } else { obert+=15; if (atelo0) { // Només si ja existeix // amplada imatge que surt if (outtm>outm) outtm-=(outtm-outm)/pas; else iant.width=outm; iant.width=outtm; // alçada de la imatge que surt if (outtl>outl) outtl-=(outtl-outl)/pas; else iant.width=outm; iant.height=outtl; } } // Moviment scrolling fotos dif=Math.abs((ini-fin)/accel); if (ini>fin) ini-=dif; else ini+=dif; if (Math.round(ini)!=Math.round(fin)) { //document.body.scrollLeft=ini; cont.scrollLeft=ini; to=setTimeout("moure()",speed); } else { clearTimeout(to); recoloca(); } //dif=Math.abs(ini-fin)/speed; //dif=Math.round(Math.sqrt(Math.abs(ini-fin))); } function recoloca(){ teloe.style.width=atelo; telod.style.width=atelo; iafec.width=inm; iafec.height=inl; iant.width=outm; iant.height=outl; } function entra() { mando.innerHTML=Math.round(delaysld/1000); mides(); coloca(ci); coloca(0); } function menu(acc){ estmen.value=acc; moumenu(); if (acc=="o") { tpad.style.display='none'; pillacodi('menu.php','dmenu',''); contmenu.style.height=menuh-100; contmenu.style.width=menuw-160; posar(); } else { tpad.style.display='block'; } } function moumenu(){ var ref=true; if (estmen.value=="o") { stop(); dmenu.style.display='block'; if (posmenux100) { posmenux-=decx; posmenuy-=decy; } else var ref=false; } dmenu.style.width=posmenux; dmenu.style.height=posmenuy; //alert("que="+estmen.value+" /ref="+ref+" / posmenux="+posmenux+" / menuw="+menuw); if (ref) { setTimeout("moumenu()",0); } else if (estmen.value=="t") { dmenu.style.width=77; dmenu.style.height=50; } } function desplaca(com) { var vigent=new Number(actual.value)+com; if (vigent<=ci && vigent>-1) { coloca(vigent); } } function engega() { secs.style.display='block'; if (playest.value!="n") { playest.value="n"; desplaca(1); slo=setInterval("desplaca(1)",delaysld); } } function stop() { if (reengega==false) secs.style.display='none'; clearInterval(slo); playest.value="f"; if (estmen.value=="o") play.src="img/play.gif"; } espera=0; var reengega=false; function mouvel() { if (playest.value=="c") { reengega=true; stop(); playest.value='c'; } else reengega=false; clearTimeout(espera); var posact=event.clientX; var posfin=posact-155; if (posfin<7) posfin=7; if (posfin>84) posfin=84; mando.style.marginRight=84-posfin; delaysld=Math.round(Math.pow((posfin*2.02),2)+1300); mando.innerHTML=Math.round(delaysld/1000); if(reengega) { espera=setTimeout("engega()",600); reengega=false; } } ////////////////// Control teclat document.onkeydown=teclaPulsada function teclaPulsada(elEvento) { if (estmen.value=="t") { var evento = elEvento || window.event; var codiTecla = evento.charCode || evento.keyCode; var codiTecla=evento.keyCode; if (codiTecla==36) coloca(0); // Inici if (codiTecla==35) coloca(ci); // Final if (codiTecla==39 || codiTecla==40) desplaca(1); // Dereta if (codiTecla==37 || codiTecla==38) desplaca(-1); // Esquerra } } /////////////////////////Final control teclat ////////////////////////// Mousewheel var control=true; function handle(delta) { //alert(navigator.appVersion); if (control==true) { if (delta>0) res=-1; else if (delta<0) res=1; desplaca(res); if (navigator.appVersion.indexOf ("Chrome")>0 || navigator.appVersion.indexOf ("Safari")>0) control=false; } else control=true; } /** Event handler for mouse wheel event. */ function wheel(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } /** If delta is nonzero, handle it. * Basically, delta is now positive if wheel was scrolled up, * and negative, if wheel was scrolled down. */ if (delta) handle(delta); } /** Initialization code. * If you use your own event management code, change it as required. */ if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener('DOMMouseScroll', wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; ////////////// FINAL mousewheel ////////////////////// CARTELL MENUS var poscar=new Array(); var st=0; var cadena=""; var prv=0; function acaba(){ prv=0; for (h=0;h91) poscar[j]=29; //90 document.getElementById('l'+j).innerHTML=String.fromCharCode(poscar[j]); } //else eval("clearInterval(st["+on+"]);"); } } ////////////// FINAL CARTELL MENUS