FadeStep = 0.1;
FadeSpeed = 50;

FadeTimers = new Object();
FadeValue = new Object();

function fFadeIn(obj,value) {	
	obj.style.display='block';
	nv=Number(obj.style.opacity)+FadeStep;
	if (nv>=1) {nv=0.99;value=0.99;}
	obj.style.opacity=nv;
	obj.style.filter = 'alpha(opacity=' + nv*100 + ')';
	if (nv<=value) return;
		clearInterval(FadeTimers[obj.id]);
		FadeTimers[obj.id]=undefined;
		FadeValue[obj.id]=undefined;
	
}

function fFadeOut(obj,value) {
	nv=Number(obj.style.opacity)-FadeStep;
	if (nv<0) {nv=0;value=0;}
	obj.style.opacity=nv;
	obj.style.filter = 'alpha(opacity=' + nv*100 + ')';
	if (nv>value) return;
		clearInterval(FadeTimers[obj.id]);
		obj.style.display='none';
		FadeTimers[obj.id]=undefined;
		FadeValue[obj.id]=undefined;
}

function Fade(obj,show,speed){
		if (FadeTimers[obj.id]==undefined) {
			v=Number(obj.style.opacity);
			if (show==v) return;
			FadeValue[obj.id]=show;
			if (isNaN(speed)) speed=FadeSpeed;
			if (v<show) FadeTimers[obj.id]=setInterval(function(){fFadeIn(obj,show);},speed);
			if (v>show) FadeTimers[obj.id]=setInterval(function(){fFadeOut(obj,show);},speed);
			return;
		}
		if (FadeValue[obj.id]!=show) { 
					clearInterval(FadeTimers[obj.id]);
					FadeTimers[obj.id]=undefined;
					FadeValue[obj.id]=undefined;
					Fade(obj,show,speed);
					return;
		}
}

function ShowHide(obName){
	ob=document.getElementById(obName);
	if (!ob) return;
	if (ob.tag=='1') {
		Fade(ob,-1,10); 
		ob.tag=0;
	} else  {
		Fade(ob,100,10); 
		ob.tag=1;
	}
}


function showModelPhoto(id, value) {
	
	document.getElementById(id).src = value;
}
