
function fadeOutNF(x){
	//document.getElementById('test').innerHTML += ';'+(x/100)+'<br />';
	document.getElementById('newFacePicture').style.opacity = (x/100);
	if(x <= 0){
		document.getElementById('newFacePicture').style.visibility = 'hidden';
		++curNF;
		makeNewFace(curNF);
		fadeInNF(0);
		return true;
	}
	setTimeout("fadeOutNF("+(x-5)+")", 10);
}

function fadeInNF(x){
	if(x==0){
		document.getElementById('newFacePicture').style.opacity = '0';
		document.getElementById('newFacePicture').style.visibility = 'visible';
	}
	if(x >= 100){
		document.getElementById('newFacePicture').style.opacity = '1';
		return true;
	}
	document.getElementById('newFacePicture').style.opacity = (x/100);
	setTimeout("fadeInNF("+(x+5)+")", 10);
}

function makeNewFace(c){
	if(c>maxNF){
		curNF = 0;
		c = 0;
	}
	if(c<0){
		curNF = maxNF;
		c = maxNF;
	}

	if (document.getElementById) {
		var pictDiv = document.getElementById('newFacePicture');
		pictDiv.style.backgroundImage = 'url("'+newFace[c]['pic_name']+'")';
		clearTimeout(tNF);
		tNF = setTimeout("fadeOutNF(100)", 3000);
	}
}
function nextNF(){
	clearTimeout(tNF);
	fadeOutNF(100);
}

function prevNF(){
	clearTimeout(tNF);
	--curNF;
	--curNF;
	fadeOutNF(100);
}

function pauseNF(){
	clearTimeout(tNF);
}

function resumeNF(){
	tNF = setTimeout("fadeOutNF(100)", 3000);
}
