/*
File Name: wp-sss.js
Description: A very simple slideshow written for jQuery (http://www.jquery.com/)
Version: 1.0
Author: Wallace Rodrigues
Author URI: http://www.dreamyguy.com
Tags: javascript, jquery, slideshow

	WP-SimplestSlideShow v1.0
	http://www.dreamyguy.com

	I'm Wallace Rodrigues and you will find me at http://www.dreamyguy.com
	
 	----------- Please link out to me if you like it :) ----------

	--------------------------------------------------------------

	Copyright 2009  Wallace Rodrigues  (email : i@dreamyguy.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	--------------------------------------------------------------
*/

function slideSwitch() {
    var $active = $('#wp-sss-slideshow div.active');

    if ( $active.length == 0 ) $active = $('#wp-sss-slideshow div:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#wp-sss-slideshow div: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}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 8000 );
});
