﻿function slideshow() 
{
    var $active = $('.banner div.active');

    if ( $active.length == 0 ) $active = $('.banner div:last');
    
    var $sibs  = $active.siblings();
    var rndNum = Math.floor(Math.random() * $sibs.length );
    var $next  = $( $sibs[ rndNum ] );
    //var $next =  $active.next().length ? $active.next() : $('.banner div:first');
    $active.removeClass('active')
    $active.addClass('last-active');

    
    

    
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
    inlineStyling(document.getElementById('ctl00_Content_DivFrontTopImage'), $('div.active').css('color'));
}
function inlineStyling(element, color)
{
jQuery(element).find('a').attr('style','color:' + color);
jQuery(element).find('s').attr('style','color:' + color);
jQuery(element).find('td').attr('style','color:' + color);
jQuery(element).find('tr').attr('style','color:' + color);
jQuery(element).find('th').attr('style','color:' + color);
jQuery(element).find('table').attr('style','color:' + color);
jQuery(element).find('k').attr('style','color:' + color);
jQuery(element).find('p').attr('style','color:' + color);
jQuery(element).find('b').attr('style','color:' + color);
jQuery(element).find('i').attr('style','color:' + color);
//jQuery(element).find('div').attr('style','color:' + color);
jQuery(element).find('span').attr('style','color:' + color);
jQuery(element).find('td').attr('style','color:' + color);
jQuery(element).find('h4').attr('style','color:' + color);
jQuery(element).find('h3').attr('style','color:' + color);
jQuery(element).find('h2').attr('style','color:' + color);
jQuery(element).find('h1').attr('style','color:' + color);
jQuery(element).find('li').attr('style','color:' + color);
jQuery(element).find('ul').attr('style','color:' + color);
jQuery(element).find('hr').attr('style','color:' + color);
}

$(function() {
    var delay=document.getElementById('imageRotatorDelay');
    inlineStyling(document.getElementById('ctl00_Content_DivFrontTopImage'), document.getElementById('ctl00_Content_DivFrontTopImage').style.color);
    setInterval( "slideshow()", delay.value );
});
