function op(n,v){
    if ((ie6)||(ie7)) {
    	n.style.filter = "alpha(opacity="+v*100+")";
    } else {
    	n.style.opacity = v;
    }
}

function readOp(n) {
    if ((ie6)||(ie7)) {
    	return parseFloat(n.style.filter.substring(14, n.style.filter.length-1))/100;
    } else {
	    return parseFloat(n.style.opacity);
    }
}
var iWallCount = 0;
var CurrentOpacity = 0;
var Auto="si"

while (document.getElementById(tipo + iWallCount)) {
	op(document.getElementById(tipo + iWallCount), 0);
	iWallCount++;
}

var iCurrentWall = Math.floor(iWallCount*Math.random());
op(document.getElementById(tipo + iCurrentWall), 1); 
if (ie7){
	 document.getElementById(tipo + iCurrentWall).removeAttribute("style");
	 CurrentOpacity = 1;
}


function nextWallpaper() {
	if (ie7){
			iOpacity = CurrentOpacity;
			if (iOpacity >= 0.05) {
			op(document.getElementById(tipo + iCurrentWall), Math.max(iOpacity-0.05, 0));
			op(document.getElementById(tipo + (iCurrentWall+1)%iWallCount), Math.min(1-iOpacity+0.05, 1));			
			CurrentOpacity = Math.max(iOpacity-0.1, 0);
	    iTimeoutID2 = window.setTimeout("nextWallpaper()", 20);
		}
		else {
			op(document.getElementById(tipo + iCurrentWall), 0);
			iCurrentWall = (iCurrentWall+1)%iWallCount;
			op(document.getElementById(tipo + iCurrentWall), 1);
			CurrentOpacity = 1 ;
			document.getElementById(tipo + iCurrentWall).removeAttribute("style"); 
      iTimeoutID = window.setTimeout("nextWallpaper()", 5000);
		}
	}
	else{
		iOpacity =readOp(document.getElementById(tipo + iCurrentWall));
		if (iOpacity >= 0.05) {
			op(document.getElementById(tipo + iCurrentWall), Math.max(iOpacity-0.05, 0));
			op(document.getElementById(tipo + (iCurrentWall+1)%iWallCount), Math.min(1-iOpacity+0.05, 1));			
	    iTimeoutID2 = window.setTimeout("nextWallpaper()", 20);
		}
		else {
			op(document.getElementById(tipo + iCurrentWall), 0);
			iCurrentWall = (iCurrentWall+1)%iWallCount;
			op(document.getElementById(tipo + iCurrentWall), 1);
    	iTimeoutID = window.setTimeout("nextWallpaper()", 5000);
		}
	}
}
var iTimeoutID;
var iTimeoutID2;

nextWallpaper();

function NextFoto() {
		if (undefined != iTimeoutID) { window.clearTimeout(iTimeoutID)};
		if (undefined != iTimeoutID2) { window.clearTimeout(iTimeoutID2)};
		nextWallpaper();
	}
	
