var cyclers = new Array();
INTERVAL = 8000;
function cycle(i)
{
    var object = cyclers[i];
    if (document.images)
    {

        function banner_change() {
            object.img.src = object.images_[object.counter].src;
            $(object.img).fadeIn();
        }

        object.counter++;
        if (object.counter == object.imgs.length) {
            object.counter = 0;
        }
        if (object.urls[object.counter]!='') {
            object.a.href = object.urls[object.counter];
            object.a.style.cursor = 'pointer';
        } else {
            object.a.href = '';
            object.a.style.cursor = 'default';
        }

        object.div.style.height = object.images_[object.counter].height;
        //object.div.style.width = object.images_[object.counter].width;
        object.div.style.backgroundImage = "url("+object.images_[object.counter].src+")";
        $(object.img).fadeOut(1000, banner_change);
    }

    setTimeout("cycle("+i+")", INTERVAL);
}

function Cycler(imgs, urls, img, a, div) {
    this.imgs = imgs;
    this.images_ = new Array();
    var im;
    for (im in imgs) {
        this.images_[im] = new Image();
        this.images_[im].src = imgs[im];
    }
    this.urls = urls;
    this.img = img;
    this.a = a;
    this.div = div;
    this.counter = 0;
    cyclers[cyclers.length] = this;
    setTimeout("cycle("+(cyclers.length-1)+")", INTERVAL);
}

