var banner1Interval = 2000; // millis
var banner2Interval = 1800; // millis

function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');
    // uncomment the 3 lines below to pull the images in random order
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, banner1Interval, function() {
            $active.removeClass('active last-active');
        });
}

function slideSwitch2() {
    var $active = jQuery('#slideshow2 IMG.active');
    if ( $active.length == 0 ) $active = jQuery('#slideshow2 IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow2 IMG:first');
    // uncomment the 3 lines below to pull the images in random order
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, banner2Interval, function() {
            $active.removeClass('active last-active');
        });
}

jQuery(function() {
	if (document.getElementById("banner1") != null)
		setInterval( "slideSwitch()", banner1Interval * (jQuery('#slideshow IMG.active').siblings().length + 1));
	if (document.getElementById("banner2") != null)
		setInterval( "slideSwitch2()", banner2Interval * (jQuery('#slideshow2 IMG.active').siblings().length + 1));
});

function bannerPopup(myUrl) {
    var myTitle = "Banner_Popup";
    var myAttributes = "";
    var w = window.open(myUrl,myTitle,myAttributes);
}

