var fadeimages = [];
fadeimages[0] = ["../../images/web/vb/foto1.jpg", "", ""];
fadeimages[1] = ["../../images/web/vb/foto2.jpg", "", ""];
var fadebgcolor = "#000000";
var fadearray = [];
var fadeclear = [];
var dom = (document.getElementById);
var iebrowser = document.all;

function fadeshow(b, f, a, g, e, h, c, d) {
    this.pausecheck = h;
    this.mouseovercheck = 0;
    this.delay = e;
    this.degree = 10;
    this.curimageindex = 0;
    this.nextimageindex = 1;
    fadearray[fadearray.length] = this;
    this.slideshowid = fadearray.length - 1;
    this.canvasbase = "canvas" + this.slideshowid;
    this.curcanvas = this.canvasbase + "_0";
    this.fadedelay = 10;
    if (typeof d != "undefined" && d != 0) {
        this.fadedelay = d
    }
    if (typeof c != "undefined" && c != 0) {
        b.sort(function () {
            return 0.2 - Math.random()
        })
    }
    this.theimages = b;
    this.imageborder = parseInt(g);
    this.postimages = [];
    for (p = 0; p < b.length; p++) {
        this.postimages[p] = new Image();
        this.postimages[p].src = b[p][0]
    }
    var f = f + this.imageborder * 2;
    var a = a + this.imageborder * 2;
    if (iebrowser && dom || dom) {
        document.write('<div id="master' + this.slideshowid + '" style="margin-top:-200px;position:relative;width:' + f + "px;height:" + a + 'px;overflow:hidden;"><div id="' + this.canvasbase + '_0" style="position:absolute;width:' + f + "px;height:" + a + "px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=5);opacity:0.5;-moz-opacity:0.5;-khtml-opacity:0.1;background-color:" + fadebgcolor + '"></div><div id="' + this.canvasbase + '_1" style="position:absolute;width:' + f + "px;height:" + a + "px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:" + fadebgcolor + '"></div></div>')
    } else {
        document.write('<div><img name="defaultslide' + this.slideshowid + '" src="' + this.postimages[0].src + '"></div>')
    }
    if (iebrowser && dom || dom) {
        this.startit()
    } else {
        this.curimageindex++;
        setInterval("fadearray[" + this.slideshowid + "].rotateimage()", this.delay)
    }
}
function fadepic(a) {
    if (a.degree < 100) {
        a.degree += 1;
        if (a.tempobj.filters && a.tempobj.filters[0]) {
            if (typeof a.tempobj.filters[0].opacity == "number") {
                a.tempobj.filters[0].opacity = a.degree
            } else {
                a.tempobj.style.filter = "alpha(opacity=" + a.degree + ")"
            }
        } else {
            if (a.tempobj.style.MozOpacity) {
                a.tempobj.style.MozOpacity = a.degree / 100
            } else {
                if (a.tempobj.style.KhtmlOpacity) {
                    a.tempobj.style.KhtmlOpacity = a.degree / 100
                } else {
                    if (a.tempobj.style.opacity && !a.tempobj.filters) {
                        a.tempobj.style.opacity = a.degree / 101
                    }
                }
            }
        }
    } else {
        clearInterval(fadeclear[a.slideshowid]);
        a.nextcanvas = (a.curcanvas == a.canvasbase + "_0") ? a.canvasbase + "_0" : a.canvasbase + "_1";
        a.tempobj = iebrowser ? iebrowser[a.nextcanvas] : document.getElementById(a.nextcanvas);
        a.populateslide(a.tempobj, a.nextimageindex);
        a.nextimageindex = (a.nextimageindex < a.postimages.length - 1) ? a.nextimageindex + 1 : 0;
        setTimeout("fadearray[" + a.slideshowid + "].rotateimage()", a.delay)
    }
}
fadeshow.prototype.populateslide = function (a, c) {
    var b = "";
    if (this.theimages[c][1] != "") {
        b = '<a href="' + this.theimages[c][1] + '" target="' + this.theimages[c][2] + '">'
    }
    b += '<img src="' + this.postimages[c].src + '" border="' + this.imageborder + 'px">';
    if (this.theimages[c][1] != "") {
        b += "</a>"
    }
    a.innerHTML = b
};
fadeshow.prototype.rotateimage = function () {
    if (this.pausecheck == 1) {
        var c = this
    }
    if (this.mouseovercheck == 1) {
        setTimeout(function () {
            c.rotateimage()
        }, 100)
    } else {
        if (iebrowser && dom || dom) {
            this.resetit();
            var a = this.tempobj = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas);
            a.style.zIndex++;
            fadeclear[this.slideshowid] = setInterval("fadepic(fadearray[" + this.slideshowid + "])", this.fadedelay);
            this.curcanvas = (this.curcanvas == this.canvasbase + "_0") ? this.canvasbase + "_1" : this.canvasbase + "_0"
        } else {
            var b = document.images["defaultslide" + this.slideshowid];
            b.src = this.postimages[this.curimageindex].src
        }
    }
    this.curimageindex = (this.curimageindex < this.postimages.length - 1) ? this.curimageindex + 1 : 0
};
fadeshow.prototype.resetit = function () {
    this.degree = 10;
    var a = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas);
    if (a.filters && a.filters[0]) {
        if (typeof a.filters[0].opacity == "number") {
            a.filters(0).opacity = this.degree
        } else {
            a.style.filter = "alpha(opacity=" + this.degree + ")"
        }
    } else {
        if (a.style.MozOpacity) {
            a.style.MozOpacity = this.degree / 101
        } else {
            if (a.style.KhtmlOpacity) {
                a.style.KhtmlOpacity = this.degree / 100
            } else {
                if (a.style.opacity && !a.filters) {
                    a.style.opacity = this.degree / 101
                }
            }
        }
    }
};
fadeshow.prototype.startit = function () {
    var a = iebrowser ? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas);
    this.populateslide(a, this.curimageindex);
    if (this.pausecheck == 1) {
        var c = this;
        var b = iebrowser ? iebrowser["master" + this.slideshowid] : document.getElementById("master" + this.slideshowid);
        b.onmouseover = function () {
            c.mouseovercheck = 1
        };
        b.onmouseout = function () {
            c.mouseovercheck = 0
        }
    }
    this.rotateimage()
};
