var img = document.getElementById("pict");
var interval1 = 5000;
var interval2 = 30;
var n = 0;
var alph = 100;
var up = false;

var int1;
var int2;

img.src=pict[n];
next();

function next(){
	int1 = setInterval('nextImg()',interval1);
}

function nextAlph(){
	if (alph>0 && !up){
		alph-=5;
	}
	if (alph==0 && !up){
		up=true;
		img.src=pict[n];
	}
	if (alph<100 && up){
		alph+=5;
	}
	if(alph==100 && up){
		up=false;
		clearInterval(int2);
		next();
	}
	setAlpha(img,alph);
}

function nextImg(){
	if (n<pict.length-1){
		n++;
	}else{
		n=0;
	}
	clearInterval(int1);
	int2=setInterval('nextAlph()',interval2);
}

function setAlpha(img,v) {
   img.style.opacity = v/100;
   img.style.filter = 'alpha(opacity=' + v + ')';
}