function showPicNext() {
    hideText('content');
    clearInterval(refreshIntervalId);
    slideSwitch();
}
function showPicPrevious() {
    hideText('content');
    clearInterval(refreshIntervalId);
    slideSwitchPrev();
}
function hideText(id) {
//    if (document.getElementById) {
//        document.getElementById(id).style.display = 'none';
//        document.getElementById('showText').style.display = 'inline';
    //    }

    $('#content:visible').fadeOut("fast");
    $('#showText').fadeIn();


}

function showText(id) {
//    if (document.getElementById) {
//        document.getElementById(id).style.display = 'block';
//        document.getElementById('showText').style.display = 'none';
    //    }
    $('#content').fadeIn("fast");
    $('#showText').fadeOut();
    
}


function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

$(document).ready(function() {
    doResize();
    carousel();
    $('#content').hide();
    $('#showText').show();
});


$(window).resize(function() {
    doResize();
});


function doResize() {
    if ($('#carouselDetail').length != 0) {
        $('#carouselDetail').width(0);
        var w = $('#spacerCell').width() < 450 ? 450 : $('#spacerCell').width();
        $('#carouselDetail').width(w);
    }
}



var refreshIntervalId;
function carousel() {

    if ($('#thumbs').length != 0) {
        var cl = 0;
        var $first = $('#thumbs li a:first').attr('href');
        $('<img src="' + $first + '" />').load(start);
    }
    
    function start() {
        
        $('#thumbs li a').each(function() {
            var $lia = this.href;
            if (cl == 0) {

                $("#slideshow").append('<img alt="' + $lia + '" class="active" src="' + $lia + '" />')

            } else {
            $("#slideshow").append('<img src="/images/impressions/spacer.gif" alt="' + $lia + '" class="' + $(this).attr('class') + '" />')
            }
            cl += 1;
        })

        if (cl != 1) {
            refreshIntervalId = setInterval("slideSwitch()", 4000);
        }
        
    }


}

function slideSwitch() {
    var $active = $('#slideshow img.active');
    if ($active.length == 0) $active = $('#slideshow img.active');
    var $next = $active.next().length ? $active.next() : $('#slideshow img:first');

    $('<img src="' + $next.attr('alt') + '" />').load(nextImg);

    function nextImg() {
        $next.attr('src', $next.attr('alt'));
        $active.addClass('last-active');
        $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        })

    }

}function slideSwitchPrev() {
    var $active = $('#slideshow img.active');
    if ($active.length == 0) $active = $('#slideshow img.active');
    var $prev = $active.prev().length ? $active.prev() : $('#slideshow img:last');

    $('<img src="' + $prev.attr('alt') + '" />').load(prevImg);

    function prevImg() {
        $prev.attr('src', $prev.attr('alt'));
        $active.addClass('last-active');
        $prev.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function() {
            $active.removeClass('active last-active');
        })

    }

}


function impressions() {
}