function rotate() {
    // Images to rotate though:
    var imageNames = new Array( '/images/bbq/rotating/gtg_1.jpg',
                                                                '/images/bbq/rotating/solo.jpg',
								'/images/bbq/rotating/combo.jpg',	
								'/images/bbq/rotating/solid_combo.jpg',	
								'/images/bbq/rotating/trio.jpg',
                                '/images/bbq/rotating/master.jpg');
    img1 = document.getElementById('rotate');
    window.setTimeout(function() { cycle(0,10,img1,imageNames,1)},500);
}

function cycle(index,step,obj,imageNames,fade_dir){
if (fade_dir == 1) {
        if (step == -1) 
        {
            index = index + 1;
            
            if (index == imageNames.length) 
            {
                index = 0;
            }
            obj.src=imageNames[index];
            window.setTimeout(function() { cycle(index,0,obj,imageNames,0)},400);  //stay fadded out 
        }
        else
        {
           setOpacity(obj,(step * 10));
           step = step - 1;
           window.setTimeout(function() { cycle(index,step,obj,imageNames,1)},100);
        }
    }
    else {
        if (step == 11) 
        {
            window.setTimeout(function() { cycle(index,10,obj,imageNames,1)},4000); // stay fadded in
        }
        else
        {
           setOpacity(obj,(step * 10));
            step = step + 1;
            window.setTimeout(function() { cycle(index,step,obj,imageNames,0)},100);
        }
    }
}



function setOpacity(obj, opacity) {
    opacity = (opacity == 100)?99.999:opacity;
    obj.style.filter = "alpha(opacity:"+opacity+")";

    if (obj.style.filters && obj.style.filters.item) {
        obj.style.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
    }

    obj.style.KHTMLOpacity = opacity/100;
    obj.style.MozOpacity = opacity/100;
    obj.style.opacity = opacity/100;
}

window.onload = function() {
    if (document.getElementById('rotate')) {
        rotate("rotate");
    }
}
