
function imageFade( elementID, value, imageArray )
{   
    //increment the opacity by one
    value+=1;
    
    //if the value equals 100, reset to a negative number, 
    //this will cause the addition of one to the 
    //count to reduce the opacity
    if ( value >= 100 )
        value = -1 * value;    
        
    //handle rotating the image
    if ( value == 0 )
    {
        //debugger;
    
        //get the image url and parse it
        var image = document.getElementById( elementID ).src.split("/");      
        
        //extract only the image name
        image = image[ image.length - 1 ]; 
        
        //declare i for later use
        var i=0;
        
        //loop through the images array to find the current image index
        for( i=0; i < imageArray.length; i++)
        {
            //do the image names match?
            if ( image == imageArray[i] )
            {
                //alert( image + " == " + imageArray[i] );
                break;                
            }
        }
        
        //if the index is == to the length either 
        //we didn't find a match or the count needs to reset
        if( i == ( imageArray.length -1) )
            document.getElementById( elementID ).src = document.getElementById( elementID ).src.replace( image, imageArray[0] );
        else  
            document.getElementById( elementID ).src = document.getElementById( elementID ).src.replace( image, imageArray[i+1] );        
    }
    
    //IE
    if( document.all )        
        document.getElementById( elementID ).filters[0].opacity = Math.abs( value );
        
    //Mozilla
    if (window.sidebar)
        document.getElementById( elementID ).style.MozOpacity = Math.abs( value )+"%";        
        
    return value;
       
}
    
    

