// Main page slide show
function slideSwitch() {
    // get active image
    var $active = $('#slideshow a.active');

    // if the active image is the first one, select the last one
    if ( $active.length == 0 ) $active = $('#slideshow a:last');

    // work out which is the next one. If its the end get the first one
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow a:first');

    // Add the last active to the previous active slide.
    $active.addClass('last-active');

    // run the fader
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideSwitchSelect(control) {
    control = control.replace('control-', '');

    // Get the current active one
    var $active = $('#slideshow a.active');

    if ( $active.length == 0 ) $active = $('#slideshow a:last');

    // Assign next image to the selected one
    var $next = $('#slide-'+control);

    // Add the last active to the previous active slide.
    $active.addClass('last-active');

    // run the fader
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        
    clearInternal(interval)
//    interval = setInterval( "slideSwitch()", 5000 );        
}



