function c4SlideShow(id, random, interval, duration_transition)
{
    this.show_random = random;
    this.interval = interval;
    this.duration_transition = duration_transition;
    this.pics = new Array();

    this.current_pic = 0;
    this.next_pic = 0;
    this.numver_of_pics = 0;
    this.current_opacity = 99
    this.next_opacity = 0;

    this.id = id;

    this.initSlideShow();
}

c4SlideShow.prototype.initSlideShow = function()
{
    if (!document.getElementById || !document.createElement) return;

    this.pics = $('#' + this.id + ' img'); //= document.getElementById("briask-iss"+this.idModule).getElementsByTagName("img");
    this.number_of_pics = this.pics.length ;

    for(i = 0; i < this.pics.length; i++)
	{
		$(this.pics[i]).fadeTo(0,0);
		/*
		this.pics[i].opacity = 0;
		this.pics[i].style.MozOpacity = .0;
		this.pics[i].style.filter = "alpha(opacity=0)";
		*/
	}
	$('#' + this.id + ' img').removeClass('hide');

    if (this.picRandom == 3)
    {
        this.getNextPic();
    }	
	
	$(this.pics[this.next_pic]).fadeTo(0,0.99);
    this.pics[this.next_pic].style.display = "block";
    /*this.pics[this.next_pic].style.opacity = .99;
    this.pics[this.next_pic].style.MozOpacity = .99;
    this.pics[this.next_pic].style.filter = "alpha(opacity=" + (.99*100) + ")";*/

    this.curPic = this.nextPic;
	if(this.number_of_pics > 1)
    	setTimeout('c4' + this.id + '.showPic()', this.interval);
}

c4SlideShow.prototype.showPic = function()
{
    this.getNextPic();
    this.current_opacity = 100;
	this.next_opacity = 0;
    setTimeout('c4' + this.id + '.slide()', this.delay);
}

c4SlideShow.prototype.getNextPic = function()
{
    if (!this.show_random)
    {
        if (this.current_pic < (this.number_of_pics - 1))
            this.next_pic = this.current_pic + 1;
        else
            this.next_pic = 0;
    }
    else
    {
        do
        {
            now = new Date();
            var random_pic = Math.ceil(this.number_of_pics * Math.random(this.id)) - 1;
        }   while (this.current_pic == random_pic)
        this.next_pic = random_pic;
    }
	if($(this.pics[this.next_pic]).attr('orgImg') != '')
	{
		$(this.pics[this.next_pic]).attr('src',$(this.pics[this.next_pic]).attr('orgImg'));
		$(this.pics[this.next_pic]).attr('orgImg','');
	}
}

c4SlideShow.prototype.hideOld = function()
{
	this.pics[this.current_pic].style.display = "none";
    this.current_pic = this.next_pic;
	setTimeout('c4' + this.id + '.showPic()', this.interval);
}

c4SlideShow.prototype.slide = function ()
{
	this.pics[this.next_pic].style.display = "block";
	$(this.pics[this.current_pic]).fadeTo(this.duration_transition,0);
	$(this.pics[this.next_pic]).fadeTo(this.duration_transition,0.99,function(){
			setTimeout('c4' + $(this).parents('ul').attr('id') + '.hideOld()', 0);												 
	});
    
	/*
	this.pics[this.current_pic].style.opacity = this.current_opacity / 100;
    this.pics[this.current_pic].style.MozOpacity = this.current_opacity / 100;
    this.pics[this.current_pic].style.filter = "alpha(opacity=" + (this.current_opacity) + ")";

	
	this.pics[this.next_pic].style.opacity = this.next_opacity/100;
    this.pics[this.next_pic].style.MozOpacity = this.next_opacity/100;
    this.pics[this.next_pic].style.filter = "alpha(opacity=" + (this.next_opacity) + ")";

    if (this.current_opacity > 0)
    {
        this.current_opacity -= 4;
        this.next_opacity += 4;
        setTimeout(this.id + '.slide()', this.delay);
    }
    else
    {
        this.pics[this.current_pic].style.display = "none";
        this.current_pic = this.next_pic;
        
    }*/
}
