(function($){
	$.fn.slideshow = function(options) {

	var defaults = {
		//animation: 'fade',
		speed: 4000,
		random: false
	};

	var options = $.extend(defaults, options);

	return this.each(function() {
	
		var $this = $(this);
		var $active = ( typeof $active == "undefined" || $active.length == 0 ? $("img:last-child", this) : $(".active", this) );
		var $next =  $active.next( ).length ? $active.next( ) : $("img:first-child", this);
	
		if( options.random )
		{
			var $sibs  = $active.siblings();
			var rndNum = Math.floor(Math.random() * $sibs.length );
			var $next  = $( $sibs[ rndNum ] );
		}
	
		$active.fadeOut( options.speed );
		$active.removeClass( 'active' );
	
		$next
			.addClass( 'active' )
			.fadeIn( options.speed+2000, function() {
				$this.slideshow( );
				
			});
	});
	
	function change( )
	{
		
	}
 };
})(jQuery);



$(document).ready( function( ){

	//setInterval( "slideSwitch()", 5000 );
	//$('#slideshow').slideshow( );
	slideSwitch( );
	//$('#gallery a').lightBox( {
	//	containerBorderSize: 10,
	//	overlayBgColor: "#fff",
	//	imageBtnNext: assets_url + "images/lightbox-btn-next.png",
	//	imageBtnPrev: assets_url + "images/lightbox-btn-prev.png",
	//	imageBtnClose: assets_url + "images/lightbox-btn-close.png",
	//	imageLoading : assets_url + "images/logo.png",
	//	txtImage: '',
	//	txtOf: '/'
	//});

});


/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

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

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

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

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

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


