function opacity(id, opacStart, opacEnd, millisec, func) {

    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
			if(i == opacEnd)
			{
				//alert(document.getElementById(id).style.filter);
            	setTimeout("changeOpac(" + i + ",'" + id + "', '" + func + "')",(timer * speed));
			}
			else
				setTimeout("changeOpac(" + i + ",'" + id + "', '')",(timer * speed));
            				
            timer++;	
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
			if(i == opacEnd)
            	setTimeout("changeOpac(" + i + ",'" + id + "',  '" + func + "')",(timer * speed));
			else
				setTimeout("changeOpac(" + i + ",'" + id + "', '')",(timer * speed));
            timer++;					
        }
    }


}

//change the opacity for different browsers
function changeOpac(opacity, id, func) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	
	if(func.length > 0)
	{			
		setTimeout(func,1);
	}
} 



var ima = [];
ima[0] = '/img/ebene1.gif';
ima[1] = '/img/ebene2.gif';
/*ima[2] = '/img/ebene3.gif';*/

function chg (id)
{
	opacity( id, 100, 5, 800, "BildWechsel(\""+id+"\")" );
}

var idx = ima.length -1;


function BildWechsel(id)
{				
	if(++idx > ima.length -1)
	{
		idx = 0;
	}
	document.images['wechsel'+id].src = ima[idx];
	var xyz=idx+1;
	document.images['wechsel'+id].setAttribute("usemap", "#"+xyz,0);

	opacity( id, 5, 100, 1000, "" );				
}
