// JavaScript Document


function SlideShow(target, param)
{
   // debug("init");
	var _this = this;
	var targ = jQuery(target);
	var paused = true;
	if(param==null) param={};
	param = jQuery.extend({},{delay:4000},param);
	targ.children().css({position:"absolute", opacity:0});
    
	this.start = function()
	{
        //debug("start");
		if(paused)
		{
			paused = false;
			setTimeout(jQuery.proxy(_this,'nextSlide'),param.delay);
		}
	}
	
	this.stop = function()
	{
		paused = true;
	}
	
	this.nextSlide = function()
	{
       // debug("next");
		targ.children().stop();
		var jQueryactive = targ.find('.activeSlide');
		var jQuerynext = jQueryactive.next().length==0 ? targ.find(':first-child') : jQueryactive.next();
		jQuerynext.addClass('activeSlide');
		jQueryactive.removeClass('activeSlide');
		jQuerynext.animate({opacity:1},param.delay*.25);
		jQueryactive.animate({opacity:0},param.delay*.25);
		
		if(!paused) setTimeout(jQuery.proxy(_this,'nextSlide'),param.delay);
	}
	_this.nextSlide();
}

function debug(s)
{
	jQuery('#log').append(s+'<br>');
	if(hasOwnProperty("console") && console.log) console.log(s);
}

