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;

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

var iCurrentWall = Math.floor(iWallCount*Math.random());

op(document.getElementById("wallpaper" + iCurrentWall), 1); 
if (ie7){
	 document.getElementById("wallpaper" + iCurrentWall).removeAttribute("style");
	 CurrentOpacity = 1
}

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

function show(Img,DivNb)
{
document.getElementById(DivNb).innerHTML = "<img src=\"http://www.vehiculosvip.com/images/" + Img +"\" border=\"0\" onMouseOut=\"hide('" + DivNb +"');\" >";
}

function hide(DivNb)
{
document.getElementById(DivNb).innerHTML = "";
}

window.setTimeout("nextWallpaper()", 7000);
