function fadeIn(element, opacity) {
	var reduceOpacityBy = 25;
	var rate = 200;

	if (opacity < 100) {
		opacity += reduceOpacityBy;

		if (element.filters) {
			try {
				element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
			}
		} else {
			element.style.opacity = opacity / 100;
		}
	}

	if (opacity < 100) {
		setTimeout(function () {
			if (opacity<=reduceOpacityBy) { 
				element.style.display='';
			}
			fadeIn(element, opacity);
		}, rate);
	}
}

function fadeOut(element, opacity) {
	var reduceOpacityBy = 25;
	var rate = 200;


	if (opacity > 0) {
		opacity -= reduceOpacityBy;

		if (element.filters) {
			try {
				element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
			}
		} else {
			element.style.opacity = opacity / 100;
		}
	}

	if (opacity > 0) {
		setTimeout(function () {
			if (opacity<reduceOpacityBy+1) { 
				element.style.display='none';
			}
			fadeOut(element, opacity);
		}, rate);
		
	}
}
