var desplazamiento=400;var imagen=-5;var colores=['#f00','#ff0','#0ff','#00f','#f0f','#0f0'];d=document;w=window.innerWidth;cen=w/2;var xmlHttp=new XMLHttpRequest();function E(x){return d.getElementById(x);}
function T(x){return d.getElementsByTagName(x)}
function C(x){var t=new Array();var t=T('*');var tn=new Array();for(i=0;i<t.length;i++){if(t[i].className==x){tn=tn.concat(t[i]);}}return tn}
function I(){if(E("m2")){mueve()};x=C("ocm");for(i=0;i<x.length;i++){x[i].firstChild.setAttribute('onclick','abrirCerrar(this);return false');}
fls=C('false');for(i=0;i<fls.length;i++){fls[i].onclick=FLS;}
lnk=C('lnk');for(i=0;i<lnk.length;i++){lnk[i].onclick=lightBox;lnk[i].onmouseover=AgrandaImagen;}
clrs=C('colores');for(i=0;i<clrs.length;i++){clrs[i].onmouseover=AgrandaImagen;}
Color();return false;}
function Color(){cambalache=C('colores');for(i=0;i<cambalache.length;i++){ca=Math.floor(Math.random()*6);cambalache[i].style.borderColor=colores[ca];}
setTimeout("Color()",1000);}
function mueve(){if(imagen>-desplazamiento){izquierda();}else{derecha();}}
function derecha(){if(imagen<-5){imagen++;E("m2").style.left=imagen+'px';setTimeout("derecha()",50);}else{izquierda();}}
function izquierda(){if(imagen>-desplazamiento){imagen--;E("m2").style.left=imagen+'px';setTimeout("izquierda()",50);}else{derecha();}}
function Color(){cambalache=C('colores');for(i=0;i<cambalache.length;i++){ca=Math.floor(Math.random()*6);cambalache[i].style.borderColor=colores[ca];}
setTimeout("Color()",1000);}
function abrirCerrar(x){if(x.parentNode.style.height!='auto'){x.parentNode.style.height='auto';}else{x.parentNode.style.height='33px';}}
function lightBox(){var url='detalles_ajax.php?p='+this.id;xmlHttp.open("GET",url,true);xmlHttp.onreadystatechange=loadLightBox;xmlHttp.send(null);}
function loadLightBox(){if(xmlHttp.readyState==4){var fondo=document.createElement("div");fondo.setAttribute('id','fondo');fondo.id='fondo';E('body').appendChild(fondo);var response=xmlHttp.responseText;var LB=document.createElement("div");LB.setAttribute('id','detalles');LB.innerHTML=response;E('body').appendChild(LB);cerr=C('cerrar');for(i=0;i<cerr.length;i++){cerr[i].onclick=cerrar;}
cerr=C('cerrar');for(i=0;i<cerr.length;i++){cerr[i].onclick=cerrar;}
document.onclick=cerrar;thDet=C('th-det');for(i=0;i<thDet.length;i++){thDet[i].onmouseover=AgrandaImagen;}}}
function cerrar(){E('body').removeChild(E('fondo'));E('body').removeChild(E('detalles'));}
function AgrandaImagen(event){w=this.src;alt=this.alt;x=w.match(/\d+/);y=w.match(/\.[a-z]+$/);var grnd=document.createElement("img");grnd.setAttribute('id','grnd');grnd.setAttribute('src','large/'+x+y);grnd.style.border='solid';grnd.style.position='fixed';grnd.style.zIndex='999';if(IE()){this.attachEvent("onmouseout",imgDes);d.attachEvent("onscroll",imgDes);d.attachEvent("onmousemove",imgPos);}else{this.addEventListener("mouseout",imgDes,true);d.addEventListener("onscroll",imgDes,true);d.addEventListener("mousemove",imgPos,true);}
E('body').appendChild(grnd);}
function imgDes(){if(IE()){d.detachEvent("onmousemove",imgPos);d.detachEvent("onscroll",imgPos);}else{d.removeEventListener("mousemove",imgPos,true);d.removeEventListener("onscroll",imgPos,true);}
E('body').removeChild(E('grnd'));}
function imgPos(event){E('grnd').style.top=event.clientY-70+'px';E('grnd').style.left=event.clientX+25+'px';}
function IE(){if(navigator.appName=='Microsoft Internet Explorer'){return true;}else{return false;}}
function VOLVER(){window.history.go(-1);return false;}
function FLS(){return false;}
window.onload=I;
