var speed   = 3;
var timer   = 0;
var opacity = 0;
var i       = 0;
var timeout       = 0;

function fadeOut() {
    for(i = 100; i > 0; i--) {
        timeout = setTimeout("changeOpac(" + i + ",'img')",(timer * speed));
        timer++;
    }
}

function fadeIn() {
    timer=0;
    for(i = 0; i < 100; i++) {
        timeout = setTimeout("changeOpac(" + i + ",'img')",(timer * speed));
        timer++;
    }
}

function changeOpac(opacity, id) {
    var object = oe(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function nextImg(page,nr,cnt,width,height){
    changeOpac(0, 'img');
    oe('inner_img').src                = 'fx/pagefx/'+page+"_"+nr+".jpg";
    oe('img_link').href                = 'fx/pagefx/'+page+"_"+nr+".jpg";

    for(i=1;i<=cnt+1;i++)
    {
        if(oe('th_'+i))
            oe('th_'+i).style.display  = 'inline';
    }
    oe("th_"+nr).style.display         = 'none';
    fadeIn();
}