window.onerror         = new Function("return true");
document.onselectstart = new Function("return false");
screen.bufferDepth     = 16;
O   = new Array();
box = 0;
img = 0;
txt = 0;
tit = 0;
W   = 0;
H   = 0;
nI  = 0;
sel = 0;
si  = 0;
//////////////////
ZOOM  = 4;
rImg  = 1.33;
speed = .1;
//////////////////

function dText(){
    txt.style.textAlign = tit.style.textAlign = (sel<nI/2)?"left":"right";
    txt.innerHTML = O[sel].tx;
    tit.innerHTML = O[sel].ti;
}

function CObj(n, s, x, tx, ti){
    this.n    = n;
    this.dim  = s;
    this.tx   = tx;
    this.ti   = ti;
    this.is   = img[n].style;
    this.vz   = 0;
    this.sx   = 0;
    this.x0   = x;
    this.x1   = 0;
    this.zo   = 0;
    this.clic = function() {
        with(this){
            if(n!=sel){
                O[sel].is.cursor = "pointer";
                O[n].is.cursor = "default";
                O[sel].dim = 100;
                O[n].dim = ZOOM * 100;
                sel = n;
                l = 0;
                for(k=0; k<nI; k++){
                    O[k].x0 = l;
                    l += O[k].dim;
                }
                txt.innerHTML = tit.innerHTML = "";
                setTimeout("dText()", 32);
            } else {
                // not implemented
            }
        }
    }
    this.anim = function () {
        with(this){
            vz  = speed*(vz+(x1-sx)*.5);
            x1 -= vz;
            sx  = (n==0)?0:O[n-1].x0+O[n-1].dim;
            zo -= (zo-dim)*speed;
            l   = Math.round((x1*si)+6*(n+1));
            w   = Math.round(zo*si);
            is.left   = l;
            is.top    = (H-w*rImg)*.5;
            is.width  = w;
            is.height = w*rImg;
            if(sel == n){
                if(sel<nI*.5)tit.style.left = txt.style.left = l+w+6;
                else tit.style.left = txt.style.left = l-(nx*.25)-6;
                txt.style.top = -(w*rImg)*.25;
                tit.style.top =  (w*rImg)*.33;
            }
        }
    }
}

function run(){
    for(j in O)O[j].anim();
    setTimeout("run()", 16);
}

function doResize(){
    tit.style.width = nx*.25;
    txt.style.width = nx*.25;
    tit.style.fontSize = (nx / 30) + "px";
    txt.style.fontSize = (nx / 70) + "px";
    with(box.style){
        width  = W;
        height = H;
        left   = nx / 2 - W / 2;
       
    }
}

function resize(){
    nx = document.body.offsetWidth;
    ny = document.body.offsetHeight;
    W  =  nx * 70 / 100;
    si = (W-((nI+1)*6))/((ZOOM*100)+((nI-1)*100));
    H  = (100 * si * rImg) + 16;
    setTimeout("doResize()", 16);
}
onresize = resize;

onload = function(){
    box = document.getElementById("box");
    tit = document.getElementById("tit");
    txt = document.getElementById("txt");
    img = box.getElementsByTagName("img");
    nI  = img.length;
    resize();
    s = ZOOM * 100;
    x = 0;
    tit.innerHTML = img[0].title;
    txt.innerHTML = img[0].alt;
    for(i=0; i<nI; i++) {
        O[i] = new CObj(i, s, x, img[i].alt, img[i].title);
        img[i].alt = "";
        img[i].title = "";
        img[i].onmousedown = new Function("return false;");
        x += s;
        s = 100;
    }
    O[0].is.cursor = "default";
    setTimeout("box.style.visibility='visible';",100);
    run();
}