
function startRotation()
{   
    bannerCurrent=0;
    advertCurrent=0;
    
    b = document.getElementById("rotationImages");
    image = b.getElementsByTagName("img");
    topImage=image[bannerCurrent];
    
    if (b = document.getElementById("adverts"))
    {
        advertImage = b.getElementsByTagName("img");
        topAdvertImage = advertImage[advertCurrent];
    }
    else
    {
        advertImage = false;
    }
    
    if (image.length > 1)
    {
        z=setInterval(function(){showImage()},10000);
    }
}

function showImage()
{
    var x=bannerCurrent+1;
    var y=advertCurrent+1;
    
    if (x >= image.length)
    {
        x=0;
    }
    
    if (advertImage)
    {
        if (y >= advertImage.length)
        {
            y=0;
        }
    }
    
    bottomImage=image[bannerCurrent];
    topImage=image[x];
    
    if (advertImage)
    {
        bottomAdvertImage=advertImage[advertCurrent];
        topAdvertImage=advertImage[y];
    }
    
    bannerCurrent=x;
    advertCurrent=y;
 
    opacity=0;
    topImage.style.opacity = 0;
    topImage.style.filter = "alpha(opacity=0)";
    bottomImage.style.zIndex = 1;
    topImage.style.zIndex = 2;
    topImage.style.visibility = "visible";
    
    if (advertImage)
    {
        topAdvertImage.style.opacity = 0;
        topAdvertImage.style.filter = "alpha(opacity=0)";
        bottomAdvertImage.style.zIndex = 1;
        topAdvertImage.style.zIndex = 2;
        topAdvertImage.style.visibility = "visible";
    }  
    
    r=setInterval(function(){loadImage(topImage)},1);
}

function loadImage(image)
{
    image.style.opacity = (opacity/100);
    image.style.filter = "alpha(opacity=" + opacity + ")";
    
    if (advertImage)
    {
        topAdvertImage.style.opacity = (opacity/100);
        topAdvertImage.style.filter = "alpha(opacity=" + opacity + ")";
    }
        
    opacity += 1
    if (opacity > 100)
    {
        clearInterval(r);
        bottomImage.style.visibility = "hidden";
        
        if (advertImage)
        {
            bottomAdvertImage.style.visibility = "hidden";
        }
    }
}

