function cycleImages() {
	blendimage('img_image', 'image_block', imageurl[0], 1000);
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 50);
	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--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)ø
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	
	if(i_image < imageurl.length) {
		var speed = Math.round(millisec / 50);
		var timer_b = 1;
		var timer_f = 0;
		
		var imageid_b = imageid + '_b';
		var imageid_f = imageid + '_f';
	
		var curr_src = document.getElementById(imageid_f).src;
		if(curr_src.indexOf(img_urlbase) >= 0) { 
			document.getElementById(imageid_b).src = document.getElementById(imageid_f).src;
		}
		
		//make sure background is showing
		changeOpac(100, imageid_b);
		
		//make foreground image transparent
		changeOpac(0, imageid_f);
		
		//put next pic in foreground
		document.getElementById(imageid_f).src = imagefile;

		//alert('old image still');
		//fade in image
		for(i = 0; i <= 100; i++) {
			setTimeout("changeOpac(" + i + ",'" + imageid_f + "')",(timer_f * speed));
			timer_f++
			
			setTimeout("changeOpac(" + (100 - i) + ",'" + imageid_b + "')",(timer_b * speed));
			timer_b++;
		}
		
		i_image += 1;
		//reset the image counter to 0 if looping is desired
		if((i_image >= imageurl.length) && (loopimages)) {
			i_image = 0;
		}
	
		window.setTimeout("blendimage('img_image', 'image_block', imageurl[" + i_image + "], 1000)", i_delay);
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}