﻿/* Derived from http://jonraasch.com/blog/a-simple-jquery-slideshow
Modified 04/05/2011 by Dan Kupka - dkupka32@gmail.com
Note - document ready does not work with this script! */

// variables declaration

// Photo: tomn_cdrelease_37_w.jpg
var $slideshowtext3 = "Watch the <a href=\"http://tomnmusic.com/category/media/videos\">Tōmn CD Release Party Video</a> featuring the song \"Off the Map\" <br /><br /> Assista <a href=\"http://tomnmusic.com/category/media/videos\">o clip no show de lançamento do Tōmn</a> apresentando a musica \"Off the Map\"";
// Photo: Fred MT concept.
var $slideshowtext1 = "<a href=\"http://tomnmusic.com/category/media/music\">Free Download</a /> of the Tōmn Debut<br /><br /> <a href=\"http://tomnmusic.com/category/media/music\">Baixa</a /> o estréia do Tōmn, gratis";
//Photo: tomn_passim_201101_07_w
var $slideshowtext2 = "See the latest show <a href=\"http://tomnmusic.com/category/media/photos\">photos</a /> <br /><br /> Veja as <a href=\"http://tomnmusic.com/category/media/photos\">fotos</a /> mais recentes dos shows ao vivo";
var $counter = 1;

// function slideSwitch(), allowing one image to fade out and in to the next

function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');

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

    var $next = $active.next().length ? $active.next()
		: jQuery('#slideshow IMG:first');

    $active.addClass('last-active');

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

    // if - else conditionals added for simultaneous text display associated with particular slides;
    // modify accordingly if slides are added or removed

    jQuery('#slideshowtext').html(eval('$slideshowtext' + $counter));
    
    $counter++;

    // counter reset after number 3 reached; modify with higher or lower number if slides are added or removed

    if ($counter > 3) $counter = 1;
}

// determines the interval between slide switches - default 5000ms, change to preference

jQuery(function () {
    setInterval("slideSwitch()", 5000);
});
