function jsf_animate_opacity(id,dur,sttime,from,to){
	var obj=document.getElementById(id);
	var opacity=obj.style.opacity * 100;
	var now=(new Date()).getTime();
	opacity=from+(to-from)*(now-sttime)/dur;
	if (opacity<0)
		jsf_setopacity(obj,0)
	else if (opacity>100)
		jsf_setopacity(obj,100)
	else{
		jsf_setopacity(obj,opacity);
		obj.timer=window.setTimeout("jsf_animate_opacity('"+id+"',"+dur+","+sttime+","+from+","+to+")",1);	}
	
}

function jsf_setopacity(obj,opac){
	obj.style.filter='alpha(opacity='+opac+')'; // old mozilla and firefox
	obj.style.MozOpacity=opac/100; // other browsers
	obj.style.opacity=opac/100;
}

function jsf_img_faderepalce(imgurl,id,linkid,dur,imgholderid,link){
	var foreground=document.getElementById(id);
	if (imgholderid){
		var background=document.getElementById(imgholderid);
		if (background){
			background.style.backgroundImage='url('+foreground.src+')';
			background.style.backgroundRepeat='no-repeat';
			/*background.style.backgroundPosition='top center';*/
		}
	}
	jsf_setopacity(foreground,0);
	foreground.src=imgurl;
	//if (link){
	//	document.getElementById(linkid).setAttribute('href',link);
	//}
	if (foreground.timer){window.clearTimeout(foreground.timer);}
	var now=(new Date()).getTime();
	foreground.timer=window.setTimeout("jsf_animate_opacity('"+id+"','"+dur+"',"+now+",0,50)",10);
}
